Skip to content

Commit

Permalink
fix:(Scripts/Spells): Undo database changes, replace $n target name i…
Browse files Browse the repository at this point in the history
…n bct
  • Loading branch information
xaenerys0 committed Apr 15, 2024
1 parent bb4ccfd commit f389615
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
4 changes: 0 additions & 4 deletions data/sql/updates/pending_db_world/xxxx_xx_xx_xx.sql

This file was deleted.

16 changes: 14 additions & 2 deletions src/server/scripts/Spells/spell_generic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class spell_the_flag_of_ownership : public SpellScript
return true;
}

void HandleScript(SpellEffIndex /*effIndex*/)
void HandleScript(SpellEffIndex /*effIndex*/)
{
Unit* caster = GetCaster();
if (!caster || caster->GetTypeId() != TYPEID_PLAYER)
Expand All @@ -140,9 +140,21 @@ class spell_the_flag_of_ownership : public SpellScript
if (!target)
return;
caster->CastSpell(target, 52605, true);

const BroadcastText* bct = sObjectMgr->GetBroadcastText(BROADCAST_TEXT_FLAG_OF_OWNERSHIP);
if (!bct)
return;
Player* player = caster->ToPlayer();
LocaleConstant loc_idx = player->GetSession()->GetSessionDbLocaleIndex();

std::string formatString = bct->GetText(loc_idx, caster->getGender());
size_t pos = formatString.find("$n");
if (pos != std::string::npos) {
formatString.replace(pos, 2, target->GetName().c_str());
}

char buff[100];
snprintf(buff, sizeof(buff), bct->GetText().c_str(), "", target->GetName().c_str());
snprintf(buff, sizeof(buff), formatString.c_str(), caster->GetName().c_str(), target->GetName().c_str());
caster->TextEmote(buff, caster);
haveTarget = true;
}
Expand Down

0 comments on commit f389615

Please sign in to comment.