mirror of
https://github.com/NathanHandley/mod-ah-bot-plus.git
synced 2026-01-13 01:08:37 +00:00
feat(Hook): Use hooks instead of the patch file (#15)
This commit is contained in:
@@ -6,16 +6,17 @@
|
||||
CU_SET_PATH("CMAKE_MOD_AHBOT_DIR" "${CMAKE_CURRENT_LIST_DIR}")
|
||||
|
||||
# CMake hooks
|
||||
CU_ADD_HOOK(AFTER_LOAD_CONF "${CMAKE_MOD_AHBOT_DIR}/cmake/after_load_conf.cmake")
|
||||
CU_ADD_HOOK(AFTER_GAME_LIBRARY "${CMAKE_MOD_AHBOT_DIR}/cmake/after_game_lib.cmake")
|
||||
|
||||
# Add SC
|
||||
AC_ADD_SCRIPT("${CMAKE_MOD_AHBOT_DIR}/src/cs_ah_bot.cpp")
|
||||
AC_ADD_SCRIPT("${CMAKE_MOD_AHBOT_DIR}/src/AuctionHouseBot.cpp")
|
||||
AC_ADD_SCRIPT("${CMAKE_MOD_AHBOT_DIR}/src/AuctionHouseBot.h")
|
||||
AC_ADD_SCRIPT("${CMAKE_MOD_AHBOT_DIR}/src/AuctionHouseBotScript.cpp")
|
||||
|
||||
# Add SL
|
||||
AC_ADD_SCRIPT_LOADER("AHBotCommand" "${CMAKE_MOD_AHBOT_DIR}/src/loader_cs_ah_bot.h")
|
||||
AC_ADD_SCRIPT_LOADER("AHBot" "${CMAKE_MOD_AHBOT_DIR}/src/loader_ah_bot.h")
|
||||
|
||||
# Add conf file
|
||||
AC_ADD_CONFIG_FILE("${CMAKE_MOD_AHBOT_DIR}/conf/mod_ahbot.conf.dist")
|
||||
|
||||
147
ahbot.patch
147
ahbot.patch
@@ -1,147 +0,0 @@
|
||||
diff --git a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp
|
||||
index b8363279..05318818 100644
|
||||
--- a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp
|
||||
+++ b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp
|
||||
@@ -21,6 +21,9 @@
|
||||
#include <vector>
|
||||
#include "AvgDiffTracker.h"
|
||||
#include "AsyncAuctionListing.h"
|
||||
+#ifdef MOD_AH_BOT
|
||||
+#include "AuctionHouseBot.h"
|
||||
+#endif
|
||||
|
||||
enum eAuctionHouse
|
||||
{
|
||||
@@ -145,8 +148,11 @@ void AuctionHouseMgr::SendAuctionSuccessfulMail(AuctionEntry* auction, SQLTransa
|
||||
if (owner || owner_accId)
|
||||
{
|
||||
uint32 profit = auction->bid + auction->deposit - auction->GetAuctionCut();
|
||||
-
|
||||
+#ifdef MOD_AH_BOT
|
||||
+ if (owner && owner->GetGUIDLow() != auctionbot->GetAHBplayerGUID())
|
||||
+#else
|
||||
if (owner)
|
||||
+#endif
|
||||
{
|
||||
owner->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GOLD_EARNED_BY_AUCTIONS, profit);
|
||||
owner->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_SOLD, auction->bid);
|
||||
@@ -189,7 +195,11 @@ void AuctionHouseMgr::SendAuctionExpiredMail(AuctionEntry* auction, SQLTransacti
|
||||
// owner exist
|
||||
if (owner || owner_accId)
|
||||
{
|
||||
+#ifdef MOD_AH_BOT
|
||||
+ if (owner && owner->GetGUIDLow() != auctionbot->GetAHBplayerGUID())
|
||||
+#else
|
||||
if (owner)
|
||||
+#endif
|
||||
owner->GetSession()->SendAuctionOwnerNotification(auction);
|
||||
|
||||
MailDraft(auction->BuildAuctionMailSubject(AUCTION_EXPIRED), AuctionEntry::BuildAuctionMailBody(0, 0, auction->buyout, auction->deposit, 0))
|
||||
@@ -213,6 +223,11 @@ void AuctionHouseMgr::SendAuctionOutbiddedMail(AuctionEntry* auction, uint32 new
|
||||
// old bidder exist
|
||||
if (oldBidder || oldBidder_accId)
|
||||
{
|
||||
+#ifdef MOD_AH_BOT
|
||||
+ if (oldBidder && !newBidder)
|
||||
+ oldBidder->GetSession()->SendAuctionBidderNotification(auction->GetHouseId(), auction->Id, auctionbot->GetAHBplayerGUID(), newPrice, auction->GetAuctionOutBid(), auction->item_template);
|
||||
+#endif // MOD_AH_BOT
|
||||
+
|
||||
if (oldBidder && newBidder)
|
||||
oldBidder->GetSession()->SendAuctionBidderNotification(auction->GetHouseId(), auction->Id, newBidder->GetGUID(), newPrice, auction->GetAuctionOutBid(), auction->item_template);
|
||||
|
||||
@@ -413,10 +428,16 @@ void AuctionHouseObject::AddAuction(AuctionEntry* auction)
|
||||
|
||||
AuctionsMap[auction->Id] = auction;
|
||||
sScriptMgr->OnAuctionAdd(this, auction);
|
||||
+#ifdef MOD_AH_BOT
|
||||
+ auctionbot->IncrementItemCounts(auction);
|
||||
+#endif
|
||||
}
|
||||
|
||||
bool AuctionHouseObject::RemoveAuction(AuctionEntry* auction)
|
||||
{
|
||||
+#ifdef MOD_AH_BOT
|
||||
+ auctionbot->DecrementItemCounts(auction, auction->item_template);
|
||||
+#endif
|
||||
bool wasInMap = AuctionsMap.erase(auction->Id) ? true : false;
|
||||
|
||||
sScriptMgr->OnAuctionRemove(this, auction);
|
||||
diff --git a/src/server/game/Mails/Mail.cpp b/src/server/game/Mails/Mail.cpp
|
||||
index 6683fe2f..9fcd2094 100644
|
||||
--- a/src/server/game/Mails/Mail.cpp
|
||||
+++ b/src/server/game/Mails/Mail.cpp
|
||||
@@ -15,6 +15,9 @@
|
||||
#include "Item.h"
|
||||
#include "AuctionHouseMgr.h"
|
||||
#include "CalendarMgr.h"
|
||||
+#ifdef MOD_AH_BOT
|
||||
+#include "AuctionHouseBot.h"
|
||||
+#endif
|
||||
|
||||
MailSender::MailSender(Object* sender, MailStationery stationery) : m_stationery(stationery)
|
||||
{
|
||||
@@ -175,6 +178,15 @@ void MailDraft::SendMailTo(SQLTransaction& trans, MailReceiver const& receiver,
|
||||
|
||||
uint32 mailId = sObjectMgr->GenerateMailID();
|
||||
|
||||
+#ifdef MOD_AH_BOT
|
||||
+ if (receiver.GetPlayerGUIDLow() == auctionbot->GetAHBplayerGUID())
|
||||
+ {
|
||||
+ if (sender.GetMailMessageType() == MAIL_AUCTION) // auction mail with items
|
||||
+ deleteIncludedItems(trans, true);
|
||||
+ return;
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
time_t deliver_time = time(NULL) + deliver_delay;
|
||||
|
||||
//expire time if COD 3 days, if no COD 30 days, if auction sale pending 1 hour
|
||||
diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp
|
||||
index 7b0f464f..997e52ad 100644
|
||||
--- a/src/server/game/World/World.cpp
|
||||
+++ b/src/server/game/World/World.cpp
|
||||
@@ -83,6 +83,10 @@
|
||||
#include "LuaEngine.h"
|
||||
#endif
|
||||
|
||||
+#ifdef MOD_AH_BOT
|
||||
+#include "AuctionHouseBot.h"
|
||||
+#endif
|
||||
+
|
||||
ACE_Atomic_Op<ACE_Thread_Mutex, bool> World::m_stopEvent = false;
|
||||
uint8 World::m_ExitCode = SHUTDOWN_EXIT_CODE;
|
||||
uint32 World::m_worldLoopCounter = 0;
|
||||
@@ -1742,6 +1746,11 @@ void World::SetInitialWorldSettings()
|
||||
sLog->outString("Loading Completed Achievements...");
|
||||
sAchievementMgr->LoadCompletedAchievements();
|
||||
|
||||
+#ifdef MOD_AH_BOT
|
||||
+ // Initialize AHBot settings before deleting expired auctions due to AHBot hooks
|
||||
+ auctionbot->InitializeConfiguration();
|
||||
+#endif
|
||||
+
|
||||
///- Load dynamic data tables from the database
|
||||
sLog->outString("Loading Item Auctions...");
|
||||
sAuctionMgr->LoadAuctionItems();
|
||||
@@ -2003,6 +2012,11 @@ void World::SetInitialWorldSettings()
|
||||
}
|
||||
}
|
||||
|
||||
+ #ifdef MOD_AH_BOT
|
||||
+ sLog->outString("Initialize AuctionHouseBot...");
|
||||
+ auctionbot->Initialize();
|
||||
+ #endif
|
||||
+
|
||||
uint32 startupDuration = GetMSTimeDiffToNow(startupBegin);
|
||||
sLog->outString();
|
||||
sLog->outError("WORLD: World initialized in %u minutes %u seconds", (startupDuration / 60000), ((startupDuration % 60000) / 1000)); // outError for red color in console
|
||||
@@ -2168,6 +2182,9 @@ void World::Update(uint32 diff)
|
||||
// pussywizard: handle auctions when the timer has passed
|
||||
if (m_timers[WUPDATE_AUCTIONS].Passed())
|
||||
{
|
||||
+#ifdef MOD_AH_BOT
|
||||
+ auctionbot->Update();
|
||||
+#endif
|
||||
m_timers[WUPDATE_AUCTIONS].Reset();
|
||||
|
||||
// pussywizard: handle expired auctions, auctions expired when realm was offline are also handled here (not during loading when many required things aren't loaded yet)
|
||||
@@ -1,6 +0,0 @@
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
# Add definitions
|
||||
add_definitions(-DMOD_AH_BOT)
|
||||
@@ -91,10 +91,6 @@ AuctionHouseBot.ItemsPerCycle = 200
|
||||
# Bind_Quest_Item
|
||||
# Default 0 (False)
|
||||
#
|
||||
# AuctionHouseBot.DisableBeta_PTR_Unused
|
||||
# Disable certain items that are usually unavailable to Players
|
||||
# Default 0 (False)
|
||||
#
|
||||
# AuctionHouseBot.DisablePermEnchant
|
||||
# Disable Items with a Permanent Enchantment
|
||||
# Default 0 (False)
|
||||
@@ -147,7 +143,6 @@ AuctionHouseBot.Bind_When_Picked_Up = 0
|
||||
AuctionHouseBot.Bind_When_Equipped = 1
|
||||
AuctionHouseBot.Bind_When_Use = 1
|
||||
AuctionHouseBot.Bind_Quest_Item = 0
|
||||
AuctionHouseBot.DisableBeta_PTR_Unused = 0
|
||||
AuctionHouseBot.DisablePermEnchant = 0
|
||||
AuctionHouseBot.DisableConjured = 0
|
||||
AuctionHouseBot.DisableGems = 0
|
||||
|
||||
89
src/AuctionHouseBotScript.cpp
Normal file
89
src/AuctionHouseBotScript.cpp
Normal file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3
|
||||
*/
|
||||
|
||||
#include "ScriptMgr.h"
|
||||
#include "Player.h"
|
||||
#include "AuctionHouseBot.h"
|
||||
|
||||
class AHBot_WorldScript : public WorldScript
|
||||
{
|
||||
public:
|
||||
AHBot_WorldScript() : WorldScript("AHBot_WorldScript") { }
|
||||
|
||||
void OnBeforeConfigLoad(bool /*reload*/) override
|
||||
{
|
||||
auctionbot->InitializeConfiguration();
|
||||
}
|
||||
|
||||
void OnStartup() override
|
||||
{
|
||||
sLog->outString("Initialize AuctionHouseBot...");
|
||||
auctionbot->Initialize();
|
||||
}
|
||||
};
|
||||
|
||||
class AHBot_AuctionHouseScript : public AuctionHouseScript
|
||||
{
|
||||
public:
|
||||
AHBot_AuctionHouseScript() : AuctionHouseScript("AHBot_AuctionHouseScript") { }
|
||||
|
||||
void OnBeforeAuctionHouseMgrSendAuctionSuccessfulMail(AuctionHouseMgr* /*auctionHouseMgr*/, AuctionEntry* /*auction*/, Player* owner, uint32& /*owner_accId*/, uint32& /*profit*/, bool& sendNotification, bool& updateAchievementCriteria, bool& /*sendMail*/) override
|
||||
{
|
||||
if (owner && owner->GetGUIDLow() == auctionbot->GetAHBplayerGUID())
|
||||
{
|
||||
sendNotification = false;
|
||||
updateAchievementCriteria = false;
|
||||
}
|
||||
}
|
||||
|
||||
void OnBeforeAuctionHouseMgrSendAuctionExpiredMail(AuctionHouseMgr* /*auctionHouseMgr*/, AuctionEntry* /*auction*/, Player* owner, uint32& /*owner_accId*/, bool& sendNotification, bool& /*sendMail*/) override
|
||||
{
|
||||
if (owner && owner->GetGUIDLow() == auctionbot->GetAHBplayerGUID())
|
||||
sendNotification = false;
|
||||
}
|
||||
|
||||
void OnBeforeAuctionHouseMgrSendAuctionOutbiddedMail(AuctionHouseMgr* /*auctionHouseMgr*/, AuctionEntry* auction, Player* oldBidder, uint32& /*oldBidder_accId*/, Player* newBidder, uint32& newPrice, bool& /*sendNotification*/, bool& /*sendMail*/) override
|
||||
{
|
||||
if (oldBidder && !newBidder)
|
||||
oldBidder->GetSession()->SendAuctionBidderNotification(auction->GetHouseId(), auction->Id, auctionbot->GetAHBplayerGUID(), newPrice, auction->GetAuctionOutBid(), auction->item_template);
|
||||
}
|
||||
|
||||
void OnAuctionAdd(AuctionHouseObject* /*ah*/, AuctionEntry* auction) override
|
||||
{
|
||||
auctionbot->IncrementItemCounts(auction);
|
||||
}
|
||||
|
||||
void OnAuctionRemove(AuctionHouseObject* /*ah*/, AuctionEntry* auction) override
|
||||
{
|
||||
auctionbot->DecrementItemCounts(auction, auction->item_template);
|
||||
}
|
||||
|
||||
void OnBeforeAuctionHouseMgrUpdate() override
|
||||
{
|
||||
auctionbot->Update();
|
||||
}
|
||||
};
|
||||
|
||||
class AHBot_MailScript : public MailScript
|
||||
{
|
||||
public:
|
||||
AHBot_MailScript() : MailScript("AHBot_MailScript") { }
|
||||
|
||||
void OnBeforeMailDraftSendMailTo(MailDraft* /*mailDraft*/, MailReceiver const& receiver, MailSender const& sender, MailCheckMask& /*checked*/, uint32& /*deliver_delay*/, uint32& /*custom_expiration*/, bool& deleteMailItemsFromDB, bool& sendMail) override
|
||||
{
|
||||
if (receiver.GetPlayerGUIDLow() == auctionbot->GetAHBplayerGUID())
|
||||
{
|
||||
if (sender.GetMailMessageType() == MAIL_AUCTION) // auction mail with items
|
||||
deleteMailItemsFromDB = true;
|
||||
sendMail = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void AddAHBotScripts()
|
||||
{
|
||||
new AHBot_WorldScript();
|
||||
new AHBot_AuctionHouseScript();
|
||||
new AHBot_MailScript();
|
||||
}
|
||||
@@ -476,7 +476,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
void AddSC_ah_bot_commandscript()
|
||||
void AddAHBotCommandScripts()
|
||||
{
|
||||
new ah_bot_commandscript();
|
||||
}
|
||||
|
||||
1
src/loader_ah_bot.h
Normal file
1
src/loader_ah_bot.h
Normal file
@@ -0,0 +1 @@
|
||||
void AddAHBotScripts();
|
||||
@@ -1,6 +1 @@
|
||||
void AddSC_ah_bot_commandscript();
|
||||
|
||||
void AddAHBotCommandScripts()
|
||||
{
|
||||
AddSC_ah_bot_commandscript();
|
||||
}
|
||||
void AddAHBotCommandScripts();
|
||||
|
||||
Reference in New Issue
Block a user