mirror of
https://github.com/azerothcore/mod-ale
synced 2025-11-29 15:38:17 +08:00
Eluna fix addon msg hook for mangos and for TC's latest changes. Also improve it a little
This commit is contained in:
30
HookMgr.cpp
30
HookMgr.cpp
@@ -215,14 +215,14 @@ bool HookMgr::OnPacketReceive(WorldSession* session, WorldPacket& packet)
|
||||
return result;
|
||||
}
|
||||
// AddOns
|
||||
void HookMgr::OnAddonMessage(Player* pPlayer, std::string& msg, uint32 type, std::string& to)
|
||||
void HookMgr::OnAddonMessage(Player* sender, uint32 type, std::string& msg, Player* receiver, Guild* guild, Group* group, Channel* channel)
|
||||
{
|
||||
if (!sEluna->ServerEventBindings.HasEvents(ADDON_EVENT_ON_MESSAGE))
|
||||
return;
|
||||
ELUNA_GUARD();
|
||||
sEluna->ServerEventBindings.BeginCall(ADDON_EVENT_ON_MESSAGE);
|
||||
sEluna->Push(sEluna->L, pPlayer);
|
||||
|
||||
sEluna->Push(sEluna->L, sender);
|
||||
sEluna->Push(sEluna->L, type);
|
||||
const char* c_msg = msg.c_str();
|
||||
char* arg = strtok((char*)c_msg, "\t");
|
||||
while (arg)
|
||||
@@ -230,12 +230,16 @@ void HookMgr::OnAddonMessage(Player* pPlayer, std::string& msg, uint32 type, std
|
||||
sEluna->Push(sEluna->L, arg);
|
||||
arg = strtok(NULL, "\t");
|
||||
}
|
||||
|
||||
sEluna->Push(sEluna->L, type);
|
||||
if (to.empty())
|
||||
sEluna->Push(sEluna->L);
|
||||
if (receiver)
|
||||
sEluna->Push(sEluna->L, receiver);
|
||||
else if (guild)
|
||||
sEluna->Push(sEluna->L, guild);
|
||||
else if (group)
|
||||
sEluna->Push(sEluna->L, group);
|
||||
else if (channel)
|
||||
sEluna->Push(sEluna->L, channel->GetChannelId());
|
||||
else
|
||||
sEluna->Push(sEluna->L, to);
|
||||
sEluna->Push(sEluna->L);
|
||||
sEluna->ServerEventBindings.ExecuteCall();
|
||||
sEluna->ServerEventBindings.EndCall();
|
||||
}
|
||||
@@ -978,6 +982,8 @@ void HookMgr::OnMapChanged(Player* player)
|
||||
|
||||
bool HookMgr::OnChat(Player* pPlayer, uint32 type, uint32 lang, std::string& msg)
|
||||
{
|
||||
if (lang == LANG_ADDON)
|
||||
OnAddonMessage(pPlayer, type, msg, NULL, NULL, NULL, NULL);
|
||||
bool result = true;
|
||||
if (sEluna->PlayerEventBindings.HasEvents(PLAYER_EVENT_ON_CHAT))
|
||||
{
|
||||
@@ -1007,6 +1013,8 @@ bool HookMgr::OnChat(Player* pPlayer, uint32 type, uint32 lang, std::string& msg
|
||||
|
||||
bool HookMgr::OnChat(Player* pPlayer, uint32 type, uint32 lang, std::string& msg, Group* pGroup)
|
||||
{
|
||||
if (lang == LANG_ADDON)
|
||||
OnAddonMessage(pPlayer, type, msg, NULL, NULL, pGroup, NULL);
|
||||
bool result = true;
|
||||
if (sEluna->PlayerEventBindings.HasEvents(PLAYER_EVENT_ON_GROUP_CHAT))
|
||||
{
|
||||
@@ -1037,6 +1045,8 @@ bool HookMgr::OnChat(Player* pPlayer, uint32 type, uint32 lang, std::string& msg
|
||||
|
||||
bool HookMgr::OnChat(Player* pPlayer, uint32 type, uint32 lang, std::string& msg, Guild* pGuild)
|
||||
{
|
||||
if (lang == LANG_ADDON)
|
||||
OnAddonMessage(pPlayer, type, msg, NULL, pGuild, NULL, NULL);
|
||||
bool result = true;
|
||||
if (sEluna->PlayerEventBindings.HasEvents(PLAYER_EVENT_ON_GUILD_CHAT))
|
||||
{
|
||||
@@ -1067,6 +1077,8 @@ bool HookMgr::OnChat(Player* pPlayer, uint32 type, uint32 lang, std::string& msg
|
||||
|
||||
bool HookMgr::OnChat(Player* pPlayer, uint32 type, uint32 lang, std::string& msg, Channel* pChannel)
|
||||
{
|
||||
if (lang == LANG_ADDON)
|
||||
OnAddonMessage(pPlayer, type, msg, NULL, NULL, NULL, pChannel);
|
||||
bool result = true;
|
||||
if (sEluna->PlayerEventBindings.HasEvents(PLAYER_EVENT_ON_CHANNEL_CHAT))
|
||||
{
|
||||
@@ -1097,6 +1109,8 @@ bool HookMgr::OnChat(Player* pPlayer, uint32 type, uint32 lang, std::string& msg
|
||||
|
||||
bool HookMgr::OnChat(Player* pPlayer, uint32 type, uint32 lang, std::string& msg, Player* pReceiver)
|
||||
{
|
||||
if (lang == LANG_ADDON)
|
||||
OnAddonMessage(pPlayer, type, msg, pReceiver, NULL, NULL, NULL);
|
||||
bool result = true;
|
||||
if (sEluna->PlayerEventBindings.HasEvents(PLAYER_EVENT_ON_WHISPER))
|
||||
{
|
||||
|
||||
@@ -125,7 +125,7 @@ enum ServerEvents
|
||||
AUCTION_EVENT_ON_EXPIRE = 29, // (event, AHObject) // NOT SUPPORTED YET
|
||||
|
||||
// AddOns
|
||||
ADDON_EVENT_ON_MESSAGE = 30, // (event, sender, msg)
|
||||
ADDON_EVENT_ON_MESSAGE = 30, // (event, sender, type, msg_split_by_\t, nil/whisper_target/guid/group/channel)
|
||||
|
||||
SERVER_EVENT_COUNT
|
||||
};
|
||||
@@ -332,7 +332,7 @@ public:
|
||||
void OnGmTicketDelete(Player* pPlayer); // Not on TC
|
||||
InventoryResult OnCanUseItem(const Player* pPlayer, uint32 itemEntry);
|
||||
void OnEngineRestart();
|
||||
void OnAddonMessage(Player* pPlayer, std::string& msg, uint32 type, std::string& to);
|
||||
void OnAddonMessage(Player* sender, uint32 type, std::string& msg, Player* receiver, Guild* guild, Group* group, Channel* channel);
|
||||
|
||||
/* Item */
|
||||
bool OnDummyEffect(Unit* pCaster, uint32 spellId, SpellEffIndex effIndex, Item* pTarget);
|
||||
|
||||
Reference in New Issue
Block a user