void IdleState::Update(Map &m, NGridType &grid, GridInfo &, const uint32) const { m.ResetGridExpiry(grid); grid.SetGridState(GRID_STATE_REMOVAL); sLog.outDebug("Grid[%u, %u] on map %u moved to REMOVAL state", grid.getX(), grid.getY(), m.GetId()); }
void Map::Update(const uint32 &t_diff) { return; for (GridRefManager<NGridType>::iterator i = GridRefManager<NGridType>::begin(); i != GridRefManager<NGridType>::end(); ) { NGridType *grid = i->getSource(); GridInfo *info = i->getSource()->getGridInfoRef(); ++i; // The update might delete the map and we need the next map before the iterator gets invalid assert(grid->GetGridState() >= 0 && grid->GetGridState() < MAX_GRID_STATE); si_GridStates[grid->GetGridState()]->Update(*this, *grid, *info, grid->getX(), grid->getY(), t_diff); } }
void ActiveState::Update(Map &m, NGridType &grid, GridInfo & info, const uint32 t_diff) const { // Only check grid activity every (grid_expiry/10) ms, because it's really useless to do it every cycle info.UpdateTimeTracker(t_diff); if (info.getTimeTracker().Passed()) { if (!grid.GetWorldObjectCountInNGrid<Player>() && !m.ActiveObjectsNearGrid(grid)) { ObjectGridStoper worker; TypeContainerVisitor<ObjectGridStoper, GridTypeMapContainer> visitor(worker); grid.VisitAllGrids(visitor); grid.SetGridState(GRID_STATE_IDLE); sLog.outDebug("Grid[%u, %u] on map %u moved to IDLE state", grid.getX(), grid.getY(), m.GetId()); } else m.ResetGridExpiry(grid, 0.1f); } }
void RemovalState::Update(Map &m, NGridType &grid, GridInfo &info, const uint32 t_diff) const { if (!info.getUnloadLock()) { info.UpdateTimeTracker(t_diff); if (info.getTimeTracker().Passed()) { if (!m.UnloadGrid(grid, false)) { sLog->outDebug(LOG_FILTER_MAPS, "Grid[%u, %u] for map %u differed unloading due to players or active objects nearby", grid.getX(), grid.getY(), m.GetId()); m.ResetGridExpiry(grid); } } } }
void RemovalState::Update(Map& map, NGridType& grid, GridInfo& info, uint32 diff) const { if (!info.getUnloadLock()) { info.UpdateTimeTracker(diff); if (info.getTimeTracker().Passed() && !map.UnloadGrid(grid, false)) { TC_LOG_DEBUG("maps", "Grid[%u, %u] for map %u differed unloading due to players or active objects nearby", grid.getX(), grid.getY(), map.GetId()); map.ResetGridExpiry(grid); } } }
void IdleState::Update(Map& map, NGridType& grid, GridInfo&, uint32) const { map.ResetGridExpiry(grid); grid.SetGridState(GRID_STATE_REMOVAL); TC_LOG_DEBUG("maps", "Grid[%u, %u] on map %u moved to REMOVAL state", grid.getX(), grid.getY(), map.GetId()); }