Core/Scripts: return const modifier to Player methods back (should restore compilation for those with custom scripts).

NOTE: The main idea of original change is to allow scripts change content of message so that calling method sends modified message to client.
For example, moderating script which cuts illegal words from message.

--HG--
branch : trunk
This commit is contained in:
azazel
2010-11-18 10:26:34 +06:00
parent 3de2f6af01
commit 87d723405e
5 changed files with 39 additions and 36 deletions
+28 -26
View File
@@ -18804,74 +18804,76 @@ void Player::StopCastingCharm()
}
}
void Player::BuildPlayerChat(WorldPacket *data, uint8 msgtype, const std::string& text, uint32 language) const
inline void Player::BuildPlayerChat(WorldPacket *data, uint8 msgtype, const std::string& text, uint32 language) const
{
*data << (uint8)msgtype;
*data << (uint32)language;
*data << (uint64)GetGUID();
*data << (uint32)language; //language 2.1.0 ?
*data << (uint64)GetGUID();
*data << (uint32)(text.length()+1);
*data << uint8(msgtype);
*data << uint32(language);
*data << uint64(GetGUID());
*data << uint32(language); //language 2.1.0 ?
*data << uint64(GetGUID());
*data << uint32(text.length() + 1);
*data << text;
*data << (uint8)chatTag();
*data << uint8(chatTag());
}
void Player::Say(std::string& text, const uint32 language)
void Player::Say(const std::string& text, const uint32 language)
{
sScriptMgr.OnPlayerChat(this, CHAT_MSG_SAY, language, text);
std::string _text(text);
sScriptMgr.OnPlayerChat(this, CHAT_MSG_SAY, language, _text);
WorldPacket data(SMSG_MESSAGECHAT, 200);
BuildPlayerChat(&data, CHAT_MSG_SAY, text, language);
SendMessageToSetInRange(&data,sWorld.getFloatConfig(CONFIG_LISTEN_RANGE_SAY),true);
BuildPlayerChat(&data, CHAT_MSG_SAY, _text, language);
SendMessageToSetInRange(&data, sWorld.getFloatConfig(CONFIG_LISTEN_RANGE_SAY), true);
}
void Player::Yell(std::string& text, const uint32 language)
void Player::Yell(const std::string& text, const uint32 language)
{
sScriptMgr.OnPlayerChat(this, CHAT_MSG_YELL, language, text);
std::string _text(text);
sScriptMgr.OnPlayerChat(this, CHAT_MSG_YELL, language, _text);
WorldPacket data(SMSG_MESSAGECHAT, 200);
BuildPlayerChat(&data, CHAT_MSG_YELL, text, language);
SendMessageToSetInRange(&data,sWorld.getFloatConfig(CONFIG_LISTEN_RANGE_YELL),true);
BuildPlayerChat(&data, CHAT_MSG_YELL, _text, language);
SendMessageToSetInRange(&data, sWorld.getFloatConfig(CONFIG_LISTEN_RANGE_YELL), true);
}
void Player::TextEmote(std::string& text)
void Player::TextEmote(const std::string& text)
{
sScriptMgr.OnPlayerChat(this, CHAT_MSG_EMOTE, LANG_UNIVERSAL, text);
std::string _text(text);
sScriptMgr.OnPlayerChat(this, CHAT_MSG_EMOTE, LANG_UNIVERSAL, _text);
WorldPacket data(SMSG_MESSAGECHAT, 200);
BuildPlayerChat(&data, CHAT_MSG_EMOTE, text, LANG_UNIVERSAL);
SendMessageToSetInRange(&data,sWorld.getFloatConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE),true, !sWorld.getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHAT));
BuildPlayerChat(&data, CHAT_MSG_EMOTE, _text, LANG_UNIVERSAL);
SendMessageToSetInRange(&data, sWorld.getFloatConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE), true, !sWorld.getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHAT));
}
void Player::Whisper(std::string& text, uint32 language,uint64 receiver)
void Player::Whisper(const std::string& text, uint32 language, uint64 receiver)
{
if (language != LANG_ADDON) // if not addon data
language = LANG_UNIVERSAL; // whispers should always be readable
Player *rPlayer = sObjectMgr.GetPlayer(receiver);
sScriptMgr.OnPlayerChat(this, CHAT_MSG_WHISPER, language, text, rPlayer);
std::string _text(text);
sScriptMgr.OnPlayerChat(this, CHAT_MSG_WHISPER, language, _text, rPlayer);
// when player you are whispering to is dnd, he cannot receive your message, unless you are in gm mode
if (!rPlayer->isDND() || isGameMaster())
{
WorldPacket data(SMSG_MESSAGECHAT, 200);
BuildPlayerChat(&data, CHAT_MSG_WHISPER, text, language);
BuildPlayerChat(&data, CHAT_MSG_WHISPER, _text, language);
rPlayer->GetSession()->SendPacket(&data);
// not send confirmation for addon messages
if (language != LANG_ADDON)
{
data.Initialize(SMSG_MESSAGECHAT, 200);
rPlayer->BuildPlayerChat(&data, CHAT_MSG_WHISPER_INFORM, text, language);
rPlayer->BuildPlayerChat(&data, CHAT_MSG_WHISPER_INFORM, _text, language);
GetSession()->SendPacket(&data);
}
}
else
{
// announce to player that player he is whispering to is dnd and cannot receive his message
ChatHandler(this).PSendSysMessage(LANG_PLAYER_DND, rPlayer->GetName(), rPlayer->dndMsg.c_str());
}
if (!isAcceptWhispers() && !isGameMaster() && !rPlayer->isGameMaster())
{
+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(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 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 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(std::string("This is Madness!"), LANG_UNIVERSAL);
this->ToPlayer()->Say("This is Madness!", LANG_UNIVERSAL); // TODO: It should be moved to database, shouldn't it?
break;
}
// Sunwell Exalted Caster Neck (??? neck)
@@ -625,18 +625,18 @@ public:
if (say_timer <= diff)
{
say_timer = 3000;
Player *plr = SelectRandomPlayer(100.0f,false);
Player *plr = SelectRandomPlayer(100.0f, false);
if (count < 3)
{
if (plr)
plr->Say(std::string(Text[count]),0);
plr->Say(Text[count], 0);
}
else
{
DoCast(me, SPELL_RHYME_BIG);
if (plr)
{
plr->Say(std::string(Text[count]),0);
plr->Say(Text[count], 0);
plr->HandleEmoteCommand(ANIM_EMOTE_SHOUT);
}
wp_reached = true;
+3 -2
View File
@@ -270,8 +270,9 @@ public:
return false;
else
{
//This should be sent to the player as red text.
pPlayer->Say(std::string("You have created enough ghouls. Return to Gothik the Harvester at Death's Breach."), LANG_UNIVERSAL);
// This should be sent to the player as red text.
// TODO: Text should be moved to DB
pPlayer->Say("You have created enough ghouls. Return to Gothik the Harvester at Death's Breach.", LANG_UNIVERSAL);
return true;
}
}