void MapMgr::UnloadCell(uint32 x,uint32 y) { MapCell * c = GetCell(x,y); if(c == NULL || c->HasPlayers() || _CellActive(x,y) || !c->IsUnloadPending()) return; sLog.outDetail("Unloading Cell [%d][%d] on map %d (instance %d)...", x,y,_mapId,m_instanceID); c->Unload(); }
void MapMgr::UnloadCell(uint32 x, uint32 y) { MapCell* c = GetCell(x, y); if(c == NULL || c->HasPlayers() || _CellActive(x, y) || !c->IsUnloadPending()) return; LOG_DETAIL("Unloading Cell [%u][%u] on map %u (instance %u)...", x, y, _mapId, m_instanceID); c->Unload(); }
void MapMgr::UpdateCellActivity(uint32 x, uint32 y, int radius) { CellSpawns * sp; uint32 endX = (x + radius) <= _sizeX ? x + radius : (_sizeX-1); uint32 endY = (y + radius) <= _sizeY ? y + radius : (_sizeY-1); uint32 startX = x - radius > 0 ? x - radius : 0; uint32 startY = y - radius > 0 ? y - radius : 0; uint32 posX, posY; MapCell *objCell; for (posX = startX; posX <= endX; posX++ ) { for (posY = startY; posY <= endY; posY++ ) { objCell = GetCell(posX, posY); if (!objCell) { if (_CellActive(posX, posY)) { objCell = Create(posX, posY); objCell->Init(posX, posY, _mapId, this); sLog.outDetail("Cell [%d,%d] on map %d (instance %d) is now active.", posX, posY, this->_mapId, m_instanceID); objCell->SetActivity(true); _map->CellGoneActive(posX, posY); ASSERT(!objCell->IsLoaded()); sLog.outDetail("Loading objects for Cell [%d][%d] on map %d (instance %d)...", posX, posY, this->_mapId, m_instanceID); sp = _map->GetSpawnsList(posX, posY); if(sp) objCell->LoadObjects(sp); } } else { //Cell is now active if (_CellActive(posX, posY) && !objCell->IsActive()) { sLog.outDetail("Cell [%d,%d] on map %d (instance %d) is now active.", posX, posY, this->_mapId, m_instanceID); _map->CellGoneActive(posX, posY); objCell->SetActivity(true); if (!objCell->IsLoaded()) { sLog.outDetail("Loading objects for Cell [%d][%d] on map %d (instance %d)...", posX, posY, this->_mapId, m_instanceID); sp = _map->GetSpawnsList(posX, posY); if(sp) objCell->LoadObjects(sp); } } //Cell is no longer active else if (!_CellActive(posX, posY) && objCell->IsActive()) { sLog.outDetail("Cell [%d,%d] on map %d (instance %d) is now idle.", posX, posY, this->_mapId, m_instanceID); _map->CellGoneIdle(posX, posY); objCell->SetActivity(false); } } } } }
void MapMgr::UpdateCellActivity(uint32 x, uint32 y, uint32 radius) { CellSpawns* sp; uint32 endX = (x + radius) <= _sizeX ? x + radius : (_sizeX - 1); uint32 endY = (y + radius) <= _sizeY ? y + radius : (_sizeY - 1); uint32 startX = x > radius ? x - radius : 0; uint32 startY = y > radius ? y - radius : 0; uint32 posX, posY; MapCell* objCell; for(posX = startX; posX <= endX; posX++) { for(posY = startY; posY <= endY; posY++) { objCell = GetCell(posX, posY); if(!objCell) { if(_CellActive(posX, posY)) { objCell = Create(posX, posY); objCell->Init(posX, posY, this); LOG_DETAIL("Cell [%u,%u] on map %u (instance %u) is now active.", posX, posY, this->_mapId, m_instanceID); objCell->SetActivity(true); _map->CellGoneActive(posX, posY); _terrain->LoadTile((int32)posX / 8, (int32)posY / 8); ARCEMU_ASSERT(!objCell->IsLoaded()); LOG_DETAIL("Loading objects for Cell [%u][%u] on map %u (instance %u)...", posX, posY, this->_mapId, m_instanceID); sp = _map->GetSpawnsList(posX, posY); if(sp) objCell->LoadObjects(sp); } } else { //Cell is now active if(_CellActive(posX, posY) && !objCell->IsActive()) { LOG_DETAIL("Cell [%u,%u] on map %u (instance %u) is now active.", posX, posY, this->_mapId, m_instanceID); _map->CellGoneActive(posX, posY); _terrain->LoadTile((int32)posX / 8, (int32)posY / 8); objCell->SetActivity(true); if(!objCell->IsLoaded()) { LOG_DETAIL("Loading objects for Cell [%u][%u] on map %u (instance %u)...", posX, posY, this->_mapId, m_instanceID); sp = _map->GetSpawnsList(posX, posY); if(sp) objCell->LoadObjects(sp); } } //Cell is no longer active else if(!_CellActive(posX, posY) && objCell->IsActive()) { LOG_DETAIL("Cell [%u,%u] on map %u (instance %u) is now idle.", posX, posY, _mapId, m_instanceID); _map->CellGoneIdle(posX, posY); objCell->SetActivity(false); _terrain->UnloadTile((int32)posX / 8, (int32)posY / 8); } } } } }