Merge new_bindings, closes #151
Refer to 6194ddb43c for new C++11 required changes for mangos based cores
This commit is contained in:
@@ -4,97 +4,81 @@
|
||||
* Please see the included DOCS/LICENSE.md for more information
|
||||
*/
|
||||
|
||||
#ifndef _GUILD_HOOKS_H
|
||||
#define _GUILD_HOOKS_H
|
||||
|
||||
#include "Hooks.h"
|
||||
#include "HookHelpers.h"
|
||||
#include "LuaEngine.h"
|
||||
#include "ElunaBinding.h"
|
||||
#include "BindingMap.h"
|
||||
#include "ElunaTemplate.h"
|
||||
|
||||
using namespace Hooks;
|
||||
|
||||
#define START_HOOK(EVENT) \
|
||||
if (!IsEnabled())\
|
||||
return;\
|
||||
auto key = EventKey<GuildEvents>(EVENT);\
|
||||
if (!GuildEventBindings->HasBindingsFor(key))\
|
||||
return;\
|
||||
LOCK_ELUNA
|
||||
|
||||
void Eluna::OnAddMember(Guild* guild, Player* player, uint32 plRank)
|
||||
{
|
||||
if (!GuildEventBindings->HasEvents(GUILD_EVENT_ON_ADD_MEMBER))
|
||||
return;
|
||||
|
||||
LOCK_ELUNA;
|
||||
START_HOOK(GUILD_EVENT_ON_ADD_MEMBER);
|
||||
Push(guild);
|
||||
Push(player);
|
||||
Push(plRank);
|
||||
CallAllFunctions(GuildEventBindings, GUILD_EVENT_ON_ADD_MEMBER);
|
||||
CallAllFunctions(GuildEventBindings, key);
|
||||
}
|
||||
|
||||
void Eluna::OnRemoveMember(Guild* guild, Player* player, bool isDisbanding)
|
||||
{
|
||||
if (!GuildEventBindings->HasEvents(GUILD_EVENT_ON_REMOVE_MEMBER))
|
||||
return;
|
||||
|
||||
LOCK_ELUNA;
|
||||
START_HOOK(GUILD_EVENT_ON_REMOVE_MEMBER);
|
||||
Push(guild);
|
||||
Push(player);
|
||||
Push(isDisbanding);
|
||||
CallAllFunctions(GuildEventBindings, GUILD_EVENT_ON_REMOVE_MEMBER);
|
||||
CallAllFunctions(GuildEventBindings, key);
|
||||
}
|
||||
|
||||
void Eluna::OnMOTDChanged(Guild* guild, const std::string& newMotd)
|
||||
{
|
||||
if (!GuildEventBindings->HasEvents(GUILD_EVENT_ON_MOTD_CHANGE))
|
||||
return;
|
||||
|
||||
LOCK_ELUNA;
|
||||
START_HOOK(GUILD_EVENT_ON_MOTD_CHANGE);
|
||||
Push(guild);
|
||||
Push(newMotd);
|
||||
CallAllFunctions(GuildEventBindings, GUILD_EVENT_ON_MOTD_CHANGE);
|
||||
CallAllFunctions(GuildEventBindings, key);
|
||||
}
|
||||
|
||||
void Eluna::OnInfoChanged(Guild* guild, const std::string& newInfo)
|
||||
{
|
||||
if (!GuildEventBindings->HasEvents(GUILD_EVENT_ON_INFO_CHANGE))
|
||||
return;
|
||||
|
||||
LOCK_ELUNA;
|
||||
START_HOOK(GUILD_EVENT_ON_INFO_CHANGE);
|
||||
Push(guild);
|
||||
Push(newInfo);
|
||||
CallAllFunctions(GuildEventBindings, GUILD_EVENT_ON_INFO_CHANGE);
|
||||
CallAllFunctions(GuildEventBindings, key);
|
||||
}
|
||||
|
||||
void Eluna::OnCreate(Guild* guild, Player* leader, const std::string& name)
|
||||
{
|
||||
if (!GuildEventBindings->HasEvents(GUILD_EVENT_ON_CREATE))
|
||||
return;
|
||||
|
||||
LOCK_ELUNA;
|
||||
START_HOOK(GUILD_EVENT_ON_CREATE);
|
||||
Push(guild);
|
||||
Push(leader);
|
||||
Push(name);
|
||||
CallAllFunctions(GuildEventBindings, GUILD_EVENT_ON_CREATE);
|
||||
CallAllFunctions(GuildEventBindings, key);
|
||||
}
|
||||
|
||||
void Eluna::OnDisband(Guild* guild)
|
||||
{
|
||||
if (!GuildEventBindings->HasEvents(GUILD_EVENT_ON_DISBAND))
|
||||
return;
|
||||
|
||||
LOCK_ELUNA;
|
||||
START_HOOK(GUILD_EVENT_ON_DISBAND);
|
||||
Push(guild);
|
||||
CallAllFunctions(GuildEventBindings, GUILD_EVENT_ON_DISBAND);
|
||||
CallAllFunctions(GuildEventBindings, key);
|
||||
}
|
||||
|
||||
void Eluna::OnMemberWitdrawMoney(Guild* guild, Player* player, uint32& amount, bool isRepair) // isRepair not a part of Mangos, implement?
|
||||
{
|
||||
if (!GuildEventBindings->HasEvents(GUILD_EVENT_ON_MONEY_WITHDRAW))
|
||||
return;
|
||||
|
||||
LOCK_ELUNA;
|
||||
START_HOOK(GUILD_EVENT_ON_MONEY_WITHDRAW);
|
||||
Push(guild);
|
||||
Push(player);
|
||||
Push(amount);
|
||||
Push(isRepair); // isRepair not a part of Mangos, implement?
|
||||
int amountIndex = lua_gettop(L) - 1;
|
||||
int n = SetupStack(GuildEventBindings, GUILD_EVENT_ON_MONEY_WITHDRAW, 4);
|
||||
int n = SetupStack(GuildEventBindings, key, 4);
|
||||
|
||||
while (n > 0)
|
||||
{
|
||||
@@ -115,15 +99,12 @@ void Eluna::OnMemberWitdrawMoney(Guild* guild, Player* player, uint32& amount, b
|
||||
|
||||
void Eluna::OnMemberDepositMoney(Guild* guild, Player* player, uint32& amount)
|
||||
{
|
||||
if (!GuildEventBindings->HasEvents(GUILD_EVENT_ON_MONEY_DEPOSIT))
|
||||
return;
|
||||
|
||||
LOCK_ELUNA;
|
||||
START_HOOK(GUILD_EVENT_ON_MONEY_DEPOSIT);
|
||||
Push(guild);
|
||||
Push(player);
|
||||
Push(amount);
|
||||
int amountIndex = lua_gettop(L);
|
||||
int n = SetupStack(GuildEventBindings, GUILD_EVENT_ON_MONEY_DEPOSIT, 3);
|
||||
int n = SetupStack(GuildEventBindings, key, 3);
|
||||
|
||||
while (n > 0)
|
||||
{
|
||||
@@ -145,10 +126,7 @@ void Eluna::OnMemberDepositMoney(Guild* guild, Player* player, uint32& amount)
|
||||
void Eluna::OnItemMove(Guild* guild, Player* player, Item* pItem, bool isSrcBank, uint8 srcContainer, uint8 srcSlotId,
|
||||
bool isDestBank, uint8 destContainer, uint8 destSlotId)
|
||||
{
|
||||
if (!GuildEventBindings->HasEvents(GUILD_EVENT_ON_ITEM_MOVE))
|
||||
return;
|
||||
|
||||
LOCK_ELUNA;
|
||||
START_HOOK(GUILD_EVENT_ON_ITEM_MOVE);
|
||||
Push(guild);
|
||||
Push(player);
|
||||
Push(pItem);
|
||||
@@ -158,29 +136,23 @@ void Eluna::OnItemMove(Guild* guild, Player* player, Item* pItem, bool isSrcBank
|
||||
Push(isDestBank);
|
||||
Push(destContainer);
|
||||
Push(destSlotId);
|
||||
CallAllFunctions(GuildEventBindings, GUILD_EVENT_ON_ITEM_MOVE);
|
||||
CallAllFunctions(GuildEventBindings, key);
|
||||
}
|
||||
|
||||
void Eluna::OnEvent(Guild* guild, uint8 eventType, uint32 playerGuid1, uint32 playerGuid2, uint8 newRank)
|
||||
{
|
||||
if (!GuildEventBindings->HasEvents(GUILD_EVENT_ON_EVENT))
|
||||
return;
|
||||
|
||||
LOCK_ELUNA;
|
||||
START_HOOK(GUILD_EVENT_ON_EVENT);
|
||||
Push(guild);
|
||||
Push(eventType);
|
||||
Push(playerGuid1);
|
||||
Push(playerGuid2);
|
||||
Push(newRank);
|
||||
CallAllFunctions(GuildEventBindings, GUILD_EVENT_ON_EVENT);
|
||||
CallAllFunctions(GuildEventBindings, key);
|
||||
}
|
||||
|
||||
void Eluna::OnBankEvent(Guild* guild, uint8 eventType, uint8 tabId, uint32 playerGuid, uint32 itemOrMoney, uint16 itemStackCount, uint8 destTabId)
|
||||
{
|
||||
if (!GuildEventBindings->HasEvents(GUILD_EVENT_ON_BANK_EVENT))
|
||||
return;
|
||||
|
||||
LOCK_ELUNA;
|
||||
START_HOOK(GUILD_EVENT_ON_BANK_EVENT);
|
||||
Push(guild);
|
||||
Push(eventType);
|
||||
Push(tabId);
|
||||
@@ -188,7 +160,5 @@ void Eluna::OnBankEvent(Guild* guild, uint8 eventType, uint8 tabId, uint32 playe
|
||||
Push(itemOrMoney);
|
||||
Push(itemStackCount);
|
||||
Push(destTabId);
|
||||
CallAllFunctions(GuildEventBindings, GUILD_EVENT_ON_BANK_EVENT);
|
||||
CallAllFunctions(GuildEventBindings, key);
|
||||
}
|
||||
|
||||
#endif // _GUILD_HOOKS_H
|
||||
|
||||
Reference in New Issue
Block a user