diff --git a/conf/playerbots.conf.dist b/conf/playerbots.conf.dist index d10f0348..5f0e64d3 100644 --- a/conf/playerbots.conf.dist +++ b/conf/playerbots.conf.dist @@ -125,12 +125,12 @@ AiPlayerbot.BotAutologin = 0 # Default: 0 (disabled) AiPlayerbot.AllowPlayerBots = 0 -# Bots will be summoned to player when accept group invitation -AiPlayerbot.SummonWhenGroup = 1 - # Allow/deny bots from your guild AiPlayerbot.AllowGuildBots = 1 +# Bots will be summoned to player when accept group invitation +AiPlayerbot.SummonWhenGroup = 1 + # Added following config # Selfbot permission level (0 = disabled, 1 = gm only (default), 2 = all players, 3 = activate on login) AiPlayerbot.SelfBotLevel = 1 @@ -541,7 +541,7 @@ AiPlayerbot.EquipmentPersistence = 0 # default: 80 AiPlayerbot.EquipmentPersistenceLevel = 80 -# Bot automatically upgrade equipments on levelup +# Randombots automatically upgrade equipments on levelup # Default: 1 (enabled) AiPlayerbot.AutoUpgradeEquip = 1 @@ -578,15 +578,15 @@ AiPlayerbot.RandomBotQuestItems = "6948,5175,5176,5177,5178,16309,12382,13704,11 # # -# Bots automatically learn classquest reward spells on levelup +# Randombots automatically learn classquest reward spells on levelup # Default: 0 (disabled) AiPlayerbot.AutoLearnQuestSpells = 0 -# Bots automatically learn trainable spells on levelup +# Randombots automatically learn trainable spells on levelup # Default: 1 (enabled) AiPlayerbot.AutoLearnTrainerSpells = 1 -# Bot automatically picks talent points on levelup +# Randombots automatically picks talent points on levelup # Default: 1 (enabled) AiPlayerbot.AutoPickTalents = 1 @@ -635,7 +635,6 @@ AiPlayerbot.RandomBotTeleLowerLevel = 3 AiPlayerbot.RandomBotTeleHigherLevel = 1 # Bots automatically teleport to another place for leveling on levelup -# Only for random bots # Default: 1 (enabled) AiPlayerbot.AutoTeleportForLevel = 1 diff --git a/src/PlayerbotAI.cpp b/src/PlayerbotAI.cpp index 71235156..2210b263 100644 --- a/src/PlayerbotAI.cpp +++ b/src/PlayerbotAI.cpp @@ -191,7 +191,7 @@ PlayerbotAI::~PlayerbotAI() delete aiObjectContext; if (bot) - sPlayerbotsMgr->RemovePlayerBotData(bot->GetGUID()); + sPlayerbotsMgr->RemovePlayerBotData(bot->GetGUID(), true); } void PlayerbotAI::UpdateAI(uint32 elapsed, bool minimal) diff --git a/src/PlayerbotMgr.cpp b/src/PlayerbotMgr.cpp index 2429e369..3a36dbd8 100644 --- a/src/PlayerbotMgr.cpp +++ b/src/PlayerbotMgr.cpp @@ -1214,7 +1214,7 @@ PlayerbotMgr::PlayerbotMgr(Player* const master) : PlayerbotHolder(), master(ma PlayerbotMgr::~PlayerbotMgr() { if (master) - sPlayerbotsMgr->RemovePlayerBotData(master->GetGUID()); + sPlayerbotsMgr->RemovePlayerBotData(master->GetGUID(), false); } void PlayerbotMgr::UpdateAIInternal(uint32 elapsed, bool /*minimal*/) @@ -1427,31 +1427,44 @@ void PlayerbotsMgr::AddPlayerbotData(Player* player, bool isBotAI) return; } // If the guid already exists in the map, remove it - std::unordered_map::iterator itr = _playerbotsMap.find(player->GetGUID()); - if (itr != _playerbotsMap.end()) + std::unordered_map::iterator itr = _playerbotsAIMap.find(player->GetGUID()); + if (itr != _playerbotsAIMap.end()) { - _playerbotsMap.erase(itr); + _playerbotsAIMap.erase(itr); + } + itr = _playerbotsMgrMap.find(player->GetGUID()); + if (itr != _playerbotsMgrMap.end()) + { + _playerbotsMgrMap.erase(itr); } if (!isBotAI) { PlayerbotMgr* playerbotMgr = new PlayerbotMgr(player); - ASSERT(_playerbotsMap.emplace(player->GetGUID(), playerbotMgr).second); + ASSERT(_playerbotsAIMap.emplace(player->GetGUID(), playerbotMgr).second); playerbotMgr->OnPlayerLogin(player); } else { PlayerbotAI* botAI = new PlayerbotAI(player); - ASSERT(_playerbotsMap.emplace(player->GetGUID(), botAI).second); + ASSERT(_playerbotsMgrMap.emplace(player->GetGUID(), botAI).second); } } -void PlayerbotsMgr::RemovePlayerBotData(ObjectGuid const& guid) +void PlayerbotsMgr::RemovePlayerBotData(ObjectGuid const& guid, bool is_AI) { - std::unordered_map::iterator itr = _playerbotsMap.find(guid); - if (itr != _playerbotsMap.end()) - { - _playerbotsMap.erase(itr); + if (is_AI) { + std::unordered_map::iterator itr = _playerbotsAIMap.find(guid); + if (itr != _playerbotsAIMap.end()) + { + _playerbotsAIMap.erase(itr); + } + } else { + std::unordered_map::iterator itr = _playerbotsMgrMap.find(guid); + if (itr != _playerbotsMgrMap.end()) + { + _playerbotsMgrMap.erase(itr); + } } } @@ -1464,8 +1477,8 @@ PlayerbotAI* PlayerbotsMgr::GetPlayerbotAI(Player* player) // if (player->GetSession()->isLogingOut() || player->IsDuringRemoveFromWorld()) { // return nullptr; // } - auto itr = _playerbotsMap.find(player->GetGUID()); - if (itr != _playerbotsMap.end()) + auto itr = _playerbotsAIMap.find(player->GetGUID()); + if (itr != _playerbotsAIMap.end()) { if (itr->second->IsBotAI()) return reinterpret_cast(itr->second); @@ -1480,8 +1493,8 @@ PlayerbotMgr* PlayerbotsMgr::GetPlayerbotMgr(Player* player) { return nullptr; } - auto itr = _playerbotsMap.find(player->GetGUID()); - if (itr != _playerbotsMap.end()) + auto itr = _playerbotsMgrMap.find(player->GetGUID()); + if (itr != _playerbotsMgrMap.end()) { if (!itr->second->IsBotAI()) return reinterpret_cast(itr->second); diff --git a/src/PlayerbotMgr.h b/src/PlayerbotMgr.h index d430d414..c8297c0a 100644 --- a/src/PlayerbotMgr.h +++ b/src/PlayerbotMgr.h @@ -99,13 +99,14 @@ class PlayerbotsMgr } void AddPlayerbotData(Player* player, bool isBotAI); - void RemovePlayerBotData(ObjectGuid const& guid); + void RemovePlayerBotData(ObjectGuid const& guid, bool is_AI); PlayerbotAI* GetPlayerbotAI(Player* player); PlayerbotMgr* GetPlayerbotMgr(Player* player); private: - std::unordered_map _playerbotsMap; + std::unordered_map _playerbotsAIMap; + std::unordered_map _playerbotsMgrMap; }; #define sPlayerbotsMgr PlayerbotsMgr::instance()