@@ -1004,6 +1004,16 @@ void RandomPlayerbotMgr::OnPlayerLogout(Player* player)
10041004 {
10051005 players.erase (i);
10061006 }
1007+
1008+ uint32 zone = player->GetZoneId ();
1009+ std::unordered_map<uint32, uint32>::iterator zi = m_playerZoneCounts.find (zone);
1010+ if (zi != m_playerZoneCounts.end ())
1011+ {
1012+ if (zi->second <= 1 )
1013+ m_playerZoneCounts.erase (zi);
1014+ else
1015+ zi->second --;
1016+ }
10071017 }
10081018}
10091019
@@ -1042,7 +1052,35 @@ void RandomPlayerbotMgr::OnPlayerLogin(Player* player)
10421052 {
10431053 players.push_back (player);
10441054 sLog .outDebug (" Including non-random bot player %s into random bot update" , player->GetName ());
1055+ m_playerZoneCounts[player->GetZoneId ()]++;
1056+ }
1057+ }
1058+
1059+ void RandomPlayerbotMgr::OnPlayerZoneChange (Player* player, uint32 newZone)
1060+ {
1061+ if (player->GetPlayerbotAI ())
1062+ return ;
1063+
1064+ uint32 oldZone = player->GetCachedZoneId ();
1065+ if (oldZone == newZone)
1066+ return ;
1067+
1068+ std::unordered_map<uint32, uint32>::iterator zi = m_playerZoneCounts.find (oldZone);
1069+ if (zi != m_playerZoneCounts.end ())
1070+ {
1071+ if (zi->second <= 1 )
1072+ m_playerZoneCounts.erase (zi);
1073+ else
1074+ zi->second --;
10451075 }
1076+
1077+ m_playerZoneCounts[newZone]++;
1078+ }
1079+
1080+ bool RandomPlayerbotMgr::HasRealPlayerInZone (uint32 zoneId) const
1081+ {
1082+ std::unordered_map<uint32, uint32>::const_iterator zi = m_playerZoneCounts.find (zoneId);
1083+ return zi != m_playerZoneCounts.end () && zi->second > 0 ;
10461084}
10471085
10481086Player* RandomPlayerbotMgr::GetRandomPlayer ()
0 commit comments