void MapMgr::SendChatMessageToCellPlayers(Object * obj, WorldPacket * packet, uint32 cell_radius, uint32 langpos, int32 lang, WorldSession * originator) { uint32 cellX = GetPosX(obj->GetPositionX()); uint32 cellY = GetPosY(obj->GetPositionY()); uint32 endX = ((cellX+cell_radius) <= _sizeX) ? cellX + cell_radius : (_sizeX-1); uint32 endY = ((cellY+cell_radius) <= _sizeY) ? cellY + cell_radius : (_sizeY-1); uint32 startX = (cellX-cell_radius) > 0 ? cellX - cell_radius : 0; uint32 startY = (cellY-cell_radius) > 0 ? cellY - cell_radius : 0; uint32 posX, posY; MapCell *cell; MapCell::ObjectSet::iterator iter, iend; for (posX = startX; posX <= endX; ++posX ) { for (posY = startY; posY <= endY; ++posY ) { cell = GetCell(posX, posY); if (cell && cell->HasPlayers() ) { iter = cell->Begin(); iend = cell->End(); for(; iter != iend; ++iter) { if((*iter)->IsPlayer()) { //static_cast< Player* >(*iter)->GetSession()->SendPacket(packet); static_cast< Player* >(*iter)->GetSession()->SendChatPacket(packet, langpos, lang, originator); } } } } } }
bool MapMgr::_CellActive(uint32 x, uint32 y) { uint32 endX = ((x+1) <= _sizeX) ? x + 1 : (_sizeX-1); uint32 endY = ((y+1) <= _sizeY) ? y + 1 : (_sizeY-1); uint32 startX = x > 0 ? x - 1 : 0; uint32 startY = y > 0 ? y - 1 : 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 (objCell->HasPlayers()) { return true; } } } } return false; }
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(); }