diff options
author | Spp <none@none> | 2010-04-07 19:14:10 +0200 |
---|---|---|
committer | Spp <none@none> | 2010-04-07 19:14:10 +0200 |
commit | d19e12708001fbef2308be0e8cb5375a2ac7af48 (patch) | |
tree | 09fc8f67a6197802e0512950f0b0a3438a9834e8 /src/game/Map.cpp | |
parent | 2e127f7a30706dc1d40c65de22ff02851732da24 (diff) |
Code style (game + scripts only):
"if(" --> "if ("
--HG--
branch : trunk
Diffstat (limited to 'src/game/Map.cpp')
-rw-r--r-- | src/game/Map.cpp | 390 |
1 files changed, 195 insertions, 195 deletions
diff --git a/src/game/Map.cpp b/src/game/Map.cpp index 044f37da71d..a3b7eea375d 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -71,7 +71,7 @@ Map::~Map() obj->ResetMap(); } - if(!m_scriptSchedule.empty()) + if (!m_scriptSchedule.empty()) sWorld.DecreaseScheduledScriptCount(m_scriptSchedule.size()); } @@ -83,7 +83,7 @@ bool Map::ExistMap(uint32 mapid,int gx,int gy) FILE *pf=fopen(tmp,"rb"); - if(!pf) + if (!pf) { sLog.outError("Check existing of map file '%s': not exist!",tmp); delete[] tmp; @@ -108,13 +108,13 @@ bool Map::ExistMap(uint32 mapid,int gx,int gy) bool Map::ExistVMap(uint32 mapid,int gx,int gy) { - if(VMAP::IVMapManager* vmgr = VMAP::VMapFactory::createOrGetVMapManager()) + if (VMAP::IVMapManager* vmgr = VMAP::VMapFactory::createOrGetVMapManager()) { - if(vmgr->isMapLoadingEnabled()) + if (vmgr->isMapLoadingEnabled()) { // x and y are swapped !! => fixed now bool exists = vmgr->existsMap((sWorld.GetDataPath()+ "vmaps").c_str(), mapid, gx,gy); - if(!exists) + if (!exists) { std::string name = vmgr->getDirFileName(mapid,gx,gy); sLog.outError("VMap file '%s' is missing or point to wrong version vmap file, redo vmaps with latest vmap_assembler.exe program", (sWorld.GetDataPath()+"vmaps/"+name).c_str()); @@ -146,9 +146,9 @@ void Map::LoadVMap(int gx,int gy) void Map::LoadMap(int gx,int gy, bool reload) { - if( i_InstanceId != 0 ) + if ( i_InstanceId != 0 ) { - if(GridMaps[gx][gy]) + if (GridMaps[gx][gy]) return; // load grid map for base map @@ -160,11 +160,11 @@ void Map::LoadMap(int gx,int gy, bool reload) return; } - if(GridMaps[gx][gy] && !reload) + if (GridMaps[gx][gy] && !reload) return; //map already load, delete it before reloading (Is it necessary? Do we really need the ability the reload maps during runtime?) - if(GridMaps[gx][gy]) + if (GridMaps[gx][gy]) { sLog.outDetail("Unloading already loaded map %u before reloading.",GetId()); delete (GridMaps[gx][gy]); @@ -189,7 +189,7 @@ void Map::LoadMap(int gx,int gy, bool reload) void Map::LoadMapAndVMap(int gx,int gy) { LoadMap(gx,gy); - if(i_InstanceId == 0) + if (i_InstanceId == 0) LoadVMap(gx, gy); // Only load the data for the base map } @@ -242,7 +242,7 @@ void Map::InitVisibilityDistance() template<class T> void Map::AddToGrid(T* obj, NGridType *grid, Cell const& cell) { - if(obj->m_isWorldObject) + if (obj->m_isWorldObject) (*grid)(cell.CellX(), cell.CellY()).template AddWorldObject<T>(obj); else (*grid)(cell.CellX(), cell.CellY()).template AddGridObject<T>(obj); @@ -251,7 +251,7 @@ void Map::AddToGrid(T* obj, NGridType *grid, Cell const& cell) template<> void Map::AddToGrid(Creature* obj, NGridType *grid, Cell const& cell) { - if(obj->m_isWorldObject) + if (obj->m_isWorldObject) (*grid)(cell.CellX(), cell.CellY()).AddWorldObject(obj); else (*grid)(cell.CellX(), cell.CellY()).AddGridObject(obj); @@ -262,7 +262,7 @@ void Map::AddToGrid(Creature* obj, NGridType *grid, Cell const& cell) template<class T> void Map::RemoveFromGrid(T* obj, NGridType *grid, Cell const& cell) { - if(obj->m_isWorldObject) + if (obj->m_isWorldObject) (*grid)(cell.CellX(), cell.CellY()).template RemoveWorldObject<T>(obj); else (*grid)(cell.CellX(), cell.CellY()).template RemoveGridObject<T>(obj); @@ -272,14 +272,14 @@ template<class T> void Map::SwitchGridContainers(T* obj, bool on) { CellPair p = Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY()); - if(p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP ) + if (p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP ) { sLog.outError("Map::SwitchGridContainers: Object " I64FMT " have invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUID(), obj->GetPositionX(), obj->GetPositionY(), p.x_coord, p.y_coord); return; } Cell cell(p); - if( !loaded(GridPair(cell.data.Part.grid_x, cell.data.Part.grid_y)) ) + if ( !loaded(GridPair(cell.data.Part.grid_x, cell.data.Part.grid_y)) ) return; DEBUG_LOG("Switch object " I64FMT " from grid[%u,%u] %u", obj->GetGUID(), cell.data.Part.grid_x, cell.data.Part.grid_y, on); @@ -288,11 +288,11 @@ void Map::SwitchGridContainers(T* obj, bool on) GridType &grid = (*ngrid)(cell.CellX(), cell.CellY()); - if(on) + if (on) { grid.RemoveGridObject<T>(obj); grid.AddWorldObject<T>(obj); - /*if(!grid.RemoveGridObject<T>(obj, obj->GetGUID()) + /*if (!grid.RemoveGridObject<T>(obj, obj->GetGUID()) || !grid.AddWorldObject<T>(obj, obj->GetGUID())) { assert(false); @@ -302,7 +302,7 @@ void Map::SwitchGridContainers(T* obj, bool on) { grid.RemoveWorldObject<T>(obj); grid.AddGridObject<T>(obj); - /*if(!grid.RemoveWorldObject<T>(obj, obj->GetGUID()) + /*if (!grid.RemoveWorldObject<T>(obj, obj->GetGUID()) || !grid.AddGridObject<T>(obj, obj->GetGUID())) { assert(false); @@ -331,10 +331,10 @@ void Map::DeleteFromWorld(Player* pl) void Map::EnsureGridCreated(const GridPair &p) { - if(!getNGrid(p.x_coord, p.y_coord)) + if (!getNGrid(p.x_coord, p.y_coord)) { Guard guard(*this); - if(!getNGrid(p.x_coord, p.y_coord)) + if (!getNGrid(p.x_coord, p.y_coord)) { sLog.outDebug("Creating grid[%u,%u] for map %u instance %u", p.x_coord, p.y_coord, GetId(), i_InstanceId); @@ -350,7 +350,7 @@ Map::EnsureGridCreated(const GridPair &p) int gx = (MAX_NUMBER_OF_GRIDS - 1) - p.x_coord; int gy = (MAX_NUMBER_OF_GRIDS - 1) - p.y_coord; - if(!GridMaps[gx][gy]) + if (!GridMaps[gx][gy]) LoadMapAndVMap(gx,gy); } } @@ -373,7 +373,7 @@ Map::EnsureGridLoadedAtEnter(const Cell &cell, Player *player) } // refresh grid state & timer - if( grid->GetGridState() != GRID_STATE_ACTIVE ) + if ( grid->GetGridState() != GRID_STATE_ACTIVE ) { ResetGridExpiry(*grid, 0.1f); grid->SetGridState(GRID_STATE_ACTIVE); @@ -386,7 +386,7 @@ bool Map::EnsureGridLoaded(const Cell &cell) NGridType *grid = getNGrid(cell.GridX(), cell.GridY()); assert(grid != NULL); - if( !isGridObjectDataLoaded(cell.GridX(), cell.GridY()) ) + if ( !isGridObjectDataLoaded(cell.GridX(), cell.GridY()) ) { sLog.outDebug("Loading grid[%u,%u] for map %u instance %u", cell.GridX(), cell.GridY(), GetId(), i_InstanceId); @@ -415,7 +415,7 @@ bool Map::Add(Player *player) // Check if we are adding to correct map assert (player->GetMap() == this); CellPair p = Trinity::ComputeCellPair(player->GetPositionX(), player->GetPositionY()); - if(p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP ) + if (p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP ) { sLog.outError("Map::Add: Player (GUID: %u) have invalid coordinates X:%f Y:%f grid cell [%u:%u]", player->GetGUIDLow(), player->GetPositionX(), player->GetPositionY(), p.x_coord, p.y_coord); return false; @@ -445,20 +445,20 @@ void Map::Add(T *obj) { CellPair p = Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY()); - if(p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP ) + if (p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP ) { sLog.outError("Map::Add: Object " UI64FMTD " have invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUID(), obj->GetPositionX(), obj->GetPositionY(), p.x_coord, p.y_coord); return; } Cell cell(p); - if(obj->IsInWorld()) // need some clean up later + if (obj->IsInWorld()) // need some clean up later { obj->UpdateObjectVisibility(true); return; } - if(obj->isActiveObject()) + if (obj->isActiveObject()) EnsureGridLoadedAtEnter(cell); else EnsureGridCreated(GridPair(cell.GridX(), cell.GridY())); @@ -470,7 +470,7 @@ Map::Add(T *obj) //obj->SetMap(this); obj->AddToWorld(); - if(obj->isActiveObject()) + if (obj->isActiveObject()) AddToActive(obj); DEBUG_LOG("Object %u enters grid[%u,%u]", GUID_LOPART(obj->GetGUID()), cell.GridX(), cell.GridY()); @@ -485,7 +485,7 @@ void Map::MessageBroadcast(Player *player, WorldPacket *msg, bool to_self) { CellPair p = Trinity::ComputeCellPair(player->GetPositionX(), player->GetPositionY()); - if(p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP ) + if (p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP ) { sLog.outError("Map::MessageBroadcast: Player (GUID: %u) have invalid coordinates X:%f Y:%f grid cell [%u:%u]", player->GetGUIDLow(), player->GetPositionX(), player->GetPositionY(), p.x_coord, p.y_coord); return; @@ -495,7 +495,7 @@ void Map::MessageBroadcast(Player *player, WorldPacket *msg, bool to_self) cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); - if( !loaded(GridPair(cell.data.Part.grid_x, cell.data.Part.grid_y)) ) + if ( !loaded(GridPair(cell.data.Part.grid_x, cell.data.Part.grid_y)) ) return; Trinity::MessageDeliverer post_man(*player, msg, to_self); @@ -508,7 +508,7 @@ void Map::MessageBroadcast(WorldObject *obj, WorldPacket *msg) { CellPair p = Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY()); - if(p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP ) + if (p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP ) { sLog.outError("Map::MessageBroadcast: Object (GUID: %u TypeId: %u) have invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUIDLow(), obj->GetTypeId(), obj->GetPositionX(), obj->GetPositionY(), p.x_coord, p.y_coord); return; @@ -518,7 +518,7 @@ void Map::MessageBroadcast(WorldObject *obj, WorldPacket *msg) cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); - if( !loaded(GridPair(cell.data.Part.grid_x, cell.data.Part.grid_y)) ) + if ( !loaded(GridPair(cell.data.Part.grid_x, cell.data.Part.grid_y)) ) return; //TODO: currently on continents when Visibility.Distance.InFlight > Visibility.Distance.Continents @@ -533,7 +533,7 @@ void Map::MessageDistBroadcast(Player *player, WorldPacket *msg, float dist, boo { CellPair p = Trinity::ComputeCellPair(player->GetPositionX(), player->GetPositionY()); - if(p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP ) + if (p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP ) { sLog.outError("Map::MessageBroadcast: Player (GUID: %u) have invalid coordinates X:%f Y:%f grid cell [%u:%u]", player->GetGUIDLow(), player->GetPositionX(), player->GetPositionY(), p.x_coord, p.y_coord); return; @@ -543,7 +543,7 @@ void Map::MessageDistBroadcast(Player *player, WorldPacket *msg, float dist, boo cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); - if( !loaded(GridPair(cell.data.Part.grid_x, cell.data.Part.grid_y)) ) + if ( !loaded(GridPair(cell.data.Part.grid_x, cell.data.Part.grid_y)) ) return; Trinity::MessageDistDeliverer post_man(*player, msg, dist, to_self, own_team_only); @@ -556,7 +556,7 @@ void Map::MessageDistBroadcast(WorldObject *obj, WorldPacket *msg, float dist) { CellPair p = Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY()); - if(p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP ) + if (p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP ) { sLog.outError("Map::MessageBroadcast: Object (GUID: %u TypeId: %u) have invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUIDLow(), obj->GetTypeId(), obj->GetPositionX(), obj->GetPositionY(), p.x_coord, p.y_coord); return; @@ -566,7 +566,7 @@ void Map::MessageDistBroadcast(WorldObject *obj, WorldPacket *msg, float dist) cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); - if( !loaded(GridPair(cell.data.Part.grid_x, cell.data.Part.grid_y)) ) + if ( !loaded(GridPair(cell.data.Part.grid_x, cell.data.Part.grid_y)) ) return; Trinity::ObjectMessageDistDeliverer post_man(*obj, msg, dist); @@ -587,7 +587,7 @@ void Map::Update(const uint32 &t_diff) for (m_mapRefIter = m_mapRefManager.begin(); m_mapRefIter != m_mapRefManager.end(); ++m_mapRefIter) { Player* plr = m_mapRefIter->getSource(); - if(plr && plr->IsInWorld()) + if (plr && plr->IsInWorld()) plr->Update(t_diff); } @@ -702,7 +702,7 @@ void Map::Update(const uint32 &t_diff) MoveAllCreaturesInMoveList(); - if(!m_mapRefManager.isEmpty() || !m_activeNonPlayers.empty()) + if (!m_mapRefManager.isEmpty() || !m_activeNonPlayers.empty()) ProcessRelocationNotifies(t_diff); } @@ -741,7 +741,7 @@ void Map::ProcessRelocationNotifies(const uint32 & diff) for (uint32 y = cell_min.y_coord; y < cell_max.y_coord; ++y) { uint32 cell_id = (y * TOTAL_NUMBER_OF_CELLS_PER_MAP) + x; - if(!isCellMarked(cell_id)) + if (!isCellMarked(cell_id)) continue; CellPair pair(x,y); @@ -782,7 +782,7 @@ void Map::ProcessRelocationNotifies(const uint32 & diff) for (uint32 y = cell_min.y_coord; y < cell_max.y_coord; ++y) { uint32 cell_id = (y * TOTAL_NUMBER_OF_CELLS_PER_MAP) + x; - if(!isCellMarked(cell_id)) + if (!isCellMarked(cell_id)) continue; CellPair pair(x,y); @@ -801,7 +801,7 @@ void Map::Remove(Player *player, bool remove) SendRemoveTransports(player); CellPair p = Trinity::ComputeCellPair(player->GetPositionX(), player->GetPositionY()); - if(p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP) + if (p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP) sLog.outCrash("Map::Remove: Player is in invalid cell!"); else { @@ -866,7 +866,7 @@ Map::Remove(T *obj, bool remove) if (remove) { // if option set then object already saved at this moment - if(!sWorld.getConfig(CONFIG_SAVE_RESPAWN_TIME_IMMEDIATELY)) + if (!sWorld.getConfig(CONFIG_SAVE_RESPAWN_TIME_IMMEDIATELY)) obj->SaveRespawnTime(); DeleteFromWorld(obj); } @@ -892,7 +892,7 @@ Map::PlayerRelocation(Player *player, float x, float y, float z, float orientati NGridType* oldGrid = getNGrid(old_cell.GridX(), old_cell.GridY()); RemoveFromGrid(player, oldGrid,old_cell); - if( old_cell.DiffGrid(new_cell) ) + if ( old_cell.DiffGrid(new_cell) ) EnsureGridLoadedAtEnter(new_cell, player); NGridType* newGrid = getNGrid(new_cell.GridX(), new_cell.GridY()); @@ -987,7 +987,7 @@ bool Map::CreatureCellRelocation(Creature *c, Cell new_cell) if (old_cell.DiffCell(new_cell)) { #ifdef TRINITY_DEBUG - if((sLog.getLogFilter() & LOG_FILTER_CREATURE_MOVES)==0) + if ((sLog.getLogFilter() & LOG_FILTER_CREATURE_MOVES)==0) sLog.outDebug("Creature (GUID: %u Entry: %u) moved in grid[%u,%u] from cell[%u,%u] to cell[%u,%u].", c->GetGUIDLow(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.CellX(), new_cell.CellY()); #endif @@ -997,7 +997,7 @@ bool Map::CreatureCellRelocation(Creature *c, Cell new_cell) else { #ifdef TRINITY_DEBUG - if((sLog.getLogFilter() & LOG_FILTER_CREATURE_MOVES)==0) + if ((sLog.getLogFilter() & LOG_FILTER_CREATURE_MOVES)==0) sLog.outDebug("Creature (GUID: %u Entry: %u) move in same grid[%u,%u]cell[%u,%u].", c->GetGUIDLow(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY()); #endif } @@ -1011,7 +1011,7 @@ bool Map::CreatureCellRelocation(Creature *c, Cell new_cell) EnsureGridLoadedAtEnter(new_cell); #ifdef TRINITY_DEBUG - if((sLog.getLogFilter() & LOG_FILTER_CREATURE_MOVES)==0) + if ((sLog.getLogFilter() & LOG_FILTER_CREATURE_MOVES)==0) sLog.outDebug("Active creature (GUID: %u Entry: %u) moved from grid[%u,%u]cell[%u,%u] to grid[%u,%u]cell[%u,%u].", c->GetGUIDLow(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY()); #endif @@ -1025,7 +1025,7 @@ bool Map::CreatureCellRelocation(Creature *c, Cell new_cell) if (loaded(GridPair(new_cell.GridX(), new_cell.GridY()))) { #ifdef TRINITY_DEBUG - if((sLog.getLogFilter() & LOG_FILTER_CREATURE_MOVES)==0) + if ((sLog.getLogFilter() & LOG_FILTER_CREATURE_MOVES)==0) sLog.outDebug("Creature (GUID: %u Entry: %u) moved from grid[%u,%u]cell[%u,%u] to grid[%u,%u]cell[%u,%u].", c->GetGUIDLow(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY()); #endif @@ -1056,12 +1056,12 @@ bool Map::CreatureRespawnRelocation(Creature *c) c->GetMotionMaster()->Clear(); #ifdef TRINITY_DEBUG - if((sLog.getLogFilter() & LOG_FILTER_CREATURE_MOVES)==0) + if ((sLog.getLogFilter() & LOG_FILTER_CREATURE_MOVES)==0) sLog.outDebug("Creature (GUID: %u Entry: %u) will moved from grid[%u,%u]cell[%u,%u] to respawn grid[%u,%u]cell[%u,%u].", c->GetGUIDLow(), c->GetEntry(), c->GetCurrentCell().GridX(), c->GetCurrentCell().GridY(), c->GetCurrentCell().CellX(), c->GetCurrentCell().CellY(), resp_cell.GridX(), resp_cell.GridY(), resp_cell.CellX(), resp_cell.CellY()); #endif // teleport it to respawn point (like normal respawn if player see) - if(CreatureCellRelocation(c,resp_cell)) + if (CreatureCellRelocation(c,resp_cell)) { c->Relocate(resp_x, resp_y, resp_z, resp_o); c->GetMotionMaster()->Initialize(); // prevent possible problems with default move generators @@ -1079,14 +1079,14 @@ bool Map::UnloadGrid(const uint32 &x, const uint32 &y, bool unloadAll) assert( grid != NULL); { - if(!unloadAll && ActiveObjectsNearGrid(x, y) ) + if (!unloadAll && ActiveObjectsNearGrid(x, y) ) return false; sLog.outDebug("Unloading grid[%u,%u] for map %u", x,y, GetId()); ObjectGridUnloader unloader(*grid); - if(!unloadAll) + if (!unloadAll) { // Finish creature moves, remove and delete all creatures with delayed remove before moving to respawn grids // Must know real mob position before move @@ -1119,7 +1119,7 @@ bool Map::UnloadGrid(const uint32 &x, const uint32 &y, bool unloadAll) { if (i_InstanceId == 0) { - if(GridMaps[gx][gy]) + if (GridMaps[gx][gy]) { GridMaps[gx][gy]->unloadData(); delete GridMaps[gx][gy]; @@ -1138,12 +1138,12 @@ bool Map::UnloadGrid(const uint32 &x, const uint32 &y, bool unloadAll) void Map::RemoveAllPlayers() { - if(HavePlayers()) + if (HavePlayers()) { for (MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) { Player* plr = itr->getSource(); - if(!plr->IsBeingTeleportedFar()) + if (!plr->IsBeingTeleportedFar()) { // this is happening for bg sLog.outError("Map::UnloadAll: player %s is still in map %u during unload, should not happen!", plr->GetName(), GetId()); @@ -1685,12 +1685,12 @@ float Map::GetHeight(float x, float y, float z, bool pUseVmaps) const { // find raw .map surface under Z coordinates float mapHeight; - if(GridMap *gmap = const_cast<Map*>(this)->GetGrid(x, y)) + if (GridMap *gmap = const_cast<Map*>(this)->GetGrid(x, y)) { float _mapheight = gmap->getHeight(x,y); // look from a bit higher pos to find the floor, ignore under surface case - if(z + 2.0f > _mapheight) + if (z + 2.0f > _mapheight) mapHeight = _mapheight; else mapHeight = VMAP_INVALID_HEIGHT_VALUE; @@ -1699,10 +1699,10 @@ float Map::GetHeight(float x, float y, float z, bool pUseVmaps) const mapHeight = VMAP_INVALID_HEIGHT_VALUE; float vmapHeight; - if(pUseVmaps) + if (pUseVmaps) { VMAP::IVMapManager* vmgr = VMAP::VMapFactory::createOrGetVMapManager(); - if(vmgr->isHeightCalcEnabled()) + if (vmgr->isHeightCalcEnabled()) { // look from a bit higher pos to find the floor vmapHeight = vmgr->getHeight(GetId(), x, y, z + 2.0f); @@ -1716,15 +1716,15 @@ float Map::GetHeight(float x, float y, float z, bool pUseVmaps) const // mapHeight set for any above raw ground Z or <= INVALID_HEIGHT // vmapheight set for any under Z value or <= INVALID_HEIGHT - if( vmapHeight > INVALID_HEIGHT ) + if ( vmapHeight > INVALID_HEIGHT ) { - if( mapHeight > INVALID_HEIGHT ) + if ( mapHeight > INVALID_HEIGHT ) { // we have mapheight and vmapheight and must select more appropriate // 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( z < mapHeight || vmapHeight > mapHeight || fabs(mapHeight-z) > fabs(vmapHeight-z) ) + if ( z < mapHeight || vmapHeight > mapHeight || fabs(mapHeight-z) > fabs(vmapHeight-z) ) return vmapHeight; else return mapHeight; // better use .map surface height @@ -1735,9 +1735,9 @@ float Map::GetHeight(float x, float y, float z, bool pUseVmaps) const } else { - if(!pUseVmaps) + if (!pUseVmaps) return mapHeight; // explicitly use map data (if have) - else if(mapHeight > INVALID_HEIGHT && (z < mapHeight + 2 || z == MAX_HEIGHT)) + else if (mapHeight > INVALID_HEIGHT && (z < mapHeight + 2 || z == MAX_HEIGHT)) return mapHeight; // explicitly use map data if original z < mapHeight but map found (z+2 > mapHeight) else return VMAP_INVALID_HEIGHT_VALUE; // we not have any height @@ -1766,7 +1766,7 @@ float Map::GetVmapHeight(float x, float y, float z) const uint16 Map::GetAreaFlag(float x, float y, float z) const { uint16 areaflag; - if(GridMap *gmap = const_cast<Map*>(this)->GetGrid(x, y)) + if (GridMap *gmap = const_cast<Map*>(this)->GetGrid(x, y)) areaflag = gmap->getArea(x, y); // this used while not all *.map files generated (instances) else @@ -1809,18 +1809,18 @@ uint16 Map::GetAreaFlag(float x, float y, float z) const case 1984: // Plaguelands: The Scarlet Enclave case 2076: // Death's Breach (Plaguelands: The Scarlet Enclave) case 2745: // The Noxious Pass (Plaguelands: The Scarlet Enclave) - if(z > 350.0f) areaflag = 2048; break; + if (z > 350.0f) areaflag = 2048; break; // Acherus: The Ebon Hold (Eastern Plaguelands) case 856: // The Noxious Glade (Eastern Plaguelands) case 2456: // Death's Breach (Eastern Plaguelands) - if(z > 350.0f) areaflag = 1950; break; + if (z > 350.0f) areaflag = 1950; break; // Dalaran case 2492: // Forlorn Woods (Crystalsong Forest) case 2371: // Valley of Echoes (Icecrown Glacier) if (x > 5568.0f && x < 6022.0f && y > 374.0f && y < 918.0f && z > 563.0f) { areaflag = 2153; - if(y - 1.41f * x + 7649.55f > 0) // Violet Hold + if (y - 1.41f * x + 7649.55f > 0) // Violet Hold { if (y < 595.0f) areaflag = 2540; @@ -1906,7 +1906,7 @@ uint16 Map::GetAreaFlag(float x, float y, float z) const // Undercity (cave and ground zone, part of royal quarter) case 607: // Ruins of Lordaeron (Tirisfal Glades) // ground and near to ground (by city walls) - if(z > 0.0f) + if (z > 0.0f) { if (x > 1510.0f && x < 1839.0f && y > 29.77f && y < 433.0f) areaflag = 685; } @@ -1928,7 +1928,7 @@ uint16 Map::GetAreaFlag(float x, float y, float z) const // Makers' Overlook (ground and cave) else if (x > 5634.48f && x < 5774.53f && y < 3475.0f && z > 300.0f) { - if(y > 3380.26f || (y > 3265.0f && z < 360.0f)) + if (y > 3380.26f || (y > 3265.0f && z < 360.0f)) areaflag = 2187; } break; @@ -1955,7 +1955,7 @@ uint16 Map::GetAreaFlag(float x, float y, float z) const uint8 Map::GetTerrainType(float x, float y ) const { - if(GridMap *gmap = const_cast<Map*>(this)->GetGrid(x, y)) + if (GridMap *gmap = const_cast<Map*>(this)->GetGrid(x, y)) return gmap->getTerrainType(x, y); else return 0; @@ -1963,7 +1963,7 @@ uint8 Map::GetTerrainType(float x, float y ) const ZLiquidStatus Map::getLiquidStatus(float x, float y, float z, uint8 ReqLiquidType, LiquidData *data) const { - if(GridMap* gmap = const_cast<Map*>(this)->GetGrid(x, y)) + if (GridMap* gmap = const_cast<Map*>(this)->GetGrid(x, y)) return gmap->getLiquidStatus(x, y, z, ReqLiquidType, data); else return LIQUID_MAP_NO_WATER; @@ -1971,7 +1971,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)) + if (GridMap* gmap = const_cast<Map*>(this)->GetGrid(x, y)) return gmap->getLiquidLevel(x, y); else return 0; @@ -1991,7 +1991,7 @@ uint32 Map::GetZoneIdByAreaFlag(uint16 areaflag,uint32 map_id) { AreaTableEntry const *entry = GetAreaEntryByAreaFlagAndMap(areaflag,map_id); - if( entry ) + if ( entry ) return ( entry->zone != 0 ) ? entry->zone : entry->ID; else return 0; @@ -2036,7 +2036,7 @@ bool Map::CheckGridIntegrity(Creature* c, bool moved) const CellPair xy_val = Trinity::ComputeCellPair(c->GetPositionX(), c->GetPositionY()); Cell xy_cell(xy_val); - if(xy_cell != cur_cell) + if (xy_cell != cur_cell) { sLog.outDebug("Creature (GUID: %u) X: %f Y: %f (%s) in grid[%u,%u]cell[%u,%u] instead grid[%u,%u]cell[%u,%u]", c->GetGUIDLow(), @@ -2111,7 +2111,7 @@ void Map::SendInitSelf( Player * player ) UpdateData data; // attach to player data current transport data - if(Transport* transport = player->GetTransport()) + if (Transport* transport = player->GetTransport()) { transport->BuildCreateUpdateBlockForPlayer(&data, player); } @@ -2120,11 +2120,11 @@ void Map::SendInitSelf( Player * player ) player->BuildCreateUpdateBlockForPlayer(&data, player); // build other passengers at transport also (they always visible and marked as visible and will not send at visibility update at add to map - if(Transport* transport = player->GetTransport()) + if (Transport* transport = player->GetTransport()) { for (Transport::PlayerSet::const_iterator itr = transport->GetPassengers().begin(); itr!=transport->GetPassengers().end(); ++itr) { - if(player!=(*itr) && player->HaveAtClient(*itr)) + if (player!=(*itr) && player->HaveAtClient(*itr)) { (*itr)->BuildCreateUpdateBlockForPlayer(&data, player); } @@ -2152,7 +2152,7 @@ void Map::SendInitTransports( Player * player ) for (MapManager::TransportSet::const_iterator i = tset.begin(); i != tset.end(); ++i) { // send data for current transport in other place - if((*i) != player->GetTransport() && (*i)->GetMapId()==GetId()) + if ((*i) != player->GetTransport() && (*i)->GetMapId()==GetId()) { (*i)->BuildCreateUpdateBlockForPlayer(&transData, player); } @@ -2178,7 +2178,7 @@ void Map::SendRemoveTransports( Player * player ) // except used transport for (MapManager::TransportSet::const_iterator i = tset.begin(); i != tset.end(); ++i) - if((*i) != player->GetTransport() && (*i)->GetMapId()!=GetId()) + if ((*i) != player->GetTransport() && (*i)->GetMapId()!=GetId()) (*i)->BuildOutOfRangeUpdateBlock(&transData); WorldPacket packet; @@ -2188,7 +2188,7 @@ void Map::SendRemoveTransports( Player * player ) inline void Map::setNGrid(NGridType *grid, uint32 x, uint32 y) { - if(x >= MAX_NUMBER_OF_GRIDS || y >= MAX_NUMBER_OF_GRIDS) + if (x >= MAX_NUMBER_OF_GRIDS || y >= MAX_NUMBER_OF_GRIDS) { sLog.outError("map::setNGrid() Invalid grid coordinates found: %d, %d!",x,y); assert(false); @@ -2230,9 +2230,9 @@ void Map::AddObjectToSwitchList(WorldObject *obj, bool on) assert(obj->GetMapId()==GetId() && obj->GetInstanceId()==GetInstanceId()); std::map<WorldObject*, bool>::iterator itr = i_objectsToSwitch.find(obj); - if(itr == i_objectsToSwitch.end()) + if (itr == i_objectsToSwitch.end()) i_objectsToSwitch.insert(itr, std::make_pair(obj, on)); - else if(itr->second != on) + else if (itr->second != on) i_objectsToSwitch.erase(itr); else assert(false); @@ -2250,7 +2250,7 @@ void Map::RemoveAllObjectsInRemoveList() switch(obj->GetTypeId()) { case TYPEID_UNIT: - if(!obj->ToCreature()->isPet()) + if (!obj->ToCreature()->isPet()) SwitchGridContainers(obj->ToCreature(), on); break; } @@ -2300,7 +2300,7 @@ uint32 Map::GetPlayersCountExceptGMs() const { uint32 count = 0; for (MapRefManager::const_iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) - if(!itr->getSource()->isGameMaster()) + if (!itr->getSource()->isGameMaster()) ++count; return count; } @@ -2356,12 +2356,12 @@ void Map::AddToActive( Creature* c ) AddToActiveHelper(c); // also not allow unloading spawn grid to prevent creating creature clone at load - if(!c->isPet() && c->GetDBTableGUIDLow()) + if (!c->isPet() && c->GetDBTableGUIDLow()) { float x,y,z; c->GetRespawnCoord(x,y,z); GridPair p = Trinity::ComputeGridPair(x, y); - if(getNGrid(p.x_coord, p.y_coord)) + if (getNGrid(p.x_coord, p.y_coord)) getNGrid(p.x_coord, p.y_coord)->incUnloadActiveLock(); else { @@ -2377,12 +2377,12 @@ void Map::RemoveFromActive( Creature* c ) RemoveFromActiveHelper(c); // also allow unloading spawn grid - if(!c->isPet() && c->GetDBTableGUIDLow()) + if (!c->isPet() && c->GetDBTableGUIDLow()) { float x,y,z; c->GetRespawnCoord(x,y,z); GridPair p = Trinity::ComputeGridPair(x, y); - if(getNGrid(p.x_coord, p.y_coord)) + if (getNGrid(p.x_coord, p.y_coord)) getNGrid(p.x_coord, p.y_coord)->decUnloadActiveLock(); else { @@ -2420,7 +2420,7 @@ InstanceMap::InstanceMap(uint32 id, time_t expiry, uint32 InstanceId, uint8 Spaw InstanceMap::~InstanceMap() { - if(i_data) + if (i_data) { delete i_data; i_data = NULL; @@ -2439,7 +2439,7 @@ void InstanceMap::InitVisibilityDistance() */ bool InstanceMap::CanEnter(Player *player) { - if(player->GetMapRef().getTarget() == this) + if (player->GetMapRef().getTarget() == this) { sLog.outError("InstanceMap::CanEnter - player %s(%u) already in map %d,%d,%d!", player->GetName(), player->GetGUIDLow(), GetId(), GetInstanceId(), GetSpawnMode()); assert(false); @@ -2461,7 +2461,7 @@ bool InstanceMap::CanEnter(Player *player) // cannot enter while an encounter is in progress on raids /*Group *pGroup = player->GetGroup(); - if(!player->isGameMaster() && pGroup && pGroup->InCombatToInstance(GetInstanceId()) && player->GetMapId() != GetId())*/ + if (!player->isGameMaster() && pGroup && pGroup->InCombatToInstance(GetInstanceId()) && player->GetMapId() != GetId())*/ if (IsRaid() && GetInstanceData() && GetInstanceData()->IsEncounterInProgress()) { player->SendTransferAborted(GetId(), TRANSFER_ABORT_ZONE_IN_COMBAT); @@ -2483,15 +2483,15 @@ bool InstanceMap::Add(Player *player) { Guard guard(*this); // Check moved to void WorldSession::HandleMoveWorldportAckOpcode() - //if(!CanEnter(player)) + //if (!CanEnter(player)) //return false; // Dungeon only code - if(IsDungeon()) + if (IsDungeon()) { // get or create an instance save for the map InstanceSave *mapSave = sInstanceSaveManager.GetInstanceSave(GetInstanceId()); - if(!mapSave) + if (!mapSave) { sLog.outDetail("InstanceMap::Add: creating instance save for map %d spawnmode %d with instance id %d", GetId(), GetSpawnMode(), GetInstanceId()); mapSave = sInstanceSaveManager.AddInstanceSave(GetId(), GetInstanceId(), Difficulty(GetSpawnMode()), 0, true); @@ -2499,10 +2499,10 @@ bool InstanceMap::Add(Player *player) // check for existing instance binds InstancePlayerBind *playerBind = player->GetBoundInstance(GetId(), Difficulty(GetSpawnMode())); - if(playerBind && playerBind->perm) + if (playerBind && playerBind->perm) { // cannot enter other instances if bound permanently - if(playerBind->save != mapSave) + if (playerBind->save != mapSave) { sLog.outError("InstanceMap::Add: player %s(%d) is permanently bound to instance %d,%d,%d,%d,%d,%d but he is being put in instance %d,%d,%d,%d,%d,%d", player->GetName(), player->GetGUIDLow(), playerBind->save->GetMapId(), playerBind->save->GetInstanceId(), playerBind->save->GetDifficulty(), playerBind->save->GetPlayerCount(), playerBind->save->GetGroupCount(), playerBind->save->CanReset(), mapSave->GetMapId(), mapSave->GetInstanceId(), mapSave->GetDifficulty(), mapSave->GetPlayerCount(), mapSave->GetGroupCount(), mapSave->CanReset()); return false; @@ -2511,31 +2511,31 @@ bool InstanceMap::Add(Player *player) else { Group *pGroup = player->GetGroup(); - if(pGroup) + if (pGroup) { // solo saves should be reset when entering a group InstanceGroupBind *groupBind = pGroup->GetBoundInstance(this); - if(playerBind) + if (playerBind) { sLog.outError("InstanceMap::Add: player %s(%d) is being put in instance %d,%d,%d,%d,%d,%d but he is in group %d and is bound to instance %d,%d,%d,%d,%d,%d!", player->GetName(), player->GetGUIDLow(), mapSave->GetMapId(), mapSave->GetInstanceId(), mapSave->GetDifficulty(), mapSave->GetPlayerCount(), mapSave->GetGroupCount(), mapSave->CanReset(), GUID_LOPART(pGroup->GetLeaderGUID()), playerBind->save->GetMapId(), playerBind->save->GetInstanceId(), playerBind->save->GetDifficulty(), playerBind->save->GetPlayerCount(), playerBind->save->GetGroupCount(), playerBind->save->CanReset()); - if(groupBind) sLog.outError("InstanceMap::Add: the group is bound to instance %d,%d,%d,%d,%d,%d", groupBind->save->GetMapId(), groupBind->save->GetInstanceId(), groupBind->save->GetDifficulty(), groupBind->save->GetPlayerCount(), groupBind->save->GetGroupCount(), groupBind->save->CanReset()); + if (groupBind) sLog.outError("InstanceMap::Add: the group is bound to instance %d,%d,%d,%d,%d,%d", groupBind->save->GetMapId(), groupBind->save->GetInstanceId(), groupBind->save->GetDifficulty(), groupBind->save->GetPlayerCount(), groupBind->save->GetGroupCount(), groupBind->save->CanReset()); //assert(false); return false; } // bind to the group or keep using the group save - if(!groupBind) + if (!groupBind) pGroup->BindToInstance(mapSave, false); else { // cannot jump to a different instance without resetting it - if(groupBind->save != mapSave) + if (groupBind->save != mapSave) { sLog.outError("InstanceMap::Add: player %s(%d) is being put in instance %d,%d,%d but he is in group %d which is bound to instance %d,%d,%d!", player->GetName(), player->GetGUIDLow(), mapSave->GetMapId(), mapSave->GetInstanceId(), mapSave->GetDifficulty(), GUID_LOPART(pGroup->GetLeaderGUID()), groupBind->save->GetMapId(), groupBind->save->GetInstanceId(), groupBind->save->GetDifficulty()); - if(mapSave) + if (mapSave) sLog.outError("MapSave players: %d, group count: %d", mapSave->GetPlayerCount(), mapSave->GetGroupCount()); else sLog.outError("MapSave NULL"); - if(groupBind->save) + if (groupBind->save) sLog.outError("GroupBind save players: %d, group count: %d", groupBind->save->GetPlayerCount(), groupBind->save->GetGroupCount()); else sLog.outError("GroupBind save NULL"); @@ -2543,7 +2543,7 @@ bool InstanceMap::Add(Player *player) } // if the group/leader is permanently bound to the instance // players also become permanently bound when they enter - if(groupBind->perm) + if (groupBind->perm) { WorldPacket data(SMSG_INSTANCE_SAVE_CREATED, 4); data << uint32(0); @@ -2555,7 +2555,7 @@ bool InstanceMap::Add(Player *player) else { // set up a solo bind or continue using it - if(!playerBind) + if (!playerBind) player->BindToInstance(mapSave, false); else // cannot jump to a different instance without resetting it @@ -2731,7 +2731,7 @@ void InstanceMap::SetResetSchedule(bool on) // only for normal instances // the reset time is only scheduled when there are no payers inside // it is assumed that the reset time will rarely (if ever) change while the reset is scheduled - if(IsDungeon() && !HavePlayers() && !IsRaidOrHeroicDungeon()) + if (IsDungeon() && !HavePlayers() && !IsRaidOrHeroicDungeon()) { InstanceSave *save = sInstanceSaveManager.GetInstanceSave(GetInstanceId()); if (!save) sLog.outError("InstanceMap::SetResetSchedule: cannot turn schedule %s, no save available for instance %d of %d", on ? "on" : "off", GetInstanceId(), GetId()); @@ -2746,9 +2746,9 @@ MapDifficulty const* InstanceMap::GetMapDifficulty() const uint32 InstanceMap::GetMaxPlayers() const { - if(MapDifficulty const* mapDiff = GetMapDifficulty()) + if (MapDifficulty const* mapDiff = GetMapDifficulty()) { - if(mapDiff->maxPlayers || IsRegularDifficulty()) // Normal case (expect that regular difficulty always have correct maxplayers) + if (mapDiff->maxPlayers || IsRegularDifficulty()) // Normal case (expect that regular difficulty always have correct maxplayers) return mapDiff->maxPlayers; else // DBC have 0 maxplayers for heroic instances with expansion < 2 { // The heroic entry exists, so we don't have to check anything, simply return normal max players @@ -2808,7 +2808,7 @@ bool BattleGroundMap::Add(Player * player) { Guard guard(*this); //Check moved to void WorldSession::HandleMoveWorldportAckOpcode() - //if(!CanEnter(player)) + //if (!CanEnter(player)) //return false; // reset instance validity, battleground maps do not homebind player->m_InstanceValid = true; @@ -2896,7 +2896,7 @@ void Map::ScriptCommandStart(ScriptInfo const& script, uint32 delay, Object* sou sWorld.IncreaseScheduledScriptsCount(); ///- If effects should be immediate, launch the script execution - if(delay == 0 && !i_scriptLock) + if (delay == 0 && !i_scriptLock) { i_scriptLock = true; ScriptsProcess(); @@ -2919,7 +2919,7 @@ void Map::ScriptsProcess() Object* source = NULL; - if(step.sourceGUID) + if (step.sourceGUID) { switch(GUID_HIPART(step.sourceGUID)) { @@ -2927,7 +2927,7 @@ void Map::ScriptsProcess() // case HIGHGUID_CONTAINER: ==HIGHGUID_ITEM { Player* player = HashMapHolder<Player>::Find(step.ownerGUID); - if(player) + if (player) source = player->GetItemByGuid(step.sourceGUID); break; } @@ -2952,7 +2952,7 @@ void Map::ScriptsProcess() case HIGHGUID_MO_TRANSPORT: for (MapManager::TransportSet::iterator iter = MapManager::Instance().m_Transports.begin(); iter != MapManager::Instance().m_Transports.end(); ++iter) { - if((*iter)->GetGUID() == step.sourceGUID) + if ((*iter)->GetGUID() == step.sourceGUID) { source = reinterpret_cast<Object*>(*iter); break; @@ -2965,11 +2965,11 @@ void Map::ScriptsProcess() } } - //if(source && !source->IsInWorld()) source = NULL; + //if (source && !source->IsInWorld()) source = NULL; Object* target = NULL; - if(step.targetGUID) + if (step.targetGUID) { switch(GUID_HIPART(step.targetGUID)) { @@ -2997,24 +2997,24 @@ void Map::ScriptsProcess() } } - //if(target && !target->IsInWorld()) target = NULL; + //if (target && !target->IsInWorld()) target = NULL; switch (step.script->command) { case SCRIPT_COMMAND_TALK: { - if(!source) + if (!source) { sLog.outError("SCRIPT_COMMAND_TALK call for NULL creature."); break; } - if(source->GetTypeId()!=TYPEID_UNIT) + if (source->GetTypeId()!=TYPEID_UNIT) { sLog.outError("SCRIPT_COMMAND_TALK call for non-creature (TypeId: %u, Entry: %u, GUID: %u), skipping.",source->GetTypeId(),source->GetEntry(),source->GetGUIDLow()); break; } - if(step.script->datalong > 4) + if (step.script->datalong > 4) { sLog.outError("SCRIPT_COMMAND_TALK invalid chat type (%u), skipping.",step.script->datalong); break; @@ -3029,7 +3029,7 @@ void Map::ScriptsProcess() source->ToCreature()->Say(step.script->dataint, LANG_UNIVERSAL, unit_target); break; case 1: // Whisper - if(!unit_target) + if (!unit_target) { sLog.outError("SCRIPT_COMMAND_TALK attempt to whisper (%u) NULL, skipping.",step.script->datalong); break; @@ -3052,13 +3052,13 @@ void Map::ScriptsProcess() } case SCRIPT_COMMAND_EMOTE: - if(!source) + if (!source) { sLog.outError("SCRIPT_COMMAND_EMOTE call for NULL creature."); break; } - if(source->GetTypeId()!=TYPEID_UNIT) + if (source->GetTypeId()!=TYPEID_UNIT) { sLog.outError("SCRIPT_COMMAND_EMOTE call for non-creature (TypeId: %u, Entry: %u, GUID: %u), skipping.",source->GetTypeId(),source->GetEntry(),source->GetGUIDLow()); break; @@ -3070,12 +3070,12 @@ void Map::ScriptsProcess() ((Creature *)source)->HandleEmoteCommand(step.script->datalong); break; case SCRIPT_COMMAND_FIELD_SET: - if(!source) + if (!source) { sLog.outError("SCRIPT_COMMAND_FIELD_SET call for NULL object."); break; } - if(step.script->datalong <= OBJECT_FIELD_ENTRY || step.script->datalong >= source->GetValuesCount()) + if (step.script->datalong <= OBJECT_FIELD_ENTRY || step.script->datalong >= source->GetValuesCount()) { sLog.outError("SCRIPT_COMMAND_FIELD_SET call for wrong field %u (max count: %u) in object (TypeId: %u, Entry: %u, GUID: %u).", step.script->datalong,source->GetValuesCount(),source->GetTypeId(),source->GetEntry(),source->GetGUIDLow()); @@ -3085,13 +3085,13 @@ void Map::ScriptsProcess() source->SetUInt32Value(step.script->datalong, step.script->datalong2); break; case SCRIPT_COMMAND_MOVE_TO: - if(!source) + if (!source) { sLog.outError("SCRIPT_COMMAND_MOVE_TO call for NULL creature."); break; } - if(source->GetTypeId()!=TYPEID_UNIT) + if (source->GetTypeId()!=TYPEID_UNIT) { sLog.outError("SCRIPT_COMMAND_MOVE_TO call for non-creature (TypeId: %u, Entry: %u, GUID: %u), skipping.",source->GetTypeId(),source->GetEntry(),source->GetGUIDLow()); break; @@ -3100,12 +3100,12 @@ void Map::ScriptsProcess() source->ToCreature()->GetMap()->CreatureRelocation((source->ToCreature()), step.script->x, step.script->y, step.script->z, 0); break; case SCRIPT_COMMAND_FLAG_SET: - if(!source) + if (!source) { sLog.outError("SCRIPT_COMMAND_FLAG_SET call for NULL object."); break; } - if(step.script->datalong <= OBJECT_FIELD_ENTRY || step.script->datalong >= source->GetValuesCount()) + if (step.script->datalong <= OBJECT_FIELD_ENTRY || step.script->datalong >= source->GetValuesCount()) { sLog.outError("SCRIPT_COMMAND_FLAG_SET call for wrong field %u (max count: %u) in object (TypeId: %u, Entry: %u, GUID: %u).", step.script->datalong,source->GetValuesCount(),source->GetTypeId(),source->GetEntry(),source->GetGUIDLow()); @@ -3115,12 +3115,12 @@ void Map::ScriptsProcess() source->SetFlag(step.script->datalong, step.script->datalong2); break; case SCRIPT_COMMAND_FLAG_REMOVE: - if(!source) + if (!source) { sLog.outError("SCRIPT_COMMAND_FLAG_REMOVE call for NULL object."); break; } - if(step.script->datalong <= OBJECT_FIELD_ENTRY || step.script->datalong >= source->GetValuesCount()) + if (step.script->datalong <= OBJECT_FIELD_ENTRY || step.script->datalong >= source->GetValuesCount()) { sLog.outError("SCRIPT_COMMAND_FLAG_REMOVE call for wrong field %u (max count: %u) in object (TypeId: %u, Entry: %u, GUID: %u).", step.script->datalong,source->GetValuesCount(),source->GetTypeId(),source->GetEntry(),source->GetGUIDLow()); @@ -3140,7 +3140,7 @@ void Map::ScriptsProcess() } // must be only Player - if((!target || target->GetTypeId() != TYPEID_PLAYER) && (!source || source->GetTypeId() != TYPEID_PLAYER)) + if ((!target || target->GetTypeId() != TYPEID_PLAYER) && (!source || source->GetTypeId() != TYPEID_PLAYER)) { sLog.outError("SCRIPT_COMMAND_TELEPORT_TO call for non-player (TypeIdSource: %u)(TypeIdTarget: %u), skipping.", source ? source->GetTypeId() : 0, target ? target->GetTypeId() : 0); break; @@ -3162,7 +3162,7 @@ void Map::ScriptsProcess() } // must be only Player - if((!target || target->GetTypeId() != TYPEID_PLAYER) && (!source || source->GetTypeId() != TYPEID_PLAYER)) + if ((!target || target->GetTypeId() != TYPEID_PLAYER) && (!source || source->GetTypeId() != TYPEID_PLAYER)) { sLog.outError("SCRIPT_COMMAND_KILL_CREDIT call for non-player (TypeIdSource: %u)(TypeIdTarget: %u), skipping.", source ? source->GetTypeId() : 0, target ? target->GetTypeId() : 0); break; @@ -3184,13 +3184,13 @@ void Map::ScriptsProcess() case SCRIPT_COMMAND_TEMP_SUMMON_CREATURE: { - if(!step.script->datalong) // creature not specified + if (!step.script->datalong) // creature not specified { sLog.outError("SCRIPT_COMMAND_TEMP_SUMMON_CREATURE call for NULL creature."); break; } - if(!source) + if (!source) { sLog.outError("SCRIPT_COMMAND_TEMP_SUMMON_CREATURE call for NULL world object."); break; @@ -3198,7 +3198,7 @@ void Map::ScriptsProcess() WorldObject* summoner = dynamic_cast<WorldObject*>(source); - if(!summoner) + if (!summoner) { sLog.outError("SCRIPT_COMMAND_TEMP_SUMMON_CREATURE call for non-WorldObject (TypeId: %u, Entry: %u, GUID: %u), skipping.",source->GetTypeId(),source->GetEntry(),source->GetGUIDLow()); break; @@ -3221,13 +3221,13 @@ void Map::ScriptsProcess() case SCRIPT_COMMAND_RESPAWN_GAMEOBJECT: { - if(!step.script->datalong) // gameobject not specified + if (!step.script->datalong) // gameobject not specified { sLog.outError("SCRIPT_COMMAND_RESPAWN_GAMEOBJECT call for NULL gameobject."); break; } - if(!source) + if (!source) { sLog.outError("SCRIPT_COMMAND_RESPAWN_GAMEOBJECT call for NULL world object."); break; @@ -3235,7 +3235,7 @@ void Map::ScriptsProcess() WorldObject* summoner = dynamic_cast<WorldObject*>(source); - if(!summoner) + if (!summoner) { sLog.outError("SCRIPT_COMMAND_RESPAWN_GAMEOBJECT call for non-WorldObject (TypeId: %u, Entry: %u, GUID: %u), skipping.",source->GetTypeId(),source->GetEntry(),source->GetGUIDLow()); break; @@ -3260,7 +3260,7 @@ void Map::ScriptsProcess() break; } - if( go->GetGoType()==GAMEOBJECT_TYPE_FISHINGNODE || + if ( go->GetGoType()==GAMEOBJECT_TYPE_FISHINGNODE || go->GetGoType()==GAMEOBJECT_TYPE_DOOR || go->GetGoType()==GAMEOBJECT_TYPE_BUTTON || go->GetGoType()==GAMEOBJECT_TYPE_TRAP ) @@ -3269,7 +3269,7 @@ void Map::ScriptsProcess() break; } - if( go->isSpawned() ) + if ( go->isSpawned() ) break; //gameobject already spawned go->SetLootState(GO_READY); @@ -3280,19 +3280,19 @@ void Map::ScriptsProcess() } case SCRIPT_COMMAND_OPEN_DOOR: { - if(!step.script->datalong) // door not specified + if (!step.script->datalong) // door not specified { sLog.outError("SCRIPT_COMMAND_OPEN_DOOR call for NULL door."); break; } - if(!source) + if (!source) { sLog.outError("SCRIPT_COMMAND_OPEN_DOOR call for NULL unit."); break; } - if(!source->isType(TYPEMASK_UNIT)) // must be any Unit (creature or player) + if (!source->isType(TYPEMASK_UNIT)) // must be any Unit (creature or player) { sLog.outError("SCRIPT_COMMAND_OPEN_DOOR call for non-unit (TypeId: %u, Entry: %u, GUID: %u), skipping.",source->GetTypeId(),source->GetEntry(),source->GetGUIDLow()); break; @@ -3329,25 +3329,25 @@ void Map::ScriptsProcess() door->UseDoorOrButton(time_to_close); - if(target && target->isType(TYPEMASK_GAMEOBJECT) && ((GameObject*)target)->GetGoType()==GAMEOBJECT_TYPE_BUTTON) + if (target && target->isType(TYPEMASK_GAMEOBJECT) && ((GameObject*)target)->GetGoType()==GAMEOBJECT_TYPE_BUTTON) ((GameObject*)target)->UseDoorOrButton(time_to_close); break; } case SCRIPT_COMMAND_CLOSE_DOOR: { - if(!step.script->datalong) // guid for door not specified + if (!step.script->datalong) // guid for door not specified { sLog.outError("SCRIPT_COMMAND_CLOSE_DOOR call for NULL door."); break; } - if(!source) + if (!source) { sLog.outError("SCRIPT_COMMAND_CLOSE_DOOR call for NULL unit."); break; } - if(!source->isType(TYPEMASK_UNIT)) // must be any Unit (creature or player) + if (!source->isType(TYPEMASK_UNIT)) // must be any Unit (creature or player) { sLog.outError("SCRIPT_COMMAND_CLOSE_DOOR call for non-unit (TypeId: %u, Entry: %u, GUID: %u), skipping.",source->GetTypeId(),source->GetEntry(),source->GetGUIDLow()); break; @@ -3379,25 +3379,25 @@ void Map::ScriptsProcess() break; } - if( door->GetGoState() == GO_STATE_READY ) + if ( door->GetGoState() == GO_STATE_READY ) break; //door already closed door->UseDoorOrButton(time_to_open); - if(target && target->isType(TYPEMASK_GAMEOBJECT) && ((GameObject*)target)->GetGoType()==GAMEOBJECT_TYPE_BUTTON) + if (target && target->isType(TYPEMASK_GAMEOBJECT) && ((GameObject*)target)->GetGoType()==GAMEOBJECT_TYPE_BUTTON) ((GameObject*)target)->UseDoorOrButton(time_to_open); break; } case SCRIPT_COMMAND_QUEST_EXPLORED: { - if(!source) + if (!source) { sLog.outError("SCRIPT_COMMAND_QUEST_EXPLORED call for NULL source."); break; } - if(!target) + if (!target) { sLog.outError("SCRIPT_COMMAND_QUEST_EXPLORED call for NULL target."); break; @@ -3407,9 +3407,9 @@ void Map::ScriptsProcess() WorldObject* worldObject; Player* player; - if(target->GetTypeId() == TYPEID_PLAYER) + if (target->GetTypeId() == TYPEID_PLAYER) { - if(source->GetTypeId()!=TYPEID_UNIT && source->GetTypeId()!=TYPEID_GAMEOBJECT) + if (source->GetTypeId()!=TYPEID_UNIT && source->GetTypeId()!=TYPEID_GAMEOBJECT) { sLog.outError("SCRIPT_COMMAND_QUEST_EXPLORED call for non-creature and non-gameobject (TypeId: %u, Entry: %u, GUID: %u), skipping.",source->GetTypeId(),source->GetEntry(),source->GetGUIDLow()); break; @@ -3420,13 +3420,13 @@ void Map::ScriptsProcess() } else { - if(target->GetTypeId()!=TYPEID_UNIT && target->GetTypeId()!=TYPEID_GAMEOBJECT) + if (target->GetTypeId()!=TYPEID_UNIT && target->GetTypeId()!=TYPEID_GAMEOBJECT) { sLog.outError("SCRIPT_COMMAND_QUEST_EXPLORED call for non-creature and non-gameobject (TypeId: %u, Entry: %u, GUID: %u), skipping.",target->GetTypeId(),target->GetEntry(),target->GetGUIDLow()); break; } - if(source->GetTypeId() != TYPEID_PLAYER) + if (source->GetTypeId() != TYPEID_PLAYER) { sLog.outError("SCRIPT_COMMAND_QUEST_EXPLORED call for non-player(TypeId: %u, Entry: %u, GUID: %u), skipping.",source->GetTypeId(),source->GetEntry(),source->GetGUIDLow()); break; @@ -3437,7 +3437,7 @@ void Map::ScriptsProcess() } // quest id and flags checked at script loading - if( (worldObject->GetTypeId()!=TYPEID_UNIT || ((Unit*)worldObject)->isAlive()) && + if ( (worldObject->GetTypeId()!=TYPEID_UNIT || ((Unit*)worldObject)->isAlive()) && (step.script->datalong2==0 || worldObject->IsWithinDistInMap(player,float(step.script->datalong2))) ) player->AreaExploredOrEventHappens(step.script->datalong); else @@ -3448,25 +3448,25 @@ void Map::ScriptsProcess() case SCRIPT_COMMAND_ACTIVATE_OBJECT: { - if(!source) + if (!source) { sLog.outError("SCRIPT_COMMAND_ACTIVATE_OBJECT must have source caster."); break; } - if(!source->isType(TYPEMASK_UNIT)) + if (!source->isType(TYPEMASK_UNIT)) { sLog.outError("SCRIPT_COMMAND_ACTIVATE_OBJECT source caster isn't unit (TypeId: %u, Entry: %u, GUID: %u), skipping.",source->GetTypeId(),source->GetEntry(),source->GetGUIDLow()); break; } - if(!target) + if (!target) { sLog.outError("SCRIPT_COMMAND_ACTIVATE_OBJECT call for NULL gameobject."); break; } - if(target->GetTypeId()!=TYPEID_GAMEOBJECT) + if (target->GetTypeId()!=TYPEID_GAMEOBJECT) { sLog.outError("SCRIPT_COMMAND_ACTIVATE_OBJECT call for non-gameobject (TypeId: %u, Entry: %u, GUID: %u), skipping.",target->GetTypeId(),target->GetEntry(),target->GetGUIDLow()); break; @@ -3484,13 +3484,13 @@ void Map::ScriptsProcess() { Object* cmdTarget = step.script->datalong2 ? source : target; - if(!cmdTarget) + if (!cmdTarget) { sLog.outError("SCRIPT_COMMAND_REMOVE_AURA call for NULL %s.",step.script->datalong2 ? "source" : "target"); break; } - if(!cmdTarget->isType(TYPEMASK_UNIT)) + if (!cmdTarget->isType(TYPEMASK_UNIT)) { sLog.outError("SCRIPT_COMMAND_REMOVE_AURA %s isn't unit (TypeId: %u, Entry: %u, GUID: %u), skipping.",step.script->datalong2 ? "source" : "target",cmdTarget->GetTypeId(),cmdTarget->GetEntry(),cmdTarget->GetGUIDLow()); break; @@ -3502,7 +3502,7 @@ void Map::ScriptsProcess() case SCRIPT_COMMAND_CAST_SPELL: { - if(!source) + if (!source) { sLog.outError("SCRIPT_COMMAND_CAST_SPELL must have source caster."); break; @@ -3510,7 +3510,7 @@ void Map::ScriptsProcess() Object* cmdTarget = step.script->datalong2 & 0x01 ? source : target; - if(cmdTarget && !cmdTarget->isType(TYPEMASK_UNIT)) + if (cmdTarget && !cmdTarget->isType(TYPEMASK_UNIT)) { sLog.outError("SCRIPT_COMMAND_CAST_SPELL %s isn't unit (TypeId: %u, Entry: %u. GUID: %u), skipping.",step.script->datalong2 & 0x01 ? "source" : "target",cmdTarget->GetTypeId(),cmdTarget->GetEntry(),cmdTarget->GetGUIDLow()); break; @@ -3520,13 +3520,13 @@ void Map::ScriptsProcess() Object* cmdSource = step.script->datalong2 & 0x02 ? target : source; - if(!cmdSource) + if (!cmdSource) { sLog.outError("SCRIPT_COMMAND_CAST_SPELL %u call for NULL %s.", step.script->datalong, step.script->datalong2 & 0x02 ? "target" : "source"); break; } - if(!cmdSource->isType(TYPEMASK_UNIT)) + if (!cmdSource->isType(TYPEMASK_UNIT)) { sLog.outError("SCRIPT_COMMAND_CAST_SPELL %s isn't unit (TypeId: %u, Entry: %u, GUID: %u), skipping.",step.script->datalong2 & 0x02 ? "target" : "source", cmdSource->GetTypeId(),cmdSource->GetEntry(),cmdSource->GetGUIDLow()); break; @@ -3542,19 +3542,19 @@ void Map::ScriptsProcess() case SCRIPT_COMMAND_LOAD_PATH: { - if(!source) + if (!source) { sLog.outError("SCRIPT_COMMAND_START_MOVE is tried to apply to NON-existing unit."); break; } - if(!source->isType(TYPEMASK_UNIT)) + if (!source->isType(TYPEMASK_UNIT)) { sLog.outError("SCRIPT_COMMAND_START_MOVE source mover isn't unit (TypeId: %u, Entry: %u, GUID: %u), skipping.",source->GetTypeId(),source->GetEntry(),source->GetGUIDLow()); break; } - if(!WaypointMgr.GetPath(step.script->datalong)) + if (!WaypointMgr.GetPath(step.script->datalong)) { sLog.outError("SCRIPT_COMMAND_START_MOVE source mover has an invallid path, skipping.", step.script->datalong2); break; @@ -3566,7 +3566,7 @@ void Map::ScriptsProcess() case SCRIPT_COMMAND_CALLSCRIPT_TO_UNIT: { - if(!step.script->datalong || !step.script->datalong2) + if (!step.script->datalong || !step.script->datalong2) { sLog.outError("SCRIPT_COMMAND_CALLSCRIPT calls invalid db_script_id or lowguid not present: skipping."); break; @@ -3574,7 +3574,7 @@ void Map::ScriptsProcess() //our target Creature* target = NULL; - if(source) //using grid searcher + if (source) //using grid searcher { CellPair p(Trinity::ComputeCellPair(((Unit*)source)->GetPositionX(), ((Unit*)source)->GetPositionY())); Cell cell(p); @@ -3589,11 +3589,11 @@ void Map::ScriptsProcess() } else //check hashmap holders { - if(CreatureData const* data = objmgr.GetCreatureData(step.script->datalong)) + if (CreatureData const* data = objmgr.GetCreatureData(step.script->datalong)) target = ObjectAccessor::GetObjectInWorld<Creature>(data->mapid, data->posX, data->posY, MAKE_NEW_GUID(step.script->datalong, data->id, HIGHGUID_UNIT), target); } //sLog.outDebug("attempting to pass target..."); - if(!target) + if (!target) break; //sLog.outDebug("target passed"); //Lets choose our ScriptMap map @@ -3623,7 +3623,7 @@ void Map::ScriptsProcess() break; } //if no scriptmap present... - if(!datamap) + if (!datamap) break; uint32 script_id = step.script->datalong2; @@ -3634,7 +3634,7 @@ void Map::ScriptsProcess() case SCRIPT_COMMAND_KILL: { - if(!source || source->ToCreature()->isDead()) + if (!source || source->ToCreature()->isDead()) break; source->ToCreature()->DealDamage((source->ToCreature()), source->ToCreature()->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); @@ -3649,14 +3649,14 @@ void Map::ScriptsProcess() case SCRIPT_COMMAND_PLAY_SOUND: { - if(!source) + if (!source) { sLog.outError("SCRIPT_COMMAND_PLAY_SOUND call for NULL creature."); break; } WorldObject* pSource = dynamic_cast<WorldObject*>(source); - if(!pSource) + if (!pSource) { sLog.outError("SCRIPT_COMMAND_PLAY_SOUND call for non-world object (TypeId: %u, Entry: %u, GUID: %u), skipping.",source->GetTypeId(),source->GetEntry(),source->GetGUIDLow()); break; @@ -3664,15 +3664,15 @@ void Map::ScriptsProcess() // bitmask: 0/1=anyone/target, 0/2=with distance dependent Player* pTarget = NULL; - if(step.script->datalong2 & 1) + if (step.script->datalong2 & 1) { - if(!target) + if (!target) { sLog.outError("SCRIPT_COMMAND_PLAY_SOUND in targeted mode call for NULL target."); break; } - if(target->GetTypeId() != TYPEID_PLAYER) + if (target->GetTypeId() != TYPEID_PLAYER) { sLog.outError("SCRIPT_COMMAND_PLAY_SOUND in targeted mode call for non-player (TypeId: %u, Entry: %u, GUID: %u), skipping.",target->GetTypeId(),target->GetEntry(),target->GetGUIDLow()); break; @@ -3682,7 +3682,7 @@ void Map::ScriptsProcess() } // bitmask: 0/1=anyone/target, 0/2=with distance dependent - if(step.script->datalong2 & 2) + if (step.script->datalong2 & 2) pSource->PlayDistanceSound(step.script->datalong,pTarget); else pSource->PlayDirectSound(step.script->datalong,pTarget); @@ -3691,7 +3691,7 @@ void Map::ScriptsProcess() case SCRIPT_COMMAND_ORIENTATION: { - if(!source) + if (!source) { sLog.outError("SCRIPT_COMMAND_ORIENTATION call for NULL creature."); break; @@ -3704,7 +3704,7 @@ void Map::ScriptsProcess() } case SCRIPT_COMMAND_EQUIP: { - if(!source) + if (!source) { sLog.outError("SCRIPT_COMMAND_EQUIP call for NULL creature."); break; @@ -3716,7 +3716,7 @@ void Map::ScriptsProcess() } case SCRIPT_COMMAND_MODEL: { - if(!source) + if (!source) { sLog.outError("SCRIPT_COMMAND_MODEL call for NULL creature."); break; @@ -3742,16 +3742,16 @@ Creature* Map::GetCreature(uint64 guid) { Creature * ret = NULL; - if(IS_CRE_OR_VEH_GUID(guid)) + if (IS_CRE_OR_VEH_GUID(guid)) ret = ObjectAccessor::GetObjectInWorld(guid, (Creature*)NULL); - if(!ret) + if (!ret) return NULL; - if(ret->GetMapId() != GetId()) + if (ret->GetMapId() != GetId()) return NULL; - if(ret->GetInstanceId() != GetInstanceId()) + if (ret->GetInstanceId() != GetInstanceId()) return NULL; return ret; @@ -3761,11 +3761,11 @@ GameObject* Map::GetGameObject(uint64 guid) { GameObject * ret = ObjectAccessor::GetObjectInWorld(guid, (GameObject*)NULL); - if(!ret) + if (!ret) return NULL; - if(ret->GetMapId() != GetId()) + if (ret->GetMapId() != GetId()) return NULL; - if(ret->GetInstanceId() != GetInstanceId()) + if (ret->GetInstanceId() != GetInstanceId()) return NULL; return ret; } @@ -3774,17 +3774,17 @@ DynamicObject* Map::GetDynamicObject(uint64 guid) { DynamicObject * ret = ObjectAccessor::GetObjectInWorld(guid, (DynamicObject*)NULL); - if(!ret) + if (!ret) return NULL; - if(ret->GetMapId() != GetId()) + if (ret->GetMapId() != GetId()) return NULL; - if(ret->GetInstanceId() != GetInstanceId()) + if (ret->GetInstanceId() != GetInstanceId()) return NULL; return ret; } void Map::UpdateIteratorBack(Player *player) { - if(m_mapRefIter == player->GetMapRef()) + if (m_mapRefIter == player->GetMapRef()) m_mapRefIter = m_mapRefIter->nocheck_prev(); } |