* Modify PlayerScript::OnChat hook. Now it takes one optional parameter of type void *. Value of this parameter depends on chat type.

* Modify chat and emote hook in PlayerScript to take Player parameter insted on WorldSession (this is player script, isn't it?)
* Move calls of OnChat hooks after validation of parameters and before actual call to chat methods. It's more logical because otherwise it will be necessary to repeat validation inside hooks.
* Make use of new PlayeScript hooks. Move chat logging logic into separate script.
* Add one path to scripts CMakeLists to make ChatLogScript happy.

--HG--
branch : trunk
This commit is contained in:
azazel
2010-08-12 22:33:45 +06:00
parent f9997b7eb3
commit ed08bedc6e
7 changed files with 231 additions and 103 deletions
+7 -15
View File
@@ -18577,35 +18577,29 @@ void Player::BuildPlayerChat(WorldPacket *data, uint8 msgtype, const std::string
void Player::Say(const std::string& text, const uint32 language)
{
sScriptMgr.OnPlayerChat(this, CHAT_MSG_SAY, language, text);
WorldPacket data(SMSG_MESSAGECHAT, 200);
BuildPlayerChat(&data, CHAT_MSG_SAY, text, language);
SendMessageToSetInRange(&data,sWorld.getConfig(CONFIG_LISTEN_RANGE_SAY),true);
if (sWorld.getConfig(CONFIG_CHATLOG_PUBLIC))
sLog.outChat("[SAY] Player %s says (language %u): %s",
GetName(), language, text.c_str());
}
void Player::Yell(const std::string& text, const uint32 language)
{
sScriptMgr.OnPlayerChat(this, CHAT_MSG_YELL, language, text);
WorldPacket data(SMSG_MESSAGECHAT, 200);
BuildPlayerChat(&data, CHAT_MSG_YELL, text, language);
SendMessageToSetInRange(&data,sWorld.getConfig(CONFIG_LISTEN_RANGE_YELL),true);
if (sWorld.getConfig(CONFIG_CHATLOG_PUBLIC))
sLog.outChat("[YELL] Player %s yells (language %u): %s",
GetName(), language, text.c_str());
}
void Player::TextEmote(const std::string& 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.getConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE),true, !sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHAT));
if (sWorld.getConfig(CONFIG_CHATLOG_PUBLIC))
sLog.outChat("[TEXTEMOTE] Player %s emotes: %s",
GetName(), text.c_str());
}
void Player::Whisper(const std::string& text, uint32 language,uint64 receiver)
@@ -18615,9 +18609,7 @@ void Player::Whisper(const std::string& text, uint32 language,uint64 receiver)
Player *rPlayer = sObjectMgr.GetPlayer(receiver);
if (sWorld.getConfig(CONFIG_CHATLOG_WHISPER))
sLog.outChat("[WHISPER] Player %s tells %s: %s",
GetName(), rPlayer->GetName(), text.c_str());
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())