Core/Scripts: pass message parameter by reference in OnChat methods to make it possible to be modified inside the script.

--HG--
branch : trunk
This commit is contained in:
azazel
2010-11-17 18:14:35 +06:00
parent 169c2ef87a
commit 4fb572015a
9 changed files with 33 additions and 33 deletions
+4 -4
View File
@@ -18816,7 +18816,7 @@ void Player::BuildPlayerChat(WorldPacket *data, uint8 msgtype, const std::string
*data << (uint8)chatTag();
}
void Player::Say(const std::string& text, const uint32 language)
void Player::Say(std::string& text, const uint32 language)
{
sScriptMgr.OnPlayerChat(this, CHAT_MSG_SAY, language, text);
@@ -18825,7 +18825,7 @@ void Player::Say(const std::string& text, const uint32 language)
SendMessageToSetInRange(&data,sWorld.getFloatConfig(CONFIG_LISTEN_RANGE_SAY),true);
}
void Player::Yell(const std::string& text, const uint32 language)
void Player::Yell(std::string& text, const uint32 language)
{
sScriptMgr.OnPlayerChat(this, CHAT_MSG_YELL, language, text);
@@ -18834,7 +18834,7 @@ void Player::Yell(const std::string& text, const uint32 language)
SendMessageToSetInRange(&data,sWorld.getFloatConfig(CONFIG_LISTEN_RANGE_YELL),true);
}
void Player::TextEmote(const std::string& text)
void Player::TextEmote(std::string& text)
{
sScriptMgr.OnPlayerChat(this, CHAT_MSG_EMOTE, LANG_UNIVERSAL, text);
@@ -18843,7 +18843,7 @@ void Player::TextEmote(const std::string& text)
SendMessageToSetInRange(&data,sWorld.getFloatConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE),true, !sWorld.getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHAT));
}
void Player::Whisper(const std::string& text, uint32 language,uint64 receiver)
void Player::Whisper(std::string& text, uint32 language,uint64 receiver)
{
if (language != LANG_ADDON) // if not addon data
language = LANG_UNIVERSAL; // whispers should always be readable
+4 -4
View File
@@ -1113,10 +1113,10 @@ class Player : public Unit, public GridObject<Player>
void RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent = false);
uint32 GetPhaseMaskForSpawn() const; // used for proper set phase for DB at GM-mode creature/GO spawn
void Say(const std::string& text, const uint32 language);
void Yell(const std::string& text, const uint32 language);
void TextEmote(const std::string& text);
void Whisper(const std::string& text, const uint32 language,uint64 receiver);
void Say(std::string& text, const uint32 language);
void Yell(std::string& text, const uint32 language);
void TextEmote(std::string& text);
void Whisper(std::string& text, const uint32 language,uint64 receiver);
void BuildPlayerChat(WorldPacket *data, uint8 msgtype, const std::string& text, uint32 language) const;
/*********************************************************/
+1 -1
View File
@@ -5458,7 +5458,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
target = this;
if (roll_chance_i(10))
this->ToPlayer()->Say("This is Madness!", LANG_UNIVERSAL);
this->ToPlayer()->Say(std::string("This is Madness!"), LANG_UNIVERSAL);
break;
}
// Sunwell Exalted Caster Neck (??? neck)
+1 -1
View File
@@ -390,7 +390,7 @@ void Map::ScriptsProcess()
{
uint64 targetGUID = target ? target->GetGUID() : 0;
LocaleConstant loc_idx = pSource->GetSession()->GetSessionDbLocaleIndex();
const std::string text(sObjectMgr.GetTrinityString(step.script->Talk.TextID, loc_idx));
std::string text(sObjectMgr.GetTrinityString(step.script->Talk.TextID, loc_idx));
switch (step.script->Talk.ChatType)
{
+5 -5
View File
@@ -1137,27 +1137,27 @@ void ScriptMgr::OnPlayerDuelEnd(Player *winner, Player *loser, DuelCompleteType
FOREACH_SCRIPT(PlayerScript)->OnDuelEnd(winner, loser, type);
}
void ScriptMgr::OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string msg)
void ScriptMgr::OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string& msg)
{
FOREACH_SCRIPT(PlayerScript)->OnChat(player, type, lang, msg);
}
void ScriptMgr::OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string msg, Player* receiver)
void ScriptMgr::OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string& msg, Player* receiver)
{
FOREACH_SCRIPT(PlayerScript)->OnChat(player, type, lang, msg, receiver);
}
void ScriptMgr::OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string msg, Group* group)
void ScriptMgr::OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string& msg, Group* group)
{
FOREACH_SCRIPT(PlayerScript)->OnChat(player, type, lang, msg, group);
}
void ScriptMgr::OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string msg, Guild* guild)
void ScriptMgr::OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string& msg, Guild* guild)
{
FOREACH_SCRIPT(PlayerScript)->OnChat(player, type, lang, msg, guild);
}
void ScriptMgr::OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string msg, Channel* channel)
void ScriptMgr::OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string& msg, Channel* channel)
{
FOREACH_SCRIPT(PlayerScript)->OnChat(player, type, lang, msg, channel);
}
+10 -10
View File
@@ -692,11 +692,11 @@ class PlayerScript : public ScriptObject
virtual void OnDuelEnd(Player* /*winner*/, Player* /*loser*/, DuelCompleteType /*type*/) { }
// The following methods are called when a player sends a chat message
virtual void OnChat(Player* /*player*/, uint32 /*type*/, uint32 /*lang*/, std::string /*msg*/) { }
virtual void OnChat(Player* /*player*/, uint32 /*type*/, uint32 /*lang*/, std::string /*msg*/, Player* /*receiver*/) { }
virtual void OnChat(Player* /*player*/, uint32 /*type*/, uint32 /*lang*/, std::string /*msg*/, Group* /*group*/) { }
virtual void OnChat(Player* /*player*/, uint32 /*type*/, uint32 /*lang*/, std::string /*msg*/, Guild* /*guild*/) { }
virtual void OnChat(Player* /*player*/, uint32 /*type*/, uint32 /*lang*/, std::string /*msg*/, Channel* /*channel*/) { }
virtual void OnChat(Player* /*player*/, uint32 /*type*/, uint32 /*lang*/, std::string& /*msg*/) { }
virtual void OnChat(Player* /*player*/, uint32 /*type*/, uint32 /*lang*/, std::string& /*msg*/, Player* /*receiver*/) { }
virtual void OnChat(Player* /*player*/, uint32 /*type*/, uint32 /*lang*/, std::string& /*msg*/, Group* /*group*/) { }
virtual void OnChat(Player* /*player*/, uint32 /*type*/, uint32 /*lang*/, std::string& /*msg*/, Guild* /*guild*/) { }
virtual void OnChat(Player* /*player*/, uint32 /*type*/, uint32 /*lang*/, std::string& /*msg*/, Channel* /*channel*/) { }
// Both of the below are called on emote opcodes
virtual void OnEmote(Player* /*player*/, uint32 /*emote*/) { }
@@ -935,11 +935,11 @@ class ScriptMgr
void OnPlayerDuelRequest(Player* target, Player* challenger);
void OnPlayerDuelStart(Player* player1, Player* player2);
void OnPlayerDuelEnd(Player* winner, Player* loser, DuelCompleteType type);
void OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string msg);
void OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string msg, Player* receiver);
void OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string msg, Group* group);
void OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string msg, Guild* guild);
void OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string msg, Channel* channel);
void OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string& msg);
void OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string& msg, Player* receiver);
void OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string& msg, Group* group);
void OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string& msg, Guild* guild);
void OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string& msg, Channel* channel);
void OnPlayerEmote(Player* player, uint32 emote);
void OnPlayerTextEmote(Player* player, uint32 text_emote, uint32 emoteNum, uint64 guid);
void OnPlayerSpellCast(Player* player, Spell *spell, bool skipCheck);
@@ -629,14 +629,14 @@ public:
if (count < 3)
{
if (plr)
plr->Say(Text[count],0);
plr->Say(std::string(Text[count]),0);
}
else
{
DoCast(me, SPELL_RHYME_BIG);
if (plr)
{
plr->Say(Text[count],0);
plr->Say(std::string(Text[count]),0);
plr->HandleEmoteCommand(ANIM_EMOTE_SHOUT);
}
wp_reached = true;
+5 -5
View File
@@ -24,7 +24,7 @@ class ChatLogScript : public PlayerScript
public:
ChatLogScript() : PlayerScript("ChatLogScript") { }
void OnChat(Player* player, uint32 type, uint32 lang, std::string msg)
void OnChat(Player* player, uint32 type, uint32 lang, std::string& msg)
{
switch (type)
{
@@ -54,14 +54,14 @@ public:
}
}
void OnChat(Player *player, uint32 /*type*/, uint32 /*lang*/, std::string msg, Player *receiver)
void OnChat(Player *player, uint32 /*type*/, uint32 /*lang*/, std::string& msg, Player *receiver)
{
if (sWorld.getBoolConfig(CONFIG_CHATLOG_WHISPER))
sLog.outChat("[WHISPER] Player %s tells %s: %s",
player->GetName(), receiver ? receiver->GetName() : "<unknown>", msg.c_str());
}
void OnChat(Player *player, uint32 type, uint32 /*lang*/, std::string msg, Group *group)
void OnChat(Player *player, uint32 type, uint32 /*lang*/, std::string& msg, Group *group)
{
switch (type)
{
@@ -109,7 +109,7 @@ public:
}
}
void OnChat(Player *player, uint32 type, uint32 lang, std::string msg, Guild *guild)
void OnChat(Player *player, uint32 type, uint32 lang, std::string& msg, Guild *guild)
{
switch(type)
{
@@ -130,7 +130,7 @@ public:
}
}
void OnChat(Player *player, uint32 /*type*/, uint32 /*lang*/, std::string msg, Channel *channel)
void OnChat(Player *player, uint32 /*type*/, uint32 /*lang*/, std::string& msg, Channel *channel)
{
bool isSystem = channel &&
(channel->HasFlag(CHANNEL_FLAG_TRADE) ||
+1 -1
View File
@@ -271,7 +271,7 @@ public:
else
{
//This should be sent to the player as red text.
pPlayer->Say("You have created enough ghouls. Return to Gothik the Harvester at Death's Breach.",LANG_UNIVERSAL);
pPlayer->Say(std::string("You have created enough ghouls. Return to Gothik the Harvester at Death's Breach."), LANG_UNIVERSAL);
return true;
}
}