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;
|
return result;
|
||||||
}
|
}
|
||||||
// AddOns
|
// 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))
|
if (!sEluna->ServerEventBindings.HasEvents(ADDON_EVENT_ON_MESSAGE))
|
||||||
return;
|
return;
|
||||||
ELUNA_GUARD();
|
ELUNA_GUARD();
|
||||||
sEluna->ServerEventBindings.BeginCall(ADDON_EVENT_ON_MESSAGE);
|
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();
|
const char* c_msg = msg.c_str();
|
||||||
char* arg = strtok((char*)c_msg, "\t");
|
char* arg = strtok((char*)c_msg, "\t");
|
||||||
while (arg)
|
while (arg)
|
||||||
@@ -230,12 +230,16 @@ void HookMgr::OnAddonMessage(Player* pPlayer, std::string& msg, uint32 type, std
|
|||||||
sEluna->Push(sEluna->L, arg);
|
sEluna->Push(sEluna->L, arg);
|
||||||
arg = strtok(NULL, "\t");
|
arg = strtok(NULL, "\t");
|
||||||
}
|
}
|
||||||
|
if (receiver)
|
||||||
sEluna->Push(sEluna->L, type);
|
sEluna->Push(sEluna->L, receiver);
|
||||||
if (to.empty())
|
else if (guild)
|
||||||
sEluna->Push(sEluna->L);
|
sEluna->Push(sEluna->L, guild);
|
||||||
|
else if (group)
|
||||||
|
sEluna->Push(sEluna->L, group);
|
||||||
|
else if (channel)
|
||||||
|
sEluna->Push(sEluna->L, channel->GetChannelId());
|
||||||
else
|
else
|
||||||
sEluna->Push(sEluna->L, to);
|
sEluna->Push(sEluna->L);
|
||||||
sEluna->ServerEventBindings.ExecuteCall();
|
sEluna->ServerEventBindings.ExecuteCall();
|
||||||
sEluna->ServerEventBindings.EndCall();
|
sEluna->ServerEventBindings.EndCall();
|
||||||
}
|
}
|
||||||
@@ -978,6 +982,8 @@ void HookMgr::OnMapChanged(Player* player)
|
|||||||
|
|
||||||
bool HookMgr::OnChat(Player* pPlayer, uint32 type, uint32 lang, std::string& msg)
|
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;
|
bool result = true;
|
||||||
if (sEluna->PlayerEventBindings.HasEvents(PLAYER_EVENT_ON_CHAT))
|
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)
|
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;
|
bool result = true;
|
||||||
if (sEluna->PlayerEventBindings.HasEvents(PLAYER_EVENT_ON_GROUP_CHAT))
|
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)
|
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;
|
bool result = true;
|
||||||
if (sEluna->PlayerEventBindings.HasEvents(PLAYER_EVENT_ON_GUILD_CHAT))
|
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)
|
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;
|
bool result = true;
|
||||||
if (sEluna->PlayerEventBindings.HasEvents(PLAYER_EVENT_ON_CHANNEL_CHAT))
|
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)
|
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;
|
bool result = true;
|
||||||
if (sEluna->PlayerEventBindings.HasEvents(PLAYER_EVENT_ON_WHISPER))
|
if (sEluna->PlayerEventBindings.HasEvents(PLAYER_EVENT_ON_WHISPER))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ enum ServerEvents
|
|||||||
AUCTION_EVENT_ON_EXPIRE = 29, // (event, AHObject) // NOT SUPPORTED YET
|
AUCTION_EVENT_ON_EXPIRE = 29, // (event, AHObject) // NOT SUPPORTED YET
|
||||||
|
|
||||||
// AddOns
|
// 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
|
SERVER_EVENT_COUNT
|
||||||
};
|
};
|
||||||
@@ -332,7 +332,7 @@ public:
|
|||||||
void OnGmTicketDelete(Player* pPlayer); // Not on TC
|
void OnGmTicketDelete(Player* pPlayer); // Not on TC
|
||||||
InventoryResult OnCanUseItem(const Player* pPlayer, uint32 itemEntry);
|
InventoryResult OnCanUseItem(const Player* pPlayer, uint32 itemEntry);
|
||||||
void OnEngineRestart();
|
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 */
|
/* Item */
|
||||||
bool OnDummyEffect(Unit* pCaster, uint32 spellId, SpellEffIndex effIndex, Item* pTarget);
|
bool OnDummyEffect(Unit* pCaster, uint32 spellId, SpellEffIndex effIndex, Item* pTarget);
|
||||||
|
|||||||
Reference in New Issue
Block a user