This commit is contained in:
Rochet2
2014-04-13 17:09:29 +03:00
committed by Foereaper
parent 6bec5eeb44
commit 4537a7f8f0
2 changed files with 17 additions and 20 deletions

View File

@@ -215,21 +215,17 @@ bool HookMgr::OnPacketReceive(WorldSession* session, WorldPacket& packet)
return result;
}
// AddOns
void HookMgr::OnAddonMessage(Player* sender, uint32 type, std::string& msg, Player* receiver, Guild* guild, Group* group, Channel* channel)
bool 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;
return false;
ELUNA_GUARD();
sEluna->ServerEventBindings.BeginCall(ADDON_EVENT_ON_MESSAGE);
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)
{
sEluna->Push(sEluna->L, arg);
arg = strtok(NULL, "\t");
}
sEluna->Push(sEluna->L, strtok((char*)c_msg, "\t")); // prefix
sEluna->Push(sEluna->L, strtok(NULL, "")); // msg
if (receiver)
sEluna->Push(sEluna->L, receiver);
else if (guild)
@@ -242,6 +238,7 @@ void HookMgr::OnAddonMessage(Player* sender, uint32 type, std::string& msg, Play
sEluna->Push(sEluna->L);
sEluna->ServerEventBindings.ExecuteCall();
sEluna->ServerEventBindings.EndCall();
return true;
}
#ifndef MANGOS
@@ -982,8 +979,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);
if (lang == LANG_ADDON && OnAddonMessage(pPlayer, type, msg, NULL, NULL, NULL, NULL))
return true;
bool result = true;
if (sEluna->PlayerEventBindings.HasEvents(PLAYER_EVENT_ON_CHAT))
{
@@ -1013,8 +1010,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);
if (lang == LANG_ADDON && OnAddonMessage(pPlayer, type, msg, NULL, NULL, pGroup, NULL))
return true;
bool result = true;
if (sEluna->PlayerEventBindings.HasEvents(PLAYER_EVENT_ON_GROUP_CHAT))
{
@@ -1045,8 +1042,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);
if (lang == LANG_ADDON && OnAddonMessage(pPlayer, type, msg, NULL, pGuild, NULL, NULL))
return true;
bool result = true;
if (sEluna->PlayerEventBindings.HasEvents(PLAYER_EVENT_ON_GUILD_CHAT))
{
@@ -1077,8 +1074,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);
if (lang == LANG_ADDON && OnAddonMessage(pPlayer, type, msg, NULL, NULL, NULL, pChannel))
return true;
bool result = true;
if (sEluna->PlayerEventBindings.HasEvents(PLAYER_EVENT_ON_CHANNEL_CHAT))
{
@@ -1109,8 +1106,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);
if (lang == LANG_ADDON && OnAddonMessage(pPlayer, type, msg, pReceiver, NULL, NULL, NULL))
return true;
bool result = true;
if (sEluna->PlayerEventBindings.HasEvents(PLAYER_EVENT_ON_WHISPER))
{

View File

@@ -125,7 +125,7 @@ enum ServerEvents
AUCTION_EVENT_ON_EXPIRE = 29, // (event, AHObject) // NOT SUPPORTED YET
// AddOns
ADDON_EVENT_ON_MESSAGE = 30, // (event, sender, type, msg_split_by_\t, nil/whisper_target/guid/group/channel)
ADDON_EVENT_ON_MESSAGE = 30, // (event, sender, type, prefix, msg, target) - target can be 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* sender, uint32 type, std::string& msg, Player* receiver, Guild* guild, Group* group, Channel* channel);
bool 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);