From 4e787924e279eec6609d2a39c3ff0e7c44ae290c Mon Sep 17 00:00:00 2001 From: Rochet2 Date: Sun, 15 Feb 2015 00:16:22 +0200 Subject: [PATCH] Change AH hooks to work with TC --- ElunaIncludes.h | 2 ++ Hooks.h | 8 +++--- LuaEngine.h | 9 +++--- ServerHooks.cpp | 75 +++++++++++++++++++++++++++++++++++++++---------- 4 files changed, 71 insertions(+), 23 deletions(-) diff --git a/ElunaIncludes.h b/ElunaIncludes.h index eed76b6..8829006 100644 --- a/ElunaIncludes.h +++ b/ElunaIncludes.h @@ -87,6 +87,7 @@ typedef Opcodes OpcodesList; #define eGuildMgr (sGuildMgr) #define eObjectMgr (sObjectMgr) #define eAccountMgr (sAccountMgr) +#define eAuctionMgr (sAuctionMgr) #define eObjectAccessor (sObjectAccessor) #define REGEN_TIME_FULL typedef ThreatContainer::StorageType ThreatList; @@ -103,6 +104,7 @@ typedef ThreatContainer::StorageType ThreatList; #define eGuildMgr (&sGuildMgr) #define eObjectMgr (&sObjectMgr) #define eAccountMgr (&sAccountMgr) +#define eAuctionMgr (&sAuctionMgr) #define eObjectAccessor (&sObjectAccessor) #define SERVER_MSG_STRING SERVER_MSG_CUSTOM #define TOTAL_LOCALES MAX_LOCALE diff --git a/Hooks.h b/Hooks.h index 279ddd2..e7b7609 100644 --- a/Hooks.h +++ b/Hooks.h @@ -136,10 +136,10 @@ namespace Hooks WEATHER_EVENT_ON_CHANGE = 25, // (event, zoneId, state, grade) // Auction house - AUCTION_EVENT_ON_ADD = 26, // (event, auctionHouseEntry, player, item, bid, buyout, etime) - AUCTION_EVENT_ON_REMOVE = 27, // (event, auctionHouseEntry, player, item) - AUCTION_EVENT_ON_SUCCESSFUL = 28, // (event, auctionHouseEntry) // Not Implemented - AUCTION_EVENT_ON_EXPIRE = 29, // (event, auctionHouseEntry) // Not Implemented + AUCTION_EVENT_ON_ADD = 26, // (event, auctionId, owner, item, expireTime, buyout, startBid, currentBid, bidderGUIDLow) + AUCTION_EVENT_ON_REMOVE = 27, // (event, auctionId, owner, item, expireTime, buyout, startBid, currentBid, bidderGUIDLow) + AUCTION_EVENT_ON_SUCCESSFUL = 28, // (event, auctionId, owner, item, expireTime, buyout, startBid, currentBid, bidderGUIDLow) + AUCTION_EVENT_ON_EXPIRE = 29, // (event, auctionId, owner, item, expireTime, buyout, startBid, currentBid, bidderGUIDLow) // AddOns ADDON_EVENT_ON_MESSAGE = 30, // (event, sender, type, prefix, msg, target) - target can be nil/whisper_target/guild/group/channel. Can return false diff --git a/LuaEngine.h b/LuaEngine.h index 83a6cb2..98371f2 100644 --- a/LuaEngine.h +++ b/LuaEngine.h @@ -41,6 +41,7 @@ typedef int Difficulty; struct AreaTriggerEntry; class AuctionHouseObject; +struct AuctionEntry; #ifdef TRINITY class Battleground; typedef Battleground BattleGround; @@ -442,10 +443,10 @@ public: void OnChange(Weather* weather, uint32 zone, WeatherState state, float grade); /* Auction House */ - void OnAdd(AuctionHouseEntry const* auctionHouseEntry, Player* pPlayer, Item* pItem, uint32 bid, uint32 buyout, uint32 etime); - void OnRemove(AuctionHouseEntry const* auctionHouseEntry, Player* pPlayer, Item* pItem); - void OnSuccessful(AuctionHouseEntry const* auctionHouseEntry); - void OnExpire(AuctionHouseEntry const* auctionHouseEntry); + void OnAdd(AuctionHouseObject* ah, AuctionEntry* entry); + void OnRemove(AuctionHouseObject* ah, AuctionEntry* entry); + void OnSuccessful(AuctionHouseObject* ah, AuctionEntry* entry); + void OnExpire(AuctionHouseObject* ah, AuctionEntry* entry); /* Guild */ void OnAddMember(Guild* guild, Player* player, uint32 plRank); diff --git a/ServerHooks.cpp b/ServerHooks.cpp index 0de14b8..7f11656 100644 --- a/ServerHooks.cpp +++ b/ServerHooks.cpp @@ -82,50 +82,95 @@ void Eluna::OnChange(Weather* weather, uint32 zone, WeatherState state, float gr } // Auction House -void Eluna::OnAdd(AuctionHouseEntry const* auctionHouseEntry, Player* pPlayer, Item* pItem, uint32 bid, uint32 buyout, uint32 etime) +void Eluna::OnAdd(AuctionHouseObject* /*ah*/, AuctionEntry* entry) { if (!ServerEventBindings->HasEvents(AUCTION_EVENT_ON_ADD)) return; + Player* owner = eObjectAccessor->FindPlayer(MAKE_NEW_GUID(entry->owner, 0, HIGHGUID_PLAYER)); + Item* item = eAuctionMgr->GetAItem(entry->itemGUIDLow); + + if (!owner || !item) + return; + LOCK_ELUNA; - Push(auctionHouseEntry); - Push(pPlayer); - Push(pItem); - Push(bid); - Push(buyout); - Push(etime); + Push(entry->Id); + Push(owner); + Push(item); + Push(entry->expire_time); + Push(entry->buyout); + Push(entry->startbid); + Push(entry->bid); + Push(entry->bidder); CallAllFunctions(ServerEventBindings, AUCTION_EVENT_ON_ADD); } -void Eluna::OnRemove(AuctionHouseEntry const* auctionHouseEntry, Player* pPlayer, Item* pItem) +void Eluna::OnRemove(AuctionHouseObject* /*ah*/, AuctionEntry* entry) { if (!ServerEventBindings->HasEvents(AUCTION_EVENT_ON_REMOVE)) return; + Player* owner = eObjectAccessor->FindPlayer(MAKE_NEW_GUID(entry->owner, 0, HIGHGUID_PLAYER)); + Item* item = eAuctionMgr->GetAItem(entry->itemGUIDLow); + + if (!owner || !item) + return; + LOCK_ELUNA; - Push(auctionHouseEntry); - Push(pPlayer); - Push(pItem); + Push(entry->Id); + Push(owner); + Push(item); + Push(entry->expire_time); + Push(entry->buyout); + Push(entry->startbid); + Push(entry->bid); + Push(entry->bidder); CallAllFunctions(ServerEventBindings, AUCTION_EVENT_ON_REMOVE); } -void Eluna::OnSuccessful(AuctionHouseEntry const* auctionHouseEntry) +void Eluna::OnSuccessful(AuctionHouseObject* /*ah*/, AuctionEntry* entry) { if (!ServerEventBindings->HasEvents(AUCTION_EVENT_ON_SUCCESSFUL)) return; + Player* owner = eObjectAccessor->FindPlayer(MAKE_NEW_GUID(entry->owner, 0, HIGHGUID_PLAYER)); + Item* item = eAuctionMgr->GetAItem(entry->itemGUIDLow); + + if (!owner || !item) + return; + LOCK_ELUNA; - Push(auctionHouseEntry); + Push(entry->Id); + Push(owner); + Push(item); + Push(entry->expire_time); + Push(entry->buyout); + Push(entry->startbid); + Push(entry->bid); + Push(entry->bidder); CallAllFunctions(ServerEventBindings, AUCTION_EVENT_ON_SUCCESSFUL); } -void Eluna::OnExpire(AuctionHouseEntry const* auctionHouseEntry) +void Eluna::OnExpire(AuctionHouseObject* /*ah*/, AuctionEntry* entry) { if (!ServerEventBindings->HasEvents(AUCTION_EVENT_ON_EXPIRE)) return; + Player* owner = eObjectAccessor->FindPlayer(MAKE_NEW_GUID(entry->owner, 0, HIGHGUID_PLAYER)); + Item* item = eAuctionMgr->GetAItem(entry->itemGUIDLow); + + if (!owner || !item) + return; + LOCK_ELUNA; - Push(auctionHouseEntry); + Push(entry->Id); + Push(owner); + Push(item); + Push(entry->expire_time); + Push(entry->buyout); + Push(entry->startbid); + Push(entry->bid); + Push(entry->bidder); CallAllFunctions(ServerEventBindings, AUCTION_EVENT_ON_EXPIRE); }