diff options
Diffstat (limited to 'src/server/game/Maps/Map.cpp')
-rw-r--r-- | src/server/game/Maps/Map.cpp | 601 |
1 files changed, 302 insertions, 299 deletions
diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index 520cedef23..9e62efba69 100644 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -34,11 +34,11 @@ union u_map_magic uint32 asUInt; }; -u_map_magic MapMagic = { {'M','A','P','S'} }; -u_map_magic MapVersionMagic = { {'v','1','.','8'} }; -u_map_magic MapAreaMagic = { {'A','R','E','A'} }; -u_map_magic MapHeightMagic = { {'M','H','G','T'} }; -u_map_magic MapLiquidMagic = { {'M','L','I','Q'} }; +u_map_magic MapMagic = { {'M', 'A', 'P', 'S'} }; +u_map_magic MapVersionMagic = { {'v', '1', '.', '8'} }; +u_map_magic MapAreaMagic = { {'A', 'R', 'E', 'A'} }; +u_map_magic MapHeightMagic = { {'M', 'H', 'G', 'T'} }; +u_map_magic MapLiquidMagic = { {'M', 'L', 'I', 'Q'} }; Map::~Map() { @@ -64,12 +64,12 @@ Map::~Map() bool Map::ExistMap(uint32 mapid, int gx, int gy) { - int len = sWorld->GetDataPath().length()+strlen("maps/%03u%02u%02u.map")+1; + int len = sWorld->GetDataPath().length() + strlen("maps/%03u%02u%02u.map") + 1; char* tmp = new char[len]; - snprintf(tmp, len, (char *)(sWorld->GetDataPath()+"maps/%03u%02u%02u.map").c_str(), mapid, gx, gy); + snprintf(tmp, len, (char*)(sWorld->GetDataPath() + "maps/%03u%02u%02u.map").c_str(), mapid, gx, gy); bool ret = false; - FILE* pf=fopen(tmp, "rb"); + FILE* pf = fopen(tmp, "rb"); if (!pf) sLog->outError("Map file '%s': does not exist!", tmp); @@ -95,11 +95,11 @@ bool Map::ExistVMap(uint32 mapid, int gx, int gy) { if (vmgr->isMapLoadingEnabled()) { - bool exists = vmgr->existsMap((sWorld->GetDataPath()+ "vmaps").c_str(), mapid, gx, gy); + bool exists = vmgr->existsMap((sWorld->GetDataPath() + "vmaps").c_str(), mapid, gx, gy); if (!exists) { std::string name = vmgr->getDirFileName(mapid, gx, gy); - sLog->outError("VMap file '%s' is missing or points to wrong version of vmap file. Redo vmaps with latest version of vmap_assembler.exe.", (sWorld->GetDataPath()+"vmaps/"+name).c_str()); + sLog->outError("VMap file '%s' is missing or points to wrong version of vmap file. Redo vmaps with latest version of vmap_assembler.exe.", (sWorld->GetDataPath() + "vmaps/" + name).c_str()); return false; } } @@ -109,7 +109,7 @@ bool Map::ExistVMap(uint32 mapid, int gx, int gy) } void Map::LoadMMap(int gx, int gy) -{ +{ if (!MMAP::MMapFactory::IsPathfindingEnabled(this)) // pussywizard return; @@ -135,9 +135,9 @@ void Map::LoadMMap(int gx, int gy) } void Map::LoadVMap(int gx, int gy) -{ - // x and y are swapped !! - int vmapLoadResult = VMAP::VMapFactory::createOrGetVMapManager()->loadMap((sWorld->GetDataPath()+ "vmaps").c_str(), GetId(), gx, gy); +{ + // x and y are swapped !! + int vmapLoadResult = VMAP::VMapFactory::createOrGetVMapManager()->loadMap((sWorld->GetDataPath() + "vmaps").c_str(), GetId(), gx, gy); switch (vmapLoadResult) { case VMAP::VMAP_LOAD_RESULT_OK: @@ -159,14 +159,14 @@ void Map::LoadVMap(int gx, int gy) } void Map::LoadMap(int gx, int gy, bool reload) -{ +{ if (i_InstanceId != 0) { if (GridMaps[gx][gy]) return; // load grid map for base map - m_parentMap->EnsureGridCreated(GridCoord(63-gx, 63-gy)); + m_parentMap->EnsureGridCreated(GridCoord(63 - gx, 63 - gy)); GridMaps[gx][gy] = m_parentMap->GridMaps[gx][gy]; return; @@ -184,14 +184,14 @@ void Map::LoadMap(int gx, int gy, bool reload) sScriptMgr->OnUnloadGridMap(this, GridMaps[gx][gy], gx, gy); delete (GridMaps[gx][gy]); - GridMaps[gx][gy]=NULL; + GridMaps[gx][gy] = NULL; } // map file name - char *tmp=NULL; - int len = sWorld->GetDataPath().length()+strlen("maps/%03u%02u%02u.map")+1; + char* tmp = NULL; + int len = sWorld->GetDataPath().length() + strlen("maps/%03u%02u%02u.map") + 1; tmp = new char[len]; - snprintf(tmp, len, (char *)(sWorld->GetDataPath()+"maps/%03u%02u%02u.map").c_str(), GetId(), gx, gy); + snprintf(tmp, len, (char*)(sWorld->GetDataPath() + "maps/%03u%02u%02u.map").c_str(), GetId(), gx, gy); #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) sLog->outDetail("Loading map %s", tmp); #endif @@ -207,7 +207,7 @@ void Map::LoadMap(int gx, int gy, bool reload) } void Map::LoadMapAndVMap(int gx, int gy) -{ +{ LoadMap(gx, gy); if (i_InstanceId == 0) { @@ -216,19 +216,19 @@ void Map::LoadMapAndVMap(int gx, int gy) } } -Map::Map(uint32 id, uint32 InstanceId, uint8 SpawnMode, Map* _parent) : -i_mapEntry(sMapStore.LookupEntry(id)), i_spawnMode(SpawnMode), i_InstanceId(InstanceId), -m_unloadTimer(0), m_VisibleDistance(DEFAULT_VISIBILITY_DISTANCE), -_instanceResetPeriod(0), m_activeNonPlayersIter(m_activeNonPlayers.end()), -_transportsUpdateIter(_transports.end()), i_scriptLock(false), _defaultLight(GetDefaultMapLight(id)) +Map::Map(uint32 id, uint32 InstanceId, uint8 SpawnMode, Map* _parent) : + i_mapEntry(sMapStore.LookupEntry(id)), i_spawnMode(SpawnMode), i_InstanceId(InstanceId), + m_unloadTimer(0), m_VisibleDistance(DEFAULT_VISIBILITY_DISTANCE), + _instanceResetPeriod(0), m_activeNonPlayersIter(m_activeNonPlayers.end()), + _transportsUpdateIter(_transports.end()), i_scriptLock(false), _defaultLight(GetDefaultMapLight(id)) { m_parentMap = (_parent ? _parent : this); - for (unsigned int idx=0; idx < MAX_NUMBER_OF_GRIDS; ++idx) + for (unsigned int idx = 0; idx < MAX_NUMBER_OF_GRIDS; ++idx) { - for (unsigned int j=0; j < MAX_NUMBER_OF_GRIDS; ++j) + for (unsigned int j = 0; j < MAX_NUMBER_OF_GRIDS; ++j) { //z code - GridMaps[idx][j] =NULL; + GridMaps[idx][j] = NULL; setNGrid(nullptr, idx, j); } } @@ -240,7 +240,7 @@ _transportsUpdateIter(_transports.end()), i_scriptLock(false), _defaultLight(Get } void Map::InitVisibilityDistance() -{ +{ //init visibility for continents m_VisibleDistance = World::GetMaxVisibleDistanceOnContinents(); @@ -258,7 +258,7 @@ void Map::InitVisibilityDistance() // Template specialization of utility methods template<class T> void Map::AddToGrid(T* obj, Cell const& cell) -{ +{ NGridType* grid = getNGrid(cell.GridX(), cell.GridY()); if (obj->IsWorldObject()) grid->GetGridType(cell.CellX(), cell.CellY()).template AddWorldObject<T>(obj); @@ -268,7 +268,7 @@ void Map::AddToGrid(T* obj, Cell const& cell) template<> void Map::AddToGrid(Creature* obj, Cell const& cell) -{ +{ NGridType* grid = getNGrid(cell.GridX(), cell.GridY()); if (obj->IsWorldObject()) grid->GetGridType(cell.CellX(), cell.CellY()).AddWorldObject(obj); @@ -280,7 +280,7 @@ void Map::AddToGrid(Creature* obj, Cell const& cell) template<> void Map::AddToGrid(GameObject* obj, Cell const& cell) -{ +{ NGridType* grid = getNGrid(cell.GridX(), cell.GridY()); grid->GetGridType(cell.CellX(), cell.CellY()).AddGridObject(obj); @@ -289,7 +289,7 @@ void Map::AddToGrid(GameObject* obj, Cell const& cell) template<> void Map::AddToGrid(DynamicObject* obj, Cell const& cell) -{ +{ NGridType* grid = getNGrid(cell.GridX(), cell.GridY()); if (obj->IsWorldObject()) grid->GetGridType(cell.CellX(), cell.CellY()).AddWorldObject(obj); @@ -301,12 +301,12 @@ void Map::AddToGrid(DynamicObject* obj, Cell const& cell) template<class T> void Map::SwitchGridContainers(T* /*obj*/, bool /*on*/) -{ +{ } template<> void Map::SwitchGridContainers(Creature* obj, bool on) -{ +{ ASSERT(!obj->IsPermanentWorldObject()); CellCoord p = acore::ComputeCellCoord(obj->GetPositionX(), obj->GetPositionY()); if (!p.IsCoordValid()) @@ -322,10 +322,10 @@ void Map::SwitchGridContainers(Creature* obj, bool on) #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) sLog->outStaticDebug("Switch object " UI64FMTD " from grid[%u, %u] %u", obj->GetGUID(), cell.data.Part.grid_x, cell.data.Part.grid_y, on); #endif - NGridType *ngrid = getNGrid(cell.GridX(), cell.GridY()); + NGridType* ngrid = getNGrid(cell.GridX(), cell.GridY()); ASSERT(ngrid != nullptr); - GridType &grid = ngrid->GetGridType(cell.CellX(), cell.CellY()); + GridType& grid = ngrid->GetGridType(cell.CellX(), cell.CellY()); obj->RemoveFromGrid(); //This step is not really necessary but we want to do ASSERT in remove/add @@ -345,7 +345,7 @@ void Map::SwitchGridContainers(Creature* obj, bool on) template<> void Map::SwitchGridContainers(GameObject* obj, bool on) -{ +{ ASSERT(!obj->IsPermanentWorldObject()); CellCoord p = acore::ComputeCellCoord(obj->GetPositionX(), obj->GetPositionY()); if (!p.IsCoordValid()) @@ -359,10 +359,10 @@ void Map::SwitchGridContainers(GameObject* obj, bool on) return; //TC_LOG_DEBUG(LOG_FILTER_MAPS, "Switch object " UI64FMTD " from grid[%u, %u] %u", obj->GetGUID(), cell.data.Part.grid_x, cell.data.Part.grid_y, on); - NGridType *ngrid = getNGrid(cell.GridX(), cell.GridY()); + NGridType* ngrid = getNGrid(cell.GridX(), cell.GridY()); ASSERT(ngrid != nullptr); - GridType &grid = ngrid->GetGridType(cell.CellX(), cell.CellY()); + GridType& grid = ngrid->GetGridType(cell.CellX(), cell.CellY()); obj->RemoveFromGrid(); //This step is not really necessary but we want to do ASSERT in remove/add @@ -380,14 +380,14 @@ void Map::SwitchGridContainers(GameObject* obj, bool on) template<class T> void Map::DeleteFromWorld(T* obj) -{ +{ // Note: In case resurrectable corpse and pet its removed from global lists in own destructor delete obj; } template<> void Map::DeleteFromWorld(Player* player) -{ +{ sObjectAccessor->RemoveObject(player); // pussywizard: optimization @@ -400,8 +400,8 @@ void Map::DeleteFromWorld(Player* player) } -void Map::EnsureGridCreated(const GridCoord &p) -{ +void Map::EnsureGridCreated(const GridCoord& p) +{ if (getNGrid(p.x_coord, p.y_coord)) // pussywizard return; ACORE_GUARD(ACE_Thread_Mutex, GridLock); @@ -410,13 +410,13 @@ void Map::EnsureGridCreated(const GridCoord &p) //Create NGrid so the object can be added to it //But object data is not loaded here -void Map::EnsureGridCreated_i(const GridCoord &p) -{ +void Map::EnsureGridCreated_i(const GridCoord& p) +{ if (!getNGrid(p.x_coord, p.y_coord)) { // pussywizard: moved setNGrid to the end of the function - NGridType* ngt = new NGridType(p.x_coord*MAX_NUMBER_OF_GRIDS + p.y_coord, p.x_coord, p.y_coord); - + NGridType* ngt = new NGridType(p.x_coord * MAX_NUMBER_OF_GRIDS + p.y_coord, p.x_coord, p.y_coord); + // build a linkage between this map and NGridType buildNGridLinkage(ngt); // pussywizard: getNGrid(x, y) changed to: ngt @@ -435,16 +435,16 @@ void Map::EnsureGridCreated_i(const GridCoord &p) } //Create NGrid and load the object data in it -bool Map::EnsureGridLoaded(const Cell &cell) -{ +bool Map::EnsureGridLoaded(const Cell& cell) +{ EnsureGridCreated(GridCoord(cell.GridX(), cell.GridY())); - NGridType *grid = getNGrid(cell.GridX(), cell.GridY()); + NGridType* grid = getNGrid(cell.GridX(), cell.GridY()); ASSERT(grid != nullptr); if (!isGridObjectDataLoaded(cell.GridX(), cell.GridY())) { - //if (!isGridObjectDataLoaded(cell.GridX(), cell.GridY())) - //{ + //if (!isGridObjectDataLoaded(cell.GridX(), cell.GridY())) + //{ #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) sLog->outDebug(LOG_FILTER_MAPS, "Loading grid[%u, %u] for map %u instance %u", cell.GridX(), cell.GridY(), GetId(), i_InstanceId); #endif @@ -458,14 +458,14 @@ bool Map::EnsureGridLoaded(const Cell &cell) sObjectAccessor->AddCorpsesToGrid(GridCoord(cell.GridX(), cell.GridY()), grid->GetGridType(cell.CellX(), cell.CellY()), this); Balance(); return true; - //} + //} } return false; } void Map::LoadGrid(float x, float y) -{ +{ EnsureGridLoaded(Cell(x, y)); } @@ -477,7 +477,7 @@ void Map::LoadAllCells() } bool Map::AddPlayerToMap(Player* player) -{ +{ CellCoord cellCoord = acore::ComputeCellCoord(player->GetPositionX(), player->GetPositionY()); if (!cellCoord.IsCoordValid()) { @@ -507,24 +507,24 @@ bool Map::AddPlayerToMap(Player* player) template<class T> void Map::InitializeObject(T* /*obj*/) -{ +{ } template<> void Map::InitializeObject(Creature* /*obj*/) -{ +{ //obj->_moveState = MAP_OBJECT_CELL_MOVE_NONE; // pussywizard: this is shit } template<> void Map::InitializeObject(GameObject* /*obj*/) -{ +{ //obj->_moveState = MAP_OBJECT_CELL_MOVE_NONE; // pussywizard: this is shit } template<class T> bool Map::AddToMap(T* obj, bool checkTransport) -{ +{ //TODO: Needs clean up. An object should not be added to map twice. if (obj->IsInWorld()) { @@ -580,7 +580,7 @@ bool Map::AddToMap(T* obj, bool checkTransport) template<> bool Map::AddToMap(MotionTransport* obj, bool /*checkTransport*/) -{ +{ //TODO: Needs clean up. An object should not be added to map twice. if (obj->IsInWorld()) return true; @@ -622,16 +622,16 @@ bool Map::AddToMap(MotionTransport* obj, bool /*checkTransport*/) return true; } -bool Map::IsGridLoaded(const GridCoord &p) const -{ +bool Map::IsGridLoaded(const GridCoord& p) const +{ return (getNGrid(p.x_coord, p.y_coord) && isGridObjectDataLoaded(p.x_coord, p.y_coord)); } -void Map::VisitNearbyCellsOfPlayer(Player* player, TypeContainerVisitor<acore::ObjectUpdater, GridTypeMapContainer> &gridVisitor, - TypeContainerVisitor<acore::ObjectUpdater, WorldTypeMapContainer> &worldVisitor, - TypeContainerVisitor<acore::ObjectUpdater, GridTypeMapContainer> &largeGridVisitor, - TypeContainerVisitor<acore::ObjectUpdater, WorldTypeMapContainer> &largeWorldVisitor) +void Map::VisitNearbyCellsOfPlayer(Player* player, TypeContainerVisitor<acore::ObjectUpdater, GridTypeMapContainer>& gridVisitor, + TypeContainerVisitor<acore::ObjectUpdater, WorldTypeMapContainer>& worldVisitor, + TypeContainerVisitor<acore::ObjectUpdater, GridTypeMapContainer>& largeGridVisitor, + TypeContainerVisitor<acore::ObjectUpdater, WorldTypeMapContainer>& largeWorldVisitor) { // check for valid position if (!player->IsPositionValid()) @@ -663,11 +663,11 @@ void Map::VisitNearbyCellsOfPlayer(Player* player, TypeContainerVisitor<acore::O } } -void Map::VisitNearbyCellsOf(WorldObject* obj, TypeContainerVisitor<acore::ObjectUpdater, GridTypeMapContainer> &gridVisitor, - TypeContainerVisitor<acore::ObjectUpdater, WorldTypeMapContainer> &worldVisitor, - TypeContainerVisitor<acore::ObjectUpdater, GridTypeMapContainer> &largeGridVisitor, - TypeContainerVisitor<acore::ObjectUpdater, WorldTypeMapContainer> &largeWorldVisitor) -{ +void Map::VisitNearbyCellsOf(WorldObject* obj, TypeContainerVisitor<acore::ObjectUpdater, GridTypeMapContainer>& gridVisitor, + TypeContainerVisitor<acore::ObjectUpdater, WorldTypeMapContainer>& worldVisitor, + TypeContainerVisitor<acore::ObjectUpdater, GridTypeMapContainer>& largeGridVisitor, + TypeContainerVisitor<acore::ObjectUpdater, WorldTypeMapContainer>& largeWorldVisitor) +{ // Check for valid position if (!obj->IsPositionValid()) return; @@ -760,7 +760,8 @@ void Map::Update(const uint32 t_diff, const uint32 s_diff, bool /*thread*/) TypeContainerVisitor<acore::ObjectUpdater, WorldTypeMapContainer > world_large_object_update(largeObjectUpdater); // pussywizard: container for far creatures in combat with players - std::vector<Creature*> updateList; updateList.reserve(10); + std::vector<Creature*> updateList; + updateList.reserve(10); // non-player active objects, increasing iterator in the loop in case of object removal for (m_activeNonPlayersIter = m_activeNonPlayers.begin(); m_activeNonPlayersIter != m_activeNonPlayers.end();) @@ -792,7 +793,8 @@ void Map::Update(const uint32 t_diff, const uint32 s_diff, bool /*thread*/) if (player->IsInCombat()) { updateList.clear(); - float rangeSq = player->GetGridActivationRange() - 1.0f; rangeSq = rangeSq*rangeSq; + float rangeSq = player->GetGridActivationRange() - 1.0f; + rangeSq = rangeSq * rangeSq; HostileReference* ref = player->getHostileRefManager().getFirst(); while (ref) { @@ -840,7 +842,7 @@ void Map::Update(const uint32 t_diff, const uint32 s_diff, bool /*thread*/) } void Map::HandleDelayedVisibility() -{ +{ if (i_objectsForDelayedVisibility.empty()) return; for (std::unordered_set<Unit*>::iterator itr = i_objectsForDelayedVisibility.begin(); itr != i_objectsForDelayedVisibility.end(); ++itr) @@ -850,18 +852,18 @@ void Map::HandleDelayedVisibility() struct ResetNotifier { - template<class T>inline void resetNotify(GridRefManager<T> &m) + template<class T>inline void resetNotify(GridRefManager<T>& m) { - for (typename GridRefManager<T>::iterator iter=m.begin(); iter != m.end(); ++iter) + for (typename GridRefManager<T>::iterator iter = m.begin(); iter != m.end(); ++iter) iter->GetSource()->ResetAllNotifies(); } - template<class T> void Visit(GridRefManager<T> &) {} - void Visit(CreatureMapType &m) { resetNotify<Creature>(m);} - void Visit(PlayerMapType &m) { resetNotify<Player>(m);} + template<class T> void Visit(GridRefManager<T>&) {} + void Visit(CreatureMapType& m) { resetNotify<Creature>(m);} + void Visit(PlayerMapType& m) { resetNotify<Player>(m);} }; void Map::RemovePlayerFromMap(Player* player, bool remove) -{ +{ player->getHostileRefManager().deleteReferences(); // pussywizard: multithreading crashfix bool inWorld = player->IsInWorld(); @@ -888,8 +890,8 @@ void Map::AfterPlayerUnlinkFromMap() } template<class T> -void Map::RemoveFromMap(T *obj, bool remove) -{ +void Map::RemoveFromMap(T* obj, bool remove) +{ bool inWorld = obj->IsInWorld() && obj->GetTypeId() >= TYPEID_UNIT && obj->GetTypeId() <= TYPEID_GAMEOBJECT; obj->RemoveFromWorld(); @@ -909,7 +911,7 @@ void Map::RemoveFromMap(T *obj, bool remove) template<> void Map::RemoveFromMap(MotionTransport* obj, bool remove) -{ +{ obj->RemoveFromWorld(); if (obj->isActiveObject()) RemoveFromActive(obj); @@ -922,8 +924,8 @@ void Map::RemoveFromMap(MotionTransport* obj, bool remove) WorldPacket packet; data.BuildPacket(&packet); for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr) - if (itr->GetSource()->GetTransport() != obj) - itr->GetSource()->SendDirectMessage(&packet); + if (itr->GetSource()->GetTransport() != obj) + itr->GetSource()->SendDirectMessage(&packet); } if (_transportsUpdateIter != _transports.end()) @@ -950,7 +952,7 @@ void Map::RemoveFromMap(MotionTransport* obj, bool remove) } void Map::PlayerRelocation(Player* player, float x, float y, float z, float o) -{ +{ Cell old_cell(player->GetPositionX(), player->GetPositionY()); Cell new_cell(x, y); @@ -972,7 +974,7 @@ void Map::PlayerRelocation(Player* player, float x, float y, float z, float o) } void Map::CreatureRelocation(Creature* creature, float x, float y, float z, float o) -{ +{ Cell old_cell = creature->GetCurrentCell(); Cell new_cell(x, y); @@ -994,7 +996,7 @@ void Map::CreatureRelocation(Creature* creature, float x, float y, float z, floa } void Map::GameObjectRelocation(GameObject* go, float x, float y, float z, float o) -{ +{ Cell old_cell = go->GetCurrentCell(); Cell new_cell(x, y); @@ -1035,31 +1037,31 @@ void Map::DynamicObjectRelocation(DynamicObject* dynObj, float x, float y, float } void Map::AddCreatureToMoveList(Creature* c) -{ +{ if (c->_moveState == MAP_OBJECT_CELL_MOVE_NONE) _creaturesToMove.push_back(c); c->_moveState = MAP_OBJECT_CELL_MOVE_ACTIVE; } void Map::RemoveCreatureFromMoveList(Creature* c) -{ +{ if (c->_moveState == MAP_OBJECT_CELL_MOVE_ACTIVE) c->_moveState = MAP_OBJECT_CELL_MOVE_INACTIVE; } void Map::AddGameObjectToMoveList(GameObject* go) -{ +{ if (go->_moveState == MAP_OBJECT_CELL_MOVE_NONE) _gameObjectsToMove.push_back(go); go->_moveState = MAP_OBJECT_CELL_MOVE_ACTIVE; } void Map::RemoveGameObjectFromMoveList(GameObject* go) -{ +{ if (go->_moveState == MAP_OBJECT_CELL_MOVE_ACTIVE) go->_moveState = MAP_OBJECT_CELL_MOVE_INACTIVE; } - + void Map::AddDynamicObjectToMoveList(DynamicObject* dynObj) { if (dynObj->_moveState == MAP_OBJECT_CELL_MOVE_NONE) @@ -1074,7 +1076,7 @@ void Map::RemoveDynamicObjectFromMoveList(DynamicObject* dynObj) } void Map::MoveAllCreaturesInMoveList() -{ +{ for (std::vector<Creature*>::iterator itr = _creaturesToMove.begin(); itr != _creaturesToMove.end(); ++itr) { Creature* c = *itr; @@ -1103,7 +1105,7 @@ void Map::MoveAllCreaturesInMoveList() } void Map::MoveAllGameObjectsInMoveList() -{ +{ for (std::vector<GameObject*>::iterator itr = _gameObjectsToMove.begin(); itr != _gameObjectsToMove.end(); ++itr) { GameObject* go = *itr; @@ -1130,11 +1132,11 @@ void Map::MoveAllGameObjectsInMoveList() } _gameObjectsToMove.clear(); } - - void Map::MoveAllDynamicObjectsInMoveList() - { - for (std::vector<DynamicObject*>::iterator itr = _dynamicObjectsToMove.begin(); itr != _dynamicObjectsToMove.end(); ++itr) - { + +void Map::MoveAllDynamicObjectsInMoveList() +{ + for (std::vector<DynamicObject*>::iterator itr = _dynamicObjectsToMove.begin(); itr != _dynamicObjectsToMove.end(); ++itr) + { DynamicObject* dynObj = *itr; if (dynObj->FindMap() != this) continue; @@ -1161,7 +1163,7 @@ void Map::MoveAllGameObjectsInMoveList() } bool Map::UnloadGrid(NGridType& ngrid) -{ +{ // pussywizard: UnloadGrid only done when whole map is unloaded, no need to worry about moving npcs between grids, etc. const uint32 x = ngrid.getX(); @@ -1210,7 +1212,7 @@ bool Map::UnloadGrid(NGridType& ngrid) } void Map::RemoveAllPlayers() -{ +{ if (HavePlayers()) { for (MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) @@ -1227,14 +1229,14 @@ void Map::RemoveAllPlayers() } void Map::UnloadAll() -{ +{ // clear all delayed moves, useless anyway do this moves before map unload. _creaturesToMove.clear(); _gameObjectsToMove.clear(); for (GridRefManager<NGridType>::iterator i = GridRefManager<NGridType>::begin(); i != GridRefManager<NGridType>::end();) { - NGridType &grid(*i->GetSource()); + NGridType& grid(*i->GetSource()); ++i; UnloadGrid(grid); // deletes the grid and removes it from the GridRefManager } @@ -1289,7 +1291,7 @@ GridMap::~GridMap() unloadData(); } -bool GridMap::loadData(char *filename) +bool GridMap::loadData(char* filename) { // Unload old data if exist unloadData(); @@ -1369,8 +1371,8 @@ bool GridMap::loadAreaData(FILE* in, uint32 offset, uint32 /*size*/) _gridArea = header.gridArea; if (!(header.flags & MAP_AREA_NO_AREA)) { - _areaMap = new uint16 [16*16]; - if (fread(_areaMap, sizeof(uint16), 16*16, in) != 16*16) + _areaMap = new uint16 [16 * 16]; + if (fread(_areaMap, sizeof(uint16), 16 * 16, in) != 16 * 16) return false; } return true; @@ -1389,30 +1391,30 @@ bool GridMap::loadHeightData(FILE* in, uint32 offset, uint32 /*size*/) { if ((header.flags & MAP_HEIGHT_AS_INT16)) { - m_uint16_V9 = new uint16 [129*129]; - m_uint16_V8 = new uint16 [128*128]; - if (fread(m_uint16_V9, sizeof(uint16), 129*129, in) != 129*129 || - fread(m_uint16_V8, sizeof(uint16), 128*128, in) != 128*128) + m_uint16_V9 = new uint16 [129 * 129]; + m_uint16_V8 = new uint16 [128 * 128]; + if (fread(m_uint16_V9, sizeof(uint16), 129 * 129, in) != 129 * 129 || + fread(m_uint16_V8, sizeof(uint16), 128 * 128, in) != 128 * 128) return false; _gridIntHeightMultiplier = (header.gridMaxHeight - header.gridHeight) / 65535; _gridGetHeight = &GridMap::getHeightFromUint16; } else if ((header.flags & MAP_HEIGHT_AS_INT8)) { - m_uint8_V9 = new uint8 [129*129]; - m_uint8_V8 = new uint8 [128*128]; - if (fread(m_uint8_V9, sizeof(uint8), 129*129, in) != 129*129 || - fread(m_uint8_V8, sizeof(uint8), 128*128, in) != 128*128) + m_uint8_V9 = new uint8 [129 * 129]; + m_uint8_V8 = new uint8 [128 * 128]; + if (fread(m_uint8_V9, sizeof(uint8), 129 * 129, in) != 129 * 129 || + fread(m_uint8_V8, sizeof(uint8), 128 * 128, in) != 128 * 128) return false; _gridIntHeightMultiplier = (header.gridMaxHeight - header.gridHeight) / 255; _gridGetHeight = &GridMap::getHeightFromUint8; } else { - m_V9 = new float [129*129]; - m_V8 = new float [128*128]; - if (fread(m_V9, sizeof(float), 129*129, in) != 129*129 || - fread(m_V8, sizeof(float), 128*128, in) != 128*128) + m_V9 = new float [129 * 129]; + m_V8 = new float [128 * 128]; + if (fread(m_V9, sizeof(float), 129 * 129, in) != 129 * 129 || + fread(m_V8, sizeof(float), 128 * 128, in) != 128 * 128) return false; _gridGetHeight = &GridMap::getHeightFromFloat; } @@ -1425,7 +1427,7 @@ bool GridMap::loadHeightData(FILE* in, uint32 offset, uint32 /*size*/) _maxHeight = new int16[3 * 3]; _minHeight = new int16[3 * 3]; if (fread(_maxHeight, sizeof(int16), 3 * 3, in) != 3 * 3 || - fread(_minHeight, sizeof(int16), 3 * 3, in) != 3 * 3) + fread(_minHeight, sizeof(int16), 3 * 3, in) != 3 * 3) return false; } @@ -1449,18 +1451,18 @@ bool GridMap::loadLiquidData(FILE* in, uint32 offset, uint32 /*size*/) if (!(header.flags & MAP_LIQUID_NO_TYPE)) { - _liquidEntry = new uint16[16*16]; - if (fread(_liquidEntry, sizeof(uint16), 16*16, in) != 16*16) + _liquidEntry = new uint16[16 * 16]; + if (fread(_liquidEntry, sizeof(uint16), 16 * 16, in) != 16 * 16) return false; - _liquidFlags = new uint8[16*16]; - if (fread(_liquidFlags, sizeof(uint8), 16*16, in) != 16*16) + _liquidFlags = new uint8[16 * 16]; + if (fread(_liquidFlags, sizeof(uint8), 16 * 16, in) != 16 * 16) return false; } if (!(header.flags & MAP_LIQUID_NO_HEIGHT)) { _liquidMap = new float[uint32(_liquidWidth) * uint32(_liquidHeight)]; - if (fread(_liquidMap, sizeof(float), _liquidWidth*_liquidHeight, in) != (uint32(_liquidWidth) * uint32(_liquidHeight))) + if (fread(_liquidMap, sizeof(float), _liquidWidth * _liquidHeight, in) != (uint32(_liquidWidth) * uint32(_liquidHeight))) return false; } return true; @@ -1471,11 +1473,11 @@ uint16 GridMap::getArea(float x, float y) const if (!_areaMap) return _gridArea; - x = 16 * (32 - x/SIZE_OF_GRIDS); - y = 16 * (32 - y/SIZE_OF_GRIDS); + x = 16 * (32 - x / SIZE_OF_GRIDS); + y = 16 * (32 - y / SIZE_OF_GRIDS); int lx = (int)x & 15; int ly = (int)y & 15; - return _areaMap[lx*16 + ly]; + return _areaMap[lx * 16 + ly]; } float GridMap::getHeightFromFlat(float /*x*/, float /*y*/) const @@ -1488,15 +1490,15 @@ float GridMap::getHeightFromFloat(float x, float y) const if (!m_V8 || !m_V9) return _gridHeight; - x = MAP_RESOLUTION * (32 - x/SIZE_OF_GRIDS); - y = MAP_RESOLUTION * (32 - y/SIZE_OF_GRIDS); + x = MAP_RESOLUTION * (32 - x / SIZE_OF_GRIDS); + y = MAP_RESOLUTION * (32 - y / SIZE_OF_GRIDS); int x_int = (int)x; int y_int = (int)y; x -= x_int; y -= y_int; - x_int&=(MAP_RESOLUTION - 1); - y_int&=(MAP_RESOLUTION - 1); + x_int &= (MAP_RESOLUTION - 1); + y_int &= (MAP_RESOLUTION - 1); // Height stored as: h5 - its v8 grid, h1-h4 - its v9 grid // +--------------> X @@ -1515,24 +1517,24 @@ float GridMap::getHeightFromFloat(float x, float y) const float a, b, c; // Select triangle: - if (x+y < 1) + if (x + y < 1) { if (x > y) { // 1 triangle (h1, h2, h5 points) - float h1 = m_V9[(x_int)*129 + y_int]; - float h2 = m_V9[(x_int+1)*129 + y_int]; - float h5 = 2 * m_V8[x_int*128 + y_int]; - a = h2-h1; - b = h5-h1-h2; + float h1 = m_V9[(x_int) * 129 + y_int]; + float h2 = m_V9[(x_int + 1) * 129 + y_int]; + float h5 = 2 * m_V8[x_int * 128 + y_int]; + a = h2 - h1; + b = h5 - h1 - h2; c = h1; } else { // 2 triangle (h1, h3, h5 points) - float h1 = m_V9[x_int*129 + y_int ]; - float h3 = m_V9[x_int*129 + y_int+1]; - float h5 = 2 * m_V8[x_int*128 + y_int]; + float h1 = m_V9[x_int * 129 + y_int ]; + float h3 = m_V9[x_int * 129 + y_int + 1]; + float h5 = 2 * m_V8[x_int * 128 + y_int]; a = h5 - h1 - h3; b = h3 - h1; c = h1; @@ -1543,9 +1545,9 @@ float GridMap::getHeightFromFloat(float x, float y) const if (x > y) { // 3 triangle (h2, h4, h5 points) - float h2 = m_V9[(x_int+1)*129 + y_int ]; - float h4 = m_V9[(x_int+1)*129 + y_int+1]; - float h5 = 2 * m_V8[x_int*128 + y_int]; + float h2 = m_V9[(x_int + 1) * 129 + y_int ]; + float h4 = m_V9[(x_int + 1) * 129 + y_int + 1]; + float h5 = 2 * m_V8[x_int * 128 + y_int]; a = h2 + h4 - h5; b = h4 - h2; c = h5 - h4; @@ -1553,9 +1555,9 @@ float GridMap::getHeightFromFloat(float x, float y) const else { // 4 triangle (h3, h4, h5 points) - float h3 = m_V9[(x_int)*129 + y_int+1]; - float h4 = m_V9[(x_int+1)*129 + y_int+1]; - float h5 = 2 * m_V8[x_int*128 + y_int]; + float h3 = m_V9[(x_int) * 129 + y_int + 1]; + float h4 = m_V9[(x_int + 1) * 129 + y_int + 1]; + float h5 = 2 * m_V8[x_int * 128 + y_int]; a = h4 - h3; b = h3 + h4 - h5; c = h5 - h4; @@ -1570,28 +1572,28 @@ float GridMap::getHeightFromUint8(float x, float y) const if (!m_uint8_V8 || !m_uint8_V9) return _gridHeight; - x = MAP_RESOLUTION * (32 - x/SIZE_OF_GRIDS); - y = MAP_RESOLUTION * (32 - y/SIZE_OF_GRIDS); + x = MAP_RESOLUTION * (32 - x / SIZE_OF_GRIDS); + y = MAP_RESOLUTION * (32 - y / SIZE_OF_GRIDS); int x_int = (int)x; int y_int = (int)y; x -= x_int; y -= y_int; - x_int&=(MAP_RESOLUTION - 1); - y_int&=(MAP_RESOLUTION - 1); + x_int &= (MAP_RESOLUTION - 1); + y_int &= (MAP_RESOLUTION - 1); int32 a, b, c; - uint8 *V9_h1_ptr = &m_uint8_V9[x_int*128 + x_int + y_int]; - if (x+y < 1) + uint8* V9_h1_ptr = &m_uint8_V9[x_int * 128 + x_int + y_int]; + if (x + y < 1) { if (x > y) { // 1 triangle (h1, h2, h5 points) int32 h1 = V9_h1_ptr[ 0]; int32 h2 = V9_h1_ptr[129]; - int32 h5 = 2 * m_uint8_V8[x_int*128 + y_int]; - a = h2-h1; - b = h5-h1-h2; + int32 h5 = 2 * m_uint8_V8[x_int * 128 + y_int]; + a = h2 - h1; + b = h5 - h1 - h2; c = h1; } else @@ -1599,7 +1601,7 @@ float GridMap::getHeightFromUint8(float x, float y) const // 2 triangle (h1, h3, h5 points) int32 h1 = V9_h1_ptr[0]; int32 h3 = V9_h1_ptr[1]; - int32 h5 = 2 * m_uint8_V8[x_int*128 + y_int]; + int32 h5 = 2 * m_uint8_V8[x_int * 128 + y_int]; a = h5 - h1 - h3; b = h3 - h1; c = h1; @@ -1612,7 +1614,7 @@ float GridMap::getHeightFromUint8(float x, float y) const // 3 triangle (h2, h4, h5 points) int32 h2 = V9_h1_ptr[129]; int32 h4 = V9_h1_ptr[130]; - int32 h5 = 2 * m_uint8_V8[x_int*128 + y_int]; + int32 h5 = 2 * m_uint8_V8[x_int * 128 + y_int]; a = h2 + h4 - h5; b = h4 - h2; c = h5 - h4; @@ -1622,14 +1624,14 @@ float GridMap::getHeightFromUint8(float x, float y) const // 4 triangle (h3, h4, h5 points) int32 h3 = V9_h1_ptr[ 1]; int32 h4 = V9_h1_ptr[130]; - int32 h5 = 2 * m_uint8_V8[x_int*128 + y_int]; + int32 h5 = 2 * m_uint8_V8[x_int * 128 + y_int]; a = h4 - h3; b = h3 + h4 - h5; c = h5 - h4; } } // Calculate height - return (float)((a * x) + (b * y) + c)*_gridIntHeightMultiplier + _gridHeight; + return (float)((a * x) + (b * y) + c) * _gridIntHeightMultiplier + _gridHeight; } float GridMap::getHeightFromUint16(float x, float y) const @@ -1637,28 +1639,28 @@ float GridMap::getHeightFromUint16(float x, float y) const if (!m_uint16_V8 || !m_uint16_V9) return _gridHeight; - x = MAP_RESOLUTION * (32 - x/SIZE_OF_GRIDS); - y = MAP_RESOLUTION * (32 - y/SIZE_OF_GRIDS); + x = MAP_RESOLUTION * (32 - x / SIZE_OF_GRIDS); + y = MAP_RESOLUTION * (32 - y / SIZE_OF_GRIDS); int x_int = (int)x; int y_int = (int)y; x -= x_int; y -= y_int; - x_int&=(MAP_RESOLUTION - 1); - y_int&=(MAP_RESOLUTION - 1); + x_int &= (MAP_RESOLUTION - 1); + y_int &= (MAP_RESOLUTION - 1); int32 a, b, c; - uint16 *V9_h1_ptr = &m_uint16_V9[x_int*128 + x_int + y_int]; - if (x+y < 1) + uint16* V9_h1_ptr = &m_uint16_V9[x_int * 128 + x_int + y_int]; + if (x + y < 1) { if (x > y) { // 1 triangle (h1, h2, h5 points) int32 h1 = V9_h1_ptr[ 0]; int32 h2 = V9_h1_ptr[129]; - int32 h5 = 2 * m_uint16_V8[x_int*128 + y_int]; - a = h2-h1; - b = h5-h1-h2; + int32 h5 = 2 * m_uint16_V8[x_int * 128 + y_int]; + a = h2 - h1; + b = h5 - h1 - h2; c = h1; } else @@ -1666,7 +1668,7 @@ float GridMap::getHeightFromUint16(float x, float y) const // 2 triangle (h1, h3, h5 points) int32 h1 = V9_h1_ptr[0]; int32 h3 = V9_h1_ptr[1]; - int32 h5 = 2 * m_uint16_V8[x_int*128 + y_int]; + int32 h5 = 2 * m_uint16_V8[x_int * 128 + y_int]; a = h5 - h1 - h3; b = h3 - h1; c = h1; @@ -1679,7 +1681,7 @@ float GridMap::getHeightFromUint16(float x, float y) const // 3 triangle (h2, h4, h5 points) int32 h2 = V9_h1_ptr[129]; int32 h4 = V9_h1_ptr[130]; - int32 h5 = 2 * m_uint16_V8[x_int*128 + y_int]; + int32 h5 = 2 * m_uint16_V8[x_int * 128 + y_int]; a = h2 + h4 - h5; b = h4 - h2; c = h5 - h4; @@ -1689,14 +1691,14 @@ float GridMap::getHeightFromUint16(float x, float y) const // 4 triangle (h3, h4, h5 points) int32 h3 = V9_h1_ptr[ 1]; int32 h4 = V9_h1_ptr[130]; - int32 h5 = 2 * m_uint16_V8[x_int*128 + y_int]; + int32 h5 = 2 * m_uint16_V8[x_int * 128 + y_int]; a = h4 - h3; b = h3 + h4 - h5; c = h5 - h4; } } // Calculate height - return (float)((a * x) + (b * y) + c)*_gridIntHeightMultiplier + _gridHeight; + return (float)((a * x) + (b * y) + c) * _gridIntHeightMultiplier + _gridHeight; } float GridMap::getMinHeight(float x, float y) const @@ -1753,10 +1755,10 @@ float GridMap::getMinHeight(float x, float y) const quarterIndex *= 3; return G3D::Plane( - G3D::Vector3(boundGridCoords[indices[quarterIndex + 0] * 2 + 0], boundGridCoords[indices[quarterIndex + 0] * 2 + 1], _minHeight[indices[quarterIndex + 0]]), - G3D::Vector3(boundGridCoords[indices[quarterIndex + 1] * 2 + 0], boundGridCoords[indices[quarterIndex + 1] * 2 + 1], _minHeight[indices[quarterIndex + 1]]), - G3D::Vector3(boundGridCoords[indices[quarterIndex + 2] * 2 + 0], boundGridCoords[indices[quarterIndex + 2] * 2 + 1], _minHeight[indices[quarterIndex + 2]]) - ).distance(G3D::Vector3(gx, gy, 0.0f)); + G3D::Vector3(boundGridCoords[indices[quarterIndex + 0] * 2 + 0], boundGridCoords[indices[quarterIndex + 0] * 2 + 1], _minHeight[indices[quarterIndex + 0]]), + G3D::Vector3(boundGridCoords[indices[quarterIndex + 1] * 2 + 0], boundGridCoords[indices[quarterIndex + 1] * 2 + 1], _minHeight[indices[quarterIndex + 1]]), + G3D::Vector3(boundGridCoords[indices[quarterIndex + 2] * 2 + 0], boundGridCoords[indices[quarterIndex + 2] * 2 + 1], _minHeight[indices[quarterIndex + 2]]) + ).distance(G3D::Vector3(gx, gy, 0.0f)); } float GridMap::getLiquidLevel(float x, float y) const @@ -1764,18 +1766,18 @@ float GridMap::getLiquidLevel(float x, float y) const if (!_liquidMap) return _liquidLevel; - x = MAP_RESOLUTION * (32 - x/SIZE_OF_GRIDS); - y = MAP_RESOLUTION * (32 - y/SIZE_OF_GRIDS); + x = MAP_RESOLUTION * (32 - x / SIZE_OF_GRIDS); + y = MAP_RESOLUTION * (32 - y / SIZE_OF_GRIDS); - int cx_int = ((int)x & (MAP_RESOLUTION-1)) - _liquidOffY; - int cy_int = ((int)y & (MAP_RESOLUTION-1)) - _liquidOffX; + int cx_int = ((int)x & (MAP_RESOLUTION - 1)) - _liquidOffY; + int cy_int = ((int)y & (MAP_RESOLUTION - 1)) - _liquidOffX; - if (cx_int < 0 || cx_int >=_liquidHeight) + if (cx_int < 0 || cx_int >= _liquidHeight) return INVALID_HEIGHT; - if (cy_int < 0 || cy_int >=_liquidWidth) + if (cy_int < 0 || cy_int >= _liquidWidth) return INVALID_HEIGHT; - return _liquidMap[cx_int*_liquidWidth + cy_int]; + return _liquidMap[cx_int * _liquidWidth + cy_int]; } // Why does this return LIQUID data? @@ -1784,11 +1786,11 @@ uint8 GridMap::getTerrainType(float x, float y) const if (!_liquidFlags) return 0; - x = 16 * (32 - x/SIZE_OF_GRIDS); - y = 16 * (32 - y/SIZE_OF_GRIDS); + x = 16 * (32 - x / SIZE_OF_GRIDS); + y = 16 * (32 - y / SIZE_OF_GRIDS); int lx = (int)x & 15; int ly = (int)y & 15; - return _liquidFlags[lx*16 + ly]; + return _liquidFlags[lx * 16 + ly]; } // Get water state on map @@ -1799,14 +1801,14 @@ inline ZLiquidStatus GridMap::getLiquidStatus(float x, float y, float z, uint8 R return LIQUID_MAP_NO_WATER; // Get cell - float cx = MAP_RESOLUTION * (32 - x/SIZE_OF_GRIDS); - float cy = MAP_RESOLUTION * (32 - y/SIZE_OF_GRIDS); + float cx = MAP_RESOLUTION * (32 - x / SIZE_OF_GRIDS); + float cy = MAP_RESOLUTION * (32 - y / SIZE_OF_GRIDS); - int x_int = (int)cx & (MAP_RESOLUTION-1); - int y_int = (int)cy & (MAP_RESOLUTION-1); + int x_int = (int)cx & (MAP_RESOLUTION - 1); + int y_int = (int)cy & (MAP_RESOLUTION - 1); // Check water type in cell - int idx=(x_int>>3)*16 + (y_int>>3); + int idx = (x_int >> 3) * 16 + (y_int >> 3); uint8 type = _liquidFlags ? _liquidFlags[idx] : _liquidType; uint32 entry = 0; if (_liquidEntry) @@ -1844,20 +1846,20 @@ inline ZLiquidStatus GridMap::getLiquidStatus(float x, float y, float z, uint8 R return LIQUID_MAP_NO_WATER; // Check req liquid type mask - if (ReqLiquidType && !(ReqLiquidType&type)) + if (ReqLiquidType && !(ReqLiquidType & type)) return LIQUID_MAP_NO_WATER; // Check water level: // Check water height map int lx_int = x_int - _liquidOffY; int ly_int = y_int - _liquidOffX; - if (lx_int < 0 || lx_int >=_liquidHeight) + if (lx_int < 0 || lx_int >= _liquidHeight) return LIQUID_MAP_NO_WATER; - if (ly_int < 0 || ly_int >=_liquidWidth) + if (ly_int < 0 || ly_int >= _liquidWidth) return LIQUID_MAP_NO_WATER; // Get water level - float liquid_level = _liquidMap ? _liquidMap[lx_int*_liquidWidth + ly_int] : _liquidLevel; + float liquid_level = _liquidMap ? _liquidMap[lx_int * _liquidWidth + ly_int] : _liquidLevel; // Get ground level (sub 0.2 for fix some errors) float ground_level = getHeight(x, y); @@ -1883,24 +1885,24 @@ inline ZLiquidStatus GridMap::getLiquidStatus(float x, float y, float z, uint8 R return LIQUID_MAP_IN_WATER; if (delta > -0.1f) // Walk on water return LIQUID_MAP_WATER_WALK; - // Above water + // Above water return LIQUID_MAP_ABOVE_WATER; } GridMap* Map::GetGrid(float x, float y) -{ +{ // half opt method - int gx=(int)(32-x/SIZE_OF_GRIDS); //grid x - int gy=(int)(32-y/SIZE_OF_GRIDS); //grid y + int gx = (int)(32 - x / SIZE_OF_GRIDS); //grid x + int gy = (int)(32 - y / SIZE_OF_GRIDS); //grid y // ensure GridMap is loaded - EnsureGridCreated(GridCoord(63-gx, 63-gy)); + EnsureGridCreated(GridCoord(63 - gx, 63 - gy)); return GridMaps[gx][gy]; } float Map::GetWaterOrGroundLevel(uint32 phasemask, float x, float y, float z, float* ground /*= NULL*/, bool /*swim = false*/, float maxSearchDist /*= 50.0f*/) const -{ +{ if (const_cast<Map*>(this)->GetGrid(x, y)) { // we need ground level (including grid height version) for proper return water level in point @@ -1922,7 +1924,7 @@ Transport* Map::GetTransportForPos(uint32 phase, float x, float y, float z, Worl G3D::Vector3 v(x, y, z + 2.0f); G3D::Ray r(v, G3D::Vector3(0, 0, -1)); for (TransportsContainer::const_iterator itr = _transports.begin(); itr != _transports.end(); ++itr) - if ((*itr)->IsInWorld() && (*itr)->GetExactDistSq(x, y, z) < 75.0f*75.0f && (*itr)->m_model) + if ((*itr)->IsInWorld() && (*itr)->GetExactDistSq(x, y, z) < 75.0f * 75.0f && (*itr)->m_model) { float dist = 30.0f; bool hit = (*itr)->m_model->intersectRay(r, dist, false, phase); @@ -1945,7 +1947,7 @@ Transport* Map::GetTransportForPos(uint32 phase, float x, float y, float z, Worl } float Map::GetHeight(float x, float y, float z, bool checkVMap /*= true*/, float maxSearchDist /*= DEFAULT_HEIGHT_SEARCH*/) const -{ +{ // find raw .map surface under Z coordinates float mapHeight = VMAP_INVALID_HEIGHT_VALUE; if (GridMap* gmap = const_cast<Map*>(this)->GetGrid(x, y)) @@ -1961,7 +1963,7 @@ float Map::GetHeight(float x, float y, float z, bool checkVMap /*= true*/, float { VMAP::IVMapManager* vmgr = VMAP::VMapFactory::createOrGetVMapManager(); //if (vmgr->isHeightCalcEnabled()) // pussywizard: optimization - vmapHeight = vmgr->getHeight(GetId(), x, y, z + 2.0f, maxSearchDist); // look from a bit higher pos to find the floor + vmapHeight = vmgr->getHeight(GetId(), x, y, z + 2.0f, maxSearchDist); // look from a bit higher pos to find the floor } // mapHeight set for any above raw ground Z or <= INVALID_HEIGHT @@ -1974,7 +1976,7 @@ float Map::GetHeight(float x, float y, float z, bool checkVMap /*= true*/, float // we are already under the surface or vmap height above map heigt // or if the distance of the vmap height is less the land height distance - if (vmapHeight > mapHeight || fabs(mapHeight-z) > fabs(vmapHeight-z)) + if (vmapHeight > mapHeight || fabs(mapHeight - z) > fabs(vmapHeight - z)) return vmapHeight; else return mapHeight; // better use .map surface height @@ -2007,20 +2009,20 @@ inline bool IsOutdoorWMO(uint32 mogpFlags, int32 /*adtId*/, int32 /*rootId*/, in return false; } - outdoor = mogpFlags&0x8; + outdoor = mogpFlags & 0x8; if (wmoEntry) { if (wmoEntry->Flags & 4) return true; - if ((wmoEntry->Flags & 2)!=0) + if ((wmoEntry->Flags & 2) != 0) outdoor = false; } return outdoor; } bool Map::IsOutdoors(float x, float y, float z) const -{ +{ uint32 mogpFlags; int32 adtId, rootId, groupId; @@ -2029,7 +2031,7 @@ bool Map::IsOutdoors(float x, float y, float z) const return true; AreaTableEntry const* atEntry = 0; - WMOAreaTableEntry const* wmoEntry= GetWMOAreaTableEntryByTripple(rootId, adtId, groupId); + WMOAreaTableEntry const* wmoEntry = GetWMOAreaTableEntryByTripple(rootId, adtId, groupId); if (wmoEntry) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) @@ -2040,8 +2042,8 @@ bool Map::IsOutdoors(float x, float y, float z) const return IsOutdoorWMO(mogpFlags, adtId, rootId, groupId, wmoEntry, atEntry); } -bool Map::GetAreaInfo(float x, float y, float z, uint32 &flags, int32 &adtId, int32 &rootId, int32 &groupId) const -{ +bool Map::GetAreaInfo(float x, float y, float z, uint32& flags, int32& adtId, int32& rootId, int32& groupId) const +{ float vmap_z = z; VMAP::IVMapManager* vmgr = VMAP::VMapFactory::createOrGetVMapManager(); if (vmgr->getAreaInfo(GetId(), x, y, vmap_z, flags, adtId, rootId, groupId)) @@ -2059,8 +2061,8 @@ bool Map::GetAreaInfo(float x, float y, float z, uint32 &flags, int32 &adtId, in return false; } -uint32 Map::GetAreaId(float x, float y, float z, bool *isOutdoors) const -{ +uint32 Map::GetAreaId(float x, float y, float z, bool* isOutdoors) const +{ uint32 mogpFlags; int32 adtId, rootId, groupId; WMOAreaTableEntry const* wmoEntry = 0; @@ -2122,7 +2124,7 @@ void Map::GetZoneAndAreaId(uint32& zoneid, uint32& areaid, float x, float y, flo } uint8 Map::GetTerrainType(float x, float y) const -{ +{ if (GridMap* gmap = const_cast<Map*>(this)->GetGrid(x, y)) return gmap->getTerrainType(x, y); else @@ -2130,7 +2132,7 @@ uint8 Map::GetTerrainType(float x, float y) const } ZLiquidStatus Map::getLiquidStatus(float x, float y, float z, uint8 ReqLiquidType, LiquidData* data) const -{ +{ ZLiquidStatus result = LIQUID_MAP_NO_WATER; VMAP::IVMapManager* vmgr = VMAP::VMapFactory::createOrGetVMapManager(); float liquid_level = INVALID_HEIGHT; @@ -2217,7 +2219,7 @@ ZLiquidStatus Map::getLiquidStatus(float x, float y, float z, uint8 ReqLiquidTyp } float Map::GetWaterLevel(float x, float y) const -{ +{ if (GridMap* gmap = const_cast<Map*>(this)->GetGrid(x, y)) return gmap->getLiquidLevel(x, y); else @@ -2228,15 +2230,15 @@ bool Map::isInLineOfSight(float x1, float y1, float z1, float x2, float y2, floa { if ((checks & LINEOFSIGHT_CHECK_VMAP) && !VMAP::VMapFactory::createOrGetVMapManager()->isInLineOfSight(GetId(), x1, y1, z1, x2, y2, z2)) return false; - + if (sWorld->getBoolConfig(CONFIG_CHECK_GOBJECT_LOS) && (checks & LINEOFSIGHT_CHECK_GOBJECT) - && !_dynamicTree.isInLineOfSight(x1, y1, z1, x2, y2, z2, phasemask)) + && !_dynamicTree.isInLineOfSight(x1, y1, z1, x2, y2, z2, phasemask)) return false; return true; } bool Map::getObjectHitPos(uint32 phasemask, float x1, float y1, float z1, float x2, float y2, float z2, float& rx, float& ry, float& rz, float modifyDist) -{ +{ G3D::Vector3 startPos(x1, y1, z1); G3D::Vector3 dstPos(x2, y2, z2); @@ -2250,7 +2252,7 @@ bool Map::getObjectHitPos(uint32 phasemask, float x1, float y1, float z1, float } float Map::GetHeight(uint32 phasemask, float x, float y, float z, bool vmap/*=true*/, float maxSearchDist/*=DEFAULT_HEIGHT_SEARCH*/) const -{ +{ float h1, h2; h1 = GetHeight(x, y, z, vmap, maxSearchDist); h2 = _dynamicTree.getHeight(x, y, z, maxSearchDist, phasemask); @@ -2258,24 +2260,24 @@ float Map::GetHeight(uint32 phasemask, float x, float y, float z, bool vmap/*=tr } bool Map::IsInWater(float x, float y, float pZ, LiquidData* data) const -{ +{ LiquidData liquid_status; LiquidData* liquid_ptr = data ? data : &liquid_status; return getLiquidStatus(x, y, pZ, MAP_ALL_LIQUIDS, liquid_ptr) & (LIQUID_MAP_IN_WATER | LIQUID_MAP_UNDER_WATER); } bool Map::IsUnderWater(float x, float y, float z) const -{ - return getLiquidStatus(x, y, z, MAP_LIQUID_TYPE_WATER|MAP_LIQUID_TYPE_OCEAN) & LIQUID_MAP_UNDER_WATER; +{ + return getLiquidStatus(x, y, z, MAP_LIQUID_TYPE_WATER | MAP_LIQUID_TYPE_OCEAN) & LIQUID_MAP_UNDER_WATER; } char const* Map::GetMapName() const -{ +{ return i_mapEntry ? i_mapEntry->name[sWorld->GetDefaultDbcLocale()] : "UNNAMEDMAP\x0"; } void Map::SendInitSelf(Player* player) -{ +{ #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) sLog->outDetail("Creating player data for himself %u", player->GetGUIDLow()); #endif @@ -2301,7 +2303,7 @@ void Map::SendInitSelf(Player* player) } void Map::SendInitTransports(Player* player) -{ +{ // Hack to send out transports UpdateData transData; for (TransportsContainer::const_iterator itr = _transports.begin(); itr != _transports.end(); ++itr) @@ -2314,7 +2316,7 @@ void Map::SendInitTransports(Player* player) } void Map::SendRemoveTransports(Player* player) -{ +{ // Hack to send out transports UpdateData transData; for (TransportsContainer::const_iterator itr = _transports.begin(); itr != _transports.end(); ++itr) @@ -2322,7 +2324,7 @@ void Map::SendRemoveTransports(Player* player) (*itr)->BuildOutOfRangeUpdateBlock(&transData); // pussywizard: remove static transports from client - for (Player::ClientGUIDs::const_iterator it = player->m_clientGUIDs.begin();it != player->m_clientGUIDs.end(); ) + for (Player::ClientGUIDs::const_iterator it = player->m_clientGUIDs.begin(); it != player->m_clientGUIDs.end(); ) { if (IS_TRANSPORT_GUID(*it)) { @@ -2338,8 +2340,8 @@ void Map::SendRemoveTransports(Player* player) player->GetSession()->SendPacket(&packet); } -inline void Map::setNGrid(NGridType *grid, uint32 x, uint32 y) -{ +inline void Map::setNGrid(NGridType* grid, uint32 x, uint32 y) +{ if (x >= MAX_NUMBER_OF_GRIDS || y >= MAX_NUMBER_OF_GRIDS) { sLog->outError("map::setNGrid() Invalid grid coordinates found: %d, %d!", x, y); @@ -2349,7 +2351,7 @@ inline void Map::setNGrid(NGridType *grid, uint32 x, uint32 y) } void Map::DelayedUpdate(const uint32 t_diff) -{ +{ for (_transportsUpdateIter = _transports.begin(); _transportsUpdateIter != _transports.end();) { MotionTransport* transport = *_transportsUpdateIter; @@ -2365,7 +2367,7 @@ void Map::DelayedUpdate(const uint32 t_diff) } void Map::AddObjectToRemoveList(WorldObject* obj) -{ +{ ASSERT(obj->GetMapId() == GetId() && obj->GetInstanceId() == GetInstanceId()); obj->CleanupsBeforeDelete(false); // remove or simplify at least cross referenced links @@ -2375,7 +2377,7 @@ void Map::AddObjectToRemoveList(WorldObject* obj) } void Map::AddObjectToSwitchList(WorldObject* obj, bool on) -{ +{ ASSERT(obj->GetMapId() == GetId() && obj->GetInstanceId() == GetInstanceId()); // i_objectsToSwitch is iterated only in Map::RemoveAllObjectsInRemoveList() and it uses // the contained objects only if GetTypeId() == TYPEID_UNIT , so we can return in all other cases @@ -2392,7 +2394,7 @@ void Map::AddObjectToSwitchList(WorldObject* obj, bool on) } void Map::RemoveAllObjectsInRemoveList() -{ +{ while (!i_objectsToSwitch.empty()) { std::map<WorldObject*, bool>::iterator itr = i_objectsToSwitch.begin(); @@ -2426,14 +2428,14 @@ void Map::RemoveAllObjectsInRemoveList() switch (obj->GetTypeId()) { case TYPEID_CORPSE: - { - Corpse* corpse = ObjectAccessor::GetCorpse(*obj, obj->GetGUID()); - if (!corpse) - sLog->outError("Tried to delete corpse/bones %u that is not in map.", obj->GetGUIDLow()); - else - RemoveFromMap(corpse, true); - break; - } + { + Corpse* corpse = ObjectAccessor::GetCorpse(*obj, obj->GetGUID()); + if (!corpse) + sLog->outError("Tried to delete corpse/bones %u that is not in map.", obj->GetGUIDLow()); + else + RemoveFromMap(corpse, true); + break; + } case TYPEID_DYNAMICOBJECT: RemoveFromMap((DynamicObject*)obj, true); break; @@ -2468,56 +2470,56 @@ uint32 Map::GetPlayersCountExceptGMs() const } void Map::SendToPlayers(WorldPacket const* data) const -{ +{ for (MapRefManager::const_iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) itr->GetSource()->GetSession()->SendPacket(data); } template<class T> void Map::AddToActive(T* obj) -{ +{ AddToActiveHelper(obj); } template <> void Map::AddToActive(Creature* c) -{ +{ AddToActiveHelper(c); } template<> void Map::AddToActive(DynamicObject* d) -{ +{ AddToActiveHelper(d); } template<> void Map::AddToActive(GameObject* d) -{ +{ AddToActiveHelper(d); } template<class T> void Map::RemoveFromActive(T* obj) -{ +{ RemoveFromActiveHelper(obj); } template <> void Map::RemoveFromActive(Creature* c) -{ +{ RemoveFromActiveHelper(c); } template<> void Map::RemoveFromActive(DynamicObject* obj) -{ +{ RemoveFromActiveHelper(obj); } template<> void Map::RemoveFromActive(GameObject* obj) -{ +{ RemoveFromActiveHelper(obj); } @@ -2534,9 +2536,9 @@ template void Map::RemoveFromMap(DynamicObject*, bool); /* ******* Dungeon Instance Maps ******* */ InstanceMap::InstanceMap(uint32 id, uint32 InstanceId, uint8 SpawnMode, Map* _parent) - : Map(id, InstanceId, SpawnMode, _parent), - m_resetAfterUnload(false), m_unloadWhenEmpty(false), - instance_script(nullptr), i_script_id(0) + : Map(id, InstanceId, SpawnMode, _parent), + m_resetAfterUnload(false), m_unloadWhenEmpty(false), + instance_script(nullptr), i_script_id(0) { //lets initialize visibility distance for dungeons InstanceMap::InitVisibilityDistance(); @@ -2560,7 +2562,7 @@ InstanceMap::~InstanceMap() } void InstanceMap::InitVisibilityDistance() -{ +{ //init visibility distance for instances m_VisibleDistance = World::GetMaxVisibleDistanceInInstances(); @@ -2607,7 +2609,7 @@ bool InstanceMap::CanEnter(Player* player, bool loginCheck) // cannot enter if the instance is full (player cap), GMs don't count uint32 maxPlayers = GetMaxPlayers(); - if (GetPlayersCountExceptGMs() >= (loginCheck ? maxPlayers+1 : maxPlayers)) + if (GetPlayersCountExceptGMs() >= (loginCheck ? maxPlayers + 1 : maxPlayers)) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) sLog->outDetail("MAP: Instance '%u' of map '%s' cannot have more than '%u' players. Player '%s' rejected", GetInstanceId(), GetMapName(), maxPlayers, player->GetName().c_str()); @@ -2634,7 +2636,7 @@ bool InstanceMap::CanEnter(Player* player, bool loginCheck) } // cannot enter if instance is in use by another party/soloer that have a permanent save in the same instance id - PlayerList const &playerList = GetPlayers(); + PlayerList const& playerList = GetPlayers(); if (!playerList.isEmpty()) for (PlayerList::const_iterator i = playerList.begin(); i != playerList.end(); ++i) if (Player* iPlayer = i->GetSource()) @@ -2664,7 +2666,7 @@ bool InstanceMap::CanEnter(Player* player, bool loginCheck) Do map specific checks and add the player to the map if successful. */ bool InstanceMap::AddPlayerToMap(Player* player) -{ +{ if (m_resetAfterUnload) // this instance has been reset, it's not meant to be used anymore return false; @@ -2743,7 +2745,7 @@ void InstanceMap::Update(const uint32 t_diff, const uint32 s_diff, bool /*thread } void InstanceMap::RemovePlayerFromMap(Player* player, bool remove) -{ +{ // pussywizard: moved m_unloadTimer to InstanceMap::AfterPlayerUnlinkFromMap(), in this function if 2 players run out at the same time the instance won't close //if (!m_unloadTimer && m_mapRefManager.getSize() == 1) // m_unloadTimer = m_unloadWhenEmpty ? MIN_UNLOAD_DELAY : std::max(sWorld->getIntConfig(CONFIG_INSTANCE_UNLOAD_DELAY), (uint32)MIN_UNLOAD_DELAY); @@ -2758,7 +2760,7 @@ void InstanceMap::AfterPlayerUnlinkFromMap() } void InstanceMap::CreateInstanceScript(bool load, std::string data, uint32 completedEncounterMask) -{ +{ if (instance_script != nullptr) return; #ifdef ELUNA @@ -2845,7 +2847,7 @@ bool InstanceMap::Reset(uint8 method, std::list<uint32>* globalResetSkipList) } void InstanceMap::PermBindAllPlayers() -{ +{ if (!IsDungeon()) return; @@ -2883,7 +2885,7 @@ void InstanceMap::PermBindAllPlayers() } void InstanceMap::UnloadAll() -{ +{ ASSERT(!HavePlayers()); if (m_resetAfterUnload == true) @@ -2893,7 +2895,7 @@ void InstanceMap::UnloadAll() } void InstanceMap::SendResetWarnings(uint32 timeLeft) const -{ +{ for (MapRefManager::const_iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) itr->GetSource()->SendInstanceResetWarning(GetId(), itr->GetSource()->GetDifficulty(IsRaid()), timeLeft, false); } @@ -2913,7 +2915,7 @@ uint32 InstanceMap::GetMaxPlayers() const } uint32 InstanceMap::GetMaxResetDelay() const -{ +{ MapDifficulty const* mapDiff = GetMapDifficulty(); return mapDiff ? mapDiff->resetTime : 0; } @@ -2921,7 +2923,7 @@ uint32 InstanceMap::GetMaxResetDelay() const /* ******* Battleground Instance Maps ******* */ BattlegroundMap::BattlegroundMap(uint32 id, uint32 InstanceId, Map* _parent, uint8 spawnMode) - : Map(id, InstanceId, spawnMode, _parent), m_bg(nullptr) + : Map(id, InstanceId, spawnMode, _parent), m_bg(nullptr) { //lets initialize visibility distance for BG/Arenas BattlegroundMap::InitVisibilityDistance(); @@ -2938,7 +2940,7 @@ BattlegroundMap::~BattlegroundMap() } void BattlegroundMap::InitVisibilityDistance() -{ +{ //init visibility distance for BG/Arenas m_VisibleDistance = World::GetMaxVisibleDistanceInBGArenas(); @@ -2964,7 +2966,7 @@ bool BattlegroundMap::CanEnter(Player* player, bool loginCheck) } bool BattlegroundMap::AddPlayerToMap(Player* player) -{ +{ player->m_InstanceValid = true; if (IsBattleArena()) player->CastSpell(player, 100102, true); @@ -2985,12 +2987,12 @@ void BattlegroundMap::RemovePlayerFromMap(Player* player, bool remove) } void BattlegroundMap::SetUnload() -{ +{ m_unloadTimer = MIN_UNLOAD_DELAY; } void BattlegroundMap::RemoveAllPlayers() -{ +{ if (HavePlayers()) for (MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) if (Player* player = itr->GetSource()) @@ -2999,22 +3001,22 @@ void BattlegroundMap::RemoveAllPlayers() } Player* Map::GetPlayer(uint64 guid) -{ +{ return ObjectAccessor::GetObjectInMap(guid, this, (Player*)NULL); } Creature* Map::GetCreature(uint64 guid) -{ +{ return ObjectAccessor::GetObjectInMap(guid, this, (Creature*)NULL); } GameObject* Map::GetGameObject(uint64 guid) -{ +{ return ObjectAccessor::GetObjectInMap(guid, this, (GameObject*)NULL); } Transport* Map::GetTransport(uint64 guid) -{ +{ if (GUID_HIPART(guid) != HIGHGUID_MO_TRANSPORT && GUID_HIPART(guid) != HIGHGUID_TRANSPORT) return nullptr; @@ -3023,28 +3025,28 @@ Transport* Map::GetTransport(uint64 guid) } DynamicObject* Map::GetDynamicObject(uint64 guid) -{ +{ return ObjectAccessor::GetObjectInMap(guid, this, (DynamicObject*)NULL); } Pet* Map::GetPet(uint64 guid) -{ +{ return ObjectAccessor::GetObjectInMap(guid, this, (Pet*)NULL); } Corpse* Map::GetCorpse(uint64 guid) -{ +{ return ObjectAccessor::GetObjectInMap(guid, this, (Corpse*)NULL); } void Map::UpdateIteratorBack(Player* player) -{ +{ if (m_mapRefIter == player->GetMapRef()) m_mapRefIter = m_mapRefIter->nocheck_prev(); } void Map::SaveCreatureRespawnTime(uint32 dbGuid, time_t& respawnTime) -{ +{ if (!respawnTime) { // Delete only @@ -3053,8 +3055,8 @@ void Map::SaveCreatureRespawnTime(uint32 dbGuid, time_t& respawnTime) } time_t now = time(nullptr); - if (GetInstanceResetPeriod() > 0 && respawnTime-now+5 >= GetInstanceResetPeriod()) - respawnTime = now+YEAR; + if (GetInstanceResetPeriod() > 0 && respawnTime - now + 5 >= GetInstanceResetPeriod()) + respawnTime = now + YEAR; _creatureRespawnTimes[dbGuid] = respawnTime; @@ -3067,7 +3069,7 @@ void Map::SaveCreatureRespawnTime(uint32 dbGuid, time_t& respawnTime) } void Map::RemoveCreatureRespawnTime(uint32 dbGuid) -{ +{ _creatureRespawnTimes.erase(dbGuid); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CREATURE_RESPAWN); @@ -3078,7 +3080,7 @@ void Map::RemoveCreatureRespawnTime(uint32 dbGuid) } void Map::SaveGORespawnTime(uint32 dbGuid, time_t& respawnTime) -{ +{ if (!respawnTime) { // Delete only @@ -3087,8 +3089,8 @@ void Map::SaveGORespawnTime(uint32 dbGuid, time_t& respawnTime) } time_t now = time(nullptr); - if (GetInstanceResetPeriod() > 0 && respawnTime-now+5 >= GetInstanceResetPeriod()) - respawnTime = now+YEAR; + if (GetInstanceResetPeriod() > 0 && respawnTime - now + 5 >= GetInstanceResetPeriod()) + respawnTime = now + YEAR; _goRespawnTimes[dbGuid] = respawnTime; @@ -3101,7 +3103,7 @@ void Map::SaveGORespawnTime(uint32 dbGuid, time_t& respawnTime) } void Map::RemoveGORespawnTime(uint32 dbGuid) -{ +{ _goRespawnTimes.erase(dbGuid); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GO_RESPAWN); @@ -3112,7 +3114,7 @@ void Map::RemoveGORespawnTime(uint32 dbGuid) } void Map::LoadRespawnTimes() -{ +{ PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CREATURE_RESPAWNS); stmt->setUInt16(0, GetId()); stmt->setUInt32(1, GetInstanceId()); @@ -3145,7 +3147,7 @@ void Map::LoadRespawnTimes() } void Map::DeleteRespawnTimes() -{ +{ _creatureRespawnTimes.clear(); _goRespawnTimes.clear(); @@ -3166,8 +3168,8 @@ void Map::DeleteRespawnTimesInDB(uint16 mapId, uint32 instanceId) } void Map::UpdateEncounterState(EncounterCreditType type, uint32 creditEntry, Unit* source) -{ - Difficulty difficulty_fixed = (IsSharedDifficultyMap(GetId()) ? Difficulty(GetDifficulty()%2) : GetDifficulty()); +{ + Difficulty difficulty_fixed = (IsSharedDifficultyMap(GetId()) ? Difficulty(GetDifficulty() % 2) : GetDifficulty()); DungeonEncounterList const* encounters = sObjectMgr->GetDungeonEncounterList(GetId(), difficulty_fixed); if (!encounters) return; @@ -3181,9 +3183,10 @@ void Map::UpdateEncounterState(EncounterCreditType type, uint32 creditEntry, Uni if (encounter->creditType == type && encounter->creditEntry == creditEntry) { if (source) - if (InstanceScript* instanceScript = source->GetInstanceScript()) { + if (InstanceScript* instanceScript = source->GetInstanceScript()) + { uint32 prevMask = instanceScript->GetCompletedEncounterMask(); - instanceScript->SetCompletedEncountersMask((1 << encounter->dbcEntry->encounterIndex)|instanceScript->GetCompletedEncounterMask(), true); + instanceScript->SetCompletedEncountersMask((1 << encounter->dbcEntry->encounterIndex) | instanceScript->GetCompletedEncounterMask(), true); if (prevMask != instanceScript->GetCompletedEncounterMask()) updated = true; } @@ -3198,7 +3201,7 @@ void Map::UpdateEncounterState(EncounterCreditType type, uint32 creditEntry, Uni // pussywizard: LogEncounterFinished(type, creditEntry); - + sScriptMgr->OnAfterUpdateEncounterState(this, type, creditEntry, source, difficulty_fixed, encounters, dungeonId, updated); if (dungeonId) @@ -3278,7 +3281,7 @@ time_t Map::GetLinkedRespawnTime(uint64 guid) const } void Map::SendZoneDynamicInfo(Player* player) -{ +{ uint32 zoneId = GetZoneId(player->GetPositionX(), player->GetPositionY(), player->GetPositionZ()); ZoneDynamicInfoMap::const_iterator itr = _zoneDynamicInfo.find(zoneId); if (itr == _zoneDynamicInfo.end()) @@ -3326,7 +3329,7 @@ void Map::PlayDirectSoundToMap(uint32 soundId, uint32 zoneId) } void Map::SetZoneMusic(uint32 zoneId, uint32 musicId) -{ +{ if (_zoneDynamicInfo.find(zoneId) == _zoneDynamicInfo.end()) _zoneDynamicInfo.insert(ZoneDynamicInfoMap::value_type(zoneId, ZoneDynamicInfo())); @@ -3346,7 +3349,7 @@ void Map::SetZoneMusic(uint32 zoneId, uint32 musicId) } void Map::SetZoneWeather(uint32 zoneId, uint32 weatherId, float weatherGrade) -{ +{ if (_zoneDynamicInfo.find(zoneId) == _zoneDynamicInfo.end()) _zoneDynamicInfo.insert(ZoneDynamicInfoMap::value_type(zoneId, ZoneDynamicInfo())); @@ -3370,7 +3373,7 @@ void Map::SetZoneWeather(uint32 zoneId, uint32 weatherId, float weatherGrade) } void Map::SetZoneOverrideLight(uint32 zoneId, uint32 lightId, uint32 fadeInTime) -{ +{ if (_zoneDynamicInfo.find(zoneId) == _zoneDynamicInfo.end()) _zoneDynamicInfo.insert(ZoneDynamicInfoMap::value_type(zoneId, ZoneDynamicInfo())); |