mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-02-27 05:45:55 +00:00
Improper singletons migration to clean Meyer's singletons (cherry-pick) (#2082)
# Pull Request
- Applies the clean and corrected singletons, Meyer pattern. (cherry
picked from @SmashingQuasar )
Testing by just playing the game in various ways. Been tested by myself
@Celandriel and @SmashingQuasar
---
## Complexity & Impact
- Does this change add new decision branches?
- [x] No
- [ ] Yes (**explain below**)
- Does this change increase per-bot or per-tick processing?
- [x] No
- [ ] Yes (**describe and justify impact**)
- Could this logic scale poorly under load?
- [x] No
- [ ] Yes (**explain why**)
---
## Defaults & Configuration
- Does this change modify default bot behavior?
- [x] No
- [ ] Yes (**explain why**)
---
## AI Assistance
- Was AI assistance (e.g. ChatGPT or similar tools) used while working
on this change?
- [x] No
- [ ] Yes (**explain below**)
---
## Final Checklist
- [x] Stability is not compromised
- [x] Performance impact is understood, tested, and acceptable
- [x] Added logic complexity is justified and explained
- [x] Documentation updated if needed
---
## Notes for Reviewers
Anything that significantly improves realism at the cost of stability or
performance should be carefully discussed
before merging.
---------
Co-authored-by: Nicolas Lebacq <nicolas.cordier@outlook.com>
Co-authored-by: Keleborn <22352763+Celandriel@users.noreply.github.com>
This commit is contained in:
@@ -26,14 +26,14 @@ enum GuildTaskType
|
||||
|
||||
void GuildTaskMgr::Update(Player* player, Player* guildMaster)
|
||||
{
|
||||
if (!sPlayerbotAIConfig->guildTaskEnabled)
|
||||
if (!sPlayerbotAIConfig.guildTaskEnabled)
|
||||
return;
|
||||
|
||||
if (!GetTaskValue(0, 0, "advert_cleanup"))
|
||||
{
|
||||
CleanupAdverts();
|
||||
RemoveDuplicatedAdverts();
|
||||
SetTaskValue(0, 0, "advert_cleanup", 1, sPlayerbotAIConfig->guildTaskAdvertCleanupTime);
|
||||
SetTaskValue(0, 0, "advert_cleanup", 1, sPlayerbotAIConfig.guildTaskAdvertCleanupTime);
|
||||
}
|
||||
|
||||
PlayerbotAI* masterBotAI = GET_PLAYERBOT_AI(guildMaster);
|
||||
@@ -69,8 +69,8 @@ void GuildTaskMgr::Update(Player* player, Player* guildMaster)
|
||||
SetTaskValue(owner, guildId, "killTask", 0, 0);
|
||||
SetTaskValue(owner, guildId, "killCount", 0, 0);
|
||||
SetTaskValue(owner, guildId, "payment", 0, 0);
|
||||
SetTaskValue(owner, guildId, "thanks", 1, 2 * sPlayerbotAIConfig->maxGuildTaskChangeTime);
|
||||
SetTaskValue(owner, guildId, "reward", 1, 2 * sPlayerbotAIConfig->maxGuildTaskChangeTime);
|
||||
SetTaskValue(owner, guildId, "thanks", 1, 2 * sPlayerbotAIConfig.maxGuildTaskChangeTime);
|
||||
SetTaskValue(owner, guildId, "reward", 1, 2 * sPlayerbotAIConfig.maxGuildTaskChangeTime);
|
||||
|
||||
uint32 task = CreateTask(player, guildId);
|
||||
|
||||
@@ -80,11 +80,11 @@ void GuildTaskMgr::Update(Player* player, Player* guildMaster)
|
||||
player->GetName().c_str());
|
||||
}
|
||||
|
||||
uint32 time = urand(sPlayerbotAIConfig->minGuildTaskChangeTime, sPlayerbotAIConfig->maxGuildTaskChangeTime);
|
||||
uint32 time = urand(sPlayerbotAIConfig.minGuildTaskChangeTime, sPlayerbotAIConfig.maxGuildTaskChangeTime);
|
||||
SetTaskValue(owner, guildId, "activeTask", task, time);
|
||||
SetTaskValue(owner, guildId, "advertisement", 1,
|
||||
urand(sPlayerbotAIConfig->minGuildTaskAdvertisementTime,
|
||||
sPlayerbotAIConfig->maxGuildTaskAdvertisementTime));
|
||||
urand(sPlayerbotAIConfig.minGuildTaskAdvertisementTime,
|
||||
sPlayerbotAIConfig.maxGuildTaskAdvertisementTime));
|
||||
|
||||
LOG_DEBUG("playerbots", "{} / {}: guild task {} is set for {} secs", guild->GetName().c_str(),
|
||||
player->GetName().c_str(), task, time);
|
||||
@@ -101,8 +101,8 @@ void GuildTaskMgr::Update(Player* player, Player* guildMaster)
|
||||
if (SendAdvertisement(trans, owner, guildId))
|
||||
{
|
||||
SetTaskValue(owner, guildId, "advertisement", 1,
|
||||
urand(sPlayerbotAIConfig->minGuildTaskAdvertisementTime,
|
||||
sPlayerbotAIConfig->maxGuildTaskAdvertisementTime));
|
||||
urand(sPlayerbotAIConfig.minGuildTaskAdvertisementTime,
|
||||
sPlayerbotAIConfig.maxGuildTaskAdvertisementTime));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -118,7 +118,7 @@ void GuildTaskMgr::Update(Player* player, Player* guildMaster)
|
||||
|
||||
if (SendThanks(trans, owner, guildId, GetTaskValue(owner, guildId, "payment")))
|
||||
{
|
||||
SetTaskValue(owner, guildId, "thanks", 1, 2 * sPlayerbotAIConfig->maxGuildTaskChangeTime);
|
||||
SetTaskValue(owner, guildId, "thanks", 1, 2 * sPlayerbotAIConfig.maxGuildTaskChangeTime);
|
||||
SetTaskValue(owner, guildId, "payment", 0, 0);
|
||||
}
|
||||
else
|
||||
@@ -135,7 +135,7 @@ void GuildTaskMgr::Update(Player* player, Player* guildMaster)
|
||||
|
||||
if (Reward(trans, owner, guildId))
|
||||
{
|
||||
SetTaskValue(owner, guildId, "reward", 1, 2 * sPlayerbotAIConfig->maxGuildTaskChangeTime);
|
||||
SetTaskValue(owner, guildId, "reward", 1, 2 * sPlayerbotAIConfig.maxGuildTaskChangeTime);
|
||||
SetTaskValue(owner, guildId, "payment", 0, 0);
|
||||
}
|
||||
else
|
||||
@@ -190,7 +190,7 @@ bool GuildTaskMgr::CreateItemTask(Player* player, uint32 guildId)
|
||||
return false;
|
||||
|
||||
RandomItemBySkillGuildTaskPredicate predicate(player);
|
||||
uint32 itemId = sRandomItemMgr->GetRandomItem(player->GetLevel() - 5, RANDOM_ITEM_GUILD_TASK, &predicate);
|
||||
uint32 itemId = sRandomItemMgr.GetRandomItem(player->GetLevel() - 5, RANDOM_ITEM_GUILD_TASK, &predicate);
|
||||
if (!itemId)
|
||||
{
|
||||
LOG_ERROR("playerbots", "{} / {}: no items avaible for item task",
|
||||
@@ -204,9 +204,9 @@ bool GuildTaskMgr::CreateItemTask(Player* player, uint32 guildId)
|
||||
player->GetName().c_str(), itemId, count);
|
||||
|
||||
SetTaskValue(player->GetGUID().GetCounter(), guildId, "itemCount", count,
|
||||
sPlayerbotAIConfig->maxGuildTaskChangeTime);
|
||||
sPlayerbotAIConfig.maxGuildTaskChangeTime);
|
||||
SetTaskValue(player->GetGUID().GetCounter(), guildId, "itemTask", itemId,
|
||||
sPlayerbotAIConfig->maxGuildTaskChangeTime);
|
||||
sPlayerbotAIConfig.maxGuildTaskChangeTime);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -239,8 +239,8 @@ bool GuildTaskMgr::CreateKillTask(Player* player, uint32 guildId)
|
||||
if (strstr(name.c_str(), "UNUSED"))
|
||||
continue;
|
||||
|
||||
float dist = sServerFacade->GetDistance2d(player, x, y);
|
||||
if (dist > sPlayerbotAIConfig->guildTaskKillTaskDistance || player->GetMapId() != map)
|
||||
float dist = ServerFacade::instance().GetDistance2d(player, x, y);
|
||||
if (dist > sPlayerbotAIConfig.guildTaskKillTaskDistance || player->GetMapId() != map)
|
||||
continue;
|
||||
|
||||
if (find(ids.begin(), ids.end(), id) == ids.end())
|
||||
@@ -262,7 +262,7 @@ bool GuildTaskMgr::CreateKillTask(Player* player, uint32 guildId)
|
||||
player->GetName().c_str(), creatureId);
|
||||
|
||||
SetTaskValue(player->GetGUID().GetCounter(), guildId, "killTask", creatureId,
|
||||
sPlayerbotAIConfig->maxGuildTaskChangeTime);
|
||||
sPlayerbotAIConfig.maxGuildTaskChangeTime);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -525,7 +525,7 @@ uint32 GuildTaskMgr::GetMaxItemTaskCount(uint32 itemId)
|
||||
|
||||
bool GuildTaskMgr::IsGuildTaskItem(uint32 itemId, uint32 guildId)
|
||||
{
|
||||
if (!sPlayerbotAIConfig->guildTaskEnabled)
|
||||
if (!sPlayerbotAIConfig.guildTaskEnabled)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -553,7 +553,7 @@ bool GuildTaskMgr::IsGuildTaskItem(uint32 itemId, uint32 guildId)
|
||||
std::map<uint32, uint32> GuildTaskMgr::GetTaskValues(uint32 owner, std::string const type,
|
||||
[[maybe_unused]] uint32* validIn /* = nullptr */)
|
||||
{
|
||||
if (!sPlayerbotAIConfig->guildTaskEnabled)
|
||||
if (!sPlayerbotAIConfig.guildTaskEnabled)
|
||||
{
|
||||
return std::map<uint32, uint32>();
|
||||
}
|
||||
@@ -586,7 +586,7 @@ std::map<uint32, uint32> GuildTaskMgr::GetTaskValues(uint32 owner, std::string c
|
||||
|
||||
uint32 GuildTaskMgr::GetTaskValue(uint32 owner, uint32 guildId, std::string const type, [[maybe_unused]] uint32* validIn /* = nullptr */)
|
||||
{
|
||||
if (!sPlayerbotAIConfig->guildTaskEnabled)
|
||||
if (!sPlayerbotAIConfig.guildTaskEnabled)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -639,7 +639,7 @@ uint32 GuildTaskMgr::SetTaskValue(uint32 owner, uint32 guildId, std::string cons
|
||||
|
||||
bool GuildTaskMgr::HandleConsoleCommand(ChatHandler* /* handler */, char const* args)
|
||||
{
|
||||
if (!sPlayerbotAIConfig->guildTaskEnabled)
|
||||
if (!sPlayerbotAIConfig.guildTaskEnabled)
|
||||
{
|
||||
LOG_ERROR("playerbots", "Guild task system is currently disabled!");
|
||||
return false;
|
||||
@@ -703,8 +703,8 @@ bool GuildTaskMgr::HandleConsoleCommand(ChatHandler* /* handler */, char const*
|
||||
if (value == GUILD_TASK_TYPE_ITEM)
|
||||
{
|
||||
name << "ItemTask";
|
||||
uint32 itemId = sGuildTaskMgr->GetTaskValue(owner, guildId, "itemTask");
|
||||
uint32 itemCount = sGuildTaskMgr->GetTaskValue(owner, guildId, "itemCount");
|
||||
uint32 itemId = GuildTaskMgr::instance().GetTaskValue(owner, guildId, "itemTask");
|
||||
uint32 itemCount = GuildTaskMgr::instance().GetTaskValue(owner, guildId, "itemCount");
|
||||
|
||||
if (ItemTemplate const* proto = sObjectMgr->GetItemTemplate(itemId))
|
||||
{
|
||||
@@ -735,7 +735,7 @@ bool GuildTaskMgr::HandleConsoleCommand(ChatHandler* /* handler */, char const*
|
||||
else if (value == GUILD_TASK_TYPE_KILL)
|
||||
{
|
||||
name << "KillTask";
|
||||
uint32 creatureId = sGuildTaskMgr->GetTaskValue(owner, guildId, "killTask");
|
||||
uint32 creatureId = GuildTaskMgr::instance().GetTaskValue(owner, guildId, "killTask");
|
||||
|
||||
if (CreatureTemplate const* proto = sObjectMgr->GetCreatureTemplate(creatureId))
|
||||
{
|
||||
@@ -758,22 +758,22 @@ bool GuildTaskMgr::HandleConsoleCommand(ChatHandler* /* handler */, char const*
|
||||
continue;
|
||||
|
||||
uint32 advertValidIn = 0;
|
||||
uint32 advert = sGuildTaskMgr->GetTaskValue(owner, guildId, "advertisement", &advertValidIn);
|
||||
uint32 advert = GuildTaskMgr::instance().GetTaskValue(owner, guildId, "advertisement", &advertValidIn);
|
||||
if (advert && advertValidIn < validIn)
|
||||
name << " advert in " << formatTime(advertValidIn);
|
||||
|
||||
uint32 thanksValidIn = 0;
|
||||
uint32 thanks = sGuildTaskMgr->GetTaskValue(owner, guildId, "thanks", &thanksValidIn);
|
||||
uint32 thanks = GuildTaskMgr::instance().GetTaskValue(owner, guildId, "thanks", &thanksValidIn);
|
||||
if (thanks && thanksValidIn < validIn)
|
||||
name << " thanks in " << formatTime(thanksValidIn);
|
||||
|
||||
uint32 rewardValidIn = 0;
|
||||
uint32 reward = sGuildTaskMgr->GetTaskValue(owner, guildId, "reward", &rewardValidIn);
|
||||
uint32 reward = GuildTaskMgr::instance().GetTaskValue(owner, guildId, "reward", &rewardValidIn);
|
||||
if (reward && rewardValidIn < validIn)
|
||||
name << " reward in " << formatTime(rewardValidIn);
|
||||
|
||||
uint32 paymentValidIn = 0;
|
||||
uint32 payment = sGuildTaskMgr->GetTaskValue(owner, guildId, "payment", &paymentValidIn);
|
||||
uint32 payment = GuildTaskMgr::instance().GetTaskValue(owner, guildId, "payment", &paymentValidIn);
|
||||
if (payment && paymentValidIn < validIn)
|
||||
name << " payment " << ChatHelper::formatMoney(payment) << " in " << formatTime(paymentValidIn);
|
||||
|
||||
@@ -788,8 +788,8 @@ bool GuildTaskMgr::HandleConsoleCommand(ChatHandler* /* handler */, char const*
|
||||
|
||||
if (cmd == "cleanup")
|
||||
{
|
||||
sGuildTaskMgr->CleanupAdverts();
|
||||
sGuildTaskMgr->RemoveDuplicatedAdverts();
|
||||
GuildTaskMgr::instance().CleanupAdverts();
|
||||
GuildTaskMgr::instance().RemoveDuplicatedAdverts();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -840,10 +840,10 @@ bool GuildTaskMgr::HandleConsoleCommand(ChatHandler* /* handler */, char const*
|
||||
continue;
|
||||
|
||||
if (reward)
|
||||
sGuildTaskMgr->Reward(trans, owner, guildId);
|
||||
GuildTaskMgr::instance().Reward(trans, owner, guildId);
|
||||
|
||||
if (advert)
|
||||
sGuildTaskMgr->SendAdvertisement(trans, owner, guildId);
|
||||
GuildTaskMgr::instance().SendAdvertisement(trans, owner, guildId);
|
||||
} while (result->NextRow());
|
||||
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
@@ -868,7 +868,7 @@ bool GuildTaskMgr::CheckItemTask(uint32 itemId, uint32 obtained, Player* ownerPl
|
||||
if (!guild)
|
||||
return false;
|
||||
|
||||
if (!sRandomPlayerbotMgr->IsRandomBot(bot))
|
||||
if (!sRandomPlayerbotMgr.IsRandomBot(bot))
|
||||
return false;
|
||||
|
||||
LOG_DEBUG("playerbots", "{} / {}: checking guild task", guild->GetName().c_str(), ownerPlayer->GetName().c_str());
|
||||
@@ -891,7 +891,7 @@ bool GuildTaskMgr::CheckItemTask(uint32 itemId, uint32 obtained, Player* ownerPl
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32 rewardTime = urand(sPlayerbotAIConfig->minGuildTaskRewardTime, sPlayerbotAIConfig->maxGuildTaskRewardTime);
|
||||
uint32 rewardTime = urand(sPlayerbotAIConfig.minGuildTaskRewardTime, sPlayerbotAIConfig.maxGuildTaskRewardTime);
|
||||
if (byMail)
|
||||
{
|
||||
ItemTemplate const* proto = sObjectMgr->GetItemTemplate(itemId);
|
||||
@@ -915,7 +915,7 @@ bool GuildTaskMgr::CheckItemTask(uint32 itemId, uint32 obtained, Player* ownerPl
|
||||
{
|
||||
LOG_DEBUG("playerbots", "{} / {}: guild task progress {}/{}", guild->GetName().c_str(),
|
||||
ownerPlayer->GetName().c_str(), obtained, count);
|
||||
SetTaskValue(owner, guildId, "itemCount", count - obtained, sPlayerbotAIConfig->maxGuildTaskChangeTime);
|
||||
SetTaskValue(owner, guildId, "itemCount", count - obtained, sPlayerbotAIConfig.maxGuildTaskChangeTime);
|
||||
SetTaskValue(owner, guildId, "thanks", 1, rewardTime - 30);
|
||||
SendCompletionMessage(ownerPlayer, "made a progress with");
|
||||
}
|
||||
@@ -961,7 +961,7 @@ bool GuildTaskMgr::Reward(CharacterDatabaseTransaction& trans, uint32 owner, uin
|
||||
body << leader->GetName() << "\n";
|
||||
rewardType = proto->Quality > ITEM_QUALITY_NORMAL ? RANDOM_ITEM_GUILD_TASK_REWARD_EQUIP_BLUE
|
||||
: RANDOM_ITEM_GUILD_TASK_REWARD_EQUIP_GREEN;
|
||||
itemId = sRandomItemMgr->GetRandomItem(player->GetLevel() - 5, rewardType);
|
||||
itemId = sRandomItemMgr.GetRandomItem(player->GetLevel() - 5, rewardType);
|
||||
}
|
||||
else if (killTask)
|
||||
{
|
||||
@@ -977,7 +977,7 @@ bool GuildTaskMgr::Reward(CharacterDatabaseTransaction& trans, uint32 owner, uin
|
||||
body << leader->GetName() << "\n";
|
||||
rewardType = proto->rank == CREATURE_ELITE_RARE ? RANDOM_ITEM_GUILD_TASK_REWARD_TRADE
|
||||
: RANDOM_ITEM_GUILD_TASK_REWARD_TRADE_RARE;
|
||||
itemId = sRandomItemMgr->GetRandomItem(player->GetLevel(), rewardType);
|
||||
itemId = sRandomItemMgr.GetRandomItem(player->GetLevel(), rewardType);
|
||||
if (itemId)
|
||||
{
|
||||
ItemTemplate const* itemProto = sObjectMgr->GetItemTemplate(itemId);
|
||||
@@ -1086,7 +1086,7 @@ void GuildTaskMgr::CheckKillTaskInternal(Player* player, Unit* victim)
|
||||
|
||||
LOG_DEBUG("playerbots", "{} / {}: guild task complete", guild->GetName().c_str(), player->GetName().c_str());
|
||||
SetTaskValue(owner, guildId, "reward", 1,
|
||||
urand(sPlayerbotAIConfig->minGuildTaskRewardTime, sPlayerbotAIConfig->maxGuildTaskRewardTime));
|
||||
urand(sPlayerbotAIConfig.minGuildTaskRewardTime, sPlayerbotAIConfig.maxGuildTaskRewardTime));
|
||||
|
||||
SendCompletionMessage(player, "completed");
|
||||
}
|
||||
@@ -1094,7 +1094,7 @@ void GuildTaskMgr::CheckKillTaskInternal(Player* player, Unit* victim)
|
||||
|
||||
void GuildTaskMgr::CleanupAdverts()
|
||||
{
|
||||
uint32 deliverTime = time(nullptr) - sPlayerbotAIConfig->minGuildTaskChangeTime;
|
||||
uint32 deliverTime = time(nullptr) - sPlayerbotAIConfig.minGuildTaskChangeTime;
|
||||
QueryResult result = CharacterDatabase.Query(
|
||||
"SELECT id, receiver FROM mail WHERE subject LIKE 'Guild Task%%' AND deliver_time <= {}", deliverTime);
|
||||
if (!result)
|
||||
@@ -1200,7 +1200,7 @@ bool GuildTaskMgr::CheckTaskTransfer(std::string const text, Player* ownerPlayer
|
||||
if (!guild)
|
||||
return false;
|
||||
|
||||
if (!sRandomPlayerbotMgr->IsRandomBot(bot))
|
||||
if (!sRandomPlayerbotMgr.IsRandomBot(bot))
|
||||
return false;
|
||||
|
||||
if (text.empty())
|
||||
|
||||
@@ -7,56 +7,61 @@
|
||||
#define _PLAYERBOT_GUILDTASKMGR_H
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <cstdint>
|
||||
|
||||
#include "Common.h"
|
||||
#include "Transaction.h"
|
||||
|
||||
class ChatHandler;
|
||||
class Player;
|
||||
class Unit;
|
||||
#include "DatabaseEnvFwd.h"
|
||||
#include "Unit.h"
|
||||
#include "Player.h"
|
||||
#include "Chat.h"
|
||||
|
||||
class GuildTaskMgr
|
||||
{
|
||||
public:
|
||||
GuildTaskMgr(){};
|
||||
virtual ~GuildTaskMgr(){};
|
||||
|
||||
static GuildTaskMgr* instance()
|
||||
static GuildTaskMgr& instance()
|
||||
{
|
||||
static GuildTaskMgr instance;
|
||||
return &instance;
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
void Update(Player* owner, Player* guildMaster);
|
||||
|
||||
static bool HandleConsoleCommand(ChatHandler* handler, char const* args);
|
||||
bool IsGuildTaskItem(uint32 itemId, uint32 guildId);
|
||||
bool CheckItemTask(uint32 itemId, uint32 obtained, Player* owner, Player* bot, bool byMail = false);
|
||||
bool IsGuildTaskItem(uint32_t itemId, uint32_t guildId);
|
||||
bool CheckItemTask(uint32_t itemId, uint32_t obtained, Player* owner, Player* bot, bool byMail = false);
|
||||
void CheckKillTask(Player* owner, Unit* victim);
|
||||
void CheckKillTaskInternal(Player* owner, Unit* victim);
|
||||
bool CheckTaskTransfer(std::string const text, Player* owner, Player* bot);
|
||||
|
||||
private:
|
||||
std::map<uint32, uint32> GetTaskValues(uint32 owner, std::string const type, uint32* validIn = nullptr);
|
||||
uint32 GetTaskValue(uint32 owner, uint32 guildId, std::string const type, uint32* validIn = nullptr);
|
||||
uint32 SetTaskValue(uint32 owner, uint32 guildId, std::string const type, uint32 value, uint32 validIn);
|
||||
uint32 CreateTask(Player* owner, uint32 guildId);
|
||||
bool SendAdvertisement(CharacterDatabaseTransaction& trans, uint32 owner, uint32 guildId);
|
||||
bool SendItemAdvertisement(CharacterDatabaseTransaction& trans, uint32 itemId, uint32 owner, uint32 guildId,
|
||||
uint32 validIn);
|
||||
bool SendKillAdvertisement(CharacterDatabaseTransaction& trans, uint32 creatureId, uint32 owner, uint32 guildId,
|
||||
uint32 validIn);
|
||||
bool SendThanks(CharacterDatabaseTransaction& trans, uint32 owner, uint32 guildId, uint32 payment);
|
||||
bool Reward(CharacterDatabaseTransaction& trans, uint32 owner, uint32 guildId);
|
||||
bool CreateItemTask(Player* owner, uint32 guildId);
|
||||
bool CreateKillTask(Player* owner, uint32 guildId);
|
||||
uint32 GetMaxItemTaskCount(uint32 itemId);
|
||||
GuildTaskMgr() = default;
|
||||
~GuildTaskMgr() = default;
|
||||
|
||||
GuildTaskMgr(const GuildTaskMgr&) = delete;
|
||||
GuildTaskMgr& operator=(const GuildTaskMgr&) = delete;
|
||||
|
||||
GuildTaskMgr(GuildTaskMgr&&) = delete;
|
||||
GuildTaskMgr& operator=(GuildTaskMgr&&) = delete;
|
||||
|
||||
std::map<uint32_t, uint32_t> GetTaskValues(uint32_t owner, std::string const type, uint32_t* validIn = nullptr);
|
||||
uint32_t GetTaskValue(uint32_t owner, uint32_t guildId, std::string const type, uint32_t* validIn = nullptr);
|
||||
uint32_t SetTaskValue(uint32_t owner, uint32_t guildId, std::string const type, uint32_t value, uint32_t validIn);
|
||||
uint32_t CreateTask(Player* owner, uint32_t guildId);
|
||||
bool SendAdvertisement(CharacterDatabaseTransaction& trans, uint32_t owner, uint32_t guildId);
|
||||
bool SendItemAdvertisement(CharacterDatabaseTransaction& trans, uint32_t itemId, uint32_t owner, uint32_t guildId,
|
||||
uint32_t validIn);
|
||||
bool SendKillAdvertisement(CharacterDatabaseTransaction& trans, uint32_t creatureId, uint32_t owner, uint32_t guildId,
|
||||
uint32_t validIn);
|
||||
bool SendThanks(CharacterDatabaseTransaction& trans, uint32_t owner, uint32_t guildId, uint32_t payment);
|
||||
bool Reward(CharacterDatabaseTransaction& trans, uint32_t owner, uint32_t guildId);
|
||||
bool CreateItemTask(Player* owner, uint32_t guildId);
|
||||
bool CreateKillTask(Player* owner, uint32_t guildId);
|
||||
uint32_t GetMaxItemTaskCount(uint32_t itemId);
|
||||
void CleanupAdverts();
|
||||
void RemoveDuplicatedAdverts();
|
||||
void DeleteMail(std::vector<uint32> buffer);
|
||||
void DeleteMail(std::vector<uint32_t> buffer);
|
||||
void SendCompletionMessage(Player* player, std::string const verb);
|
||||
};
|
||||
|
||||
#define sGuildTaskMgr GuildTaskMgr::instance()
|
||||
|
||||
#endif
|
||||
|
||||
@@ -4,15 +4,12 @@
|
||||
#include "DatabaseEnv.h"
|
||||
#include "Guild.h"
|
||||
#include "GuildMgr.h"
|
||||
#include "RandomPlayerbotMgr.h"
|
||||
#include "ScriptMgr.h"
|
||||
|
||||
PlayerbotGuildMgr::PlayerbotGuildMgr(){}
|
||||
|
||||
void PlayerbotGuildMgr::Init()
|
||||
{
|
||||
_guildCache.clear();
|
||||
if (sPlayerbotAIConfig->deleteRandomBotGuilds)
|
||||
if (sPlayerbotAIConfig.deleteRandomBotGuilds)
|
||||
DeleteBotGuilds();
|
||||
|
||||
LoadGuildNames();
|
||||
@@ -38,7 +35,7 @@ bool PlayerbotGuildMgr::CreateGuild(Player* player, std::string guildName)
|
||||
entry.name = guildName;
|
||||
entry.memberCount = 1;
|
||||
entry.status = 1;
|
||||
entry.maxMembers = sPlayerbotAIConfig->randomBotGuildSizeMax;
|
||||
entry.maxMembers = sPlayerbotAIConfig.randomBotGuildSizeMax;
|
||||
entry.faction = player->GetTeamId();
|
||||
|
||||
_guildCache[guild->GetId()] = entry;
|
||||
@@ -113,7 +110,7 @@ std::string PlayerbotGuildMgr::AssignToGuild(Player* player)
|
||||
}
|
||||
);
|
||||
|
||||
if (count < sPlayerbotAIConfig->randomBotGuildCount)
|
||||
if (count < sPlayerbotAIConfig.randomBotGuildCount)
|
||||
{
|
||||
for (auto& key : _shuffled_guild_keys)
|
||||
{
|
||||
@@ -214,7 +211,7 @@ void PlayerbotGuildMgr::ValidateGuildCache()
|
||||
uint32 guildId = it->first;
|
||||
GuildCache cache;
|
||||
cache.name = it->second;
|
||||
cache.maxMembers = sPlayerbotAIConfig->randomBotGuildSizeMax;
|
||||
cache.maxMembers = sPlayerbotAIConfig.randomBotGuildSizeMax;
|
||||
|
||||
Guild* guild = sGuildMgr ->GetGuildById(guildId);
|
||||
if (!guild)
|
||||
@@ -224,7 +221,7 @@ void PlayerbotGuildMgr::ValidateGuildCache()
|
||||
ObjectGuid leaderGuid = guild->GetLeaderGUID();
|
||||
CharacterCacheEntry const* leaderEntry = sCharacterCache->GetCharacterCacheByGuid(leaderGuid);
|
||||
uint32 leaderAccount = leaderEntry->AccountId;
|
||||
cache.hasRealPlayer = !(sPlayerbotAIConfig->IsInRandomAccountList(leaderAccount));
|
||||
cache.hasRealPlayer = !(sPlayerbotAIConfig.IsInRandomAccountList(leaderAccount));
|
||||
cache.faction = Player::TeamIdForRace(leaderEntry->Race);
|
||||
if (cache.memberCount == 0)
|
||||
cache.status = 0; // empty
|
||||
@@ -306,7 +303,7 @@ class BotGuildCacheWorldScript : public WorldScript
|
||||
if (_validateTimer >= _validateInterval) // Validate every hour
|
||||
{
|
||||
_validateTimer = 0;
|
||||
sPlayerbotGuildMgr->ValidateGuildCache();
|
||||
PlayerbotGuildMgr::instance().ValidateGuildCache();
|
||||
LOG_INFO("playerbots", "Scheduled guild cache validation");
|
||||
}
|
||||
}
|
||||
@@ -319,4 +316,4 @@ class BotGuildCacheWorldScript : public WorldScript
|
||||
void PlayerBotsGuildValidationScript()
|
||||
{
|
||||
new BotGuildCacheWorldScript();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,15 +5,14 @@
|
||||
#include "Player.h"
|
||||
#include "PlayerbotAI.h"
|
||||
|
||||
class PlayerbotAI;
|
||||
|
||||
class PlayerbotGuildMgr
|
||||
{
|
||||
public:
|
||||
static PlayerbotGuildMgr* instance()
|
||||
static PlayerbotGuildMgr& instance()
|
||||
{
|
||||
static PlayerbotGuildMgr instance;
|
||||
return &instance;
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
void Init();
|
||||
@@ -29,7 +28,15 @@ public:
|
||||
bool IsRealGuild(Player* bot);
|
||||
|
||||
private:
|
||||
PlayerbotGuildMgr();
|
||||
PlayerbotGuildMgr() = default;
|
||||
~PlayerbotGuildMgr() = default;
|
||||
|
||||
PlayerbotGuildMgr(const PlayerbotGuildMgr&) = delete;
|
||||
PlayerbotGuildMgr& operator=(const PlayerbotGuildMgr&) = delete;
|
||||
|
||||
PlayerbotGuildMgr(PlayerbotGuildMgr&&) = delete;
|
||||
PlayerbotGuildMgr& operator=(PlayerbotGuildMgr&&) = delete;
|
||||
|
||||
std::unordered_map<std::string, bool> _guildNames;
|
||||
|
||||
struct GuildCache
|
||||
@@ -47,6 +54,4 @@ private:
|
||||
|
||||
void PlayerBotsGuildValidationScript();
|
||||
|
||||
#define sPlayerbotGuildMgr PlayerbotGuildMgr::instance()
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -92,4 +92,4 @@ bool FindItemUsageVisitor::Accept(ItemTemplate const* proto)
|
||||
bool FindUsableNamedItemVisitor::Accept(ItemTemplate const* proto)
|
||||
{
|
||||
return proto && !proto->Name1.empty() && strstri(proto->Name1.c_str(), name.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -272,7 +272,7 @@ void RandomItemMgr::BuildRandomItemCache()
|
||||
}
|
||||
}
|
||||
|
||||
uint32 maxLevel = sPlayerbotAIConfig->randomBotMaxLevel;
|
||||
uint32 maxLevel = sPlayerbotAIConfig.randomBotMaxLevel;
|
||||
if (maxLevel > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
|
||||
maxLevel = sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL);
|
||||
|
||||
@@ -2092,7 +2092,7 @@ uint32 RandomItemMgr::GetLiveStatWeight(Player* player, uint32 itemId)
|
||||
|
||||
void RandomItemMgr::BuildEquipCache()
|
||||
{
|
||||
uint32 maxLevel = sPlayerbotAIConfig->randomBotMaxLevel;
|
||||
uint32 maxLevel = sPlayerbotAIConfig.randomBotMaxLevel;
|
||||
if (maxLevel > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
|
||||
maxLevel = sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL);
|
||||
|
||||
@@ -2415,7 +2415,7 @@ void RandomItemMgr::BuildPotionCache()
|
||||
|
||||
void RandomItemMgr::BuildFoodCache()
|
||||
{
|
||||
uint32 maxLevel = sPlayerbotAIConfig->randomBotMaxLevel;
|
||||
uint32 maxLevel = sPlayerbotAIConfig.randomBotMaxLevel;
|
||||
if (maxLevel > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
|
||||
maxLevel = sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL);
|
||||
|
||||
@@ -2548,7 +2548,7 @@ uint32 RandomItemMgr::GetRandomFood(uint32 level, uint32 category)
|
||||
|
||||
void RandomItemMgr::BuildTradeCache()
|
||||
{
|
||||
uint32 maxLevel = sPlayerbotAIConfig->randomBotMaxLevel;
|
||||
uint32 maxLevel = sPlayerbotAIConfig.randomBotMaxLevel;
|
||||
if (maxLevel > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
|
||||
maxLevel = sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL);
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
#include <vector>
|
||||
|
||||
#include "AiFactory.h"
|
||||
#include "Common.h"
|
||||
#include "ItemTemplate.h"
|
||||
|
||||
class ChatHandler;
|
||||
@@ -135,12 +134,11 @@ typedef std::map<BotEquipKey, RandomItemList> BotEquipCache;
|
||||
class RandomItemMgr
|
||||
{
|
||||
public:
|
||||
RandomItemMgr();
|
||||
virtual ~RandomItemMgr();
|
||||
static RandomItemMgr* instance()
|
||||
static RandomItemMgr& instance()
|
||||
{
|
||||
static RandomItemMgr instance;
|
||||
return &instance;
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
public:
|
||||
@@ -191,6 +189,17 @@ private:
|
||||
bool CheckItemStats(uint8 clazz, uint8 sp, uint8 ap, uint8 tank);
|
||||
|
||||
private:
|
||||
// Implemented in RandomItemMgr.cpp
|
||||
RandomItemMgr();
|
||||
// Implemented in RandomItemMgr.cpp
|
||||
~RandomItemMgr();
|
||||
|
||||
RandomItemMgr(const RandomItemMgr&) = delete;
|
||||
RandomItemMgr& operator=(const RandomItemMgr&) = delete;
|
||||
|
||||
RandomItemMgr(RandomItemMgr&&) = delete;
|
||||
RandomItemMgr& operator=(RandomItemMgr&&) = delete;
|
||||
|
||||
std::map<uint32, RandomItemCache> randomItemCache;
|
||||
std::map<RandomItemType, RandomItemPredicate*> predicates;
|
||||
BotEquipCache equipCache;
|
||||
|
||||
@@ -87,4 +87,4 @@ private:
|
||||
uint32 cls_;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -34,7 +34,7 @@ void FleeManager::calculateDistanceToCreatures(FleePoint* point)
|
||||
if (!unit)
|
||||
continue;
|
||||
|
||||
float d = sServerFacade->GetDistance2d(unit, point->x, point->y);
|
||||
float d = ServerFacade::instance().GetDistance2d(unit, point->x, point->y);
|
||||
point->sumDistance += d;
|
||||
if (point->minDistance < 0 || point->minDistance > d)
|
||||
point->minDistance = d;
|
||||
@@ -81,11 +81,11 @@ void FleeManager::calculatePossibleDestinations(std::vector<FleePoint*>& points)
|
||||
enemyOri.push_back(ori);
|
||||
}
|
||||
|
||||
float distIncrement = std::max(sPlayerbotAIConfig->followDistance,
|
||||
(maxAllowedDistance - sPlayerbotAIConfig->tooCloseDistance) / 10.0f);
|
||||
for (float dist = maxAllowedDistance; dist >= sPlayerbotAIConfig->tooCloseDistance; dist -= distIncrement)
|
||||
float distIncrement = std::max(sPlayerbotAIConfig.followDistance,
|
||||
(maxAllowedDistance - sPlayerbotAIConfig.tooCloseDistance) / 10.0f);
|
||||
for (float dist = maxAllowedDistance; dist >= sPlayerbotAIConfig.tooCloseDistance; dist -= distIncrement)
|
||||
{
|
||||
float angleIncrement = std::max(M_PI / 20, M_PI / 4 / (1.0 + dist - sPlayerbotAIConfig->tooCloseDistance));
|
||||
float angleIncrement = std::max(M_PI / 20, M_PI / 4 / (1.0 + dist - sPlayerbotAIConfig.tooCloseDistance));
|
||||
for (float add = 0.0f; add < M_PI / 4 + angleIncrement; add += angleIncrement)
|
||||
{
|
||||
for (float angle = add; angle < add + 2 * static_cast<float>(M_PI) + angleIncrement;
|
||||
@@ -97,8 +97,8 @@ void FleeManager::calculatePossibleDestinations(std::vector<FleePoint*>& points)
|
||||
float x = botPosX + cos(angle) * maxAllowedDistance, y = botPosY + sin(angle) * maxAllowedDistance,
|
||||
z = botPosZ + CONTACT_DISTANCE;
|
||||
if (forceMaxDistance &&
|
||||
sServerFacade->IsDistanceLessThan(sServerFacade->GetDistance2d(bot, x, y),
|
||||
maxAllowedDistance - sPlayerbotAIConfig->tooCloseDistance))
|
||||
ServerFacade::instance().IsDistanceLessThan(ServerFacade::instance().GetDistance2d(bot, x, y),
|
||||
maxAllowedDistance - sPlayerbotAIConfig.tooCloseDistance))
|
||||
continue;
|
||||
|
||||
bot->UpdateAllowedPositionZ(x, y, z);
|
||||
@@ -113,8 +113,8 @@ void FleeManager::calculatePossibleDestinations(std::vector<FleePoint*>& points)
|
||||
FleePoint* point = new FleePoint(botAI, x, y, z);
|
||||
calculateDistanceToCreatures(point);
|
||||
|
||||
if (sServerFacade->IsDistanceGreaterOrEqualThan(point->minDistance - start.minDistance,
|
||||
sPlayerbotAIConfig->followDistance))
|
||||
if (ServerFacade::instance().IsDistanceGreaterOrEqualThan(point->minDistance - start.minDistance,
|
||||
sPlayerbotAIConfig.followDistance))
|
||||
points.push_back(point);
|
||||
else
|
||||
delete point;
|
||||
@@ -189,8 +189,8 @@ bool FleeManager::isUseful()
|
||||
creature->GetAttackDistance(bot) * creature->GetAttackDistance(bot))
|
||||
return true;
|
||||
|
||||
// float d = sServerFacade->GetDistance2d(unit, bot);
|
||||
// if (sServerFacade->IsDistanceLessThan(d, sPlayerbotAIConfig->aggroDistance)) return true;
|
||||
// float d = ServerFacade::instance().GetDistance2d(unit, bot);
|
||||
// if (ServerFacade::instance().IsDistanceLessThan(d, sPlayerbotAIConfig.aggroDistance)) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -47,7 +47,7 @@ PlayerbotSecurityLevel PlayerbotSecurity::LevelFor(Player* from, DenyReason* rea
|
||||
return PLAYERBOT_SECURITY_DENY_ALL;
|
||||
}
|
||||
|
||||
if (sPlayerbotAIConfig->IsInRandomAccountList(account))
|
||||
if (sPlayerbotAIConfig.IsInRandomAccountList(account))
|
||||
{
|
||||
// (duplicate check in case of faction change)
|
||||
if (botAI->IsOpposing(from))
|
||||
@@ -72,7 +72,7 @@ PlayerbotSecurityLevel PlayerbotSecurity::LevelFor(Player* from, DenyReason* rea
|
||||
return PLAYERBOT_SECURITY_TALK;
|
||||
}
|
||||
|
||||
if (sPlayerbotAIConfig->groupInvitationPermission <= 0)
|
||||
if (sPlayerbotAIConfig.groupInvitationPermission <= 0)
|
||||
{
|
||||
if (reason)
|
||||
*reason = PLAYERBOT_DENY_NONE;
|
||||
@@ -80,7 +80,7 @@ PlayerbotSecurityLevel PlayerbotSecurity::LevelFor(Player* from, DenyReason* rea
|
||||
return PLAYERBOT_SECURITY_TALK;
|
||||
}
|
||||
|
||||
if (sPlayerbotAIConfig->groupInvitationPermission <= 1)
|
||||
if (sPlayerbotAIConfig.groupInvitationPermission <= 1)
|
||||
{
|
||||
int32 levelDiff = int32(bot->GetLevel()) - int32(from->GetLevel());
|
||||
if (levelDiff > 5)
|
||||
@@ -98,7 +98,7 @@ PlayerbotSecurityLevel PlayerbotSecurity::LevelFor(Player* from, DenyReason* rea
|
||||
int32 botGS = static_cast<int32>(botAI->GetEquipGearScore(bot));
|
||||
int32 fromGS = static_cast<int32>(botAI->GetEquipGearScore(from));
|
||||
|
||||
if (sPlayerbotAIConfig->gearscorecheck && botGS && bot->GetLevel() > 15 && botGS > fromGS)
|
||||
if (sPlayerbotAIConfig.gearscorecheck && botGS && bot->GetLevel() > 15 && botGS > fromGS)
|
||||
{
|
||||
uint32 diffPct = uint32(100 * (botGS - fromGS) / botGS);
|
||||
uint32 reqPct = uint32(12 * sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL) / from->GetLevel());
|
||||
@@ -277,7 +277,7 @@ bool PlayerbotSecurity::CheckLevelFor(PlayerbotSecurityLevel level, bool silent,
|
||||
ObjectGuid guid = from->GetGUID();
|
||||
time_t lastSaid = whispers[guid][text];
|
||||
|
||||
if (!lastSaid || (time(nullptr) - lastSaid) >= sPlayerbotAIConfig->repeatDelay / 1000)
|
||||
if (!lastSaid || (time(nullptr) - lastSaid) >= sPlayerbotAIConfig.repeatDelay / 1000)
|
||||
{
|
||||
whispers[guid][text] = time(nullptr);
|
||||
|
||||
|
||||
@@ -2,12 +2,14 @@
|
||||
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license, you may redistribute it
|
||||
* and/or modify it under version 3 of the License, or (at your option), any later version.
|
||||
*/
|
||||
#include "DatabaseEnv.h"
|
||||
#include "WorldSessionMgr.h"
|
||||
#include "Random.h"
|
||||
// Required due to a poor implementation by AC
|
||||
#include "QueryResult.h"
|
||||
|
||||
#include "PlayerbotTextMgr.h"
|
||||
|
||||
#include "Playerbots.h"
|
||||
#include "WorldSessionMgr.h"
|
||||
|
||||
void PlayerbotTextMgr::replaceAll(std::string& str, const std::string& from, const std::string& to)
|
||||
{
|
||||
if (from.empty())
|
||||
|
||||
@@ -11,9 +11,6 @@
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
#define BOT_TEXT1(name) sPlayerbotTextMgr->GetBotText(name)
|
||||
#define BOT_TEXT2(name, replace) sPlayerbotTextMgr->GetBotText(name, replace)
|
||||
|
||||
struct BotTextEntry
|
||||
{
|
||||
BotTextEntry(std::string name, std::map<uint32, std::string> text, uint32 say_type, uint32 reply_type)
|
||||
@@ -63,18 +60,11 @@ enum ChatReplyType
|
||||
class PlayerbotTextMgr
|
||||
{
|
||||
public:
|
||||
PlayerbotTextMgr()
|
||||
{
|
||||
for (uint8 i = 0; i < MAX_LOCALES; ++i)
|
||||
{
|
||||
botTextLocalePriority[i] = 0;
|
||||
}
|
||||
};
|
||||
virtual ~PlayerbotTextMgr(){};
|
||||
static PlayerbotTextMgr* instance()
|
||||
static PlayerbotTextMgr& instance()
|
||||
{
|
||||
static PlayerbotTextMgr instance;
|
||||
return &instance;
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
std::string GetBotText(std::string name, std::map<std::string, std::string> placeholders);
|
||||
@@ -95,11 +85,24 @@ public:
|
||||
void ResetLocalePriority();
|
||||
|
||||
private:
|
||||
PlayerbotTextMgr()
|
||||
{
|
||||
for (uint8 i = 0; i < MAX_LOCALES; ++i)
|
||||
{
|
||||
botTextLocalePriority[i] = 0;
|
||||
}
|
||||
};
|
||||
~PlayerbotTextMgr() = default;
|
||||
|
||||
PlayerbotTextMgr(const PlayerbotTextMgr&) = delete;
|
||||
PlayerbotTextMgr& operator=(const PlayerbotTextMgr&) = delete;
|
||||
|
||||
PlayerbotTextMgr(PlayerbotTextMgr&&) = delete;
|
||||
PlayerbotTextMgr& operator=(PlayerbotTextMgr&&) = delete;
|
||||
|
||||
std::map<std::string, std::vector<BotTextEntry>> botTexts;
|
||||
std::map<std::string, uint32> botTextChance;
|
||||
uint32 botTextLocalePriority[MAX_LOCALES];
|
||||
};
|
||||
|
||||
#define sPlayerbotTextMgr PlayerbotTextMgr::instance()
|
||||
|
||||
#endif
|
||||
|
||||
@@ -8,17 +8,18 @@
|
||||
#include <iomanip>
|
||||
#include <numeric>
|
||||
|
||||
#include "CellImpl.h"
|
||||
#include "Talentspec.h"
|
||||
#include "ChatHelper.h"
|
||||
#include "MMapFactory.h"
|
||||
#include "MapMgr.h"
|
||||
#include "PathGenerator.h"
|
||||
#include "Playerbots.h"
|
||||
#include "StrategyContext.h"
|
||||
#include "TransportMgr.h"
|
||||
#include "VMapFactory.h"
|
||||
#include "VMapMgr2.h"
|
||||
#include "Map.h"
|
||||
#include "Corpse.h"
|
||||
#include "CellImpl.h"
|
||||
|
||||
WorldPosition::WorldPosition(std::string const str)
|
||||
{
|
||||
@@ -246,7 +247,7 @@ float WorldPosition::distance(WorldPosition* center)
|
||||
return relPoint(center).size();
|
||||
|
||||
// this -> mapTransfer | mapTransfer -> center
|
||||
return sTravelMgr->mapTransDistance(*this, *center);
|
||||
return TravelMgr::instance().mapTransDistance(*this, *center);
|
||||
};
|
||||
|
||||
float WorldPosition::fDist(WorldPosition* center)
|
||||
@@ -255,7 +256,7 @@ float WorldPosition::fDist(WorldPosition* center)
|
||||
return sqrt(sqDistance2d(center));
|
||||
|
||||
// this -> mapTransfer | mapTransfer -> center
|
||||
return sTravelMgr->fastMapTransDistance(*this, *center);
|
||||
return TravelMgr::instance().fastMapTransDistance(*this, *center);
|
||||
};
|
||||
|
||||
float mapTransfer::fDist(WorldPosition start, WorldPosition end)
|
||||
@@ -428,7 +429,7 @@ void WorldPosition::printWKT(std::vector<WorldPosition> points, std::ostringstre
|
||||
|
||||
WorldPosition WorldPosition::getDisplayLocation()
|
||||
{
|
||||
WorldPosition pos = sTravelNodeMap->getMapOffset(getMapId());
|
||||
WorldPosition pos = TravelNodeMap::instance().getMapOffset(getMapId());
|
||||
return offset(const_cast<WorldPosition*>(&pos));
|
||||
}
|
||||
|
||||
@@ -630,14 +631,14 @@ void WorldPosition::loadMapAndVMap(uint32 mapId, uint8 x, uint8 y)
|
||||
if (isOverworld() && false || false)
|
||||
{
|
||||
if (!MMAP::MMapFactory::createOrGetMMapMgr()->loadMap(mapId, x, y))
|
||||
if (sPlayerbotAIConfig->hasLog(fileName))
|
||||
if (sPlayerbotAIConfig.hasLog(fileName))
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << sPlayerbotAIConfig->GetTimestampStr();
|
||||
out << "+00,\"mmap\", " << x << "," << y << "," << (sTravelMgr->isBadMmap(mapId, x, y) ? "0" : "1")
|
||||
out << sPlayerbotAIConfig.GetTimestampStr();
|
||||
out << "+00,\"mmap\", " << x << "," << y << "," << (TravelMgr::instance().isBadMmap(mapId, x, y) ? "0" : "1")
|
||||
<< ",";
|
||||
printWKT(fromGridCoord(GridCoord(x, y)), out, 1, true);
|
||||
sPlayerbotAIConfig->log(fileName, out.str().c_str());
|
||||
sPlayerbotAIConfig.log(fileName, out.str().c_str());
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -645,7 +646,7 @@ void WorldPosition::loadMapAndVMap(uint32 mapId, uint8 x, uint8 y)
|
||||
// This needs to be disabled or maps will not load.
|
||||
// Needs more testing to check for impact on movement.
|
||||
if (false)
|
||||
if (!sTravelMgr->isBadVmap(mapId, x, y))
|
||||
if (!TravelMgr::instance().isBadVmap(mapId, x, y))
|
||||
{
|
||||
// load VMAPs for current map/grid...
|
||||
const MapEntry* i_mapEntry = sMapStore.LookupEntry(mapId);
|
||||
@@ -662,40 +663,40 @@ void WorldPosition::loadMapAndVMap(uint32 mapId, uint8 x, uint8 y)
|
||||
case VMAP::VMAP_LOAD_RESULT_ERROR:
|
||||
// LOG_ERROR("playerbots", "Could not load VMAP name:{}, id:{}, x:{}, y:{} (vmap rep.: x:{},
|
||||
// y:{})", mapName, mapId, x, y, x, y);
|
||||
sTravelMgr->addBadVmap(mapId, x, y);
|
||||
TravelMgr::instance().addBadVmap(mapId, x, y);
|
||||
break;
|
||||
case VMAP::VMAP_LOAD_RESULT_IGNORED:
|
||||
sTravelMgr->addBadVmap(mapId, x, y);
|
||||
TravelMgr::instance().addBadVmap(mapId, x, y);
|
||||
// LOG_INFO("playerbots", "Ignored VMAP name:{}, id:{}, x:{}, y:{} (vmap rep.: x:{}, y:{})",
|
||||
// mapName, mapId, x, y, x, y);
|
||||
break;
|
||||
}
|
||||
|
||||
if (sPlayerbotAIConfig->hasLog(fileName))
|
||||
if (sPlayerbotAIConfig.hasLog(fileName))
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << sPlayerbotAIConfig->GetTimestampStr();
|
||||
out << "+00,\"vmap\", " << x << "," << y << ", " << (sTravelMgr->isBadVmap(mapId, x, y) ? "0" : "1")
|
||||
out << sPlayerbotAIConfig.GetTimestampStr();
|
||||
out << "+00,\"vmap\", " << x << "," << y << ", " << (TravelMgr::instance().isBadVmap(mapId, x, y) ? "0" : "1")
|
||||
<< ",";
|
||||
printWKT(frommGridCoord(mGridCoord(x, y)), out, 1, true);
|
||||
sPlayerbotAIConfig->log(fileName, out.str().c_str());
|
||||
sPlayerbotAIConfig.log(fileName, out.str().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
if (!sTravelMgr->isBadMmap(mapId, x, y))
|
||||
if (!TravelMgr::instance().isBadMmap(mapId, x, y))
|
||||
{
|
||||
// load navmesh
|
||||
if (!MMAP::MMapFactory::createOrGetMMapMgr()->loadMap(mapId, x, y))
|
||||
sTravelMgr->addBadMmap(mapId, x, y);
|
||||
TravelMgr::instance().addBadMmap(mapId, x, y);
|
||||
|
||||
if (sPlayerbotAIConfig->hasLog(fileName))
|
||||
if (sPlayerbotAIConfig.hasLog(fileName))
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << sPlayerbotAIConfig->GetTimestampStr();
|
||||
out << "+00,\"mmap\", " << x << "," << y << "," << (sTravelMgr->isBadMmap(mapId, x, y) ? "0" : "1")
|
||||
out << sPlayerbotAIConfig.GetTimestampStr();
|
||||
out << "+00,\"mmap\", " << x << "," << y << "," << (TravelMgr::instance().isBadMmap(mapId, x, y) ? "0" : "1")
|
||||
<< ",";
|
||||
printWKT(fromGridCoord(GridCoord(x, y)), out, 1, true);
|
||||
sPlayerbotAIConfig->log(fileName, out.str().c_str());
|
||||
sPlayerbotAIConfig.log(fileName, out.str().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -733,21 +734,21 @@ std::vector<WorldPosition> WorldPosition::getPathStepFrom(WorldPosition startPos
|
||||
Movement::PointsArray points = path.GetPath();
|
||||
PathType type = path.GetPathType();
|
||||
|
||||
if (sPlayerbotAIConfig->hasLog("pathfind_attempt_point.csv"))
|
||||
if (sPlayerbotAIConfig.hasLog("pathfind_attempt_point.csv"))
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << std::fixed << std::setprecision(1);
|
||||
printWKT({startPos, *this}, out);
|
||||
sPlayerbotAIConfig->log("pathfind_attempt_point.csv", out.str().c_str());
|
||||
sPlayerbotAIConfig.log("pathfind_attempt_point.csv", out.str().c_str());
|
||||
}
|
||||
|
||||
if (sPlayerbotAIConfig->hasLog("pathfind_attempt.csv") && (type == PATHFIND_INCOMPLETE || type == PATHFIND_NORMAL))
|
||||
if (sPlayerbotAIConfig.hasLog("pathfind_attempt.csv") && (type == PATHFIND_INCOMPLETE || type == PATHFIND_NORMAL))
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << sPlayerbotAIConfig->GetTimestampStr() << "+00,";
|
||||
out << sPlayerbotAIConfig.GetTimestampStr() << "+00,";
|
||||
out << std::fixed << std::setprecision(1) << type << ",";
|
||||
printWKT(fromPointsArray(points), out, 1);
|
||||
sPlayerbotAIConfig->log("pathfind_attempt.csv", out.str().c_str());
|
||||
sPlayerbotAIConfig.log("pathfind_attempt.csv", out.str().c_str());
|
||||
}
|
||||
|
||||
if (type == PATHFIND_INCOMPLETE || type == PATHFIND_NORMAL)
|
||||
@@ -796,7 +797,7 @@ std::vector<WorldPosition> WorldPosition::getPathFromPath(std::vector<WorldPosit
|
||||
subPath = getPathStepFrom(currentPos, bot);
|
||||
|
||||
// If we could not find a path return what we have now.
|
||||
if (subPath.empty() || currentPos.distance(&subPath.back()) < sPlayerbotAIConfig->targetPosRecalcDistance)
|
||||
if (subPath.empty() || currentPos.distance(&subPath.back()) < sPlayerbotAIConfig.targetPosRecalcDistance)
|
||||
break;
|
||||
|
||||
// Append the path excluding the start (this should be the same as the end of the startPath)
|
||||
@@ -1071,7 +1072,7 @@ std::vector<WorldPosition*> TravelDestination::sortedPoints(WorldPosition* pos)
|
||||
|
||||
std::vector<WorldPosition*> TravelDestination::nextPoint(WorldPosition* pos, bool ignoreFull)
|
||||
{
|
||||
return sTravelMgr->getNextPoint(pos, ignoreFull ? points : getPoints());
|
||||
return TravelMgr::instance().getNextPoint(pos, ignoreFull ? points : getPoints());
|
||||
}
|
||||
|
||||
bool TravelDestination::isFull(bool ignoreFull)
|
||||
@@ -1108,7 +1109,7 @@ bool QuestRelationTravelDestination::isActive(Player* bot)
|
||||
if (!bot->GetMap()->GetEntry()->IsWorldMap() || !bot->CanTakeQuest(questTemplate, false))
|
||||
return false;
|
||||
|
||||
//uint32 dialogStatus = sTravelMgr->getDialogStatus(bot, entry, questTemplate); //not used, shadowed by the next declaration, line marked for removal.
|
||||
//uint32 dialogStatus = TravelMgr::instance().getDialogStatus(bot, entry, questTemplate); //not used, shadowed by the next declaration, line marked for removal.
|
||||
|
||||
if (AI_VALUE(bool, "can fight equal"))
|
||||
{
|
||||
@@ -1197,7 +1198,7 @@ bool QuestObjectiveTravelDestination::isActive(Player* bot)
|
||||
if (questTemplate->GetType() == QUEST_TYPE_ELITE && !AI_VALUE(bool, "can fight elite"))
|
||||
return false;
|
||||
|
||||
if (!sTravelMgr->getObjectiveStatus(bot, questTemplate, objective))
|
||||
if (!TravelMgr::instance().getObjectiveStatus(bot, questTemplate, objective))
|
||||
return false;
|
||||
|
||||
WorldPosition botPos(bot);
|
||||
@@ -1435,8 +1436,8 @@ TravelTarget::~TravelTarget()
|
||||
return;
|
||||
|
||||
releaseVisitors();
|
||||
// sTravelMgr->botTargets.erase(std::remove(sTravelMgr->botTargets.begin(), sTravelMgr->botTargets.end(), this),
|
||||
// sTravelMgr->botTargets.end());
|
||||
// TravelMgr::instance().botTargets.erase(std::remove(TravelMgr::instance().botTargets.begin(), TravelMgr::instance().botTargets.end(), this),
|
||||
// TravelMgr::instance().botTargets.end());
|
||||
}
|
||||
|
||||
void TravelTarget::setTarget(TravelDestination* tDestination1, WorldPosition* wPosition1, bool groupCopy1)
|
||||
@@ -1509,7 +1510,7 @@ void TravelTarget::setStatus(TravelStatus status)
|
||||
statusTime = 1;
|
||||
break;
|
||||
case TRAVEL_STATUS_TRAVEL:
|
||||
statusTime = getMaxTravelTime() * 2 + sPlayerbotAIConfig->maxWaitForMove;
|
||||
statusTime = getMaxTravelTime() * 2 + sPlayerbotAIConfig.maxWaitForMove;
|
||||
break;
|
||||
case TRAVEL_STATUS_WORK:
|
||||
statusTime = tDestination->getExpireDelay();
|
||||
@@ -1578,7 +1579,7 @@ bool TravelTarget::isTraveling()
|
||||
|
||||
if (!botAI->HasStrategy("travel", BOT_STATE_NON_COMBAT))
|
||||
{
|
||||
setTarget(sTravelMgr->nullTravelDestination, sTravelMgr->nullWorldPosition, true);
|
||||
setTarget(TravelMgr::instance().nullTravelDestination, TravelMgr::instance().nullWorldPosition, true);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1610,7 +1611,7 @@ bool TravelTarget::isWorking()
|
||||
|
||||
if (!botAI->HasStrategy("travel", BOT_STATE_NON_COMBAT))
|
||||
{
|
||||
setTarget(sTravelMgr->nullTravelDestination, sTravelMgr->nullWorldPosition, true);
|
||||
setTarget(TravelMgr::instance().nullTravelDestination, TravelMgr::instance().nullWorldPosition, true);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1767,7 +1768,7 @@ void TravelMgr::logQuestError(uint32 errorNr, Quest* quest, uint32 objective, ui
|
||||
|
||||
void TravelMgr::LoadQuestTravelTable()
|
||||
{
|
||||
if (!sTravelMgr->quests.empty())
|
||||
if (!TravelMgr::instance().quests.empty())
|
||||
return;
|
||||
|
||||
// Clearing store (for reloading case)
|
||||
@@ -1960,7 +1961,7 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
bool loadQuestData = true;
|
||||
if (loadQuestData)
|
||||
{
|
||||
questGuidpMap questMap = GAI_VALUE(questGuidpMap, "quest guidp map");
|
||||
questGuidpMap questMap = SharedValueContext::instance().getGlobalValue<questGuidpMap>("quest guidp map")->Get();
|
||||
|
||||
for (auto& q : questMap)
|
||||
{
|
||||
@@ -1982,7 +1983,7 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
if (flag & (uint32)QuestRelationFlag::questGiver)
|
||||
{
|
||||
loc = new QuestRelationTravelDestination(
|
||||
questId, entry, 0, sPlayerbotAIConfig->tooCloseDistance, sPlayerbotAIConfig->sightDistance);
|
||||
questId, entry, 0, sPlayerbotAIConfig.tooCloseDistance, sPlayerbotAIConfig.sightDistance);
|
||||
loc->setExpireDelay(5 * 60 * 1000);
|
||||
loc->setMaxVisitors(15, 0);
|
||||
container->questGivers.push_back(loc);
|
||||
@@ -1991,7 +1992,7 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
if (flag & (uint32)QuestRelationFlag::questTaker)
|
||||
{
|
||||
loc = new QuestRelationTravelDestination(
|
||||
questId, entry, 1, sPlayerbotAIConfig->tooCloseDistance, sPlayerbotAIConfig->sightDistance);
|
||||
questId, entry, 1, sPlayerbotAIConfig.tooCloseDistance, sPlayerbotAIConfig.sightDistance);
|
||||
loc->setExpireDelay(5 * 60 * 1000);
|
||||
loc->setMaxVisitors(15, 0);
|
||||
container->questTakers.push_back(loc);
|
||||
@@ -2010,8 +2011,8 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
objective = 3;
|
||||
|
||||
loc = new QuestObjectiveTravelDestination(questId, entry, objective,
|
||||
sPlayerbotAIConfig->tooCloseDistance,
|
||||
sPlayerbotAIConfig->sightDistance);
|
||||
sPlayerbotAIConfig.tooCloseDistance,
|
||||
sPlayerbotAIConfig.sightDistance);
|
||||
loc->setExpireDelay(1 * 60 * 1000);
|
||||
loc->setMaxVisitors(100, 1);
|
||||
container->questObjectives.push_back(loc);
|
||||
@@ -2060,8 +2061,8 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
|
||||
int32 entry = r.type == 0 ? r.entry : r.entry * -1;
|
||||
|
||||
loc = new QuestRelationTravelDestination(r.questId, entry, r.role, sPlayerbotAIConfig->tooCloseDistance,
|
||||
sPlayerbotAIConfig->sightDistance); loc->setExpireDelay(5 * 60 * 1000); loc->setMaxVisitors(15, 0);
|
||||
loc = new QuestRelationTravelDestination(r.questId, entry, r.role, sPlayerbotAIConfig.tooCloseDistance,
|
||||
sPlayerbotAIConfig.sightDistance); loc->setExpireDelay(5 * 60 * 1000); loc->setMaxVisitors(15, 0);
|
||||
|
||||
for (auto& u : units)
|
||||
{
|
||||
@@ -2098,8 +2099,8 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
|
||||
uint32 reqEntry = quest->RequiredNpcOrGo[i];
|
||||
|
||||
loc = new QuestObjectiveTravelDestination(questId, reqEntry, i, sPlayerbotAIConfig->tooCloseDistance,
|
||||
sPlayerbotAIConfig->sightDistance); loc->setExpireDelay(1 * 60 * 1000); loc->setMaxVisitors(100, 1);
|
||||
loc = new QuestObjectiveTravelDestination(questId, reqEntry, i, sPlayerbotAIConfig.tooCloseDistance,
|
||||
sPlayerbotAIConfig.sightDistance); loc->setExpireDelay(1 * 60 * 1000); loc->setMaxVisitors(100, 1);
|
||||
|
||||
for (auto& u : units)
|
||||
{
|
||||
@@ -2149,8 +2150,8 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
|
||||
int32 entry = l.type == 0 ? l.entry : l.entry * -1;
|
||||
|
||||
loc = new QuestObjectiveTravelDestination(questId, entry, i, sPlayerbotAIConfig->tooCloseDistance,
|
||||
sPlayerbotAIConfig->sightDistance, l.item); loc->setExpireDelay(1 * 60 * 1000); loc->setMaxVisitors(100, 1);
|
||||
loc = new QuestObjectiveTravelDestination(questId, entry, i, sPlayerbotAIConfig.tooCloseDistance,
|
||||
sPlayerbotAIConfig.sightDistance, l.item); loc->setExpireDelay(1 * 60 * 1000); loc->setMaxVisitors(100, 1);
|
||||
|
||||
for (auto& u : units)
|
||||
{
|
||||
@@ -2238,8 +2239,8 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
{
|
||||
if ((cInfo->npcflag & *i) != 0)
|
||||
{
|
||||
rLoc = new RpgTravelDestination(u.entry, sPlayerbotAIConfig->tooCloseDistance,
|
||||
sPlayerbotAIConfig->sightDistance);
|
||||
rLoc = new RpgTravelDestination(u.entry, sPlayerbotAIConfig.tooCloseDistance,
|
||||
sPlayerbotAIConfig.sightDistance);
|
||||
rLoc->setExpireDelay(5 * 60 * 1000);
|
||||
rLoc->setMaxVisitors(15, 0);
|
||||
|
||||
@@ -2251,8 +2252,8 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
|
||||
if (cInfo->mingold > 0)
|
||||
{
|
||||
gLoc = new GrindTravelDestination(u.entry, sPlayerbotAIConfig->tooCloseDistance,
|
||||
sPlayerbotAIConfig->sightDistance);
|
||||
gLoc = new GrindTravelDestination(u.entry, sPlayerbotAIConfig.tooCloseDistance,
|
||||
sPlayerbotAIConfig.sightDistance);
|
||||
gLoc->setExpireDelay(5 * 60 * 1000);
|
||||
gLoc->setMaxVisitors(100, 0);
|
||||
|
||||
@@ -2265,8 +2266,8 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
{
|
||||
std::string const nodeName = cInfo->Name;
|
||||
|
||||
bLoc = new BossTravelDestination(u.entry, sPlayerbotAIConfig->tooCloseDistance,
|
||||
sPlayerbotAIConfig->sightDistance);
|
||||
bLoc = new BossTravelDestination(u.entry, sPlayerbotAIConfig.tooCloseDistance,
|
||||
sPlayerbotAIConfig.sightDistance);
|
||||
bLoc->setExpireDelay(5 * 60 * 1000);
|
||||
bLoc->setMaxVisitors(0, 0);
|
||||
|
||||
@@ -2298,8 +2299,8 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
|
||||
if (iloc == exploreLocs.end())
|
||||
{
|
||||
loc = new ExploreTravelDestination(area->ID, sPlayerbotAIConfig->tooCloseDistance,
|
||||
sPlayerbotAIConfig->sightDistance);
|
||||
loc = new ExploreTravelDestination(area->ID, sPlayerbotAIConfig.tooCloseDistance,
|
||||
sPlayerbotAIConfig.sightDistance);
|
||||
loc->setMaxVisitors(1000, 0);
|
||||
loc->setCooldownDelay(1000);
|
||||
loc->setExpireDelay(1000);
|
||||
@@ -2315,23 +2316,23 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
}
|
||||
|
||||
// Clear these logs files
|
||||
sPlayerbotAIConfig->openLog("zones.csv", "w");
|
||||
sPlayerbotAIConfig->openLog("creatures.csv", "w");
|
||||
sPlayerbotAIConfig->openLog("gos.csv", "w");
|
||||
sPlayerbotAIConfig->openLog("bot_movement.csv", "w");
|
||||
sPlayerbotAIConfig->openLog("bot_pathfinding.csv", "w");
|
||||
sPlayerbotAIConfig->openLog("pathfind_attempt.csv", "w");
|
||||
sPlayerbotAIConfig->openLog("pathfind_attempt_point.csv", "w");
|
||||
sPlayerbotAIConfig->openLog("pathfind_result.csv", "w");
|
||||
sPlayerbotAIConfig->openLog("load_map_grid.csv", "w");
|
||||
sPlayerbotAIConfig->openLog("strategy.csv", "w");
|
||||
sPlayerbotAIConfig.openLog("zones.csv", "w");
|
||||
sPlayerbotAIConfig.openLog("creatures.csv", "w");
|
||||
sPlayerbotAIConfig.openLog("gos.csv", "w");
|
||||
sPlayerbotAIConfig.openLog("bot_movement.csv", "w");
|
||||
sPlayerbotAIConfig.openLog("bot_pathfinding.csv", "w");
|
||||
sPlayerbotAIConfig.openLog("pathfind_attempt.csv", "w");
|
||||
sPlayerbotAIConfig.openLog("pathfind_attempt_point.csv", "w");
|
||||
sPlayerbotAIConfig.openLog("pathfind_result.csv", "w");
|
||||
sPlayerbotAIConfig.openLog("load_map_grid.csv", "w");
|
||||
sPlayerbotAIConfig.openLog("strategy.csv", "w");
|
||||
|
||||
sPlayerbotAIConfig->openLog("unload_grid.csv", "w");
|
||||
sPlayerbotAIConfig->openLog("unload_obj.csv", "w");
|
||||
sPlayerbotAIConfig.openLog("unload_grid.csv", "w");
|
||||
sPlayerbotAIConfig.openLog("unload_obj.csv", "w");
|
||||
|
||||
sTravelNodeMap->loadNodeStore();
|
||||
TravelNodeMap::instance().loadNodeStore();
|
||||
|
||||
sTravelNodeMap->generateAll();
|
||||
TravelNodeMap::instance().generateAll();
|
||||
|
||||
/*
|
||||
bool fullNavPointReload = false;
|
||||
@@ -2340,9 +2341,9 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
if (!fullNavPointReload && true)
|
||||
TravelNodeStore::loadNodes();
|
||||
|
||||
//sTravelNodeMap->loadNodeStore();
|
||||
//TravelNodeMap::instance().loadNodeStore();
|
||||
|
||||
for (auto node : sTravelNodeMap->getNodes())
|
||||
for (auto node : TravelNodeMap::instance().getNodes())
|
||||
{
|
||||
node->setLinked(true);
|
||||
}
|
||||
@@ -2384,7 +2385,7 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
else
|
||||
nodeName += " flightMaster";
|
||||
|
||||
sTravelNodeMap->addNode(&pos, nodeName, true, true);
|
||||
TravelNodeMap::instance().addNode(&pos, nodeName, true, true);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -2414,8 +2415,8 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
WorldPosition startPos(startTaxiNode->map_id, startTaxiNode->x, startTaxiNode->y, startTaxiNode->z);
|
||||
WorldPosition endPos(endTaxiNode->map_id, endTaxiNode->x, endTaxiNode->y, endTaxiNode->z);
|
||||
|
||||
TravelNode* startNode = sTravelNodeMap->getNode(&startPos, nullptr, 15.0f);
|
||||
TravelNode* endNode = sTravelNodeMap->getNode(&endPos, nullptr, 15.0f);
|
||||
TravelNode* startNode = TravelNodeMap::instance().getNode(&startPos, nullptr, 15.0f);
|
||||
TravelNode* endNode = TravelNodeMap::instance().getNode(&endPos, nullptr, 15.0f);
|
||||
|
||||
if (!startNode || !endNode)
|
||||
continue;
|
||||
@@ -2448,7 +2449,7 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
if (cInfo->rank == 3 || (cInfo->rank == 1 && !pos.isOverworld() && u.c == 1))
|
||||
{
|
||||
std::string const nodeName = cInfo->Name;
|
||||
sTravelNodeMap->addNode(&pos, nodeName, true, true);
|
||||
TravelNodeMap::instance().addNode(&pos, nodeName, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2475,7 +2476,7 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
pos = WorldPosition(info->mapId, info->positionX, info->positionY, info->positionZ, info->orientation);
|
||||
|
||||
std::string const nodeName = startNames[i] + " start";
|
||||
sTravelNodeMap->addNode(&pos, nodeName, true, true);
|
||||
TravelNodeMap::instance().addNode(&pos, nodeName, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2530,7 +2531,7 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
|
||||
if (pos.distance(&lPos) == 0)
|
||||
{
|
||||
TravelNode* node = sTravelNodeMap->addNode(&pos, data->name, true, true, true,
|
||||
TravelNode* node = TravelNodeMap::instance().addNode(&pos, data->name, true, true, true,
|
||||
iter.first);
|
||||
|
||||
if (!prevNode)
|
||||
@@ -2566,7 +2567,7 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
|
||||
if (pos.distance(&lPos) == 0)
|
||||
{
|
||||
TravelNode* node = sTravelNodeMap->addNode(&pos, data->name, true, true, true,
|
||||
TravelNode* node = TravelNodeMap::instance().addNode(&pos, data->name, true, true, true,
|
||||
iter.first); if (node != prevNode)
|
||||
{
|
||||
float totalTime = (p.second->TimeSeg - timeStart) / 1000.0f;
|
||||
@@ -2605,7 +2606,7 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
|
||||
if (p->delay > 0)
|
||||
{
|
||||
TravelNode* node = sTravelNodeMap->addNode(&pos, data->name, true, true, true, iter.first);
|
||||
TravelNode* node = TravelNodeMap::instance().addNode(&pos, data->name, true, true, true, iter.first);
|
||||
|
||||
if (!prevNode)
|
||||
{
|
||||
@@ -2638,7 +2639,7 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
|
||||
if (p->delay > 0)
|
||||
{
|
||||
TravelNode* node = sTravelNodeMap->getNode(&pos, nullptr, 5.0f);
|
||||
TravelNode* node = TravelNodeMap::instance().getNode(&pos, nullptr, 5.0f);
|
||||
if (node != prevNode)
|
||||
{
|
||||
TravelNodePath travelPath(0.1f, 0.0, (uint8) TravelNodePathType::transport, entry,
|
||||
@@ -2667,13 +2668,13 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
|
||||
WorldPosition pos = WorldPosition(points, WP_MEAN_CENTROID);
|
||||
|
||||
TravelNode* node = sTravelNodeMap->addNode(&pos, pos.getAreaName(), true, true, false);
|
||||
TravelNode* node = TravelNodeMap::instance().addNode(&pos, pos.getAreaName(), true, true, false);
|
||||
}
|
||||
|
||||
LOG_INFO("playerbots", ">> Loaded {} navigation points.", sTravelNodeMap->getNodes().size());
|
||||
LOG_INFO("playerbots", ">> Loaded {} navigation points.", TravelNodeMap::instance().getNodes().size());
|
||||
}
|
||||
|
||||
sTravelNodeMap->calcMapOffset();
|
||||
TravelNodeMap::instance().calcMapOffset();
|
||||
loadMapTransfers();
|
||||
*/
|
||||
|
||||
@@ -2692,14 +2693,14 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
//PathGenerator
|
||||
std::vector<WorldPosition> ppath;
|
||||
|
||||
uint32 cur = 0, max = sTravelNodeMap->getNodes().size();
|
||||
uint32 cur = 0, max = TravelNodeMap::instance().getNodes().size();
|
||||
|
||||
for (auto& startNode : sTravelNodeMap->getNodes())
|
||||
for (auto& startNode : TravelNodeMap::instance().getNodes())
|
||||
{
|
||||
if (!preloadReLinkFullyLinked && startNode->isLinked())
|
||||
continue;
|
||||
|
||||
for (auto& endNode : sTravelNodeMap->getNodes())
|
||||
for (auto& endNode : TravelNodeMap::instance().getNodes())
|
||||
{
|
||||
if (startNode == endNode)
|
||||
continue;
|
||||
@@ -2734,18 +2735,18 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
|
||||
if (preloadSubPrint && (cur * 50) / max > ((cur - 1) * 50) / max)
|
||||
{
|
||||
sTravelNodeMap->printMap();
|
||||
sTravelNodeMap->printNodeStore();
|
||||
TravelNodeMap::instance().printMap();
|
||||
TravelNodeMap::instance().printNodeStore();
|
||||
}
|
||||
}
|
||||
|
||||
if (!preloadSubPrint)
|
||||
{
|
||||
sTravelNodeMap->printNodeStore();
|
||||
sTravelNodeMap->printMap();
|
||||
TravelNodeMap::instance().printNodeStore();
|
||||
TravelNodeMap::instance().printMap();
|
||||
}
|
||||
|
||||
LOG_INFO("playerbots", ">> Loaded paths for {} nodes.", sTravelNodeMap->getNodes().size());
|
||||
LOG_INFO("playerbots", ">> Loaded paths for {} nodes.", TravelNodeMap::instance().getNodes().size());
|
||||
}
|
||||
|
||||
bool removeLowLinkNodes = false || fullNavPointReload || storeNavPointReload;
|
||||
@@ -2754,7 +2755,7 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
{
|
||||
std::vector<TravelNode*> goodNodes;
|
||||
std::vector<TravelNode*> remNodes;
|
||||
for (auto& node : sTravelNodeMap->getNodes())
|
||||
for (auto& node : TravelNodeMap::instance().getNodes())
|
||||
{
|
||||
if (!node->getPosition()->isOverworld())
|
||||
continue;
|
||||
@@ -2774,9 +2775,9 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
}
|
||||
|
||||
for (auto& node : remNodes)
|
||||
sTravelNodeMap->removeNode(node);
|
||||
TravelNodeMap::instance().removeNode(node);
|
||||
|
||||
LOG_INFO("playerbots", ">> Checked {} nodes.", sTravelNodeMap->getNodes().size());
|
||||
LOG_INFO("playerbots", ">> Checked {} nodes.", TravelNodeMap::instance().getNodes().size());
|
||||
}
|
||||
|
||||
bool cleanUpNodeLinks = false || fullNavPointReload || storeNavPointReload;
|
||||
@@ -2786,22 +2787,22 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
{
|
||||
//Routes
|
||||
uint32 cur = 0;
|
||||
uint32 max = sTravelNodeMap->getNodes().size();
|
||||
uint32 max = TravelNodeMap::instance().getNodes().size();
|
||||
|
||||
//Clean up node links
|
||||
for (auto& startNode : sTravelNodeMap->getNodes())
|
||||
for (auto& startNode : TravelNodeMap::instance().getNodes())
|
||||
{
|
||||
startNode->cropUselessLinks();
|
||||
|
||||
cur++;
|
||||
if (cleanUpSubPrint && (cur * 10) / max > ((cur - 1) * 10) / max)
|
||||
{
|
||||
sTravelNodeMap->printMap();
|
||||
sTravelNodeMap->printNodeStore();
|
||||
TravelNodeMap::instance().printMap();
|
||||
TravelNodeMap::instance().printNodeStore();
|
||||
}
|
||||
}
|
||||
|
||||
LOG_INFO("playerbots", ">> Cleaned paths for {} nodes.", sTravelNodeMap->getNodes().size());
|
||||
LOG_INFO("playerbots", ">> Cleaned paths for {} nodes.", TravelNodeMap::instance().getNodes().size());
|
||||
}
|
||||
|
||||
bool reCalculateCost = false || fullNavPointReload || storeNavPointReload;
|
||||
@@ -2809,7 +2810,7 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
|
||||
if (reCalculateCost)
|
||||
{
|
||||
for (auto& startNode : sTravelNodeMap->getNodes())
|
||||
for (auto& startNode : TravelNodeMap::instance().getNodes())
|
||||
{
|
||||
for (auto& path : *startNode->getLinks())
|
||||
{
|
||||
@@ -2825,14 +2826,14 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
}
|
||||
}
|
||||
|
||||
LOG_INFO("playerbots", ">> Calculated pathcost for {} nodes.", sTravelNodeMap->getNodes().size());
|
||||
LOG_INFO("playerbots", ">> Calculated pathcost for {} nodes.", TravelNodeMap::instance().getNodes().size());
|
||||
}
|
||||
|
||||
bool mirrorMissingPaths = true || fullNavPointReload || storeNavPointReload;
|
||||
|
||||
if (mirrorMissingPaths)
|
||||
{
|
||||
for (auto& startNode : sTravelNodeMap->getNodes())
|
||||
for (auto& startNode : TravelNodeMap::instance().getNodes())
|
||||
{
|
||||
for (auto& path : *startNode->getLinks())
|
||||
{
|
||||
@@ -2855,16 +2856,16 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
}
|
||||
}
|
||||
|
||||
LOG_INFO("playerbots", ">> Reversed missing paths for {} nodes.", sTravelNodeMap->getNodes().size());
|
||||
LOG_INFO("playerbots", ">> Reversed missing paths for {} nodes.", TravelNodeMap::instance().getNodes().size());
|
||||
}
|
||||
*/
|
||||
|
||||
sTravelNodeMap->printMap();
|
||||
sTravelNodeMap->printNodeStore();
|
||||
sTravelNodeMap->saveNodeStore();
|
||||
TravelNodeMap::instance().printMap();
|
||||
TravelNodeMap::instance().printNodeStore();
|
||||
TravelNodeMap::instance().saveNodeStore();
|
||||
|
||||
// Creature/gos/zone export.
|
||||
if (sPlayerbotAIConfig->hasLog("creatures.csv"))
|
||||
if (sPlayerbotAIConfig.hasLog("creatures.csv"))
|
||||
{
|
||||
for (CreatureData const* cData : WorldPosition().getCreaturesNear())
|
||||
{
|
||||
@@ -2889,11 +2890,11 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
out << point.getAreaName() << ",";
|
||||
out << std::fixed;
|
||||
|
||||
sPlayerbotAIConfig->log("creatures.csv", out.str().c_str());
|
||||
sPlayerbotAIConfig.log("creatures.csv", out.str().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
if (sPlayerbotAIConfig->hasLog("vmangoslines.csv"))
|
||||
if (sPlayerbotAIConfig.hasLog("vmangoslines.csv"))
|
||||
{
|
||||
uint32 mapId = 0;
|
||||
std::vector<WorldPosition> pos;
|
||||
@@ -2924,7 +2925,7 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
WorldPosition().printWKT(pos, out, 1);
|
||||
out << std::fixed;
|
||||
|
||||
sPlayerbotAIConfig->log("vmangoslines.csv", out.str().c_str());
|
||||
sPlayerbotAIConfig.log("vmangoslines.csv", out.str().c_str());
|
||||
|
||||
static float const ironforgeAreaSouthLimit[] = {
|
||||
-7491.33f, 3093.740f, -7472.04f, -391.880f, -6366.68f, -730.100f, -6063.96f, -1411.76f,
|
||||
@@ -2951,7 +2952,7 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
WorldPosition().printWKT(pos, out, 1);
|
||||
out << std::fixed;
|
||||
|
||||
sPlayerbotAIConfig->log("vmangoslines.csv", out.str().c_str());
|
||||
sPlayerbotAIConfig.log("vmangoslines.csv", out.str().c_str());
|
||||
|
||||
static float const stormwindAreaNorthLimit[] = {
|
||||
-8004.250f, 3714.110f, -8075.000f, -179.000f, -8638.000f, 169.0000f, -9044.000f, 35.00000f,
|
||||
@@ -2979,7 +2980,7 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
WorldPosition().printWKT(pos, out, 1);
|
||||
out << std::fixed;
|
||||
|
||||
sPlayerbotAIConfig->log("vmangoslines.csv", out.str().c_str());
|
||||
sPlayerbotAIConfig.log("vmangoslines.csv", out.str().c_str());
|
||||
|
||||
static float const stormwindAreaSouthLimit[] = {
|
||||
-8725.3378910f, 3535.62402300f, -9525.6992190f, 910.13256800f, -9796.9531250f, 839.06958000f,
|
||||
@@ -3010,7 +3011,7 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
WorldPosition().printWKT(pos, out, 1);
|
||||
out << std::fixed;
|
||||
|
||||
sPlayerbotAIConfig->log("vmangoslines.csv", out.str().c_str());
|
||||
sPlayerbotAIConfig.log("vmangoslines.csv", out.str().c_str());
|
||||
|
||||
mapId = 1;
|
||||
|
||||
@@ -3044,7 +3045,7 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
WorldPosition().printWKT(pos, out, 1);
|
||||
out << std::fixed;
|
||||
|
||||
sPlayerbotAIConfig->log("vmangoslines.csv", out.str().c_str());
|
||||
sPlayerbotAIConfig.log("vmangoslines.csv", out.str().c_str());
|
||||
|
||||
static float const durotarSouthLimit[] = {
|
||||
2755.0f, -3766.f, 2225.0f, -3596.f, 1762.0f, -3746.f, 1564.0f, -3943.f, 1184.0f, -3915.f, 737.00f,
|
||||
@@ -3072,7 +3073,7 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
WorldPosition().printWKT(pos, out, 1);
|
||||
out << std::fixed;
|
||||
|
||||
sPlayerbotAIConfig->log("vmangoslines.csv", out.str().c_str());
|
||||
sPlayerbotAIConfig.log("vmangoslines.csv", out.str().c_str());
|
||||
|
||||
static float const valleyoftrialsSouthLimit[] = {-324.f, -3869.f, -774.f, -3992.f, -965.f, -4290.f, -932.f,
|
||||
-4349.f, -828.f, -4414.f, -661.f, -4541.f, -521.f, -4582.f};
|
||||
@@ -3097,7 +3098,7 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
WorldPosition().printWKT(pos, out, 1);
|
||||
out << std::fixed;
|
||||
|
||||
sPlayerbotAIConfig->log("vmangoslines.csv", out.str().c_str());
|
||||
sPlayerbotAIConfig.log("vmangoslines.csv", out.str().c_str());
|
||||
|
||||
static float const middleToSouthLimit[] = {
|
||||
-2402.010000f, 4255.7000000f, -2475.933105f, 3199.5683590f, // Desolace
|
||||
@@ -3129,7 +3130,7 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
WorldPosition().printWKT(pos, out, 1);
|
||||
out << std::fixed;
|
||||
|
||||
sPlayerbotAIConfig->log("vmangoslines.csv", out.str().c_str());
|
||||
sPlayerbotAIConfig.log("vmangoslines.csv", out.str().c_str());
|
||||
|
||||
static float const orgrimmarSouthLimit[] = {
|
||||
2132.5076f, -3912.2478f, 1944.4298f, -3855.2583f, 1735.6906f, -3834.2417f, 1654.3671f, -3380.9902f,
|
||||
@@ -3157,7 +3158,7 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
WorldPosition().printWKT(pos, out, 1);
|
||||
out << std::fixed;
|
||||
|
||||
sPlayerbotAIConfig->log("vmangoslines.csv", out.str().c_str());
|
||||
sPlayerbotAIConfig.log("vmangoslines.csv", out.str().c_str());
|
||||
|
||||
static float const feralasThousandNeedlesSouthLimit[] = {
|
||||
-6495.4995f, -4711.9810f, -6674.9995f, -4515.0019f, -6769.5717f, -4122.4272f, -6838.2651f, -3874.2792f,
|
||||
@@ -3187,10 +3188,10 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
WorldPosition().printWKT(pos, out, 1);
|
||||
out << std::fixed;
|
||||
|
||||
sPlayerbotAIConfig->log("vmangoslines.csv", out.str().c_str());
|
||||
sPlayerbotAIConfig.log("vmangoslines.csv", out.str().c_str());
|
||||
}
|
||||
|
||||
if (sPlayerbotAIConfig->hasLog("gos.csv"))
|
||||
if (sPlayerbotAIConfig.hasLog("gos.csv"))
|
||||
{
|
||||
for (GameObjectData const* gData : WorldPosition().getGameObjectsNear())
|
||||
{
|
||||
@@ -3212,11 +3213,11 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
out << point.getAreaName() << ",";
|
||||
out << std::fixed;
|
||||
|
||||
sPlayerbotAIConfig->log("gos.csv", out.str().c_str());
|
||||
sPlayerbotAIConfig.log("gos.csv", out.str().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
if (sPlayerbotAIConfig->hasLog("zones.csv"))
|
||||
if (sPlayerbotAIConfig.hasLog("zones.csv"))
|
||||
{
|
||||
std::unordered_map<std::string, std::vector<WorldPosition>> zoneLocs;
|
||||
|
||||
@@ -3238,7 +3239,7 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
if (loc.second.empty())
|
||||
continue;
|
||||
|
||||
if (!sTravelNodeMap->getMapOffset(loc.second.front().getMapId()) && loc.second.front().getMapId() != 0)
|
||||
if (!TravelNodeMap::instance().getMapOffset(loc.second.front().getMapId()) && loc.second.front().getMapId() != 0)
|
||||
continue;
|
||||
|
||||
std::vector<WorldPosition> points = loc.second;
|
||||
@@ -3266,13 +3267,13 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
|
||||
point.printWKT(points, out, 0);
|
||||
|
||||
sPlayerbotAIConfig->log("zones.csv", out.str().c_str());
|
||||
sPlayerbotAIConfig.log("zones.csv", out.str().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
bool printStrategyMap = false;
|
||||
|
||||
if (printStrategyMap && sPlayerbotAIConfig->hasLog("strategy.csv"))
|
||||
if (printStrategyMap && sPlayerbotAIConfig.hasLog("strategy.csv"))
|
||||
{
|
||||
static std::map<uint8, std::string> classes;
|
||||
static std::map<uint8, std::map<uint8, std::string>> specs;
|
||||
@@ -3328,7 +3329,7 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
|
||||
// Use randombot 0.
|
||||
std::ostringstream cout;
|
||||
cout << sPlayerbotAIConfig->randomBotAccountPrefix << 0;
|
||||
cout << sPlayerbotAIConfig.randomBotAccountPrefix << 0;
|
||||
std::string const accountName = cout.str();
|
||||
|
||||
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_GET_ACCOUNT_ID_BY_USERNAME);
|
||||
@@ -3502,7 +3503,7 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
return false;
|
||||
});
|
||||
|
||||
sPlayerbotAIConfig->log("strategy.csv", "relevance, action, trigger, strategy, classes");
|
||||
sPlayerbotAIConfig.log("strategy.csv", "relevance, action, trigger, strategy, classes");
|
||||
|
||||
for (auto& actionkey : actionKeys)
|
||||
{
|
||||
@@ -3607,17 +3608,17 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
out << actionkey << "\n";
|
||||
}
|
||||
|
||||
sPlayerbotAIConfig->log("strategy.csv", out.str().c_str());
|
||||
sPlayerbotAIConfig.log("strategy.csv", out.str().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
sPlayerbotAIConfig->openLog(7, "w");
|
||||
sPlayerbotAIConfig.openLog(7, "w");
|
||||
|
||||
//Zone area map REMOVE!
|
||||
uint32 k = 0;
|
||||
for (auto& node : sTravelNodeMap->getNodes())
|
||||
for (auto& node : TravelNodeMap::instance().getNodes())
|
||||
{
|
||||
WorldPosition* pos = node->getPosition();
|
||||
//map area
|
||||
@@ -3642,7 +3643,7 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
|
||||
std::ostringstream out;
|
||||
out << std::fixed << area << "," << npos.getDisplayX() << "," << npos.getDisplayY();
|
||||
sPlayerbotAIConfig->log(7, out.str().c_str());
|
||||
sPlayerbotAIConfig.log(7, out.str().c_str());
|
||||
}
|
||||
}
|
||||
k++;
|
||||
@@ -3653,7 +3654,7 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
|
||||
//Explore map output (REMOVE!)
|
||||
|
||||
sPlayerbotAIConfig->openLog(5, "w");
|
||||
sPlayerbotAIConfig.openLog(5, "w");
|
||||
for (auto i : exploreLocs)
|
||||
{
|
||||
for (auto j : i.second->getPoints())
|
||||
@@ -3662,7 +3663,7 @@ void TravelMgr::LoadQuestTravelTable()
|
||||
std::string const name = i.second->getTitle();
|
||||
name.erase(remove(name.begin(), name.end(), '\"'), name.end());
|
||||
out << std::fixed << std::setprecision(2) << name.c_str() << "," << i.first << "," << j->getDisplayX() <<
|
||||
"," << j->getDisplayY() << "," << j->getX() << "," << j->getY() << "," << j->getZ(); sPlayerbotAIConfig->log(5,
|
||||
"," << j->getDisplayY() << "," << j->getX() << "," << j->getY() << "," << j->getZ(); sPlayerbotAIConfig.log(5,
|
||||
out.str().c_str());
|
||||
}
|
||||
}
|
||||
@@ -3897,7 +3898,7 @@ bool TravelMgr::getObjectiveStatus(Player* bot, Quest const* pQuest, uint32 obje
|
||||
if (bot->GetQuestStatus(questId) != QUEST_STATUS_INCOMPLETE)
|
||||
return false;
|
||||
|
||||
QuestStatusData* questStatus = sTravelMgr->getQuestStatus(bot, questId);
|
||||
QuestStatusData* questStatus = TravelMgr::instance().getQuestStatus(bot, questId);
|
||||
|
||||
uint32 reqCount = pQuest->RequiredItemCount[objective];
|
||||
uint32 hasCount = questStatus->ItemCount[objective];
|
||||
@@ -4097,7 +4098,7 @@ void TravelMgr::setNullTravelTarget(Player* player)
|
||||
TravelTarget* target = playerBotAI->GetAiObjectContext()->GetValue<TravelTarget*>("travel target")->Get();
|
||||
|
||||
if (target)
|
||||
target->setTarget(sTravelMgr->nullTravelDestination, sTravelMgr->nullWorldPosition, true);
|
||||
target->setTarget(TravelMgr::instance().nullTravelDestination, TravelMgr::instance().nullWorldPosition, true);
|
||||
}
|
||||
|
||||
void TravelMgr::addMapTransfer(WorldPosition start, WorldPosition end, float portalDistance, bool makeShortcuts)
|
||||
@@ -4146,7 +4147,7 @@ void TravelMgr::addMapTransfer(WorldPosition start, WorldPosition end, float por
|
||||
|
||||
void TravelMgr::loadMapTransfers()
|
||||
{
|
||||
for (auto& node : sTravelNodeMap->getNodes())
|
||||
for (auto& node : TravelNodeMap::instance().getNodes())
|
||||
{
|
||||
for (auto& link : *node->getLinks())
|
||||
{
|
||||
@@ -4233,15 +4234,15 @@ void TravelMgr::printGrid(uint32 mapId, int x, int y, std::string const type)
|
||||
{
|
||||
std::string const fileName = "unload_grid.csv";
|
||||
|
||||
if (sPlayerbotAIConfig->hasLog(fileName))
|
||||
if (sPlayerbotAIConfig.hasLog(fileName))
|
||||
{
|
||||
WorldPosition p = WorldPosition(mapId, 0, 0, 0, 0);
|
||||
|
||||
std::ostringstream out;
|
||||
out << sPlayerbotAIConfig->GetTimestampStr();
|
||||
out << sPlayerbotAIConfig.GetTimestampStr();
|
||||
out << "+00, " << 0 << 0 << x << "," << y << ", " << type << ",";
|
||||
p.printWKT(p.fromGridCoord(GridCoord(x, y)), out, 1, true);
|
||||
sPlayerbotAIConfig->log(fileName, out.str().c_str());
|
||||
sPlayerbotAIConfig.log(fileName, out.str().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4249,7 +4250,7 @@ void TravelMgr::printObj(WorldObject* obj, std::string const type)
|
||||
{
|
||||
std::string fileName = "unload_grid.csv";
|
||||
|
||||
if (sPlayerbotAIConfig->hasLog(fileName))
|
||||
if (sPlayerbotAIConfig.hasLog(fileName))
|
||||
{
|
||||
WorldPosition p = WorldPosition(obj);
|
||||
|
||||
@@ -4261,40 +4262,40 @@ void TravelMgr::printObj(WorldObject* obj, std::string const type)
|
||||
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << sPlayerbotAIConfig->GetTimestampStr();
|
||||
out << sPlayerbotAIConfig.GetTimestampStr();
|
||||
out << "+00, " << obj->GetGUID().GetEntry() << "," << obj->GetGUID().GetCounter() << "," << cell.GridX()
|
||||
<< "," << cell.GridY() << ", " << type << ",";
|
||||
|
||||
p.printWKT(vcell, out, 1, true);
|
||||
sPlayerbotAIConfig->log(fileName, out.str().c_str());
|
||||
sPlayerbotAIConfig.log(fileName, out.str().c_str());
|
||||
}
|
||||
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << sPlayerbotAIConfig->GetTimestampStr();
|
||||
out << sPlayerbotAIConfig.GetTimestampStr();
|
||||
out << "+00, " << obj->GetGUID().GetEntry() << "," << obj->GetGUID().GetCounter() << "," << cell.GridX()
|
||||
<< "," << cell.GridY() << ", " << type << ",";
|
||||
|
||||
p.printWKT(vgrid, out, 1, true);
|
||||
sPlayerbotAIConfig->log(fileName, out.str().c_str());
|
||||
sPlayerbotAIConfig.log(fileName, out.str().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
fileName = "unload_obj.csv";
|
||||
|
||||
if (sPlayerbotAIConfig->hasLog(fileName))
|
||||
if (sPlayerbotAIConfig.hasLog(fileName))
|
||||
{
|
||||
WorldPosition p = WorldPosition(obj);
|
||||
|
||||
Cell cell(obj->GetPositionX(), obj->GetPositionY());
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << sPlayerbotAIConfig->GetTimestampStr();
|
||||
out << sPlayerbotAIConfig.GetTimestampStr();
|
||||
out << "+00, " << obj->GetGUID().GetEntry() << "," << obj->GetGUID().GetCounter() << "," << cell.GridX()
|
||||
<< "," << cell.GridY() << ", " << type << ",";
|
||||
|
||||
p.printWKT({p}, out, 0);
|
||||
sPlayerbotAIConfig->log(fileName, out.str().c_str());
|
||||
sPlayerbotAIConfig.log(fileName, out.str().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include <random>
|
||||
|
||||
#include "AiObject.h"
|
||||
#include "Corpse.h"
|
||||
#include "CreatureData.h"
|
||||
#include "GameObject.h"
|
||||
#include "GridDefines.h"
|
||||
@@ -298,11 +297,11 @@ public:
|
||||
|
||||
std::vector<WorldPosition> getPathTo(WorldPosition endPos, Unit* bot) { return endPos.getPathFrom(*this, bot); }
|
||||
|
||||
bool isPathTo(std::vector<WorldPosition> path, float maxDistance = sPlayerbotAIConfig->targetPosRecalcDistance)
|
||||
bool isPathTo(std::vector<WorldPosition> path, float maxDistance = sPlayerbotAIConfig.targetPosRecalcDistance)
|
||||
{
|
||||
return !path.empty() && distance(path.back()) < maxDistance;
|
||||
};
|
||||
bool cropPathTo(std::vector<WorldPosition>& path, float maxDistance = sPlayerbotAIConfig->targetPosRecalcDistance);
|
||||
bool cropPathTo(std::vector<WorldPosition>& path, float maxDistance = sPlayerbotAIConfig.targetPosRecalcDistance);
|
||||
bool canPathTo(WorldPosition endPos, Unit* bot) { return endPos.isPathTo(getPathTo(endPos, bot)); }
|
||||
|
||||
float getPathLength(std::vector<WorldPosition> points)
|
||||
@@ -848,12 +847,11 @@ protected:
|
||||
class TravelMgr
|
||||
{
|
||||
public:
|
||||
TravelMgr(){};
|
||||
|
||||
static TravelMgr* instance()
|
||||
static TravelMgr& instance()
|
||||
{
|
||||
static TravelMgr instance;
|
||||
return &instance;
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
void Clear();
|
||||
@@ -922,7 +920,6 @@ public:
|
||||
void printGrid(uint32 mapId, int x, int y, std::string const type);
|
||||
void printObj(WorldObject* obj, std::string const type);
|
||||
|
||||
// protected:
|
||||
void logQuestError(uint32 errorNr, Quest* quest, uint32 objective = 0, uint32 unitId = 0, uint32 itemId = 0);
|
||||
|
||||
std::vector<uint32> avoidLoaded;
|
||||
@@ -939,8 +936,16 @@ public:
|
||||
|
||||
std::unordered_map<std::pair<uint32, uint32>, std::vector<mapTransfer>, boost::hash<std::pair<uint32, uint32>>>
|
||||
mapTransfersMap;
|
||||
|
||||
private:
|
||||
TravelMgr() = default;
|
||||
~TravelMgr() = default;
|
||||
|
||||
TravelMgr(const TravelMgr&) = delete;
|
||||
TravelMgr& operator=(const TravelMgr&) = delete;
|
||||
|
||||
TravelMgr(TravelMgr&&) = delete;
|
||||
TravelMgr& operator=(TravelMgr&&) = delete;
|
||||
};
|
||||
|
||||
#define sTravelMgr TravelMgr::instance()
|
||||
|
||||
#endif
|
||||
|
||||
@@ -323,7 +323,7 @@ void TravelNode::removeLinkTo(TravelNode* node, bool removePaths)
|
||||
else
|
||||
{
|
||||
// Remove all references to this node.
|
||||
for (auto& node : sTravelNodeMap->getNodes())
|
||||
for (auto& node : TravelNodeMap::instance().getNodes())
|
||||
{
|
||||
if (node->hasPathTo(this))
|
||||
node->removeLinkTo(this, removePaths);
|
||||
@@ -397,7 +397,7 @@ bool TravelNode::isUselessLink(TravelNode* farNode)
|
||||
}
|
||||
else
|
||||
{
|
||||
TravelNodeRoute route = sTravelNodeMap->getRoute(nearNode, farNode, nullptr);
|
||||
TravelNodeRoute route = TravelNodeMap::instance().getRoute(nearNode, farNode, nullptr);
|
||||
|
||||
if (route.isEmpty())
|
||||
continue;
|
||||
@@ -432,7 +432,7 @@ bool TravelNode::cropUselessLinks()
|
||||
this->removeLinkTo(farNode);
|
||||
hasRemoved = true;
|
||||
|
||||
if (sPlayerbotAIConfig->hasLog("crop.csv"))
|
||||
if (sPlayerbotAIConfig.hasLog("crop.csv"))
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << getName() << ",";
|
||||
@@ -440,7 +440,7 @@ bool TravelNode::cropUselessLinks()
|
||||
WorldPosition().printWKT({*getPosition(), *farNode->getPosition()}, out, 1);
|
||||
out << std::fixed;
|
||||
|
||||
sPlayerbotAIConfig->log("crop.csv", out.str().c_str());
|
||||
sPlayerbotAIConfig.log("crop.csv", out.str().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -449,7 +449,7 @@ bool TravelNode::cropUselessLinks()
|
||||
farNode->removeLinkTo(this);
|
||||
hasRemoved = true;
|
||||
|
||||
if (sPlayerbotAIConfig->hasLog("crop.csv"))
|
||||
if (sPlayerbotAIConfig.hasLog("crop.csv"))
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << getName() << ",";
|
||||
@@ -457,7 +457,7 @@ bool TravelNode::cropUselessLinks()
|
||||
WorldPosition().printWKT({*getPosition(), *farNode->getPosition()}, out, 1);
|
||||
out << std::fixed;
|
||||
|
||||
sPlayerbotAIConfig->log("crop.csv", out.str().c_str());
|
||||
sPlayerbotAIConfig.log("crop.csv", out.str().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -496,7 +496,7 @@ bool TravelNode::cropUselessLinks()
|
||||
}
|
||||
else
|
||||
{
|
||||
TravelNodeRoute route = sTravelNodeMap->getRoute(firstNode, secondNode, false);
|
||||
TravelNodeRoute route = TravelNodeMap::instance().getRoute(firstNode, secondNode, false);
|
||||
|
||||
if (route.isEmpty())
|
||||
continue;
|
||||
@@ -544,7 +544,7 @@ bool TravelNode::cropUselessLinks()
|
||||
}
|
||||
else
|
||||
{
|
||||
TravelNodeRoute route = sTravelNodeMap->getRoute(firstNode, secondNode, false);
|
||||
TravelNodeRoute route = TravelNodeMap::instance().getRoute(firstNode, secondNode, false);
|
||||
|
||||
if (route.isEmpty())
|
||||
continue;
|
||||
@@ -579,7 +579,7 @@ bool TravelNode::isEqual(TravelNode* compareNode)
|
||||
if (!compareNode->hasLinkTo(this))
|
||||
return false;
|
||||
|
||||
for (auto& node : sTravelNodeMap->getNodes())
|
||||
for (auto& node : TravelNodeMap::instance().getNodes())
|
||||
{
|
||||
if (node == this || node == compareNode)
|
||||
continue;
|
||||
@@ -611,11 +611,11 @@ void TravelNode::print([[maybe_unused]] bool printFailed)
|
||||
out << (isImportant() ? 1 : 0) << ",";
|
||||
out << mapSize;
|
||||
|
||||
sPlayerbotAIConfig->log("travelNodes.csv", out.str().c_str());
|
||||
sPlayerbotAIConfig.log("travelNodes.csv", out.str().c_str());
|
||||
|
||||
std::vector<WorldPosition> ppath;
|
||||
|
||||
for (auto& endNode : sTravelNodeMap->getNodes())
|
||||
for (auto& endNode : TravelNodeMap::instance().getNodes())
|
||||
{
|
||||
if (endNode == this)
|
||||
continue;
|
||||
@@ -665,7 +665,7 @@ void TravelNode::print([[maybe_unused]] bool printFailed)
|
||||
out << std::to_string(path->getMaxLevelCreature()[1]) << ",";
|
||||
out << std::to_string(path->getMaxLevelCreature()[2]);
|
||||
|
||||
sPlayerbotAIConfig->log("travelPaths.csv", out.str().c_str());
|
||||
sPlayerbotAIConfig.log("travelPaths.csv", out.str().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -695,8 +695,8 @@ bool TravelPath::makeShortCut(WorldPosition startPos, float maxDist)
|
||||
totalDist += p.point.sqDistance(std::prev(&p)->point);
|
||||
|
||||
if (curDist <
|
||||
sPlayerbotAIConfig->tooCloseDistance *
|
||||
sPlayerbotAIConfig->tooCloseDistance) // We are on the path. This is a good starting point
|
||||
sPlayerbotAIConfig.tooCloseDistance *
|
||||
sPlayerbotAIConfig.tooCloseDistance) // We are on the path. This is a good starting point
|
||||
{
|
||||
minDist = curDist;
|
||||
totalDist = curDist;
|
||||
@@ -731,11 +731,11 @@ bool TravelPath::makeShortCut(WorldPosition startPos, float maxDist)
|
||||
WorldPosition beginPos = newPath.begin()->point;
|
||||
|
||||
// The old path seems to be the best.
|
||||
if (beginPos.distance(firstNode) < sPlayerbotAIConfig->tooCloseDistance)
|
||||
if (beginPos.distance(firstNode) < sPlayerbotAIConfig.tooCloseDistance)
|
||||
return false;
|
||||
|
||||
// We are (nearly) on the new path. Just follow the rest.
|
||||
if (beginPos.distance(startPos) < sPlayerbotAIConfig->tooCloseDistance)
|
||||
if (beginPos.distance(startPos) < sPlayerbotAIConfig.tooCloseDistance)
|
||||
{
|
||||
fullPath = newPath;
|
||||
return true;
|
||||
@@ -891,7 +891,7 @@ WorldPosition TravelPath::getNextPoint(WorldPosition startPos, float maxDist, Tr
|
||||
}
|
||||
|
||||
// We have to move far for next point. Try to make a cropped path.
|
||||
if (moveDist < sPlayerbotAIConfig->targetPosRecalcDistance && std::next(startP) != ed)
|
||||
if (moveDist < sPlayerbotAIConfig.targetPosRecalcDistance && std::next(startP) != ed)
|
||||
{
|
||||
// std::vector<WorldPosition> path = startPos.getPathTo(std::next(startP)->point, nullptr);
|
||||
// startP->point = startPos.lastInRange(path, -1, maxDist);
|
||||
@@ -905,7 +905,7 @@ std::ostringstream const TravelPath::print()
|
||||
{
|
||||
std::ostringstream out;
|
||||
|
||||
out << sPlayerbotAIConfig->GetTimestampStr();
|
||||
out << sPlayerbotAIConfig.GetTimestampStr();
|
||||
out << "+00,"
|
||||
<< "1,";
|
||||
out << std::fixed;
|
||||
@@ -1031,7 +1031,7 @@ std::ostringstream const TravelNodeRoute::print()
|
||||
{
|
||||
std::ostringstream out;
|
||||
|
||||
out << sPlayerbotAIConfig->GetTimestampStr();
|
||||
out << sPlayerbotAIConfig.GetTimestampStr();
|
||||
out << "+00"
|
||||
<< ",0,"
|
||||
<< "\"LINESTRING(";
|
||||
@@ -1046,34 +1046,6 @@ std::ostringstream const TravelNodeRoute::print()
|
||||
return out;
|
||||
}
|
||||
|
||||
TravelNodeMap::TravelNodeMap(TravelNodeMap* baseMap)
|
||||
{
|
||||
TravelNode* newNode;
|
||||
|
||||
baseMap->m_nMapMtx.lock_shared();
|
||||
|
||||
for (auto& node : baseMap->getNodes())
|
||||
{
|
||||
newNode = new TravelNode(node);
|
||||
|
||||
m_nodes.push_back(newNode);
|
||||
}
|
||||
|
||||
for (auto& node : baseMap->getNodes())
|
||||
{
|
||||
newNode = getNode(node);
|
||||
|
||||
for (auto& path : *node->getPaths())
|
||||
{
|
||||
TravelNode* endNode = getNode(path.first);
|
||||
|
||||
newNode->setPathTo(endNode, path.second);
|
||||
}
|
||||
}
|
||||
|
||||
baseMap->m_nMapMtx.unlock_shared();
|
||||
}
|
||||
|
||||
TravelNode* TravelNodeMap::addNode(WorldPosition pos, std::string const preferedName, bool isImportant,
|
||||
bool checkDuplicate, [[maybe_unused]] bool transport,
|
||||
[[maybe_unused]] uint32 transportId)
|
||||
@@ -1178,7 +1150,7 @@ TravelNode* TravelNodeMap::getNode(WorldPosition pos, [[maybe_unused]] std::vect
|
||||
|
||||
uint32 c = 0;
|
||||
|
||||
std::vector<TravelNode*> nodes = sTravelNodeMap->getNodes(pos, range);
|
||||
std::vector<TravelNode*> nodes = TravelNodeMap::instance().getNodes(pos, range);
|
||||
for (auto& node : nodes)
|
||||
{
|
||||
if (!bot || pos.canPathTo(*node->getPosition(), bot))
|
||||
@@ -1233,14 +1205,14 @@ TravelNodeRoute TravelNodeMap::getRoute(TravelNode* start, TravelNode* goal, Pla
|
||||
{
|
||||
AiObjectContext* context = botAI->GetAiObjectContext();
|
||||
|
||||
TravelNode* homeNode = sTravelNodeMap->getNode(AI_VALUE(WorldPosition, "home bind"), nullptr, 10.0f);
|
||||
TravelNode* homeNode = TravelNodeMap::instance().getNode(AI_VALUE(WorldPosition, "home bind"), nullptr, 10.0f);
|
||||
if (homeNode)
|
||||
{
|
||||
PortalNode* portNode = (PortalNode*)sTravelNodeMap->teleportNodes[bot->GetGUID()][8690];
|
||||
PortalNode* portNode = (PortalNode*)TravelNodeMap::instance().teleportNodes[bot->GetGUID()][8690];
|
||||
{
|
||||
portNode = new PortalNode(start);
|
||||
|
||||
sTravelNodeMap->teleportNodes[bot->GetGUID()][8690] = portNode;
|
||||
TravelNodeMap::instance().teleportNodes[bot->GetGUID()][8690] = portNode;
|
||||
}
|
||||
|
||||
portNode->SetPortal(start, homeNode, 8690);
|
||||
@@ -1370,7 +1342,7 @@ TravelNodeRoute TravelNodeMap::getRoute(WorldPosition startPos, WorldPosition en
|
||||
WorldPosition startNodePosition = *startNode->getPosition();
|
||||
WorldPosition endNodePosition = *endNode->getPosition();
|
||||
|
||||
float maxStartDistance = startNode->isTransport() ? 20.0f : sPlayerbotAIConfig->targetPosRecalcDistance;
|
||||
float maxStartDistance = startNode->isTransport() ? 20.0f : sPlayerbotAIConfig.targetPosRecalcDistance;
|
||||
|
||||
TravelNodeRoute route = getRoute(startNode, endNode, bot);
|
||||
|
||||
@@ -1403,10 +1375,10 @@ TravelNodeRoute TravelNodeMap::getRoute(WorldPosition startPos, WorldPosition en
|
||||
if (bot && !bot->HasSpellCooldown(8690))
|
||||
{
|
||||
startPath.clear();
|
||||
TravelNode* botNode = sTravelNodeMap->teleportNodes[bot->GetGUID()][0];
|
||||
TravelNode* botNode = TravelNodeMap::instance().teleportNodes[bot->GetGUID()][0];
|
||||
{
|
||||
botNode = new TravelNode(startPos, "Bot Pos", false);
|
||||
sTravelNodeMap->teleportNodes[bot->GetGUID()][0] = botNode;
|
||||
TravelNodeMap::instance().teleportNodes[bot->GetGUID()][0] = botNode;
|
||||
}
|
||||
|
||||
botNode->setPoint(startPos);
|
||||
@@ -1440,37 +1412,37 @@ TravelPath TravelNodeMap::getFullPath(WorldPosition startPos, WorldPosition endP
|
||||
//[[Node pathfinding system]]
|
||||
// We try to find nodes near the bot and near the end position that have a route between them.
|
||||
// Then bot has to move towards/along the route.
|
||||
sTravelNodeMap->m_nMapMtx.lock_shared();
|
||||
TravelNodeMap::instance().m_nMapMtx.lock_shared();
|
||||
|
||||
// Find the route of nodes starting at a node closest to the start position and ending at a node closest to the
|
||||
// endposition. Also returns longPath: The path from the start position to the first node in the route.
|
||||
TravelNodeRoute route = sTravelNodeMap->getRoute(startPos, endPos, beginPath, bot);
|
||||
TravelNodeRoute route = TravelNodeMap::instance().getRoute(startPos, endPos, beginPath, bot);
|
||||
|
||||
if (route.isEmpty())
|
||||
return movePath;
|
||||
|
||||
if (sPlayerbotAIConfig->hasLog("bot_pathfinding.csv"))
|
||||
if (sPlayerbotAIConfig.hasLog("bot_pathfinding.csv"))
|
||||
{
|
||||
if (botAI->HasStrategy("debug move", BOT_STATE_NON_COMBAT))
|
||||
{
|
||||
sPlayerbotAIConfig->openLog("bot_pathfinding.csv", "w");
|
||||
sPlayerbotAIConfig->log("bot_pathfinding.csv", route.print().str().c_str());
|
||||
sPlayerbotAIConfig.openLog("bot_pathfinding.csv", "w");
|
||||
sPlayerbotAIConfig.log("bot_pathfinding.csv", route.print().str().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
endPath = route.getNodes().back()->getPosition()->getPathTo(endPos, nullptr);
|
||||
movePath = route.buildPath(beginPath, endPath);
|
||||
|
||||
if (sPlayerbotAIConfig->hasLog("bot_pathfinding.csv"))
|
||||
if (sPlayerbotAIConfig.hasLog("bot_pathfinding.csv"))
|
||||
{
|
||||
if (botAI->HasStrategy("debug move", BOT_STATE_NON_COMBAT))
|
||||
{
|
||||
sPlayerbotAIConfig->openLog("bot_pathfinding.csv", "w");
|
||||
sPlayerbotAIConfig->log("bot_pathfinding.csv", movePath.print().str().c_str());
|
||||
sPlayerbotAIConfig.openLog("bot_pathfinding.csv", "w");
|
||||
sPlayerbotAIConfig.log("bot_pathfinding.csv", movePath.print().str().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
sTravelNodeMap->m_nMapMtx.unlock_shared();
|
||||
TravelNodeMap::instance().m_nMapMtx.unlock_shared();
|
||||
|
||||
return movePath;
|
||||
}
|
||||
@@ -1511,7 +1483,7 @@ TravelNode* TravelNodeMap::addZoneLinkNode(TravelNode* startNode)
|
||||
if (!getNode(pos, nullptr, 100.0f))
|
||||
{
|
||||
std::string const nodeName = zoneName + " to " + newZoneName;
|
||||
return sTravelNodeMap->addNode(pos, nodeName, false, true);
|
||||
return TravelNodeMap::instance().addNode(pos, nodeName, false, true);
|
||||
}
|
||||
|
||||
zoneName = newZoneName;
|
||||
@@ -1550,7 +1522,7 @@ TravelNode* TravelNodeMap::addRandomExtNode(TravelNode* startNode)
|
||||
WorldPosition point = path[urand(0, path.size() - 1)];
|
||||
|
||||
if (!getNode(point, nullptr, 100.0f))
|
||||
return sTravelNodeMap->addNode(point, startNode->getName(), false, true);
|
||||
return TravelNodeMap::instance().addNode(point, startNode->getName(), false, true);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
@@ -1606,7 +1578,7 @@ void TravelNodeMap::manageNodes(Unit* bot, bool mapFull)
|
||||
m_nMapMtx.unlock();
|
||||
}
|
||||
|
||||
sTravelNodeMap->m_nMapMtx.lock_shared();
|
||||
TravelNodeMap::instance().m_nMapMtx.lock_shared();
|
||||
|
||||
if (!rePrint && mapFull)
|
||||
printMap();
|
||||
@@ -1643,13 +1615,13 @@ void TravelNodeMap::generateNpcNodes()
|
||||
else if (cInfo->npcflag & UNIT_NPC_FLAG_SPIRITGUIDE)
|
||||
nodeName += " spiritguide";
|
||||
|
||||
/*TravelNode* node = */ sTravelNodeMap->addNode(guidP, nodeName, true, true); //node not used, fragment marked for removal.
|
||||
/*TravelNode* node = */ TravelNodeMap::instance().addNode(guidP, nodeName, true, true); //node not used, fragment marked for removal.
|
||||
}
|
||||
else if (cInfo->rank == 3)
|
||||
{
|
||||
std::string const nodeName = cInfo->Name;
|
||||
|
||||
sTravelNodeMap->addNode(guidP, nodeName, true, true);
|
||||
TravelNodeMap::instance().addNode(guidP, nodeName, true, true);
|
||||
}
|
||||
else if (cInfo->rank == 1 && !guidP.isOverworld())
|
||||
{
|
||||
@@ -1672,7 +1644,7 @@ void TravelNodeMap::generateNpcNodes()
|
||||
|
||||
std::string const nodeName = cInfo->Name;
|
||||
|
||||
sTravelNodeMap->addNode(guidP, nodeName, true, true);
|
||||
TravelNodeMap::instance().addNode(guidP, nodeName, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1701,7 +1673,7 @@ void TravelNodeMap::generateStartNodes()
|
||||
|
||||
std::string const nodeName = startNames[i] + " start";
|
||||
|
||||
sTravelNodeMap->addNode(pos, nodeName, true, true);
|
||||
TravelNodeMap::instance().addNode(pos, nodeName, true, true);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -1733,7 +1705,7 @@ void TravelNodeMap::generateAreaTriggerNodes()
|
||||
else
|
||||
nodeName = inPos.getAreaName(false) + " portal";
|
||||
|
||||
sTravelNodeMap->addNode(inPos, nodeName, true, true);
|
||||
TravelNodeMap::instance().addNode(inPos, nodeName, true, true);
|
||||
}
|
||||
|
||||
// Exit nodes
|
||||
@@ -1759,11 +1731,11 @@ void TravelNodeMap::generateAreaTriggerNodes()
|
||||
else
|
||||
nodeName = inPos.getAreaName(false) + " portal";
|
||||
|
||||
//TravelNode* entryNode = sTravelNodeMap->getNode(outPos, nullptr, 20.0f); // Entry side, portal exit. //not used, line marked for removal.
|
||||
//TravelNode* entryNode = TravelNodeMap::instance().getNode(outPos, nullptr, 20.0f); // Entry side, portal exit. //not used, line marked for removal.
|
||||
|
||||
TravelNode* outNode = sTravelNodeMap->addNode(outPos, nodeName, true, true); // Exit size, portal exit.
|
||||
TravelNode* outNode = TravelNodeMap::instance().addNode(outPos, nodeName, true, true); // Exit size, portal exit.
|
||||
|
||||
TravelNode* inNode = sTravelNodeMap->getNode(inPos, nullptr, 5.0f); // Entry side, portal center.
|
||||
TravelNode* inNode = TravelNodeMap::instance().getNode(inPos, nullptr, 5.0f); // Entry side, portal center.
|
||||
|
||||
// Portal link from area trigger to area trigger destination.
|
||||
if (outNode && inNode)
|
||||
@@ -1826,7 +1798,7 @@ void TravelNodeMap::generateTransportNodes()
|
||||
if (pos.distance(&lPos) == 0)
|
||||
{
|
||||
TravelNode* node =
|
||||
sTravelNodeMap->addNode(pos, data->name, true, true, true, itr.first);
|
||||
TravelNodeMap::instance().addNode(pos, data->name, true, true, true, itr.first);
|
||||
|
||||
if (!prevNode)
|
||||
{
|
||||
@@ -1866,7 +1838,7 @@ void TravelNodeMap::generateTransportNodes()
|
||||
if (pos.distance(&lPos) == 0)
|
||||
{
|
||||
TravelNode* node =
|
||||
sTravelNodeMap->addNode(pos, data->name, true, true, true, itr.first);
|
||||
TravelNodeMap::instance().addNode(pos, data->name, true, true, true, itr.first);
|
||||
if (node != prevNode)
|
||||
{
|
||||
if (p.second->TimeSeg < timeStart)
|
||||
@@ -1911,7 +1883,7 @@ void TravelNodeMap::generateTransportNodes()
|
||||
|
||||
if (p->delay > 0)
|
||||
{
|
||||
TravelNode* node = sTravelNodeMap->addNode(pos, data->name, true, true, true, itr.first);
|
||||
TravelNode* node = TravelNodeMap::instance().addNode(pos, data->name, true, true, true, itr.first);
|
||||
|
||||
if (!prevNode)
|
||||
{
|
||||
@@ -1946,7 +1918,7 @@ void TravelNodeMap::generateTransportNodes()
|
||||
|
||||
if (p->delay > 0)
|
||||
{
|
||||
TravelNode* node = sTravelNodeMap->getNode(pos, nullptr, 5.0f);
|
||||
TravelNode* node = TravelNodeMap::instance().getNode(pos, nullptr, 5.0f);
|
||||
|
||||
if (node != prevNode)
|
||||
{
|
||||
@@ -1968,7 +1940,7 @@ void TravelNodeMap::generateTransportNodes()
|
||||
void TravelNodeMap::generateZoneMeanNodes()
|
||||
{
|
||||
// Zone means
|
||||
for (auto& loc : sTravelMgr->exploreLocs)
|
||||
for (auto& loc : TravelMgr::instance().exploreLocs)
|
||||
{
|
||||
std::vector<WorldPosition*> points;
|
||||
|
||||
@@ -1981,7 +1953,7 @@ void TravelNodeMap::generateZoneMeanNodes()
|
||||
|
||||
WorldPosition pos = WorldPosition(points, WP_MEAN_CENTROID);
|
||||
|
||||
/*TravelNode* node = */sTravelNodeMap->addNode(pos, pos.getAreaName(), true, true, false); //node not used, but addNode as side effect, fragment marked for removal.
|
||||
/*TravelNode* node = */TravelNodeMap::instance().addNode(pos, pos.getAreaName(), true, true, false); //node not used, but addNode as side effect, fragment marked for removal.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2006,19 +1978,19 @@ void TravelNodeMap::generateWalkPaths()
|
||||
|
||||
std::map<uint32, bool> nodeMaps;
|
||||
|
||||
for (auto& startNode : sTravelNodeMap->getNodes())
|
||||
for (auto& startNode : TravelNodeMap::instance().getNodes())
|
||||
{
|
||||
nodeMaps[startNode->getMapId()] = true;
|
||||
}
|
||||
|
||||
for (auto& map : nodeMaps)
|
||||
{
|
||||
for (auto& startNode : sTravelNodeMap->getNodes(WorldPosition(map.first, 1, 1)))
|
||||
for (auto& startNode : TravelNodeMap::instance().getNodes(WorldPosition(map.first, 1, 1)))
|
||||
{
|
||||
if (startNode->isLinked())
|
||||
continue;
|
||||
|
||||
for (auto& endNode : sTravelNodeMap->getNodes(*startNode->getPosition(), 2000.0f))
|
||||
for (auto& endNode : TravelNodeMap::instance().getNodes(*startNode->getPosition(), 2000.0f))
|
||||
{
|
||||
if (startNode == endNode)
|
||||
continue;
|
||||
@@ -2036,7 +2008,7 @@ void TravelNodeMap::generateWalkPaths()
|
||||
}
|
||||
}
|
||||
|
||||
LOG_INFO("playerbots", ">> Generated paths for {} nodes.", sTravelNodeMap->getNodes().size());
|
||||
LOG_INFO("playerbots", ">> Generated paths for {} nodes.", TravelNodeMap::instance().getNodes().size());
|
||||
}
|
||||
|
||||
void TravelNodeMap::generateTaxiPaths()
|
||||
@@ -2066,8 +2038,8 @@ void TravelNodeMap::generateTaxiPaths()
|
||||
WorldPosition startPos(startTaxiNode->map_id, startTaxiNode->x, startTaxiNode->y, startTaxiNode->z);
|
||||
WorldPosition endPos(endTaxiNode->map_id, endTaxiNode->x, endTaxiNode->y, endTaxiNode->z);
|
||||
|
||||
TravelNode* startNode = sTravelNodeMap->getNode(startPos, nullptr, 15.0f);
|
||||
TravelNode* endNode = sTravelNodeMap->getNode(endPos, nullptr, 15.0f);
|
||||
TravelNode* startNode = TravelNodeMap::instance().getNode(startPos, nullptr, 15.0f);
|
||||
TravelNode* endNode = TravelNodeMap::instance().getNode(endPos, nullptr, 15.0f);
|
||||
|
||||
if (!startNode || !endNode)
|
||||
continue;
|
||||
@@ -2090,7 +2062,7 @@ void TravelNodeMap::removeLowNodes()
|
||||
{
|
||||
std::vector<TravelNode*> goodNodes;
|
||||
std::vector<TravelNode*> remNodes;
|
||||
for (auto& node : sTravelNodeMap->getNodes())
|
||||
for (auto& node : TravelNodeMap::instance().getNodes())
|
||||
{
|
||||
if (!node->getPosition()->isOverworld())
|
||||
continue;
|
||||
@@ -2110,13 +2082,13 @@ void TravelNodeMap::removeLowNodes()
|
||||
}
|
||||
|
||||
for (auto& node : remNodes)
|
||||
sTravelNodeMap->removeNode(node);
|
||||
TravelNodeMap::instance().removeNode(node);
|
||||
}
|
||||
|
||||
void TravelNodeMap::removeUselessPaths()
|
||||
{
|
||||
// Clean up node links
|
||||
for (auto& startNode : sTravelNodeMap->getNodes())
|
||||
for (auto& startNode : TravelNodeMap::instance().getNodes())
|
||||
{
|
||||
for (auto& path : *startNode->getPaths())
|
||||
if (path.second.getComplete() && startNode->hasLinkTo(path.first))
|
||||
@@ -2127,7 +2099,7 @@ void TravelNodeMap::removeUselessPaths()
|
||||
{
|
||||
uint32 rem = 0;
|
||||
// Clean up node links
|
||||
for (auto& startNode : sTravelNodeMap->getNodes())
|
||||
for (auto& startNode : TravelNodeMap::instance().getNodes())
|
||||
{
|
||||
if (startNode->cropUselessLinks())
|
||||
rem++;
|
||||
@@ -2146,7 +2118,7 @@ void TravelNodeMap::removeUselessPaths()
|
||||
|
||||
void TravelNodeMap::calculatePathCosts()
|
||||
{
|
||||
for (auto& startNode : sTravelNodeMap->getNodes())
|
||||
for (auto& startNode : TravelNodeMap::instance().getNodes())
|
||||
{
|
||||
for (auto& path : *startNode->getLinks())
|
||||
{
|
||||
@@ -2162,7 +2134,7 @@ void TravelNodeMap::calculatePathCosts()
|
||||
}
|
||||
}
|
||||
|
||||
LOG_INFO("playerbots", ">> Calculated pathcost for {} nodes.", sTravelNodeMap->getNodes().size());
|
||||
LOG_INFO("playerbots", ">> Calculated pathcost for {} nodes.", TravelNodeMap::instance().getNodes().size());
|
||||
}
|
||||
|
||||
void TravelNodeMap::generatePaths()
|
||||
@@ -2188,7 +2160,7 @@ void TravelNodeMap::generateAll()
|
||||
calcMapOffset();
|
||||
|
||||
LOG_INFO("playerbots", "-Generating maptransfers");
|
||||
sTravelMgr->loadMapTransfers();
|
||||
TravelMgr::instance().loadMapTransfers();
|
||||
|
||||
if (hasToGen || hasToFullGen)
|
||||
{
|
||||
@@ -2201,14 +2173,14 @@ void TravelNodeMap::generateAll()
|
||||
|
||||
void TravelNodeMap::printMap()
|
||||
{
|
||||
if (!sPlayerbotAIConfig->hasLog("travelNodes.csv") && !sPlayerbotAIConfig->hasLog("travelPaths.csv"))
|
||||
if (!sPlayerbotAIConfig.hasLog("travelNodes.csv") && !sPlayerbotAIConfig.hasLog("travelPaths.csv"))
|
||||
return;
|
||||
|
||||
printf("\r [Qgis] \r\x3D");
|
||||
fflush(stdout);
|
||||
|
||||
sPlayerbotAIConfig->openLog("travelNodes.csv", "w");
|
||||
sPlayerbotAIConfig->openLog("travelPaths.csv", "w");
|
||||
sPlayerbotAIConfig.openLog("travelNodes.csv", "w");
|
||||
sPlayerbotAIConfig.openLog("travelPaths.csv", "w");
|
||||
|
||||
std::vector<TravelNode*> anodes = getNodes();
|
||||
|
||||
@@ -2224,26 +2196,26 @@ void TravelNodeMap::printNodeStore()
|
||||
{
|
||||
std::string const nodeStore = "TravelNodeStore.h";
|
||||
|
||||
if (!sPlayerbotAIConfig->hasLog(nodeStore))
|
||||
if (!sPlayerbotAIConfig.hasLog(nodeStore))
|
||||
return;
|
||||
|
||||
printf("\r [Map] \r\x3D");
|
||||
fflush(stdout);
|
||||
|
||||
sPlayerbotAIConfig->openLog(nodeStore, "w");
|
||||
sPlayerbotAIConfig.openLog(nodeStore, "w");
|
||||
|
||||
std::unordered_map<TravelNode*, uint32> saveNodes;
|
||||
|
||||
std::vector<TravelNode*> anodes = getNodes();
|
||||
|
||||
sPlayerbotAIConfig->log(nodeStore, "#pragma once");
|
||||
sPlayerbotAIConfig->log(nodeStore, "#include \"TravelMgr.h\"");
|
||||
sPlayerbotAIConfig->log(nodeStore, "class TravelNodeStore");
|
||||
sPlayerbotAIConfig->log(nodeStore, " {");
|
||||
sPlayerbotAIConfig->log(nodeStore, " public:");
|
||||
sPlayerbotAIConfig->log(nodeStore, " static void loadNodes()");
|
||||
sPlayerbotAIConfig->log(nodeStore, " {");
|
||||
sPlayerbotAIConfig->log(nodeStore, " TravelNode** nodes = new TravelNode*[%zu];", anodes.size());
|
||||
sPlayerbotAIConfig.log(nodeStore, "#pragma once");
|
||||
sPlayerbotAIConfig.log(nodeStore, "#include \"TravelMgr.h\"");
|
||||
sPlayerbotAIConfig.log(nodeStore, "class TravelNodeStore");
|
||||
sPlayerbotAIConfig.log(nodeStore, " {");
|
||||
sPlayerbotAIConfig.log(nodeStore, " public:");
|
||||
sPlayerbotAIConfig.log(nodeStore, " static void loadNodes()");
|
||||
sPlayerbotAIConfig.log(nodeStore, " {");
|
||||
sPlayerbotAIConfig.log(nodeStore, " TravelNode** nodes = new TravelNode*[%zu];", anodes.size());
|
||||
|
||||
for (uint32 i = 0; i < anodes.size(); i++)
|
||||
{
|
||||
@@ -2266,7 +2238,7 @@ void TravelNodeMap::printNodeStore()
|
||||
|
||||
/*
|
||||
out << std::fixed << std::setprecision(2) << " nodes[" << i << "] =
|
||||
sTravelNodeMap->addNode(&WorldPosition(" << node->getMapId() << "," << node->getX() << "f," << node->getY()
|
||||
TravelNodeMap::instance().addNode(&WorldPosition(" << node->getMapId() << "," << node->getX() << "f," << node->getY()
|
||||
<< "f," << node->getZ() << "f,"<< node->getO() <<"f), \""
|
||||
<< name << "\", " << (node->isImportant() ? "true" : "false") << ", true";
|
||||
if (node->isTransport())
|
||||
@@ -2274,7 +2246,7 @@ void TravelNodeMap::printNodeStore()
|
||||
|
||||
out << ");";
|
||||
*/
|
||||
sPlayerbotAIConfig->log(nodeStore, out.str().c_str());
|
||||
sPlayerbotAIConfig.log(nodeStore, out.str().c_str());
|
||||
|
||||
saveNodes.insert(std::make_pair(node, i));
|
||||
}
|
||||
@@ -2297,12 +2269,12 @@ void TravelNodeMap::printNodeStore()
|
||||
|
||||
// out << std::fixed << std::setprecision(1) << " nodes[" << i << "]->setPathTo(nodes[" <<
|
||||
// saveNodes.find(Link.first)->second << "],TravelNodePath("; out << Link.second->print() << "), true);";
|
||||
sPlayerbotAIConfig->log(nodeStore, out.str().c_str());
|
||||
sPlayerbotAIConfig.log(nodeStore, out.str().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
sPlayerbotAIConfig->log(nodeStore, " }");
|
||||
sPlayerbotAIConfig->log(nodeStore, "};");
|
||||
sPlayerbotAIConfig.log(nodeStore, " }");
|
||||
sPlayerbotAIConfig.log(nodeStore, "};");
|
||||
|
||||
printf("\r [Done] \r\x3D");
|
||||
fflush(stdout);
|
||||
@@ -2322,7 +2294,7 @@ void TravelNodeMap::saveNodeStore()
|
||||
trans->Append(PlayerbotsDatabase.GetPreparedStatement(PLAYERBOTS_DEL_TRAVELNODE_PATH));
|
||||
|
||||
std::unordered_map<TravelNode*, uint32> saveNodes;
|
||||
std::vector<TravelNode*> anodes = sTravelNodeMap->getNodes();
|
||||
std::vector<TravelNode*> anodes = TravelNodeMap::instance().getNodes();
|
||||
|
||||
for (uint32 i = 0; i < anodes.size(); i++)
|
||||
{
|
||||
|
||||
@@ -477,13 +477,11 @@ public:
|
||||
class TravelNodeMap
|
||||
{
|
||||
public:
|
||||
TravelNodeMap(){};
|
||||
TravelNodeMap(TravelNodeMap* baseMap);
|
||||
|
||||
static TravelNodeMap* instance()
|
||||
static TravelNodeMap& instance()
|
||||
{
|
||||
static TravelNodeMap instance;
|
||||
return &instance;
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
TravelNode* addNode(WorldPosition pos, std::string const preferedName = "Travel Node", bool isImportant = false,
|
||||
@@ -586,6 +584,15 @@ public:
|
||||
std::unordered_map<ObjectGuid, std::unordered_map<uint32, TravelNode*>> teleportNodes;
|
||||
|
||||
private:
|
||||
TravelNodeMap() = default;
|
||||
~TravelNodeMap() = default;
|
||||
|
||||
TravelNodeMap(const TravelNodeMap&) = delete;
|
||||
TravelNodeMap& operator=(const TravelNodeMap&) = delete;
|
||||
|
||||
TravelNodeMap(TravelNodeMap&&) = delete;
|
||||
TravelNodeMap& operator=(TravelNodeMap&&) = delete;
|
||||
|
||||
std::vector<TravelNode*> m_nodes;
|
||||
|
||||
std::vector<std::pair<uint32, WorldPosition>> mapOffsets;
|
||||
|
||||
Reference in New Issue
Block a user