Prevent crashes when getting PlayerbotMgr

This commit is contained in:
郑佩茹
2022-03-23 16:13:36 -06:00
parent bce32cc0e8
commit cb63f59823

View File

@@ -1023,6 +1023,10 @@ void PlayerbotMgr::CheckTellErrors(uint32 elapsed)
void PlayerbotsMgr::AddPlayerbotData(Player* player, bool isBotAI)
{
if (!player)
{
return;
}
if (!isBotAI)
{
PlayerbotMgr* playerbotMgr = new PlayerbotMgr(player);
@@ -1048,6 +1052,10 @@ void PlayerbotsMgr::RemovePlayerBotData(ObjectGuid const& guid)
PlayerbotAI* PlayerbotsMgr::GetPlayerbotAI(Player* player)
{
if (!player)
{
return nullptr;
}
auto itr = _playerbotsMap.find(player->GetGUID());
if (itr != _playerbotsMap.end())
{
@@ -1060,6 +1068,10 @@ PlayerbotAI* PlayerbotsMgr::GetPlayerbotAI(Player* player)
PlayerbotMgr* PlayerbotsMgr::GetPlayerbotMgr(Player* player)
{
if (!player)
{
return nullptr;
}
auto itr = _playerbotsMap.find(player->GetGUID());
if (itr != _playerbotsMap.end())
{