Skip to content

Commit

Permalink
disable map optimizations for playerbots if sPlayerbotAIConfig.disabl…
Browse files Browse the repository at this point in the history
…eBotOptimizations (default off - optimizations enabled) to allow full activity at all times
  • Loading branch information
Redbu11 authored and killerwife committed Jul 31, 2024
1 parent 3055652 commit dd034ee
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/game/Maps/Map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,14 @@ void Map::Update(const uint32& t_diff)
plr->Update(t_diff);

#ifdef ENABLE_PLAYERBOTS
plr->UpdateAI(t_diff, !shouldUpdateBot);
if (sPlayerbotAIConfig.disableBotOptimizations)
{
plr->UpdateAI(t_diff, false);
}
else
{
plr->UpdateAI(t_diff, !shouldUpdateBot);
}
#endif
}
}
Expand All @@ -869,7 +876,7 @@ void Map::Update(const uint32& t_diff)

#ifdef ENABLE_PLAYERBOTS
// For non-players only load the grid
if (!player->isRealPlayer())
if (!sPlayerbotAIConfig.disableBotOptimizations && !player->isRealPlayer())
{
CellPair center = MaNGOS::ComputeCellPair(player->GetPositionX(), player->GetPositionY()).normalize();
uint32 cell_id = (center.y_coord * TOTAL_NUMBER_OF_CELLS_PER_MAP) + center.x_coord;
Expand Down Expand Up @@ -926,7 +933,7 @@ void Map::Update(const uint32& t_diff)

#ifdef ENABLE_PLAYERBOTS
// Skip objects on locations away from real players if world is laggy
if (IsContinent() && avgDiff > 100)
if (!sPlayerbotAIConfig.disableBotOptimizations && IsContinent() && avgDiff > 100)
{
const bool isInActiveZone = IsContinent() ? HasActiveZone(obj->GetZoneId()) : HasRealPlayers();
if (!isInActiveZone && !shouldUpdateObjects)
Expand Down Expand Up @@ -1090,7 +1097,7 @@ void Map::Remove(T* obj, bool remove)
obj->SaveRespawnTime(); // requires map not being reset

obj->ResetMap();

if (remove) // Note: In case resurrectable corpse and pet its removed from global lists in own destructor
delete obj;
}
Expand Down Expand Up @@ -1313,7 +1320,7 @@ void Map::UpdateObjectVisibility(WorldObject* obj, Cell cell, const CellPair& ce
if (Player* player = GetPlayer(guid))
{
#ifdef ENABLE_PLAYERBOTS
if (player->isRealPlayer())
if (sPlayerbotAIConfig.disableBotOptimizations || player->isRealPlayer())
#endif
player->UpdateVisibilityOf(player->GetCamera().GetBody(), obj);
}
Expand Down

0 comments on commit dd034ee

Please sign in to comment.