mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-24 02:46:33 +01: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:
@@ -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 */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user