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:
@@ -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 << uint8(msgtype);
|
||||||
*data << (uint32)language;
|
*data << uint32(language);
|
||||||
*data << (uint64)GetGUID();
|
*data << uint64(GetGUID());
|
||||||
*data << (uint32)language; //language 2.1.0 ?
|
*data << uint32(language); //language 2.1.0 ?
|
||||||
*data << (uint64)GetGUID();
|
*data << uint64(GetGUID());
|
||||||
*data << (uint32)(text.length()+1);
|
*data << uint32(text.length() + 1);
|
||||||
*data << text;
|
*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);
|
WorldPacket data(SMSG_MESSAGECHAT, 200);
|
||||||
BuildPlayerChat(&data, CHAT_MSG_SAY, text, language);
|
BuildPlayerChat(&data, CHAT_MSG_SAY, _text, language);
|
||||||
SendMessageToSetInRange(&data,sWorld.getFloatConfig(CONFIG_LISTEN_RANGE_SAY),true);
|
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);
|
WorldPacket data(SMSG_MESSAGECHAT, 200);
|
||||||
BuildPlayerChat(&data, CHAT_MSG_YELL, text, language);
|
BuildPlayerChat(&data, CHAT_MSG_YELL, _text, language);
|
||||||
SendMessageToSetInRange(&data,sWorld.getFloatConfig(CONFIG_LISTEN_RANGE_YELL),true);
|
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);
|
WorldPacket data(SMSG_MESSAGECHAT, 200);
|
||||||
BuildPlayerChat(&data, CHAT_MSG_EMOTE, text, LANG_UNIVERSAL);
|
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));
|
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
|
if (language != LANG_ADDON) // if not addon data
|
||||||
language = LANG_UNIVERSAL; // whispers should always be readable
|
language = LANG_UNIVERSAL; // whispers should always be readable
|
||||||
|
|
||||||
Player *rPlayer = sObjectMgr.GetPlayer(receiver);
|
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
|
// when player you are whispering to is dnd, he cannot receive your message, unless you are in gm mode
|
||||||
if (!rPlayer->isDND() || isGameMaster())
|
if (!rPlayer->isDND() || isGameMaster())
|
||||||
{
|
{
|
||||||
WorldPacket data(SMSG_MESSAGECHAT, 200);
|
WorldPacket data(SMSG_MESSAGECHAT, 200);
|
||||||
BuildPlayerChat(&data, CHAT_MSG_WHISPER, text, language);
|
BuildPlayerChat(&data, CHAT_MSG_WHISPER, _text, language);
|
||||||
rPlayer->GetSession()->SendPacket(&data);
|
rPlayer->GetSession()->SendPacket(&data);
|
||||||
|
|
||||||
// not send confirmation for addon messages
|
// not send confirmation for addon messages
|
||||||
if (language != LANG_ADDON)
|
if (language != LANG_ADDON)
|
||||||
{
|
{
|
||||||
data.Initialize(SMSG_MESSAGECHAT, 200);
|
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);
|
GetSession()->SendPacket(&data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
// announce to player that player he is whispering to is dnd and cannot receive his message
|
// 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());
|
ChatHandler(this).PSendSysMessage(LANG_PLAYER_DND, rPlayer->GetName(), rPlayer->dndMsg.c_str());
|
||||||
}
|
|
||||||
|
|
||||||
if (!isAcceptWhispers() && !isGameMaster() && !rPlayer->isGameMaster())
|
if (!isAcceptWhispers() && !isGameMaster() && !rPlayer->isGameMaster())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1113,10 +1113,10 @@ class Player : public Unit, public GridObject<Player>
|
|||||||
void RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent = false);
|
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
|
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 Say(const std::string& text, const uint32 language);
|
||||||
void Yell(std::string& text, const uint32 language);
|
void Yell(const std::string& text, const uint32 language);
|
||||||
void TextEmote(std::string& text);
|
void TextEmote(const std::string& text);
|
||||||
void Whisper(std::string& text, const uint32 language,uint64 receiver);
|
void Whisper(const std::string& text, const uint32 language,uint64 receiver);
|
||||||
void BuildPlayerChat(WorldPacket *data, uint8 msgtype, const std::string& text, uint32 language) const;
|
void BuildPlayerChat(WorldPacket *data, uint8 msgtype, const std::string& text, uint32 language) const;
|
||||||
|
|
||||||
/*********************************************************/
|
/*********************************************************/
|
||||||
|
|||||||
@@ -5458,7 +5458,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
|
|||||||
|
|
||||||
target = this;
|
target = this;
|
||||||
if (roll_chance_i(10))
|
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;
|
break;
|
||||||
}
|
}
|
||||||
// Sunwell Exalted Caster Neck (??? neck)
|
// Sunwell Exalted Caster Neck (??? neck)
|
||||||
|
|||||||
@@ -625,18 +625,18 @@ public:
|
|||||||
if (say_timer <= diff)
|
if (say_timer <= diff)
|
||||||
{
|
{
|
||||||
say_timer = 3000;
|
say_timer = 3000;
|
||||||
Player *plr = SelectRandomPlayer(100.0f,false);
|
Player *plr = SelectRandomPlayer(100.0f, false);
|
||||||
if (count < 3)
|
if (count < 3)
|
||||||
{
|
{
|
||||||
if (plr)
|
if (plr)
|
||||||
plr->Say(std::string(Text[count]),0);
|
plr->Say(Text[count], 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DoCast(me, SPELL_RHYME_BIG);
|
DoCast(me, SPELL_RHYME_BIG);
|
||||||
if (plr)
|
if (plr)
|
||||||
{
|
{
|
||||||
plr->Say(std::string(Text[count]),0);
|
plr->Say(Text[count], 0);
|
||||||
plr->HandleEmoteCommand(ANIM_EMOTE_SHOUT);
|
plr->HandleEmoteCommand(ANIM_EMOTE_SHOUT);
|
||||||
}
|
}
|
||||||
wp_reached = true;
|
wp_reached = true;
|
||||||
|
|||||||
@@ -270,8 +270,9 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//This should be sent to the player as red text.
|
// 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);
|
// 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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user