Compare commits

..

1 Commits

Author SHA1 Message Date
bashermens
057ba2ab5e Minor fix 2026-01-15 00:41:41 +01:00
1161 changed files with 291 additions and 308 deletions

View File

@@ -25,25 +25,21 @@ jobs:
with: with:
repository: 'mod-playerbots/azerothcore-wotlk' repository: 'mod-playerbots/azerothcore-wotlk'
ref: 'Playerbot' ref: 'Playerbot'
path: 'ac'
- name: Checkout Playerbot Module - name: Checkout Playerbot Module
uses: actions/checkout@v3 uses: actions/checkout@v3
with: with:
repository: 'mod-playerbots/mod-playerbots' repository: 'mod-playerbots/mod-playerbots'
#path: 'modules/mod-playerbots' path: 'modules/mod-playerbots'
path: ac/modules/mod-playerbots
- name: ccache - name: ccache
uses: hendrikmuhs/ccache-action@v1.2.13 uses: hendrikmuhs/ccache-action@v1.2.13
- name: Configure OS - name: Configure OS
shell: bash shell: bash
working-directory: ac
env: env:
CONTINUOUS_INTEGRATION: true CONTINUOUS_INTEGRATION: true
run: | run: |
./acore.sh install-deps ./acore.sh install-deps
- name: Build - name: Build
shell: bash shell: bash
working-directory: ac
run: | run: |
export CTOOLS_BUILD=all export CTOOLS_BUILD=all
./acore.sh compiler build ./acore.sh compiler build

View File

@@ -1 +0,0 @@
void AddPlayerbotsCommandscripts();

View File

@@ -1,21 +0,0 @@
#ifndef _PLAYERBOT_WOTLKDUNGEONACTIONCONTEXT_H
#define _PLAYERBOT_WOTLKDUNGEONACTIONCONTEXT_H
#include "UtgardeKeep/UtgardeKeepActionContext.h"
#include "Nexus/NexusActionContext.h"
#include "AzjolNerub/AzjolNerubActionContext.h"
#include "OldKingdom/OldKingdomActionContext.h"
#include "DraktharonKeep/DrakTharonKeepActionContext.h"
#include "VioletHold/VioletHoldActionContext.h"
#include "Gundrak/GundrakActionContext.h"
#include "HallsOfStone/HallsOfStoneActionContext.h"
#include "HallsOfLightning/HallsOfLightningActionContext.h"
#include "Oculus/OculusActionContext.h"
#include "UtgardePinnacle/UtgardePinnacleActionContext.h"
#include "CullingOfStratholme/CullingOfStratholmeActionContext.h"
#include "ForgeOfSouls/ForgeOfSoulsActionContext.h"
#include "PitOfSaron/PitOfSaronActionContext.h"
#include "TrialOfTheChampion/TrialOfTheChampionActionContext.h"
// #include "HallsOfReflection/HallsOfReflectionActionContext.h"
#endif

View File

@@ -1,21 +0,0 @@
#ifndef _PLAYERBOT_WOTLKDUNGEONTRIGGERCONTEXT_H
#define _PLAYERBOT_WOTLKDUNGEONTRIGGERCONTEXT_H
#include "UtgardeKeep/UtgardeKeepTriggerContext.h"
#include "Nexus/NexusTriggerContext.h"
#include "AzjolNerub/AzjolNerubTriggerContext.h"
#include "OldKingdom/OldKingdomTriggerContext.h"
#include "DraktharonKeep/DrakTharonKeepTriggerContext.h"
#include "VioletHold/VioletHoldTriggerContext.h"
#include "Gundrak/GundrakTriggerContext.h"
#include "HallsOfStone/HallsOfStoneTriggerContext.h"
#include "HallsOfLightning/HallsOfLightningTriggerContext.h"
#include "Oculus/OculusTriggerContext.h"
#include "UtgardePinnacle/UtgardePinnacleTriggerContext.h"
#include "CullingOfStratholme/CullingOfStratholmeTriggerContext.h"
#include "ForgeOfSouls/ForgeOfSoulsTriggerContext.h"
#include "PitOfSaron/PitOfSaronTriggerContext.h"
#include "TrialOfTheChampion/TrialOfTheChampionTriggerContext.h"
// #include "HallsOfReflection/HallsOfReflectionTriggerContext.h"
#endif

View File

@@ -3,11 +3,11 @@
* and/or modify it under version 3 of the License, or (at your option), any later version. * and/or modify it under version 3 of the License, or (at your option), any later version.
*/ */
#include "PerfMonitor.h" #include "PerformanceMonitor.h"
#include "Playerbots.h" #include "Playerbots.h"
PerfMonitorOperation* PerfMonitor::start(PerformanceMetric metric, std::string const name, PerformanceMonitorOperation* PerformanceMonitor::start(PerformanceMetric metric, std::string const name,
PerformanceStack* stack) PerformanceStack* stack)
{ {
if (!sPlayerbotAIConfig->perfMonEnabled) if (!sPlayerbotAIConfig->perfMonEnabled)
@@ -45,10 +45,10 @@ PerfMonitorOperation* PerfMonitor::start(PerformanceMetric metric, std::string c
data[metric][stackName] = pd; data[metric][stackName] = pd;
} }
return new PerfMonitorOperation(pd, name, stack); return new PerformanceMonitorOperation(pd, name, stack);
} }
void PerfMonitor::PrintStats(bool perTick, bool fullStack) void PerformanceMonitor::PrintStats(bool perTick, bool fullStack)
{ {
if (data.empty()) if (data.empty())
return; return;
@@ -247,7 +247,7 @@ void PerfMonitor::PrintStats(bool perTick, bool fullStack)
} }
} }
void PerfMonitor::Reset() void PerformanceMonitor::Reset()
{ {
for (std::map<PerformanceMetric, std::map<std::string, PerformanceData*>>::iterator i = data.begin(); for (std::map<PerformanceMetric, std::map<std::string, PerformanceData*>>::iterator i = data.begin();
i != data.end(); ++i) i != data.end(); ++i)
@@ -265,7 +265,7 @@ void PerfMonitor::Reset()
} }
} }
PerfMonitorOperation::PerfMonitorOperation(PerformanceData* data, std::string const name, PerformanceMonitorOperation::PerformanceMonitorOperation(PerformanceData* data, std::string const name,
PerformanceStack* stack) PerformanceStack* stack)
: data(data), name(name), stack(stack) : data(data), name(name), stack(stack)
{ {
@@ -273,7 +273,7 @@ PerfMonitorOperation::PerfMonitorOperation(PerformanceData* data, std::string co
.time_since_epoch(); .time_since_epoch();
} }
void PerfMonitorOperation::finish() void PerformanceMonitorOperation::finish()
{ {
std::chrono::microseconds finished = std::chrono::microseconds finished =
(std::chrono::time_point_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now())) (std::chrono::time_point_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now()))

View File

@@ -34,10 +34,10 @@ enum PerformanceMetric
PERF_MON_TOTAL PERF_MON_TOTAL
}; };
class PerfMonitorOperation class PerformanceMonitorOperation
{ {
public: public:
PerfMonitorOperation(PerformanceData* data, std::string const name, PerformanceStack* stack); PerformanceMonitorOperation(PerformanceData* data, std::string const name, PerformanceStack* stack);
void finish(); void finish();
private: private:
@@ -47,19 +47,19 @@ private:
std::chrono::microseconds started; std::chrono::microseconds started;
}; };
class PerfMonitor class PerformanceMonitor
{ {
public: public:
PerfMonitor(){}; PerformanceMonitor(){};
virtual ~PerfMonitor(){}; virtual ~PerformanceMonitor(){};
static PerfMonitor* instance() static PerformanceMonitor* instance()
{ {
static PerfMonitor instance; static PerformanceMonitor instance;
return &instance; return &instance;
} }
public: public:
PerfMonitorOperation* start(PerformanceMetric metric, std::string const name, PerformanceMonitorOperation* start(PerformanceMetric metric, std::string const name,
PerformanceStack* stack = nullptr); PerformanceStack* stack = nullptr);
void PrintStats(bool perTick = false, bool fullStack = false); void PrintStats(bool perTick = false, bool fullStack = false);
void Reset(); void Reset();
@@ -69,6 +69,6 @@ private:
std::mutex lock; std::mutex lock;
}; };
#define sPerfMonitor PerfMonitor::instance() #define sPerformanceMonitor PerformanceMonitor::instance()
#endif #endif

View File

@@ -10,7 +10,7 @@
#include "Common.h" #include "Common.h"
#include "Player.h" #include "Player.h"
#include "PlayerbotDungeonRepository.h" #include "PlayerbotDungeonSuggestionMgr.h"
typedef std::map<std::string, std::string> PlaceholderMap; typedef std::map<std::string, std::string> PlaceholderMap;

View File

@@ -38,10 +38,10 @@
#include "NewRpgStrategy.h" #include "NewRpgStrategy.h"
#include "ObjectGuid.h" #include "ObjectGuid.h"
#include "ObjectMgr.h" #include "ObjectMgr.h"
#include "PerfMonitor.h" #include "PerformanceMonitor.h"
#include "Player.h" #include "Player.h"
#include "PlayerbotAIConfig.h" #include "PlayerbotAIConfig.h"
#include "PlayerbotRepository.h" #include "PlayerbotDbStore.h"
#include "PlayerbotMgr.h" #include "PlayerbotMgr.h"
#include "PlayerbotGuildMgr.h" #include "PlayerbotGuildMgr.h"
#include "Playerbots.h" #include "Playerbots.h"
@@ -441,8 +441,8 @@ void PlayerbotAI::UpdateAIInternal([[maybe_unused]] uint32 elapsed, bool minimal
return; return;
std::string const mapString = WorldPosition(bot).isOverworld() ? std::to_string(bot->GetMapId()) : "I"; std::string const mapString = WorldPosition(bot).isOverworld() ? std::to_string(bot->GetMapId()) : "I";
PerfMonitorOperation* pmo = PerformanceMonitorOperation* pmo =
sPerfMonitor->start(PERF_MON_TOTAL, "PlayerbotAI::UpdateAIInternal " + mapString); sPerformanceMonitor->start(PERF_MON_TOTAL, "PlayerbotAI::UpdateAIInternal " + mapString);
ExternalEventHelper helper(aiObjectContext); ExternalEventHelper helper(aiObjectContext);
// chat replies // chat replies
@@ -1731,7 +1731,7 @@ void PlayerbotAI::ResetStrategies(bool load)
engines[i]->Init(); engines[i]->Init();
// if (load) // if (load)
// sPlayerbotRepository->Load(this); // sPlayerbotDbStore->Load(this);
} }
bool PlayerbotAI::IsRanged(Player* player, bool bySpec) bool PlayerbotAI::IsRanged(Player* player, bool bySpec)

View File

@@ -14,7 +14,7 @@ void PlayerbotAIBase::UpdateAI(uint32 elapsed, bool minimal)
if (totalPmo) if (totalPmo)
totalPmo->finish(); totalPmo->finish();
totalPmo = sPerfMonitor->start(PERF_MON_TOTAL, "PlayerbotAIBase::FullTick"); totalPmo = sPerformanceMonitor->start(PERF_MON_TOTAL, "PlayerbotAIBase::FullTick");
if (nextAICheckDelay > elapsed) if (nextAICheckDelay > elapsed)
nextAICheckDelay -= elapsed; nextAICheckDelay -= elapsed;

View File

@@ -25,7 +25,7 @@ public:
protected: protected:
uint32 nextAICheckDelay; uint32 nextAICheckDelay;
class PerfMonitorOperation* totalPmo = nullptr; class PerformanceMonitorOperation* totalPmo = nullptr;
private: private:
bool _isBotAI; bool _isBotAI;

View File

@@ -7,7 +7,7 @@
#include <iostream> #include <iostream>
#include "Config.h" #include "Config.h"
#include "NewRpgInfo.h" #include "NewRpgInfo.h"
#include "PlayerbotDungeonRepository.h" #include "PlayerbotDungeonSuggestionMgr.h"
#include "PlayerbotFactory.h" #include "PlayerbotFactory.h"
#include "Playerbots.h" #include "Playerbots.h"
#include "PlayerbotGuildMgr.h" #include "PlayerbotGuildMgr.h"
@@ -678,7 +678,7 @@ bool PlayerbotAIConfig::Initialize()
if (sPlayerbotAIConfig->randomBotSuggestDungeons) if (sPlayerbotAIConfig->randomBotSuggestDungeons)
{ {
sPlayerbotDungeonRepository->LoadDungeonSuggestions(); sPlayerbotDungeonSuggestionMgr->LoadDungeonSuggestions();
} }
excludedHunterPetFamilies.clear(); excludedHunterPetFamilies.clear();

View File

@@ -3,13 +3,13 @@
* and/or modify it under version 3 of the License, or (at your option), any later version. * and/or modify it under version 3 of the License, or (at your option), any later version.
*/ */
#include "PlayerbotRepository.h" #include "PlayerbotDbStore.h"
#include <iostream> #include <iostream>
#include "Playerbots.h" #include "Playerbots.h"
void PlayerbotRepository::Load(PlayerbotAI* botAI) void PlayerbotDbStore::Load(PlayerbotAI* botAI)
{ {
ObjectGuid::LowType guid = botAI->GetBot()->GetGUID().GetCounter(); ObjectGuid::LowType guid = botAI->GetBot()->GetGUID().GetCounter();
@@ -46,7 +46,7 @@ void PlayerbotRepository::Load(PlayerbotAI* botAI)
} }
} }
void PlayerbotRepository::Save(PlayerbotAI* botAI) void PlayerbotDbStore::Save(PlayerbotAI* botAI)
{ {
ObjectGuid::LowType guid = botAI->GetBot()->GetGUID().GetCounter(); ObjectGuid::LowType guid = botAI->GetBot()->GetGUID().GetCounter();
@@ -68,7 +68,7 @@ void PlayerbotRepository::Save(PlayerbotAI* botAI)
SaveValue(guid, "dead", FormatStrategies("dead", botAI->GetStrategies(BOT_STATE_DEAD))); SaveValue(guid, "dead", FormatStrategies("dead", botAI->GetStrategies(BOT_STATE_DEAD)));
} }
std::string const PlayerbotRepository::FormatStrategies(std::string const type, std::vector<std::string> strategies) std::string const PlayerbotDbStore::FormatStrategies(std::string const type, std::vector<std::string> strategies)
{ {
std::ostringstream out; std::ostringstream out;
for (std::vector<std::string>::iterator i = strategies.begin(); i != strategies.end(); ++i) for (std::vector<std::string>::iterator i = strategies.begin(); i != strategies.end(); ++i)
@@ -78,7 +78,7 @@ std::string const PlayerbotRepository::FormatStrategies(std::string const type,
return res.substr(0, res.size() - 1); return res.substr(0, res.size() - 1);
} }
void PlayerbotRepository::Reset(PlayerbotAI* botAI) void PlayerbotDbStore::Reset(PlayerbotAI* botAI)
{ {
ObjectGuid::LowType guid = botAI->GetBot()->GetGUID().GetCounter(); ObjectGuid::LowType guid = botAI->GetBot()->GetGUID().GetCounter();
@@ -87,7 +87,7 @@ void PlayerbotRepository::Reset(PlayerbotAI* botAI)
PlayerbotsDatabase.Execute(stmt); PlayerbotsDatabase.Execute(stmt);
} }
void PlayerbotRepository::SaveValue(uint32 guid, std::string const key, std::string const value) void PlayerbotDbStore::SaveValue(uint32 guid, std::string const key, std::string const value)
{ {
PlayerbotsDatabasePreparedStatement* stmt = PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_INS_DB_STORE); PlayerbotsDatabasePreparedStatement* stmt = PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_INS_DB_STORE);
stmt->SetData(0, guid); stmt->SetData(0, guid);

View File

@@ -3,8 +3,8 @@
* and/or modify it under version 3 of the License, or (at your option), any later version. * and/or modify it under version 3 of the License, or (at your option), any later version.
*/ */
#ifndef _PLAYERBOT_PLAYERBOTREPOSITORY_H #ifndef _PLAYERBOT_PLAYERBOTDBSTORE_H
#define _PLAYERBOT_PLAYERBOTREPOSITORY_H #define _PLAYERBOT_PLAYERBOTDBSTORE_H
#include <vector> #include <vector>
@@ -12,14 +12,14 @@
class PlayerbotAI; class PlayerbotAI;
class PlayerbotRepository class PlayerbotDbStore
{ {
public: public:
PlayerbotRepository() {} PlayerbotDbStore() {}
virtual ~PlayerbotRepository() {} virtual ~PlayerbotDbStore() {}
static PlayerbotRepository* instance() static PlayerbotDbStore* instance()
{ {
static PlayerbotRepository instance; static PlayerbotDbStore instance;
return &instance; return &instance;
} }
@@ -32,6 +32,6 @@ private:
std::string const FormatStrategies(std::string const type, std::vector<std::string> strategies); std::string const FormatStrategies(std::string const type, std::vector<std::string> strategies);
}; };
#define sPlayerbotRepository PlayerbotRepository::instance() #define sPlayerbotDbStore PlayerbotDbStore::instance()
#endif #endif

View File

@@ -3,16 +3,16 @@
* and/or modify it under version 3 of the License, or (at your option), any later version. * and/or modify it under version 3 of the License, or (at your option), any later version.
*/ */
#include "PlayerbotDungeonRepository.h" #include "PlayerbotDungeonSuggestionMgr.h"
#include "Playerbots.h" #include "Playerbots.h"
std::vector<DungeonSuggestion> const PlayerbotDungeonRepository::GetDungeonSuggestions() std::vector<DungeonSuggestion> const PlayerbotDungeonSuggestionMgr::GetDungeonSuggestions()
{ {
return m_dungeonSuggestions; return m_dungeonSuggestions;
} }
void PlayerbotDungeonRepository::LoadDungeonSuggestions() void PlayerbotDungeonSuggestionMgr::LoadDungeonSuggestions()
{ {
LOG_INFO("server.loading", "Loading playerbots dungeon suggestions..."); LOG_INFO("server.loading", "Loading playerbots dungeon suggestions...");
uint32 oldMSTime = getMSTime(); uint32 oldMSTime = getMSTime();

View File

@@ -3,8 +3,8 @@
* and/or modify it under version 3 of the License, or (at your option), any later version. * and/or modify it under version 3 of the License, or (at your option), any later version.
*/ */
#ifndef _PLAYERBOT_PLAYERBOTDUNGEONREPOSITORY_H #ifndef _PLAYERBOT_PLAYERBOTDUNGEONSUGGESTIONMGR_H
#define _PLAYERBOT_PLAYERBOTDUNGEONREPOSITORY_H #define _PLAYERBOT_PLAYERBOTDUNGEONSUGGESTIONMGR_H
#include <map> #include <map>
#include <vector> #include <vector>
@@ -22,14 +22,14 @@ struct DungeonSuggestion
std::string strategy; std::string strategy;
}; };
class PlayerbotDungeonRepository class PlayerbotDungeonSuggestionMgr
{ {
public: public:
PlayerbotDungeonRepository(){}; PlayerbotDungeonSuggestionMgr(){};
~PlayerbotDungeonRepository(){}; ~PlayerbotDungeonSuggestionMgr(){};
static PlayerbotDungeonRepository* instance() static PlayerbotDungeonSuggestionMgr* instance()
{ {
static PlayerbotDungeonRepository instance; static PlayerbotDungeonSuggestionMgr instance;
return &instance; return &instance;
} }
@@ -40,6 +40,6 @@ private:
std::vector<DungeonSuggestion> m_dungeonSuggestions; std::vector<DungeonSuggestion> m_dungeonSuggestions;
}; };
#define sPlayerbotDungeonRepository PlayerbotDungeonRepository::instance() #define sPlayerbotDungeonSuggestionMgr PlayerbotDungeonSuggestionMgr::instance()
#endif #endif

View File

@@ -26,7 +26,7 @@
#include "ObjectGuid.h" #include "ObjectGuid.h"
#include "ObjectMgr.h" #include "ObjectMgr.h"
#include "PlayerbotAIConfig.h" #include "PlayerbotAIConfig.h"
#include "PlayerbotRepository.h" #include "PlayerbotDbStore.h"
#include "PlayerbotFactory.h" #include "PlayerbotFactory.h"
#include "PlayerbotOperations.h" #include "PlayerbotOperations.h"
#include "PlayerbotSecurity.h" #include "PlayerbotSecurity.h"
@@ -442,7 +442,7 @@ void PlayerbotHolder::DisablePlayerBot(ObjectGuid guid)
Group* group = bot->GetGroup(); Group* group = bot->GetGroup();
if (group && !bot->InBattleground() && !bot->InBattlegroundQueue() && botAI->HasActivePlayerMaster()) if (group && !bot->InBattleground() && !bot->InBattlegroundQueue() && botAI->HasActivePlayerMaster())
{ {
sPlayerbotRepository->Save(botAI); sPlayerbotDbStore->Save(botAI);
} }
LOG_DEBUG("playerbots", "Bot {} logged out", bot->GetName().c_str()); LOG_DEBUG("playerbots", "Bot {} logged out", bot->GetName().c_str());
@@ -554,7 +554,7 @@ void PlayerbotHolder::OnBotLogin(Player* const bot)
{ {
botAI->ResetStrategies(!sRandomPlayerbotMgr->IsRandomBot(bot)); botAI->ResetStrategies(!sRandomPlayerbotMgr->IsRandomBot(bot));
} }
sPlayerbotRepository->Load(botAI); sPlayerbotDbStore->Load(botAI);
if (master && !master->HasUnitState(UNIT_STATE_IN_FLIGHT)) if (master && !master->HasUnitState(UNIT_STATE_IN_FLIGHT))
{ {

View File

@@ -15,7 +15,7 @@
#include "Player.h" #include "Player.h"
#include "PlayerbotAI.h" #include "PlayerbotAI.h"
#include "PlayerbotMgr.h" #include "PlayerbotMgr.h"
#include "PlayerbotRepository.h" #include "PlayerbotDbStore.h"
#include "RandomPlayerbotMgr.h" #include "RandomPlayerbotMgr.h"
#include "WorldSession.h" #include "WorldSession.h"
#include "WorldSessionMgr.h" #include "WorldSessionMgr.h"
@@ -418,7 +418,7 @@ public:
Group* group = bot->GetGroup(); Group* group = bot->GetGroup();
if (group && !bot->InBattleground() && !bot->InBattlegroundQueue() && botAI->HasActivePlayerMaster()) if (group && !bot->InBattleground() && !bot->InBattlegroundQueue() && botAI->HasActivePlayerMaster())
sPlayerbotRepository->Save(botAI); sPlayerbotDbStore->Save(botAI);
return true; return true;
} }

View File

@@ -26,11 +26,11 @@
#include "PlayerScript.h" #include "PlayerScript.h"
#include "PlayerbotAIConfig.h" #include "PlayerbotAIConfig.h"
#include "PlayerbotGuildMgr.h" #include "PlayerbotGuildMgr.h"
#include "PlayerbotSpellRepository.h" #include "PlayerbotSpellCache.h"
#include "PlayerbotWorldThreadProcessor.h" #include "PlayerbotWorldThreadProcessor.h"
#include "RandomPlayerbotMgr.h" #include "RandomPlayerbotMgr.h"
#include "ScriptMgr.h" #include "ScriptMgr.h"
#include "PlayerbotCommandScript.h" #include "cs_playerbots.h"
#include "cmath" #include "cmath"
#include "BattleGroundTactics.h" #include "BattleGroundTactics.h"
@@ -365,7 +365,7 @@ public:
LOG_INFO("server.loading", ">> Loaded playerbots config in {} ms", GetMSTimeDiffToNow(oldMSTime)); LOG_INFO("server.loading", ">> Loaded playerbots config in {} ms", GetMSTimeDiffToNow(oldMSTime));
LOG_INFO("server.loading", " "); LOG_INFO("server.loading", " ");
sPlayerbotSpellRepository->Initialize(); sPlayerbotSpellCache->Initialize();
LOG_INFO("server.loading", "Playerbots World Thread Processor initialized"); LOG_INFO("server.loading", "Playerbots World Thread Processor initialized");
} }
@@ -515,6 +515,6 @@ void AddPlayerbotsScripts()
new PlayerbotsScript(); new PlayerbotsScript();
new PlayerBotsBGScript(); new PlayerBotsBGScript();
AddPlayerbotsSecureLoginScripts(); AddPlayerbotsSecureLoginScripts();
AddPlayerbotsCommandscripts(); AddSC_playerbots_commandscript();
PlayerBotsGuildValidationScript(); PlayerBotsGuildValidationScript();
} }

View File

@@ -35,7 +35,7 @@
#include "NewRpgInfo.h" #include "NewRpgInfo.h"
#include "NewRpgStrategy.h" #include "NewRpgStrategy.h"
#include "ObjectGuid.h" #include "ObjectGuid.h"
#include "PerfMonitor.h" #include "PerformanceMonitor.h"
#include "Player.h" #include "Player.h"
#include "PlayerbotAI.h" #include "PlayerbotAI.h"
#include "PlayerbotAIConfig.h" #include "PlayerbotAIConfig.h"
@@ -358,7 +358,7 @@ void RandomPlayerbotMgr::UpdateAIInternal(uint32 elapsed, bool /*minimal*/)
if (totalPmo) if (totalPmo)
totalPmo->finish(); totalPmo->finish();
totalPmo = sPerfMonitor->start(PERF_MON_TOTAL, "RandomPlayerbotMgr::FullTick"); totalPmo = sPerformanceMonitor->start(PERF_MON_TOTAL, "RandomPlayerbotMgr::FullTick");
if (!sPlayerbotAIConfig->randomBotAutologin || !sPlayerbotAIConfig->enabled) if (!sPlayerbotAIConfig->randomBotAutologin || !sPlayerbotAIConfig->enabled)
return; return;
@@ -401,7 +401,7 @@ void RandomPlayerbotMgr::UpdateAIInternal(uint32 elapsed, bool /*minimal*/)
uint32 updateIntervalTurboBoost = _isBotInitializing ? 1 : sPlayerbotAIConfig->randomBotUpdateInterval; uint32 updateIntervalTurboBoost = _isBotInitializing ? 1 : sPlayerbotAIConfig->randomBotUpdateInterval;
SetNextCheckDelay(updateIntervalTurboBoost * (onlineBotFocus + 25) * 10); SetNextCheckDelay(updateIntervalTurboBoost * (onlineBotFocus + 25) * 10);
PerfMonitorOperation* pmo = sPerfMonitor->start( PerformanceMonitorOperation* pmo = sPerformanceMonitor->start(
PERF_MON_TOTAL, PERF_MON_TOTAL,
onlineBotCount < maxAllowedBotCount ? "RandomPlayerbotMgr::Login" : "RandomPlayerbotMgr::UpdateAIInternal"); onlineBotCount < maxAllowedBotCount ? "RandomPlayerbotMgr::Login" : "RandomPlayerbotMgr::UpdateAIInternal");
@@ -1707,7 +1707,7 @@ void RandomPlayerbotMgr::RandomTeleport(Player* bot, std::vector<WorldLocation>&
return; return;
} }
PerfMonitorOperation* pmo = sPerfMonitor->start(PERF_MON_RNDBOT, "RandomTeleportByLocations"); PerformanceMonitorOperation* pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "RandomTeleportByLocations");
std::shuffle(std::begin(tlocs), std::end(tlocs), RandomEngine::Instance()); std::shuffle(std::begin(tlocs), std::end(tlocs), RandomEngine::Instance());
for (uint32 i = 0; i < tlocs.size(); i++) for (uint32 i = 0; i < tlocs.size(); i++)
@@ -2300,7 +2300,7 @@ void RandomPlayerbotMgr::RandomTeleport(Player* bot)
if (bot->InBattleground()) if (bot->InBattleground())
return; return;
PerfMonitorOperation* pmo = sPerfMonitor->start(PERF_MON_RNDBOT, "RandomTeleport"); PerformanceMonitorOperation* pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "RandomTeleport");
std::vector<WorldLocation> locs; std::vector<WorldLocation> locs;
std::list<Unit*> targets; std::list<Unit*> targets;
@@ -2362,7 +2362,7 @@ void RandomPlayerbotMgr::IncreaseLevel(Player* bot)
if (maxLevel > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)) if (maxLevel > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
maxLevel = sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL); maxLevel = sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL);
PerfMonitorOperation* pmo = sPerfMonitor->start(PERF_MON_RNDBOT, "IncreaseLevel"); PerformanceMonitorOperation* pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "IncreaseLevel");
uint32 lastLevel = GetValue(bot, "level"); uint32 lastLevel = GetValue(bot, "level");
uint8 level = bot->GetLevel() + 1; uint8 level = bot->GetLevel() + 1;
if (level > maxLevel) if (level > maxLevel)
@@ -2401,7 +2401,7 @@ void RandomPlayerbotMgr::RandomizeFirst(Player* bot)
minLevel = std::max(minLevel, sWorld->getIntConfig(CONFIG_START_HEROIC_PLAYER_LEVEL)); minLevel = std::max(minLevel, sWorld->getIntConfig(CONFIG_START_HEROIC_PLAYER_LEVEL));
} }
PerfMonitorOperation* pmo = sPerfMonitor->start(PERF_MON_RNDBOT, "RandomizeFirst"); PerformanceMonitorOperation* pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "RandomizeFirst");
uint32 level; uint32 level;
@@ -2480,7 +2480,7 @@ void RandomPlayerbotMgr::RandomizeMin(Player* bot)
if (!botAI) if (!botAI)
return; return;
PerfMonitorOperation* pmo = sPerfMonitor->start(PERF_MON_RNDBOT, "RandomizeMin"); PerformanceMonitorOperation* pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "RandomizeMin");
uint32 level = sPlayerbotAIConfig->randomBotMinLevel; uint32 level = sPlayerbotAIConfig->randomBotMinLevel;
SetValue(bot, "level", level); SetValue(bot, "level", level);
PlayerbotFactory factory(bot, level); PlayerbotFactory factory(bot, level);
@@ -2569,7 +2569,7 @@ void RandomPlayerbotMgr::Refresh(Player* bot)
LOG_DEBUG("playerbots", "Refreshing bot {} <{}>", bot->GetGUID().ToString().c_str(), bot->GetName().c_str()); LOG_DEBUG("playerbots", "Refreshing bot {} <{}>", bot->GetGUID().ToString().c_str(), bot->GetName().c_str());
PerfMonitorOperation* pmo = sPerfMonitor->start(PERF_MON_RNDBOT, "Refresh"); PerformanceMonitorOperation* pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "Refresh");
botAI->Reset(); botAI->Reset();
@@ -3214,12 +3214,6 @@ void RandomPlayerbotMgr::PrintStats()
lvlPerRace[bot->getRace()] += bot->GetLevel(); lvlPerRace[bot->getRace()] += bot->GetLevel();
PlayerbotAI* botAI = GET_PLAYERBOT_AI(bot); PlayerbotAI* botAI = GET_PLAYERBOT_AI(bot);
if (!botAI)
{
LOG_ERROR("playerbots", "Player/Bot {} is registered in sRandomPlayerbotMgr playerBots and has no bot AI!", bot->GetName().c_str());
continue;
}
if (botAI->AllowActivity()) if (botAI->AllowActivity())
++active; ++active;

View File

@@ -43,7 +43,7 @@ struct BattlegroundInfo
}; };
class ChatHandler; class ChatHandler;
class PerfMonitorOperation; class PerformanceMonitorOperation;
class WorldLocation; class WorldLocation;
struct CachedEvent struct CachedEvent

View File

@@ -16,7 +16,7 @@
#include "BattleGroundTactics.h" #include "BattleGroundTactics.h"
#include "Chat.h" #include "Chat.h"
#include "GuildTaskMgr.h" #include "GuildTaskMgr.h"
#include "PerfMonitor.h" #include "PerformanceMonitor.h"
#include "PlayerbotMgr.h" #include "PlayerbotMgr.h"
#include "RandomPlayerbotMgr.h" #include "RandomPlayerbotMgr.h"
#include "ScriptMgr.h" #include "ScriptMgr.h"
@@ -76,19 +76,19 @@ public:
{ {
if (!strcmp(args, "reset")) if (!strcmp(args, "reset"))
{ {
sPerfMonitor->Reset(); sPerformanceMonitor->Reset();
return true; return true;
} }
if (!strcmp(args, "tick")) if (!strcmp(args, "tick"))
{ {
sPerfMonitor->PrintStats(true, false); sPerformanceMonitor->PrintStats(true, false);
return true; return true;
} }
if (!strcmp(args, "stack")) if (!strcmp(args, "stack"))
{ {
sPerfMonitor->PrintStats(false, true); sPerformanceMonitor->PrintStats(false, true);
return true; return true;
} }
@@ -102,7 +102,7 @@ public:
return true; return true;
} }
sPerfMonitor->PrintStats(); sPerformanceMonitor->PrintStats();
return true; return true;
} }
@@ -209,4 +209,4 @@ public:
} }
}; };
void AddPlayerbotsCommandscripts() { new playerbots_commandscript(); } void AddSC_playerbots_commandscript() { new playerbots_commandscript(); }

1
src/cs_playerbots.h Normal file
View File

@@ -0,0 +1 @@
void AddSC_playerbots_commandscript();

View File

@@ -1,10 +1,9 @@
#include "PlayerbotSpellRepository.h" #include "PlayerbotSpellCache.h"
// caches the result set void PlayerbotSpellCache::Initialize()
void PlayerbotSpellRepository::Initialize()
{ {
LOG_INFO("playerbots", "Playerbots: ListSpellsAction caches initialized"); LOG_INFO("playerbots",
"Playerbots: ListSpellsAction caches initialized");
for (uint32 j = 0; j < sSkillLineAbilityStore.GetNumRows(); ++j) for (uint32 j = 0; j < sSkillLineAbilityStore.GetNumRows(); ++j)
{ {
if (SkillLineAbilityEntry const* skillLine = sSkillLineAbilityStore.LookupEntry(j)) if (SkillLineAbilityEntry const* skillLine = sSkillLineAbilityStore.LookupEntry(j))
@@ -32,7 +31,7 @@ void PlayerbotSpellRepository::Initialize()
skillSpells.size(), vendorItems.size()); skillSpells.size(), vendorItems.size());
} }
SkillLineAbilityEntry const* PlayerbotSpellRepository::GetSkillLine(uint32 spellId) const SkillLineAbilityEntry const* PlayerbotSpellCache::GetSkillLine(uint32 spellId) const
{ {
auto itr = skillSpells.find(spellId); auto itr = skillSpells.find(spellId);
if (itr != skillSpells.end()) if (itr != skillSpells.end())
@@ -40,7 +39,7 @@ SkillLineAbilityEntry const* PlayerbotSpellRepository::GetSkillLine(uint32 spell
return nullptr; return nullptr;
} }
bool PlayerbotSpellRepository::IsItemBuyable(uint32 itemId) const bool PlayerbotSpellCache::IsItemBuyable(uint32 itemId) const
{ {
return vendorItems.find(itemId) != vendorItems.end(); return vendorItems.find(itemId) != vendorItems.end();
} }

View File

@@ -3,17 +3,17 @@
* and/or modify it under version 3 of the License, or (at your option), any later version. * and/or modify it under version 3 of the License, or (at your option), any later version.
*/ */
#ifndef _PLAYERBOT_PLAYERBOTSPELLREPOSITORY_H #ifndef _PLAYERBOT_PLAYERBOTSPELLCACHE_H
#define _PLAYERBOT_PLAYERBOTSPELLREPOSITORY_H #define _PLAYERBOT_PLAYERBOTSPELLCACHE_H
#include "Playerbots.h" #include "Playerbots.h"
class PlayerbotSpellRepository class PlayerbotSpellCache
{ {
public: public:
static PlayerbotSpellRepository* Instance() static PlayerbotSpellCache* Instance()
{ {
static PlayerbotSpellRepository instance; static PlayerbotSpellCache instance;
return &instance; return &instance;
} }
@@ -23,12 +23,12 @@ public:
bool IsItemBuyable(uint32 itemId) const; bool IsItemBuyable(uint32 itemId) const;
private: private:
PlayerbotSpellRepository() = default; PlayerbotSpellCache() = default;
std::map<uint32, SkillLineAbilityEntry const*> skillSpells; std::map<uint32, SkillLineAbilityEntry const*> skillSpells;
std::set<uint32> vendorItems; std::set<uint32> vendorItems;
}; };
#define sPlayerbotSpellRepository PlayerbotSpellRepository::Instance() #define sPlayerbotSpellCache PlayerbotSpellCache::Instance()
#endif #endif

View File

@@ -24,12 +24,12 @@
#include "LootMgr.h" #include "LootMgr.h"
#include "MapMgr.h" #include "MapMgr.h"
#include "ObjectMgr.h" #include "ObjectMgr.h"
#include "PerfMonitor.h" #include "PerformanceMonitor.h"
#include "PetDefines.h" #include "PetDefines.h"
#include "Player.h" #include "Player.h"
#include "PlayerbotAI.h" #include "PlayerbotAI.h"
#include "PlayerbotAIConfig.h" #include "PlayerbotAIConfig.h"
#include "PlayerbotRepository.h" #include "PlayerbotDbStore.h"
#include "PlayerbotGuildMgr.h" #include "PlayerbotGuildMgr.h"
#include "Playerbots.h" #include "Playerbots.h"
#include "QuestDef.h" #include "QuestDef.h"
@@ -240,7 +240,7 @@ void PlayerbotFactory::Randomize(bool incremental)
// LOG_DEBUG("playerbots", "Preparing to {} randomize...", (incremental ? "incremental" : "full")); // LOG_DEBUG("playerbots", "Preparing to {} randomize...", (incremental ? "incremental" : "full"));
Prepare(); Prepare();
LOG_DEBUG("playerbots", "Resetting player..."); LOG_DEBUG("playerbots", "Resetting player...");
PerfMonitorOperation* pmo = sPerfMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Reset"); PerformanceMonitorOperation* pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Reset");
if (!sPlayerbotAIConfig->equipmentPersistence || level < sPlayerbotAIConfig->equipmentPersistenceLevel) if (!sPlayerbotAIConfig->equipmentPersistence || level < sPlayerbotAIConfig->equipmentPersistenceLevel)
{ {
bot->resetTalents(true); bot->resetTalents(true);
@@ -266,7 +266,7 @@ void PlayerbotFactory::Randomize(bool incremental)
if (pmo) if (pmo)
pmo->finish(); pmo->finish();
// pmo = sPerfMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Immersive"); // pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Immersive");
// LOG_INFO("playerbots", "Initializing immersive..."); // LOG_INFO("playerbots", "Initializing immersive...");
// InitImmersive(); // InitImmersive();
// if (pmo) // if (pmo)
@@ -274,7 +274,7 @@ void PlayerbotFactory::Randomize(bool incremental)
if (sPlayerbotAIConfig->randomBotPreQuests) if (sPlayerbotAIConfig->randomBotPreQuests)
{ {
pmo = sPerfMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Quests"); pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Quests");
InitInstanceQuests(); InitInstanceQuests();
InitAttunementQuests(); InitAttunementQuests();
if (pmo) if (pmo)
@@ -282,27 +282,27 @@ void PlayerbotFactory::Randomize(bool incremental)
} }
else else
{ {
pmo = sPerfMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Quests"); pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Quests");
InitAttunementQuests(); InitAttunementQuests();
if (pmo) if (pmo)
pmo->finish(); pmo->finish();
} }
LOG_DEBUG("playerbots", "Initializing skills (step 1)..."); pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Spells1");
pmo = sPerfMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Skills1");
bot->LearnDefaultSkills();
InitSkills();
if (pmo)
pmo->finish();
pmo = sPerfMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Spells1");
LOG_DEBUG("playerbots", "Initializing spells (step 1)..."); LOG_DEBUG("playerbots", "Initializing spells (step 1)...");
bot->LearnDefaultSkills();
InitClassSpells(); InitClassSpells();
InitAvailableSpells(); InitAvailableSpells();
if (pmo) if (pmo)
pmo->finish(); pmo->finish();
pmo = sPerfMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Talents"); LOG_DEBUG("playerbots", "Initializing skills (step 1)...");
pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Skills1");
InitSkills();
if (pmo)
pmo->finish();
pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Talents");
LOG_DEBUG("playerbots", "Initializing talents..."); LOG_DEBUG("playerbots", "Initializing talents...");
if (!incremental || !sPlayerbotAIConfig->equipmentPersistence || if (!incremental || !sPlayerbotAIConfig->equipmentPersistence ||
bot->GetLevel() < sPlayerbotAIConfig->equipmentPersistenceLevel) bot->GetLevel() < sPlayerbotAIConfig->equipmentPersistenceLevel)
@@ -312,45 +312,45 @@ void PlayerbotFactory::Randomize(bool incremental)
sRandomPlayerbotMgr->SetValue(bot->GetGUID().GetCounter(), "specNo", 0); sRandomPlayerbotMgr->SetValue(bot->GetGUID().GetCounter(), "specNo", 0);
if (botAI) if (botAI)
{ {
sPlayerbotRepository->Reset(botAI); sPlayerbotDbStore->Reset(botAI);
// botAI->DoSpecificAction("auto talents"); // botAI->DoSpecificAction("auto talents");
botAI->ResetStrategies(false); // fix wrong stored strategy botAI->ResetStrategies(false); // fix wrong stored strategy
} }
if (pmo) if (pmo)
pmo->finish(); pmo->finish();
pmo = sPerfMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Spells2"); pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Spells2");
LOG_DEBUG("playerbots", "Initializing spells (step 2)..."); LOG_DEBUG("playerbots", "Initializing spells (step 2)...");
InitAvailableSpells(); InitAvailableSpells();
if (pmo) if (pmo)
pmo->finish(); pmo->finish();
pmo = sPerfMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Reputation"); pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Reputation");
LOG_DEBUG("playerbots", "Initializing reputation..."); LOG_DEBUG("playerbots", "Initializing reputation...");
InitReputation(); InitReputation();
if (pmo) if (pmo)
pmo->finish(); pmo->finish();
LOG_DEBUG("playerbots", "Initializing special spells..."); LOG_DEBUG("playerbots", "Initializing special spells...");
pmo = sPerfMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Spells3"); pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Spells3");
InitSpecialSpells(); InitSpecialSpells();
if (pmo) if (pmo)
pmo->finish(); pmo->finish();
pmo = sPerfMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Mounts"); pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Mounts");
LOG_DEBUG("playerbots", "Initializing mounts..."); LOG_DEBUG("playerbots", "Initializing mounts...");
InitMounts(); InitMounts();
// bot->SaveToDB(false, false); // bot->SaveToDB(false, false);
if (pmo) if (pmo)
pmo->finish(); pmo->finish();
// pmo = sPerfMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Skills2"); // pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Skills2");
// LOG_INFO("playerbots", "Initializing skills (step 2)..."); // LOG_INFO("playerbots", "Initializing skills (step 2)...");
// UpdateTradeSkills(); // UpdateTradeSkills();
// if (pmo) // if (pmo)
// pmo->finish(); // pmo->finish();
pmo = sPerfMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Equip"); pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Equip");
LOG_DEBUG("playerbots", "Initializing equipmemt..."); LOG_DEBUG("playerbots", "Initializing equipmemt...");
if (!incremental || !sPlayerbotAIConfig->equipmentPersistence || if (!incremental || !sPlayerbotAIConfig->equipmentPersistence ||
bot->GetLevel() < sPlayerbotAIConfig->equipmentPersistenceLevel) bot->GetLevel() < sPlayerbotAIConfig->equipmentPersistenceLevel)
@@ -364,51 +364,51 @@ void PlayerbotFactory::Randomize(bool incremental)
// if (bot->GetLevel() >= sPlayerbotAIConfig->minEnchantingBotLevel) // if (bot->GetLevel() >= sPlayerbotAIConfig->minEnchantingBotLevel)
// { // {
// pmo = sPerfMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Enchant"); // pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Enchant");
// LOG_INFO("playerbots", "Initializing enchant templates..."); // LOG_INFO("playerbots", "Initializing enchant templates...");
// LoadEnchantContainer(); // LoadEnchantContainer();
// if (pmo) // if (pmo)
// pmo->finish(); // pmo->finish();
// } // }
pmo = sPerfMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Bags"); pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Bags");
LOG_DEBUG("playerbots", "Initializing bags..."); LOG_DEBUG("playerbots", "Initializing bags...");
InitBags(); InitBags();
// bot->SaveToDB(false, false); // bot->SaveToDB(false, false);
if (pmo) if (pmo)
pmo->finish(); pmo->finish();
pmo = sPerfMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Ammo"); pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Ammo");
LOG_DEBUG("playerbots", "Initializing ammo..."); LOG_DEBUG("playerbots", "Initializing ammo...");
InitAmmo(); InitAmmo();
if (pmo) if (pmo)
pmo->finish(); pmo->finish();
pmo = sPerfMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Food"); pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Food");
LOG_DEBUG("playerbots", "Initializing food..."); LOG_DEBUG("playerbots", "Initializing food...");
InitFood(); InitFood();
if (pmo) if (pmo)
pmo->finish(); pmo->finish();
pmo = sPerfMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Potions"); pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Potions");
LOG_DEBUG("playerbots", "Initializing potions..."); LOG_DEBUG("playerbots", "Initializing potions...");
InitPotions(); InitPotions();
if (pmo) if (pmo)
pmo->finish(); pmo->finish();
pmo = sPerfMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Reagents"); pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Reagents");
LOG_DEBUG("playerbots", "Initializing reagents..."); LOG_DEBUG("playerbots", "Initializing reagents...");
InitReagents(); InitReagents();
if (pmo) if (pmo)
pmo->finish(); pmo->finish();
pmo = sPerfMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Keys"); pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Keys");
LOG_DEBUG("playerbots", "Initializing keys..."); LOG_DEBUG("playerbots", "Initializing keys...");
InitKeyring(); InitKeyring();
if (pmo) if (pmo)
pmo->finish(); pmo->finish();
// pmo = sPerfMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_EqSets"); // pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_EqSets");
// LOG_DEBUG("playerbots", "Initializing second equipment set..."); // LOG_DEBUG("playerbots", "Initializing second equipment set...");
// InitSecondEquipmentSet(); // InitSecondEquipmentSet();
// if (pmo) // if (pmo)
@@ -419,20 +419,20 @@ void PlayerbotFactory::Randomize(bool incremental)
ApplyEnchantAndGemsNew(); ApplyEnchantAndGemsNew();
} }
// { // {
// pmo = sPerfMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_EnchantTemplate"); // pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_EnchantTemplate");
// LOG_INFO("playerbots", "Initializing enchant templates..."); // LOG_INFO("playerbots", "Initializing enchant templates...");
// ApplyEnchantTemplate(); // ApplyEnchantTemplate();
// if (pmo) // if (pmo)
// pmo->finish(); // pmo->finish();
// } // }
pmo = sPerfMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Inventory"); pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Inventory");
LOG_DEBUG("playerbots", "Initializing inventory..."); LOG_DEBUG("playerbots", "Initializing inventory...");
// InitInventory(); // InitInventory();
if (pmo) if (pmo)
pmo->finish(); pmo->finish();
pmo = sPerfMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Consumable"); pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Consumable");
LOG_DEBUG("playerbots", "Initializing consumables..."); LOG_DEBUG("playerbots", "Initializing consumables...");
InitConsumables(); InitConsumables();
if (pmo) if (pmo)
@@ -442,7 +442,7 @@ void PlayerbotFactory::Randomize(bool incremental)
InitGlyphs(); InitGlyphs();
// bot->SaveToDB(false, false); // bot->SaveToDB(false, false);
pmo = sPerfMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Guilds"); pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Guilds");
// bot->SaveToDB(false, false); // bot->SaveToDB(false, false);
if (sPlayerbotAIConfig->randomBotGuildCount > 0) if (sPlayerbotAIConfig->randomBotGuildCount > 0)
{ {
@@ -455,7 +455,7 @@ void PlayerbotFactory::Randomize(bool incremental)
if (bot->GetLevel() >= 70) if (bot->GetLevel() >= 70)
{ {
pmo = sPerfMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Arenas"); pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Arenas");
// LOG_INFO("playerbots", "Initializing arena teams..."); // LOG_INFO("playerbots", "Initializing arena teams...");
InitArenaTeam(); InitArenaTeam();
if (pmo) if (pmo)
@@ -470,7 +470,7 @@ void PlayerbotFactory::Randomize(bool incremental)
} }
if (bot->GetLevel() >= 10) if (bot->GetLevel() >= 10)
{ {
pmo = sPerfMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Pet"); pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Pet");
LOG_DEBUG("playerbots", "Initializing pet..."); LOG_DEBUG("playerbots", "Initializing pet...");
InitPet(); InitPet();
// bot->SaveToDB(false, false); // bot->SaveToDB(false, false);
@@ -479,7 +479,7 @@ void PlayerbotFactory::Randomize(bool incremental)
pmo->finish(); pmo->finish();
} }
pmo = sPerfMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Save"); pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Save");
LOG_DEBUG("playerbots", "Saving to DB..."); LOG_DEBUG("playerbots", "Saving to DB...");
bot->SetMoney(urand(level * 100000, level * 5 * 100000)); bot->SetMoney(urand(level * 100000, level * 5 * 100000));
bot->SetHealth(bot->GetMaxHealth()); bot->SetHealth(bot->GetMaxHealth());
@@ -506,9 +506,9 @@ void PlayerbotFactory::Refresh()
InitPotions(); InitPotions();
InitPet(); InitPet();
InitPetTalents(); InitPetTalents();
InitSkills();
InitClassSpells(); InitClassSpells();
InitAvailableSpells(); InitAvailableSpells();
InitSkills();
InitReputation(); InitReputation();
InitSpecialSpells(); InitSpecialSpells();
InitMounts(); InitMounts();
@@ -2550,19 +2550,13 @@ void PlayerbotFactory::InitAvailableSpells()
for (auto& spell : trainer->GetSpells()) for (auto& spell : trainer->GetSpells())
{ {
// simplified version of Trainer::TeachSpell method if (!trainer->CanTeachSpell(bot, trainer->GetSpell(spell.SpellId)))
Trainer::Spell const* trainerSpell = trainer->GetSpell(spell.SpellId);
if (!trainerSpell)
continue; continue;
if (!trainer->CanTeachSpell(bot, trainerSpell)) if (spell.IsCastable())
continue; bot->CastSpell(bot, spell.SpellId, true);
if (trainerSpell->IsCastable())
bot->CastSpell(bot, trainerSpell->SpellId, true);
else else
bot->learnSpell(trainerSpell->SpellId, false); bot->learnSpell(spell.SpellId, false);
} }
} }
} }

View File

@@ -27,32 +27,32 @@
#include "WarriorAiObjectContext.h" #include "WarriorAiObjectContext.h"
#include "WorldPacketActionContext.h" #include "WorldPacketActionContext.h"
#include "WorldPacketTriggerContext.h" #include "WorldPacketTriggerContext.h"
#include "Extend/DungeonAi/DungeonStrategyContext.h" #include "dungeons/DungeonStrategyContext.h"
#include "Extend/DungeonAi/Wotlk/WotlkDungeonActionContext.h" #include "dungeons/wotlk/WotlkDungeonActionContext.h"
#include "Extend/DungeonAi/Wotlk/WotlkDungeonTriggerContext.h" #include "dungeons/wotlk/WotlkDungeonTriggerContext.h"
#include "Extend/RaidAi/RaidStrategyContext.h" #include "raids/RaidStrategyContext.h"
#include "Extend/RaidAi/Aq20/RaidAq20ActionContext.h" #include "raids/aq20/RaidAq20ActionContext.h"
#include "Extend/RaidAi/Aq20/RaidAq20TriggerContext.h" #include "raids/aq20/RaidAq20TriggerContext.h"
#include "Extend/RaidAi/MoltenCore/RaidMcActionContext.h" #include "raids/moltencore/RaidMcActionContext.h"
#include "Extend/RaidAi/MoltenCore/RaidMcTriggerContext.h" #include "raids/moltencore/RaidMcTriggerContext.h"
#include "Extend/RaidAi/BlackwingLair/RaidBwlActionContext.h" #include "raids/blackwinglair/RaidBwlActionContext.h"
#include "Extend/RaidAi/BlackwingLair/RaidBwlTriggerContext.h" #include "raids/blackwinglair/RaidBwlTriggerContext.h"
#include "Extend/RaidAi/Karazhan/RaidKarazhanActionContext.h" #include "raids/karazhan/RaidKarazhanActionContext.h"
#include "Extend/RaidAi/Karazhan/RaidKarazhanTriggerContext.h" #include "raids/karazhan/RaidKarazhanTriggerContext.h"
#include "Extend/RaidAi/Magtheridon/RaidMagtheridonActionContext.h" #include "raids/magtheridon/RaidMagtheridonActionContext.h"
#include "Extend/RaidAi/Magtheridon/RaidMagtheridonTriggerContext.h" #include "raids/magtheridon/RaidMagtheridonTriggerContext.h"
#include "Extend/RaidAi/GruulsLair/RaidGruulsLairActionContext.h" #include "raids/gruulslair/RaidGruulsLairActionContext.h"
#include "Extend/RaidAi/GruulsLair/RaidGruulsLairTriggerContext.h" #include "raids/gruulslair/RaidGruulsLairTriggerContext.h"
#include "Extend/RaidAi/EyeOfEternity/RaidEoEActionContext.h" #include "raids/eyeofeternity/RaidEoEActionContext.h"
#include "Extend/RaidAi/EyeOfEternity/RaidEoETriggerContext.h" #include "raids/eyeofeternity/RaidEoETriggerContext.h"
#include "Extend/RaidAi/VaultOfArchavon/RaidVoAActionContext.h" #include "raids/vaultofarchavon/RaidVoAActionContext.h"
#include "Extend/RaidAi/VaultOfArchavon/RaidVoATriggerContext.h" #include "raids/vaultofarchavon/RaidVoATriggerContext.h"
#include "Extend/RaidAi/ObsidianSanctum/RaidOsActionContext.h" #include "raids/obsidiansanctum/RaidOsActionContext.h"
#include "Extend/RaidAi/ObsidianSanctum/RaidOsTriggerContext.h" #include "raids/obsidiansanctum/RaidOsTriggerContext.h"
#include "Extend/RaidAi/Onyxia/RaidOnyxiaActionContext.h" #include "raids/onyxia/RaidOnyxiaActionContext.h"
#include "Extend/RaidAi/Onyxia/RaidOnyxiaTriggerContext.h" #include "raids/onyxia/RaidOnyxiaTriggerContext.h"
#include "Extend/RaidAi/Icecrown/RaidIccActionContext.h" #include "raids/icecrown/RaidIccActionContext.h"
#include "Extend/RaidAi/Icecrown/RaidIccTriggerContext.h" #include "raids/icecrown/RaidIccTriggerContext.h"
SharedNamedObjectContextList<Strategy> AiObjectContext::sharedStrategyContexts; SharedNamedObjectContextList<Strategy> AiObjectContext::sharedStrategyContexts;
SharedNamedObjectContextList<Action> AiObjectContext::sharedActionContexts; SharedNamedObjectContextList<Action> AiObjectContext::sharedActionContexts;

View File

@@ -7,7 +7,7 @@
#include "Action.h" #include "Action.h"
#include "Event.h" #include "Event.h"
#include "PerfMonitor.h" #include "PerformanceMonitor.h"
#include "Playerbots.h" #include "Playerbots.h"
#include "Queue.h" #include "Queue.h"
#include "Strategy.h" #include "Strategy.h"
@@ -204,7 +204,7 @@ bool Engine::DoNextAction(Unit* unit, uint32 depth, bool minimal)
} }
} }
PerfMonitorOperation* pmo = sPerfMonitor->start(PERF_MON_ACTION, action->getName(), &aiObjectContext->performanceStack); PerformanceMonitorOperation* pmo = sPerformanceMonitor->start(PERF_MON_ACTION, action->getName(), &aiObjectContext->performanceStack);
actionExecuted = ListenAndExecute(action, event); actionExecuted = ListenAndExecute(action, event);
if (pmo) if (pmo)
pmo->finish(); pmo->finish();
@@ -456,8 +456,8 @@ void Engine::ProcessTriggers(bool minimal)
if (minimal && node->getFirstRelevance() < 100) if (minimal && node->getFirstRelevance() < 100)
continue; continue;
PerfMonitorOperation* pmo = PerformanceMonitorOperation* pmo =
sPerfMonitor->start(PERF_MON_TRIGGER, trigger->getName(), &aiObjectContext->performanceStack); sPerformanceMonitor->start(PERF_MON_TRIGGER, trigger->getName(), &aiObjectContext->performanceStack);
Event event = trigger->Check(); Event event = trigger->Check();
if (pmo) if (pmo)
pmo->finish(); pmo->finish();

Some files were not shown because too many files have changed in this diff Show More