mirror of
https://github.com/araxiaonline/TrinityCore2.git
synced 2026-06-20 14:51:34 -04:00
* 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:
@@ -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())
|
||||
|
||||
@@ -535,6 +535,9 @@ void AddSC_outdoorpvp_si();
|
||||
void AddSC_outdoorpvp_tf();
|
||||
void AddSC_outdoorpvp_zm();
|
||||
|
||||
// player
|
||||
void AddSC_chat_log();
|
||||
|
||||
#endif
|
||||
|
||||
void AddScripts()
|
||||
@@ -597,6 +600,7 @@ void AddWorldScripts()
|
||||
AddSC_npcs_special();
|
||||
AddSC_npc_taxi();
|
||||
AddSC_achievement_scripts();
|
||||
AddSC_chat_log();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -1112,19 +1112,19 @@ void ScriptMgr::OnPlayerReputationChange(Player *player, uint32 factionID, int32
|
||||
FOREACH_SCRIPT(PlayerScript)->OnReputationChange(player, factionID, standing, incremental);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnPlayerChat(WorldSession *session, uint32 type, uint32 lang, std::string msg, std::string toOrChannel)
|
||||
void ScriptMgr::OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string msg, void* param)
|
||||
{
|
||||
FOREACH_SCRIPT(PlayerScript)->OnChat(session, type, lang, msg, toOrChannel);
|
||||
FOREACH_SCRIPT(PlayerScript)->OnChat(player, type, lang, msg, param);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnPlayerEmote(WorldSession *session, uint32 emote)
|
||||
void ScriptMgr::OnPlayerEmote(Player* player, uint32 emote)
|
||||
{
|
||||
FOREACH_SCRIPT(PlayerScript)->OnEmote(session, emote);
|
||||
FOREACH_SCRIPT(PlayerScript)->OnEmote(player, emote);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnPlayerTextEmote(WorldSession *session, uint32 text_emote, uint32 emoteNum, uint64 guid)
|
||||
void ScriptMgr::OnPlayerTextEmote(Player* player, uint32 text_emote, uint32 emoteNum, uint64 guid)
|
||||
{
|
||||
FOREACH_SCRIPT(PlayerScript)->OnTextEmote(session, text_emote, emoteNum, guid);
|
||||
FOREACH_SCRIPT(PlayerScript)->OnTextEmote(player, text_emote, emoteNum, guid);
|
||||
}
|
||||
|
||||
SpellHandlerScript::SpellHandlerScript(const char* name)
|
||||
|
||||
@@ -687,12 +687,19 @@ public:
|
||||
// Called when a player's reputation changes (before it is actually changed)
|
||||
virtual void OnReputationChange(Player *player, uint32 factionID, int32& standing, bool incremental) { }
|
||||
|
||||
// Called when a player sends a chat message. toOrChannel is empty when type is neither whisper nor channel
|
||||
virtual void OnChat(WorldSession *session, uint32 type, uint32 lang, std::string msg, std::string toOrChannel) { }
|
||||
// Called when a player sends a chat message. param depends on the chat type:
|
||||
// CHAT_MSG_WHISPER - Player*: receiver;
|
||||
// CHAT_MSG_PARTY, CHAT_MSG_PARTY_LEADER - Group*: group of player;
|
||||
// CHAT_MSG_OFFICER, CHAT_MSG_GUILD - Guild*: guild of player;
|
||||
// CHAT_MSG_RAID, CHAT_MSG_RAID_LEADER, CHAT_MSG_RAID_WARNING - Group*: group of player;
|
||||
// CHAT_MSG_BATTLEGROUND, CHAT_MSG_BATTLEGROUND_LEADER - Group*: group of player;
|
||||
// CHAT_MSG_CHANNEL - Channel*: channel player speaks to;
|
||||
// other - NULL.
|
||||
virtual void OnChat(Player* player, uint32 type, uint32 lang, std::string msg, void* param = NULL) { }
|
||||
|
||||
// Both of the below are called on emote opcodes
|
||||
virtual void OnEmote(WorldSession *session, uint32 emote) { }
|
||||
virtual void OnTextEmote(WorldSession *session, uint32 text_emote, uint32 emoteNum, uint64 guid) { }
|
||||
virtual void OnEmote(Player* player, uint32 emote) { }
|
||||
virtual void OnTextEmote(Player* player, uint32 text_emote, uint32 emoteNum, uint64 guid) { }
|
||||
};
|
||||
|
||||
// Placed here due to ScriptRegistry::AddScript dependency.
|
||||
@@ -877,9 +884,9 @@ class ScriptMgr
|
||||
void OnPlayerMoneyChanged(Player *player, int32& amount);
|
||||
void OnGivePlayerXP(Player *player, uint32& amount, Unit *victim);
|
||||
void OnPlayerReputationChange(Player *player, uint32 factionID, int32& standing, bool incremental);
|
||||
void OnPlayerChat(WorldSession *session, uint32 type, uint32 lang, std::string msg, std::string toOrChannel);
|
||||
void OnPlayerEmote(WorldSession *session, uint32 emote);
|
||||
void OnPlayerTextEmote(WorldSession *session, uint32 text_emote, uint32 emoteNum, uint64 guid);
|
||||
void OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string msg, void* param = NULL);
|
||||
void OnPlayerEmote(Player* player, uint32 emote);
|
||||
void OnPlayerTextEmote(Player* player, uint32 text_emote, uint32 emoteNum, uint64 guid);
|
||||
|
||||
public: /* ScriptRegistry */
|
||||
|
||||
|
||||
@@ -119,8 +119,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recv_data)
|
||||
return;
|
||||
}
|
||||
|
||||
sLog.outChat("[ADDON] Player %s sends: %s",
|
||||
GetPlayer()->GetName(), msg.c_str());
|
||||
sScriptMgr.OnPlayerChat(GetPlayer(), CHAT_MSG_ADDON, lang, msg);
|
||||
}
|
||||
|
||||
// Disabled addon channel?
|
||||
@@ -193,7 +192,6 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recv_data)
|
||||
{
|
||||
std::string msg;
|
||||
recv_data >> msg;
|
||||
sScriptMgr.OnPlayerChat(this, type, lang, msg, "");
|
||||
|
||||
if (msg.empty())
|
||||
break;
|
||||
@@ -226,7 +224,6 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recv_data)
|
||||
std::string to, msg;
|
||||
recv_data >> to;
|
||||
recv_data >> msg;
|
||||
sScriptMgr.OnPlayerChat(this, type, lang, msg, to);
|
||||
|
||||
if (_player->getLevel() < sWorld.getConfig(CONFIG_CHAT_WHISPER_LEVEL_REQ))
|
||||
{
|
||||
@@ -280,7 +277,6 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recv_data)
|
||||
{
|
||||
std::string msg;
|
||||
recv_data >> msg;
|
||||
sScriptMgr.OnPlayerChat(this, type, lang, msg, "");
|
||||
|
||||
if (msg.empty())
|
||||
break;
|
||||
@@ -306,20 +302,17 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recv_data)
|
||||
if ((type == CHAT_MSG_PARTY_LEADER) && !group->IsLeader(_player->GetGUID()))
|
||||
return;
|
||||
|
||||
sScriptMgr.OnPlayerChat(GetPlayer(), type, lang, msg, group);
|
||||
|
||||
WorldPacket data;
|
||||
ChatHandler::FillMessageData(&data, this, type, lang, NULL, 0, msg.c_str(), NULL);
|
||||
group->BroadcastPacket(&data, false, group->GetMemberGroup(GetPlayer()->GetGUID()));
|
||||
|
||||
if (sWorld.getConfig(CONFIG_CHATLOG_PARTY))
|
||||
sLog.outChat("[PARTY] Player %s tells group with leader %s: %s",
|
||||
GetPlayer()->GetName(), group->GetLeaderName(), msg.c_str());
|
||||
} break;
|
||||
|
||||
case CHAT_MSG_GUILD:
|
||||
{
|
||||
std::string msg;
|
||||
recv_data >> msg;
|
||||
sScriptMgr.OnPlayerChat(this, type, lang, msg, "");
|
||||
|
||||
if (msg.empty())
|
||||
break;
|
||||
@@ -335,20 +328,11 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recv_data)
|
||||
|
||||
if (GetPlayer()->GetGuildId())
|
||||
{
|
||||
Guild *guild = sObjectMgr.GetGuildById(GetPlayer()->GetGuildId());
|
||||
if (Guild *guild = sObjectMgr.GetGuildById(GetPlayer()->GetGuildId()))
|
||||
{
|
||||
sScriptMgr.OnPlayerChat(GetPlayer(), type, lang, msg, guild);
|
||||
|
||||
if (guild)
|
||||
guild->BroadcastToGuild(this, msg, lang == LANG_ADDON ? LANG_ADDON : LANG_UNIVERSAL);
|
||||
|
||||
if (lang != LANG_ADDON && sWorld.getConfig(CONFIG_CHATLOG_GUILD))
|
||||
{
|
||||
sLog.outChat("[GUILD] Player %s tells guild %s: %s",
|
||||
GetPlayer()->GetName(), guild->GetName().c_str(), msg.c_str());
|
||||
}
|
||||
else if (lang == LANG_ADDON && sWorld.getConfig(CONFIG_CHATLOG_ADDON))
|
||||
{
|
||||
sLog.outChat("[ADDON] Player %s sends to guild %s: %s",
|
||||
GetPlayer()->GetName(), guild->GetName().c_str(), msg.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -358,7 +342,6 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recv_data)
|
||||
{
|
||||
std::string msg;
|
||||
recv_data >> msg;
|
||||
sScriptMgr.OnPlayerChat(this, type, lang, msg, "");
|
||||
|
||||
if (msg.empty())
|
||||
break;
|
||||
@@ -374,14 +357,12 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recv_data)
|
||||
|
||||
if (GetPlayer()->GetGuildId())
|
||||
{
|
||||
Guild *guild = sObjectMgr.GetGuildById(GetPlayer()->GetGuildId());
|
||||
if (Guild *guild = sObjectMgr.GetGuildById(GetPlayer()->GetGuildId()))
|
||||
{
|
||||
sScriptMgr.OnPlayerChat(GetPlayer(), type, lang, msg, guild);
|
||||
|
||||
if (guild)
|
||||
guild->BroadcastToOfficers(this, msg, lang == LANG_ADDON ? LANG_ADDON : LANG_UNIVERSAL);
|
||||
|
||||
if (sWorld.getConfig(CONFIG_CHATLOG_GUILD))
|
||||
sLog.outChat("[OFFICER] Player %s tells guild %s officers: %s",
|
||||
GetPlayer()->GetName(), guild->GetName().c_str(), msg.c_str());
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -389,7 +370,6 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recv_data)
|
||||
{
|
||||
std::string msg;
|
||||
recv_data >> msg;
|
||||
sScriptMgr.OnPlayerChat(this, type, lang, msg, "");
|
||||
|
||||
if (msg.empty())
|
||||
break;
|
||||
@@ -412,19 +392,16 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recv_data)
|
||||
return;
|
||||
}
|
||||
|
||||
sScriptMgr.OnPlayerChat(GetPlayer(), type, lang, msg, group);
|
||||
|
||||
WorldPacket data;
|
||||
ChatHandler::FillMessageData(&data, this, CHAT_MSG_RAID, lang, "", 0, msg.c_str(), NULL);
|
||||
group->BroadcastPacket(&data, false);
|
||||
|
||||
if (sWorld.getConfig(CONFIG_CHATLOG_RAID))
|
||||
sLog.outChat("[RAID] Player %s tells raid with leader %s: %s",
|
||||
GetPlayer()->GetName(), group->GetLeaderName(), msg.c_str());
|
||||
} break;
|
||||
case CHAT_MSG_RAID_LEADER:
|
||||
{
|
||||
std::string msg;
|
||||
recv_data >> msg;
|
||||
sScriptMgr.OnPlayerChat(this, type, lang, msg, "");
|
||||
|
||||
if (msg.empty())
|
||||
break;
|
||||
@@ -447,19 +424,16 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recv_data)
|
||||
return;
|
||||
}
|
||||
|
||||
sScriptMgr.OnPlayerChat(GetPlayer(), type, lang, msg, group);
|
||||
|
||||
WorldPacket data;
|
||||
ChatHandler::FillMessageData(&data, this, CHAT_MSG_RAID_LEADER, lang, "", 0, msg.c_str(), NULL);
|
||||
group->BroadcastPacket(&data, false);
|
||||
|
||||
if (sWorld.getConfig(CONFIG_CHATLOG_RAID))
|
||||
sLog.outChat("[RAID] Leader player %s tells raid: %s",
|
||||
GetPlayer()->GetName(), msg.c_str());
|
||||
} break;
|
||||
case CHAT_MSG_RAID_WARNING:
|
||||
{
|
||||
std::string msg;
|
||||
recv_data >> msg;
|
||||
sScriptMgr.OnPlayerChat(this, type, lang, msg, "");
|
||||
|
||||
if (!processChatmessageFurtherAfterSecurityChecks(msg, lang))
|
||||
return;
|
||||
@@ -471,21 +445,18 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recv_data)
|
||||
if (!group || !group->isRaidGroup() || !(group->IsLeader(GetPlayer()->GetGUID()) || group->IsAssistant(GetPlayer()->GetGUID())) || group->isBGGroup())
|
||||
return;
|
||||
|
||||
sScriptMgr.OnPlayerChat(GetPlayer(), type, lang, msg, group);
|
||||
|
||||
WorldPacket data;
|
||||
//in battleground, raid warning is sent only to players in battleground - code is ok
|
||||
ChatHandler::FillMessageData(&data, this, CHAT_MSG_RAID_WARNING, lang, "", 0, msg.c_str(), NULL);
|
||||
group->BroadcastPacket(&data, false);
|
||||
|
||||
if (sWorld.getConfig(CONFIG_CHATLOG_RAID))
|
||||
sLog.outChat("[RAID] Leader player %s warns raid with: %s",
|
||||
GetPlayer()->GetName(), msg.c_str());
|
||||
} break;
|
||||
|
||||
case CHAT_MSG_BATTLEGROUND:
|
||||
{
|
||||
std::string msg;
|
||||
recv_data >> msg;
|
||||
sScriptMgr.OnPlayerChat(this, type, lang, msg, "");
|
||||
|
||||
if (!processChatmessageFurtherAfterSecurityChecks(msg, lang))
|
||||
return;
|
||||
@@ -498,20 +469,17 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recv_data)
|
||||
if (!group || !group->isBGGroup())
|
||||
return;
|
||||
|
||||
sScriptMgr.OnPlayerChat(GetPlayer(), type, lang, msg, group);
|
||||
|
||||
WorldPacket data;
|
||||
ChatHandler::FillMessageData(&data, this, CHAT_MSG_BATTLEGROUND, lang, "", 0, msg.c_str(), NULL);
|
||||
group->BroadcastPacket(&data, false);
|
||||
|
||||
if (sWorld.getConfig(CONFIG_CHATLOG_BGROUND))
|
||||
sLog.outChat("[BATTLEGROUND] Player %s tells battleground with leader %s: %s",
|
||||
GetPlayer()->GetName(), group->GetLeaderName(), msg.c_str());
|
||||
} break;
|
||||
|
||||
case CHAT_MSG_BATTLEGROUND_LEADER:
|
||||
{
|
||||
std::string msg;
|
||||
recv_data >> msg;
|
||||
sScriptMgr.OnPlayerChat(this, type, lang, msg, "");
|
||||
|
||||
if (!processChatmessageFurtherAfterSecurityChecks(msg, lang))
|
||||
return;
|
||||
@@ -524,13 +492,11 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recv_data)
|
||||
if (!group || !group->isBGGroup() || !group->IsLeader(GetPlayer()->GetGUID()))
|
||||
return;
|
||||
|
||||
sScriptMgr.OnPlayerChat(GetPlayer(), type, lang, msg, group);
|
||||
|
||||
WorldPacket data;
|
||||
ChatHandler::FillMessageData(&data, this, CHAT_MSG_BATTLEGROUND_LEADER, lang, "", 0, msg.c_str(), NULL);
|
||||
group->BroadcastPacket(&data, false);
|
||||
|
||||
if (sWorld.getConfig(CONFIG_CHATLOG_BGROUND))
|
||||
sLog.outChat("[RAID] Leader player %s tells battleground: %s",
|
||||
GetPlayer()->GetName(), msg.c_str());
|
||||
} break;
|
||||
|
||||
case CHAT_MSG_CHANNEL:
|
||||
@@ -538,16 +504,15 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recv_data)
|
||||
std::string channel, msg;
|
||||
recv_data >> channel;
|
||||
recv_data >> msg;
|
||||
sScriptMgr.OnPlayerChat(this, type, lang, msg, channel);
|
||||
|
||||
if (!processChatmessageFurtherAfterSecurityChecks(msg, lang))
|
||||
return;
|
||||
|
||||
if (_player->getLevel() < sWorld.getConfig(CONFIG_CHAT_CHANNEL_LEVEL_REQ))
|
||||
{
|
||||
SendNotification(GetTrinityString(LANG_CHANNEL_REQ), sWorld.getConfig(CONFIG_CHAT_CHANNEL_LEVEL_REQ));
|
||||
return;
|
||||
}
|
||||
if (_player->getLevel() < sWorld.getConfig(CONFIG_CHAT_CHANNEL_LEVEL_REQ))
|
||||
{
|
||||
SendNotification(GetTrinityString(LANG_CHANNEL_REQ), sWorld.getConfig(CONFIG_CHAT_CHANNEL_LEVEL_REQ));
|
||||
return;
|
||||
}
|
||||
|
||||
if (msg.empty())
|
||||
break;
|
||||
@@ -557,18 +522,9 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recv_data)
|
||||
|
||||
if (Channel *chn = cMgr->GetChannel(channel, _player))
|
||||
{
|
||||
chn->Say(_player->GetGUID(), msg.c_str(), lang);
|
||||
sScriptMgr.OnPlayerChat(_player, type, lang, msg, chn);
|
||||
|
||||
if ((chn->HasFlag(CHANNEL_FLAG_TRADE) ||
|
||||
chn->HasFlag(CHANNEL_FLAG_GENERAL) ||
|
||||
chn->HasFlag(CHANNEL_FLAG_CITY) ||
|
||||
chn->HasFlag(CHANNEL_FLAG_LFG)) &&
|
||||
sWorld.getConfig(CONFIG_CHATLOG_SYSCHAN))
|
||||
sLog.outChat("[SYSCHAN] Player %s tells channel %s: %s",
|
||||
GetPlayer()->GetName(), chn->GetName().c_str(), msg.c_str());
|
||||
else if (sWorld.getConfig(CONFIG_CHATLOG_CHANNEL))
|
||||
sLog.outChat("[CHANNEL] Player %s tells channel %s: %s",
|
||||
GetPlayer()->GetName(), chn->GetName().c_str(), msg.c_str());
|
||||
chn->Say(_player->GetGUID(), msg.c_str(), lang);
|
||||
}
|
||||
}
|
||||
} break;
|
||||
@@ -577,7 +533,6 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recv_data)
|
||||
{
|
||||
std::string msg;
|
||||
recv_data >> msg;
|
||||
sScriptMgr.OnPlayerChat(this, type, lang, msg, "");
|
||||
|
||||
if ((msg.empty() || !_player->isAFK()) && !_player->isInCombat())
|
||||
{
|
||||
@@ -587,6 +542,9 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recv_data)
|
||||
msg = GetTrinityString(LANG_PLAYER_AFK_DEFAULT);
|
||||
_player->afkMsg = msg;
|
||||
}
|
||||
|
||||
sScriptMgr.OnPlayerChat(_player, type, lang, msg);
|
||||
|
||||
_player->ToggleAFK();
|
||||
if (_player->isAFK() && _player->isDND())
|
||||
_player->ToggleDND();
|
||||
@@ -597,7 +555,6 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recv_data)
|
||||
{
|
||||
std::string msg;
|
||||
recv_data >> msg;
|
||||
sScriptMgr.OnPlayerChat(this, type, lang, msg, "");
|
||||
|
||||
if (msg.empty() || !_player->isDND())
|
||||
{
|
||||
@@ -607,6 +564,9 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recv_data)
|
||||
msg = GetTrinityString(LANG_PLAYER_DND_DEFAULT);
|
||||
_player->dndMsg = msg;
|
||||
}
|
||||
|
||||
sScriptMgr.OnPlayerChat(_player, type, lang, msg);
|
||||
|
||||
_player->ToggleDND();
|
||||
if (_player->isDND() && _player->isAFK())
|
||||
_player->ToggleAFK();
|
||||
@@ -626,7 +586,7 @@ void WorldSession::HandleEmoteOpcode(WorldPacket & recv_data)
|
||||
|
||||
uint32 emote;
|
||||
recv_data >> emote;
|
||||
sScriptMgr.OnPlayerEmote(this, emote);
|
||||
sScriptMgr.OnPlayerEmote(GetPlayer(), emote);
|
||||
GetPlayer()->HandleEmoteCommand(emote);
|
||||
}
|
||||
|
||||
@@ -681,7 +641,7 @@ void WorldSession::HandleTextEmoteOpcode(WorldPacket & recv_data)
|
||||
recv_data >> emoteNum;
|
||||
recv_data >> guid;
|
||||
|
||||
sScriptMgr.OnPlayerTextEmote(this, text_emote, emoteNum, guid);
|
||||
sScriptMgr.OnPlayerTextEmote(GetPlayer(), text_emote, emoteNum, guid);
|
||||
|
||||
EmotesTextEntry const *em = sEmotesTextStore.LookupEntry(text_emote);
|
||||
if (!em)
|
||||
|
||||
@@ -84,6 +84,7 @@ include_directories(
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Battlegrounds
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Calendar
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Chat
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Chat/Channels
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Conditions
|
||||
${CMAKE_SOURCE_DIR}/src/server/shared/Configuration
|
||||
${CMAKE_SOURCE_DIR}/src/server/game/Combat
|
||||
|
||||
@@ -0,0 +1,164 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2010 Trinity <http://www.trinitycore.org/>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "ScriptPCH.h"
|
||||
#include "Channel.h"
|
||||
#include "Guild.h"
|
||||
|
||||
class ChatLogScript : public PlayerScript
|
||||
{
|
||||
public:
|
||||
ChatLogScript() : PlayerScript("ChatLogScript") { }
|
||||
|
||||
void OnChat(Player* player, uint32 type, uint32 lang, std::string msg, void* param)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case CHAT_MSG_ADDON:
|
||||
if (sWorld.getConfig(CONFIG_CHATLOG_ADDON))
|
||||
sLog.outChat("[ADDON] Player %s sends: %s",
|
||||
player->GetName(), msg.c_str());
|
||||
break;
|
||||
|
||||
case CHAT_MSG_SAY:
|
||||
if (sWorld.getConfig(CONFIG_CHATLOG_PUBLIC))
|
||||
sLog.outChat("[SAY] Player %s says (language %u): %s",
|
||||
player->GetName(), lang, msg.c_str());
|
||||
break;
|
||||
|
||||
case CHAT_MSG_EMOTE:
|
||||
if (sWorld.getConfig(CONFIG_CHATLOG_PUBLIC))
|
||||
sLog.outChat("[TEXTEMOTE] Player %s emotes: %s",
|
||||
player->GetName(), msg.c_str());
|
||||
break;
|
||||
|
||||
case CHAT_MSG_YELL:
|
||||
if (sWorld.getConfig(CONFIG_CHATLOG_PUBLIC))
|
||||
sLog.outChat("[YELL] Player %s yells (language %u): %s",
|
||||
player->GetName(), lang, msg.c_str());
|
||||
break;
|
||||
|
||||
case CHAT_MSG_WHISPER:
|
||||
if (sWorld.getConfig(CONFIG_CHATLOG_WHISPER))
|
||||
{
|
||||
Player* pReceiver = reinterpret_cast <Player*> (param);
|
||||
sLog.outChat("[WHISPER] Player %s tells %s: %s",
|
||||
player->GetName(), pReceiver ? pReceiver->GetName() : "<unknown>", msg.c_str());
|
||||
}
|
||||
break;
|
||||
|
||||
case CHAT_MSG_PARTY:
|
||||
if (sWorld.getConfig(CONFIG_CHATLOG_PARTY))
|
||||
{
|
||||
Group* pGroup = reinterpret_cast <Group*> (param);
|
||||
sLog.outChat("[PARTY] Player %s tells group with leader %s: %s",
|
||||
player->GetName(), pGroup ? pGroup->GetLeaderName() : "<unknown>", msg.c_str());
|
||||
}
|
||||
break;
|
||||
|
||||
case CHAT_MSG_PARTY_LEADER:
|
||||
if (sWorld.getConfig(CONFIG_CHATLOG_PARTY))
|
||||
sLog.outChat("[PARTY] Leader %s tells group: %s",
|
||||
player->GetName(), msg.c_str());
|
||||
break;
|
||||
|
||||
case CHAT_MSG_GUILD:
|
||||
{
|
||||
Guild* pGuild = reinterpret_cast <Guild*> (param);
|
||||
if (lang != LANG_ADDON && sWorld.getConfig(CONFIG_CHATLOG_GUILD))
|
||||
{
|
||||
sLog.outChat("[GUILD] Player %s tells guild %s: %s",
|
||||
player->GetName(), pGuild ? pGuild->GetName().c_str() : "<unknown>", msg.c_str());
|
||||
}
|
||||
else if (lang == LANG_ADDON && sWorld.getConfig(CONFIG_CHATLOG_ADDON))
|
||||
{
|
||||
sLog.outChat("[ADDON] Player %s sends to guild %s: %s",
|
||||
player->GetName(), pGuild ? pGuild->GetName().c_str() : "<unknown>", msg.c_str());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case CHAT_MSG_OFFICER:
|
||||
if (sWorld.getConfig(CONFIG_CHATLOG_GUILD))
|
||||
{
|
||||
Guild* pGuild = reinterpret_cast <Guild*> (param);
|
||||
sLog.outChat("[OFFICER] Player %s tells guild %s officers: %s",
|
||||
player->GetName(), pGuild ? pGuild->GetName().c_str() : "<unknown>", msg.c_str());
|
||||
}
|
||||
break;
|
||||
|
||||
case CHAT_MSG_RAID:
|
||||
if (sWorld.getConfig(CONFIG_CHATLOG_RAID))
|
||||
{
|
||||
Group* pGroup = reinterpret_cast <Group*> (param);
|
||||
sLog.outChat("[RAID] Player %s tells raid with leader %s: %s",
|
||||
player->GetName(), pGroup ? pGroup->GetLeaderName() : "<unknown>", msg.c_str());
|
||||
}
|
||||
break;
|
||||
|
||||
case CHAT_MSG_RAID_LEADER:
|
||||
if (sWorld.getConfig(CONFIG_CHATLOG_RAID))
|
||||
sLog.outChat("[RAID] Leader player %s tells raid: %s",
|
||||
player->GetName(), msg.c_str());
|
||||
break;
|
||||
|
||||
case CHAT_MSG_RAID_WARNING:
|
||||
if (sWorld.getConfig(CONFIG_CHATLOG_RAID))
|
||||
sLog.outChat("[RAID] Leader player %s warns raid with: %s",
|
||||
player->GetName(), msg.c_str());
|
||||
break;
|
||||
|
||||
case CHAT_MSG_BATTLEGROUND:
|
||||
if (sWorld.getConfig(CONFIG_CHATLOG_BGROUND))
|
||||
{
|
||||
Group* pGroup = reinterpret_cast <Group*> (param);
|
||||
sLog.outChat("[BATTLEGROUND] Player %s tells battleground with leader %s: %s",
|
||||
player->GetName(), pGroup ? pGroup->GetLeaderName() : "<unknown>", msg.c_str());
|
||||
}
|
||||
break;
|
||||
|
||||
case CHAT_MSG_BATTLEGROUND_LEADER:
|
||||
if (sWorld.getConfig(CONFIG_CHATLOG_BGROUND))
|
||||
sLog.outChat("[RAID] Leader player %s tells battleground: %s",
|
||||
player->GetName(), msg.c_str());
|
||||
break;
|
||||
|
||||
case CHAT_MSG_CHANNEL:
|
||||
{
|
||||
Channel* pChannel = reinterpret_cast <Channel*> (param);
|
||||
bool isSystem = pChannel &&
|
||||
(pChannel->HasFlag(CHANNEL_FLAG_TRADE) ||
|
||||
pChannel->HasFlag(CHANNEL_FLAG_GENERAL) ||
|
||||
pChannel->HasFlag(CHANNEL_FLAG_CITY) ||
|
||||
pChannel->HasFlag(CHANNEL_FLAG_LFG));
|
||||
if (sWorld.getConfig(CONFIG_CHATLOG_SYSCHAN) && isSystem)
|
||||
sLog.outChat("[SYSCHAN] Player %s tells channel %s: %s",
|
||||
player->GetName(), pChannel->GetName().c_str(), msg.c_str());
|
||||
else if (sWorld.getConfig(CONFIG_CHATLOG_CHANNEL))
|
||||
sLog.outChat("[CHANNEL] Player %s tells channel %s: %s",
|
||||
player->GetName(), pChannel ? pChannel->GetName().c_str() : "<unknown>", msg.c_str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void AddSC_chat_log()
|
||||
{
|
||||
new ChatLogScript();
|
||||
}
|
||||
Reference in New Issue
Block a user