diff --git a/src/game/ConfusedMovementGenerator.cpp b/src/game/ConfusedMovementGenerator.cpp index 5928a20d9..2d46808c9 100644 --- a/src/game/ConfusedMovementGenerator.cpp +++ b/src/game/ConfusedMovementGenerator.cpp @@ -31,9 +31,8 @@ ConfusedMovementGenerator::Initialize(T &unit) x = unit.GetPositionX(); y = unit.GetPositionY(); z = unit.GetPositionZ(); - uint32 mapid=unit.GetMapId(); - Map const* map = MapManager::Instance().GetBaseMap(mapid); + Map const* map = unit.GetBaseMap(); i_nextMove = 1; diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index 11f03ac50..921d86444 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -182,8 +182,8 @@ bool Creature::InitEntry(uint32 Entry, uint32 team, const CreatureData *data ) CreatureInfo const *cinfo = normalInfo; if(normalInfo->HeroicEntry) { - Map *map = MapManager::Instance().FindMap(GetMapId(), GetInstanceId()); - if(map && map->IsHeroic()) + //we already have valid Map pointer for current creature! + if(GetMap()->IsHeroic()) { cinfo = objmgr.GetCreatureTemplate(normalInfo->HeroicEntry); if(!cinfo) diff --git a/src/game/DestinationHolder.h b/src/game/DestinationHolder.h index 72ee77762..5e4dc9dca 100644 --- a/src/game/DestinationHolder.h +++ b/src/game/DestinationHolder.h @@ -23,6 +23,7 @@ #include "Timer.h" class WorldObject; +class Map; #define TRAVELLER_UPDATE_INTERVAL 300 @@ -51,7 +52,7 @@ class MANGOS_DLL_DECL DestinationHolder bool HasArrived(void) const { return (i_totalTravelTime == 0 || i_timeElapsed >= i_totalTravelTime); } bool UpdateTraveller(TRAVELLER &traveller, uint32 diff, bool force_update=false, bool micro_movement=false); uint32 StartTravel(TRAVELLER &traveller, bool sendMove = true); - void GetLocationNow(uint32 mapid, float &x, float &y, float &z, bool is3D = false) const; + void GetLocationNow(const Map * map, float &x, float &y, float &z, bool is3D = false) const; void GetLocationNowNoMicroMovement(float &x, float &y, float &z) const; // For use without micro movement float GetDistance2dFromDestSq(const WorldObject &obj) const; diff --git a/src/game/DestinationHolderImp.h b/src/game/DestinationHolderImp.h index 0db69fdde..bb8f54829 100644 --- a/src/game/DestinationHolderImp.h +++ b/src/game/DestinationHolderImp.h @@ -126,9 +126,9 @@ DestinationHolder::UpdateTraveller(TRAVELLER &traveller, uint32 diff, return true; if(traveller.GetTraveller().hasUnitState(UNIT_STAT_IN_FLIGHT)) - GetLocationNow(traveller.GetTraveller().GetMapId() ,x, y, z, true); // Should repositione Object with right Coord, so I can bypass some Grid Relocation + GetLocationNow(traveller.GetTraveller().GetBaseMap() ,x, y, z, true); // Should reposition Object with right Coord, so I can bypass some Grid Relocation else - GetLocationNow(traveller.GetTraveller().GetMapId(), x, y, z, false); + GetLocationNow(traveller.GetTraveller().GetBaseMap(), x, y, z, false); if( x == -431602080 ) return false; @@ -158,7 +158,7 @@ DestinationHolder::UpdateTraveller(TRAVELLER &traveller, uint32 diff, template void -DestinationHolder::GetLocationNow(uint32 mapid, float &x, float &y, float &z, bool is3D) const +DestinationHolder::GetLocationNow(const Map * map, float &x, float &y, float &z, bool is3D) const { if( HasArrived() ) { @@ -180,8 +180,8 @@ DestinationHolder::GetLocationNow(uint32 mapid, float &x, float &y, f z = z2; else { - //That part is good for mob Walking on the floor. But the floor is not allways what we thought. - z = MapManager::Instance().GetBaseMap(mapid)->GetHeight(x,y,i_fromZ,false); // Disable cave check + //That part is good for mob Walking on the floor. But the floor is not always what we thought. + z = map->GetHeight(x,y,i_fromZ,false); // Disable cave check const float groundDist = sqrt(distanceX*distanceX + distanceY*distanceY); const float zDist = fabs(i_fromZ - z) + 0.000001f; const float slope = groundDist / zDist; diff --git a/src/game/FleeingMovementGenerator.cpp b/src/game/FleeingMovementGenerator.cpp index 373d85660..f8f193ac9 100644 --- a/src/game/FleeingMovementGenerator.cpp +++ b/src/game/FleeingMovementGenerator.cpp @@ -60,7 +60,7 @@ FleeingMovementGenerator::_getPoint(T &owner, float &x, float &y, float &z) z = owner.GetPositionZ(); float temp_x, temp_y, angle; - const Map * _map = MapManager::Instance().GetBaseMap(owner.GetMapId()); + const Map * _map = owner.GetBaseMap(); //primitive path-finding for(uint8 i = 0; i < 18; ++i) { diff --git a/src/game/GameEventMgr.cpp b/src/game/GameEventMgr.cpp index d06b24f17..3c0847895 100644 --- a/src/game/GameEventMgr.cpp +++ b/src/game/GameEventMgr.cpp @@ -517,7 +517,7 @@ void GameEventMgr::GameEventSpawn(int16 event_id) objmgr.AddCreatureToGrid(*itr, data); // Spawn if necessary (loaded grids only) - Map* map = const_cast(MapManager::Instance().GetBaseMap(data->mapid)); + Map* map = const_cast(MapManager::Instance().CreateBaseMap(data->mapid)); // We use spawn coords to spawn if(!map->Instanceable() && !map->IsRemovalGrid(data->posX,data->posY)) { @@ -550,7 +550,7 @@ void GameEventMgr::GameEventSpawn(int16 event_id) objmgr.AddGameobjectToGrid(*itr, data); // Spawn if necessary (loaded grids only) // this base map checked as non-instanced and then only existed - Map* map = const_cast(MapManager::Instance().GetBaseMap(data->mapid)); + Map* map = const_cast(MapManager::Instance().CreateBaseMap(data->mapid)); // We use current coords to unspawn, not spawn coords since creature can have changed grid if(!map->Instanceable() && !map->IsRemovalGrid(data->posX, data->posY)) { diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp index 951171ee5..04b0351d2 100644 --- a/src/game/GameObject.cpp +++ b/src/game/GameObject.cpp @@ -69,8 +69,17 @@ GameObject::~GameObject() Unit* owner = ObjectAccessor::GetUnit(*this,owner_guid); if(owner) owner->RemoveGameObject(this,false); - else if(!IS_PLAYER_GUID(owner_guid)) - sLog.outError("Delete GameObject (GUID: %u Entry: %u ) that have references in not found creature %u GO list. Crash possible later.",GetGUIDLow(),GetGOInfo()->id,GUID_LOPART(owner_guid)); + else + { + char * ownerType = "creature"; + if(IS_PLAYER_GUID(owner_guid)) + ownerType = "player"; + else if(IS_PET_GUID(owner_guid)) + ownerType = "pet"; + + sLog.outError("Delete GameObject (GUID: %u Entry: %u SpellId %u LinkedGO %u) that lost references to owner (GUID %u Type '%s') GO list. Crash possible later.", + GetGUIDLow(), GetGOInfo()->id, m_spellId, GetLinkedGameObjectEntry(), GUID_LOPART(owner_guid), ownerType); + } } } } diff --git a/src/game/InstanceSaveMgr.cpp b/src/game/InstanceSaveMgr.cpp index 193bb8e00..c19462472 100644 --- a/src/game/InstanceSaveMgr.cpp +++ b/src/game/InstanceSaveMgr.cpp @@ -558,7 +558,7 @@ void InstanceSaveManager::_ResetSave(InstanceSaveHashMap::iterator &itr) void InstanceSaveManager::_ResetInstance(uint32 mapid, uint32 instanceId) { sLog.outDebug("InstanceSaveMgr::_ResetInstance %u, %u", mapid, instanceId); - Map *map = (MapInstanced*)MapManager::Instance().GetBaseMap(mapid); + Map *map = (MapInstanced*)MapManager::Instance().CreateBaseMap(mapid); if(!map->Instanceable()) return; @@ -575,7 +575,7 @@ void InstanceSaveManager::_ResetOrWarnAll(uint32 mapid, bool warn, uint32 timeLe { // global reset for all instances of the given map // note: this isn't fast but it's meant to be executed very rarely - Map const *map = MapManager::Instance().GetBaseMap(mapid); + Map const *map = MapManager::Instance().CreateBaseMap(mapid); if(!map->Instanceable()) return; uint64 now = (uint64)time(NULL); diff --git a/src/game/Level1.cpp b/src/game/Level1.cpp index f44561998..a8d6a003f 100644 --- a/src/game/Level1.cpp +++ b/src/game/Level1.cpp @@ -2315,7 +2315,7 @@ bool ChatHandler::HandleGoXYCommand(const char* args) else _player->SaveRecallPosition(); - Map const *map = MapManager::Instance().GetBaseMap(mapid); + Map const *map = MapManager::Instance().CreateBaseMap(mapid); float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y)); _player->TeleportTo(mapid, x, y, z, _player->GetOrientation()); @@ -2408,7 +2408,7 @@ bool ChatHandler::HandleGoZoneXYCommand(const char* args) // update to parent zone if exist (client map show only zones without parents) AreaTableEntry const* zoneEntry = areaEntry->zone ? GetAreaEntryByAreaID(areaEntry->zone) : areaEntry; - Map const *map = MapManager::Instance().GetBaseMap(zoneEntry->mapid); + Map const *map = MapManager::Instance().CreateBaseMap(zoneEntry->mapid); if(map->Instanceable()) { @@ -2483,7 +2483,7 @@ bool ChatHandler::HandleGoGridCommand(const char* args) else _player->SaveRecallPosition(); - Map const *map = MapManager::Instance().GetBaseMap(mapid); + Map const *map = MapManager::Instance().CreateBaseMap(mapid); float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y)); _player->TeleportTo(mapid, x, y, z, _player->GetOrientation()); diff --git a/src/game/Map.cpp b/src/game/Map.cpp index ed03747a8..d315f1cc9 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -124,7 +124,7 @@ void Map::LoadMap(int gx,int gy, bool reload) if(GridMaps[gx][gy]) return; - Map* baseMap = const_cast(MapManager::Instance().GetBaseMap(i_id)); + Map* baseMap = const_cast(MapManager::Instance().CreateBaseMap(i_id)); // load grid map for base map if (!baseMap->GridMaps[gx][gy]) @@ -422,10 +422,9 @@ template void Map::Add(T *obj) { - CellPair p = MaNGOS::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY()); - assert(obj); + CellPair p = MaNGOS::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY()); if(p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP ) { sLog.outError("Map::Add: 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); @@ -1022,7 +1021,7 @@ bool Map::UnloadGrid(const uint32 &x, const uint32 &y, bool pForce) VMAP::VMapFactory::createOrGetVMapManager()->unloadMap(GetId(), gy, gx); } else - ((MapInstanced*)(MapManager::Instance().GetBaseMap(i_id)))->RemoveGridMapReference(GridPair(gx, gy)); + ((MapInstanced*)(MapManager::Instance().CreateBaseMap(i_id)))->RemoveGridMapReference(GridPair(gx, gy)); GridMaps[gx][gy] = NULL; } DEBUG_LOG("Unloading grid[%u,%u] for map %u finished", x,y, i_id); diff --git a/src/game/MapInstanced.h b/src/game/MapInstanced.h index 783de74ad..8a6cfdb9f 100644 --- a/src/game/MapInstanced.h +++ b/src/game/MapInstanced.h @@ -39,7 +39,7 @@ class MANGOS_DLL_DECL MapInstanced : public Map void UnloadAll(bool pForce); Map* GetInstance(const WorldObject* obj); - Map* FindMap(uint32 InstanceId) { return _FindMap(InstanceId); } + Map* FindMap(uint32 InstanceId) const { return _FindMap(InstanceId); } void DestroyInstance(uint32 InstanceId); void DestroyInstance(InstancedMaps::iterator &itr); @@ -65,10 +65,9 @@ class MANGOS_DLL_DECL MapInstanced : public Map InstancedMaps m_InstancedMaps; - Map* _FindMap(uint32 InstanceId) + Map* _FindMap(uint32 InstanceId) const { - InstancedMaps::iterator i = m_InstancedMaps.find(InstanceId); - + InstancedMaps::const_iterator i = m_InstancedMaps.find(InstanceId); return(i == m_InstancedMaps.end() ? NULL : i->second); } diff --git a/src/game/MapManager.cpp b/src/game/MapManager.cpp index 074034d2b..276e6f4da 100644 --- a/src/game/MapManager.cpp +++ b/src/game/MapManager.cpp @@ -98,7 +98,7 @@ void MapManager::checkAndCorrectGridStatesArray() } Map* -MapManager::_GetBaseMap(uint32 id) +MapManager::_createBaseMap(uint32 id) { Map *m = _findMap(id); @@ -124,19 +124,24 @@ MapManager::_GetBaseMap(uint32 id) Map* MapManager::GetMap(uint32 id, const WorldObject* obj) { + ASSERT(obj); //if(!obj->IsInWorld()) sLog.outError("GetMap: called for map %d with object (typeid %d, guid %d, mapid %d, instanceid %d) who is not in world!", id, obj->GetTypeId(), obj->GetGUIDLow(), obj->GetMapId(), obj->GetInstanceId()); - Map *m = _GetBaseMap(id); + Map *m = _createBaseMap(id); if (m && obj && m->Instanceable()) m = ((MapInstanced*)m)->GetInstance(obj); return m; } -Map* MapManager::FindMap(uint32 mapid, uint32 instanceId) +Map* MapManager::FindMap(uint32 mapid, uint32 instanceId) const { - Map *map = FindMap(mapid); - if(!map) return NULL; - if(!map->Instanceable()) return instanceId == 0 ? map : NULL; + Map *map = _findMap(mapid); + if(!map) + return NULL; + + if(!map->Instanceable()) + return instanceId == 0 ? map : NULL; + return ((MapInstanced*)map)->FindMap(instanceId); } @@ -223,14 +228,14 @@ bool MapManager::CanPlayerEnter(uint32 mapid, Player* player) void MapManager::DeleteInstance(uint32 mapid, uint32 instanceId) { - Map *m = _GetBaseMap(mapid); + Map *m = _createBaseMap(mapid); if (m && m->Instanceable()) ((MapInstanced*)m)->DestroyInstance(instanceId); } void MapManager::RemoveBonesFromMap(uint32 mapid, uint64 guid, float x, float y) { - bool remove_result = _GetBaseMap(mapid)->RemoveBones(guid, x, y); + bool remove_result = _createBaseMap(mapid)->RemoveBones(guid, x, y); if (!remove_result) { @@ -283,13 +288,6 @@ bool MapManager::IsValidMAP(uint32 mapid) // TODO: add check for battleground template } -void MapManager::LoadGrid(int mapid, float x, float y, const WorldObject* obj, bool no_unload) -{ - CellPair p = MaNGOS::ComputeCellPair(x,y); - Cell cell(p); - GetMap(mapid, obj)->LoadGrid(cell,no_unload); -} - void MapManager::UnloadAll() { for(MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter) diff --git a/src/game/MapManager.h b/src/game/MapManager.h index 0de79a8b9..8755a3f45 100644 --- a/src/game/MapManager.h +++ b/src/game/MapManager.h @@ -38,16 +38,15 @@ class MANGOS_DLL_DECL MapManager : public MaNGOS::Singleton(this)->_createBaseMap(id); } + Map* FindMap(uint32 mapid, uint32 instanceId = 0) const; // only const version for outer users - Map const* GetBaseMap(uint32 id) const { return const_cast(this)->_GetBaseMap(id); } void DeleteInstance(uint32 mapid, uint32 instanceId); uint16 GetAreaFlag(uint32 mapid, float x, float y, float z) const { - Map const* m = GetBaseMap(mapid); + Map const* m = CreateBaseMap(mapid); return m->GetAreaFlag(x, y, z); } uint32 GetAreaId(uint32 mapid, float x, float y, float z) const @@ -83,7 +82,7 @@ class MANGOS_DLL_DECL MapManager : public MaNGOS::SingletonGetTeleportDest(); // possible errors in the coordinate validity check - if(!MapManager::IsValidMapCoord(loc.mapid, loc.x, loc.y, loc.z, loc.o)) + if(!MapManager::IsValidMapCoord(loc.mapid, loc.coord_x, loc.coord_y, loc.coord_z, loc.orientation)) { LogoutPlayer(false); return; @@ -66,7 +66,7 @@ void WorldSession::HandleMoveWorldportAckOpcode() // relocate the player to the teleport destination GetPlayer()->SetMapId(loc.mapid); - GetPlayer()->Relocate(loc.x, loc.y, loc.z, loc.o); + GetPlayer()->Relocate(loc.coord_x, loc.coord_y, loc.coord_z, loc.orientation); // since the MapId is set before the GetInstance call, the InstanceId must be set to 0 // to let GetInstance() determine the proper InstanceId based on the player's binds @@ -77,7 +77,7 @@ void WorldSession::HandleMoveWorldportAckOpcode() // while the player is in transit, for example the map may get full if(!GetPlayer()->GetMap()->Add(GetPlayer())) { - sLog.outDebug("WORLD: teleport of player %s (%d) to location %d, %f, %f, %f, %f failed", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow(), loc.mapid, loc.x, loc.y, loc.z, loc.o); + sLog.outDebug("WORLD: teleport of player %s (%d) to location %d, %f, %f, %f, %f failed", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow(), loc.mapid, loc.coord_x, loc.coord_y, loc.coord_z, loc.orientation); // teleport the player home if(!GetPlayer()->TeleportTo(GetPlayer()->m_homebindMapId, GetPlayer()->m_homebindX, GetPlayer()->m_homebindY, GetPlayer()->m_homebindZ, GetPlayer()->GetOrientation())) { @@ -184,7 +184,7 @@ void WorldSession::HandleMoveTeleportAck(WorldPacket& recv_data) WorldLocation const& dest = plMover->GetTeleportDest(); - plMover->SetPosition(dest.x, dest.y, dest.z, dest.o, true); + plMover->SetPosition(dest.coord_x, dest.coord_y, dest.coord_z, dest.orientation, true); uint32 newzone, newarea; plMover->GetZoneAndAreaId(newzone, newarea); diff --git a/src/game/Object.cpp b/src/game/Object.cpp index d722b033b..4f16c3dbd 100644 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -1063,17 +1063,17 @@ void WorldObject::_Create( uint32 guidlow, HighGuid guidhigh, uint32 mapid, uint uint32 WorldObject::GetZoneId() const { - return MapManager::Instance().GetBaseMap(m_mapId)->GetZoneId(m_positionX, m_positionY, m_positionZ); + return GetBaseMap()->GetZoneId(m_positionX, m_positionY, m_positionZ); } uint32 WorldObject::GetAreaId() const { - return MapManager::Instance().GetBaseMap(m_mapId)->GetAreaId(m_positionX, m_positionY, m_positionZ); + return GetBaseMap()->GetAreaId(m_positionX, m_positionY, m_positionZ); } void WorldObject::GetZoneAndAreaId(uint32& zoneid, uint32& areaid) const { - MapManager::Instance().GetBaseMap(m_mapId)->GetZoneAndAreaId(zoneid, areaid, m_positionX, m_positionY, m_positionZ); + GetBaseMap()->GetZoneAndAreaId(zoneid, areaid, m_positionX, m_positionY, m_positionZ); } InstanceData* WorldObject::GetInstanceData() @@ -1345,7 +1345,7 @@ void WorldObject::GetRandomPoint( float x, float y, float z, float distance, flo void WorldObject::UpdateGroundPositionZ(float x, float y, float &z) const { - float new_z = MapManager::Instance().GetBaseMap(GetMapId())->GetHeight(x,y,z,true); + float new_z = GetBaseMap()->GetHeight(x,y,z,true); if(new_z > INVALID_HEIGHT) z = new_z+ 0.05f; // just to be sure that we are not a few pixel under the surface } @@ -1578,7 +1578,7 @@ Map* WorldObject::GetMap() const Map const* WorldObject::GetBaseMap() const { - return MapManager::Instance().GetBaseMap(GetMapId()); + return MapManager::Instance().CreateBaseMap(GetMapId()); } void WorldObject::AddObjectToRemoveList() diff --git a/src/game/Object.h b/src/game/Object.h index 31b90f352..9e4ff7cf6 100644 --- a/src/game/Object.h +++ b/src/game/Object.h @@ -98,14 +98,14 @@ typedef UNORDERED_MAP UpdateDataMapType; struct WorldLocation { uint32 mapid; - float x; - float y; - float z; - float o; + float coord_x; + float coord_y; + float coord_z; + float orientation; explicit WorldLocation(uint32 _mapid = 0, float _x = 0, float _y = 0, float _z = 0, float _o = 0) - : mapid(_mapid), x(_x), y(_y), z(_z), o(_o) {} + : mapid(_mapid), coord_x(_x), coord_y(_y), coord_z(_z), orientation(_o) {} WorldLocation(WorldLocation const &loc) - : mapid(loc.mapid), x(loc.x), y(loc.y), z(loc.z), o(loc.o) {} + : mapid(loc.mapid), coord_x(loc.coord_x), coord_y(loc.coord_y), coord_z(loc.coord_z), orientation(loc.orientation) {} }; class MANGOS_DLL_SPEC Object @@ -363,12 +363,6 @@ class MANGOS_DLL_SPEC WorldObject : public Object m_positionZ = z; } - void Relocate(WorldLocation const & loc) - { - SetMapId(loc.mapid); - Relocate(loc.x, loc.y, loc.z, loc.o); - } - void SetOrientation(float orientation) { m_orientation = orientation; } float GetPositionX( ) const { return m_positionX; } @@ -377,7 +371,7 @@ class MANGOS_DLL_SPEC WorldObject : public Object void GetPosition( float &x, float &y, float &z ) const { x = m_positionX; y = m_positionY; z = m_positionZ; } void GetPosition( WorldLocation &loc ) const - { loc.mapid = GetMapId(); GetPosition(loc.x, loc.y, loc.z); loc.o = GetOrientation(); } + { loc.mapid = m_mapId; GetPosition(loc.coord_x, loc.coord_y, loc.coord_z); loc.orientation = GetOrientation(); } float GetOrientation( ) const { return m_orientation; } void GetNearPoint2D( float &x, float &y, float distance, float absAngle) const; void GetNearPoint( WorldObject const* searcher, float &x, float &y, float &z, float searcher_size, float distance2d,float absAngle) const; diff --git a/src/game/Player.cpp b/src/game/Player.cpp index d5416d874..68298e5d9 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -2042,7 +2042,7 @@ GameObject* Player::GetGameObjectIfCanInteractWith(uint64 guid, GameobjectTypes bool Player::IsUnderWater() const { return IsInWater() && - GetPositionZ() < (MapManager::Instance().GetBaseMap(GetMapId())->GetWaterLevel(GetPositionX(),GetPositionY())-2); + GetPositionZ() < (GetBaseMap()->GetWaterLevel(GetPositionX(),GetPositionY())-2); } void Player::SetInWater(bool apply) @@ -5623,7 +5623,7 @@ void Player::CheckExploreSystem() if (isInFlight()) return; - uint16 areaFlag=MapManager::Instance().GetBaseMap(GetMapId())->GetAreaFlag(GetPositionX(),GetPositionY(),GetPositionZ()); + uint16 areaFlag = GetBaseMap()->GetAreaFlag(GetPositionX(),GetPositionY(),GetPositionZ()); if(areaFlag==0xffff) return; int offset = areaFlag / 32; @@ -14061,7 +14061,9 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) } else { - Relocate(GetBattleGroundEntryPoint()); + const WorldLocation& _loc = GetBattleGroundEntryPoint(); + SetMapId(_loc.mapid); + Relocate(_loc.coord_x, _loc.coord_y, _loc.coord_z, _loc.orientation); //RemoveArenaAuras(true); } } @@ -14173,7 +14175,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) if(at) Relocate(at->target_X, at->target_Y, at->target_Z, at->target_Orientation); else - sLog.outError("Player %s(GUID: %u) logged in to a reset instance (map: %u) and there is no aretrigger leading to this map. Thus he can't be ported back to the entrance. This _might_ be an exploit attempt.", GetName(), GetGUIDLow(), GetMapId()); + sLog.outError("Player %s(GUID: %u) logged in to a reset instance (map: %u) and there is no area-trigger leading to this map. Thus he can't be ported back to the entrance. This _might_ be an exploit attempt.", GetName(), GetGUIDLow(), GetMapId()); } SaveRecallPosition(); @@ -15428,10 +15430,10 @@ void Player::SaveToDB() { ss << GetTeleportDest().mapid << ", " << (uint32)GetDifficulty() << ", " - << finiteAlways(GetTeleportDest().x) << ", " - << finiteAlways(GetTeleportDest().y) << ", " - << finiteAlways(GetTeleportDest().z) << ", " - << finiteAlways(GetTeleportDest().o) << ", '"; + << finiteAlways(GetTeleportDest().coord_x) << ", " + << finiteAlways(GetTeleportDest().coord_y) << ", " + << finiteAlways(GetTeleportDest().coord_z) << ", " + << finiteAlways(GetTeleportDest().orientation) << ", '"; } uint16 i; @@ -15503,10 +15505,10 @@ void Player::SaveToDB() ss << GetBGTeam(); ss << ", "; ss << m_bgEntryPoint.mapid << ", " - << finiteAlways(m_bgEntryPoint.x) << ", " - << finiteAlways(m_bgEntryPoint.y) << ", " - << finiteAlways(m_bgEntryPoint.z) << ", " - << finiteAlways(m_bgEntryPoint.o); + << finiteAlways(m_bgEntryPoint.coord_x) << ", " + << finiteAlways(m_bgEntryPoint.coord_y) << ", " + << finiteAlways(m_bgEntryPoint.coord_z) << ", " + << finiteAlways(m_bgEntryPoint.orientation); ss << ")"; CharacterDatabase.Execute( ss.str().c_str() ); diff --git a/src/game/Player.h b/src/game/Player.h index 01f8ab8d3..bb5c7f192 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -884,7 +884,7 @@ class MANGOS_DLL_SPEC Player : public Unit bool TeleportTo(WorldLocation const &loc, uint32 options = 0) { - return TeleportTo(loc.mapid, loc.x, loc.y, loc.z, options); + return TeleportTo(loc.mapid, loc.coord_x, loc.coord_y, loc.coord_z, options); } void SetSummonPoint(uint32 mapid, float x, float y, float z) diff --git a/src/game/PoolHandler.cpp b/src/game/PoolHandler.cpp index 753b6a249..09a1d4293 100644 --- a/src/game/PoolHandler.cpp +++ b/src/game/PoolHandler.cpp @@ -233,7 +233,7 @@ bool PoolGroup::Spawn1Object(uint32 guid) objmgr.AddCreatureToGrid(guid, data); // Spawn if necessary (loaded grids only) - Map* map = const_cast(MapManager::Instance().GetBaseMap(data->mapid)); + Map* map = const_cast(MapManager::Instance().CreateBaseMap(data->mapid)); // We use spawn coords to spawn if (!map->Instanceable() && !map->IsRemovalGrid(data->posX, data->posY)) { @@ -263,7 +263,7 @@ bool PoolGroup::Spawn1Object(uint32 guid) objmgr.AddGameobjectToGrid(guid, data); // Spawn if necessary (loaded grids only) // this base map checked as non-instanced and then only existed - Map* map = const_cast(MapManager::Instance().GetBaseMap(data->mapid)); + Map* map = const_cast(MapManager::Instance().CreateBaseMap(data->mapid)); // We use current coords to unspawn, not spawn coords since creature can have changed grid if (!map->Instanceable() && !map->IsRemovalGrid(data->posX, data->posY)) { diff --git a/src/game/QueryHandler.cpp b/src/game/QueryHandler.cpp index e78843b0e..bae1fd330 100644 --- a/src/game/QueryHandler.cpp +++ b/src/game/QueryHandler.cpp @@ -306,7 +306,7 @@ void WorldSession::HandleCorpseQueryOpcode(WorldPacket & /*recv_data*/) if(corpseMapEntry->IsDungeon() && corpseMapEntry->entrance_map >= 0) { // if corpse map have entrance - if(Map const* entranceMap = MapManager::Instance().GetBaseMap(corpseMapEntry->entrance_map)) + if(Map const* entranceMap = MapManager::Instance().CreateBaseMap(corpseMapEntry->entrance_map)) { mapid = corpseMapEntry->entrance_map; x = corpseMapEntry->entrance_x; diff --git a/src/game/RandomMovementGenerator.cpp b/src/game/RandomMovementGenerator.cpp index c2ff8e85d..fcd9f7fc7 100644 --- a/src/game/RandomMovementGenerator.cpp +++ b/src/game/RandomMovementGenerator.cpp @@ -34,8 +34,7 @@ RandomMovementGenerator::_setRandomLocation(Creature &creature) creature.GetRespawnCoord(X, Y, Z, &ori, &wander_distance); z = creature.GetPositionZ(); - uint32 mapid=creature.GetMapId(); - Map const* map = MapManager::Instance().GetBaseMap(mapid); + Map const* map = creature.GetBaseMap(); // For 2D/3D system selection //bool is_land_ok = creature.canWalk(); // not used? diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 99676426c..3aac4ad29 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -4396,7 +4396,7 @@ SpellCastResult Spell::CheckCast(bool strict) float fx = m_caster->GetPositionX() + dis * cos(m_caster->GetOrientation()); float fy = m_caster->GetPositionY() + dis * sin(m_caster->GetOrientation()); // teleport a bit above terrain level to avoid falling below it - float fz = MapManager::Instance().GetBaseMap(m_caster->GetMapId())->GetHeight(fx,fy,m_caster->GetPositionZ(),true); + float fz = m_caster->GetBaseMap()->GetHeight(fx,fy,m_caster->GetPositionZ(),true); if(fz <= INVALID_HEIGHT) // note: this also will prevent use effect in instances without vmaps height enabled return SPELL_FAILED_TRY_AGAIN; diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 521d56d24..735e4ad36 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -2742,7 +2742,7 @@ void Spell::EffectPersistentAA(uint32 i) dynObj->SetUInt32Value(GAMEOBJECT_DISPLAYID, 368003); dynObj->SetUInt32Value(DYNAMICOBJECT_BYTES, 0x01eeeeee); m_caster->AddDynObject(dynObj); - dynObj->GetMap()->Add(dynObj); + m_caster->GetMap()->Add(dynObj); } void Spell::EffectEnergize(uint32 i) @@ -3536,7 +3536,7 @@ void Spell::EffectAddFarsight(uint32 i) dynObj->SetUInt32Value(OBJECT_FIELD_TYPE, 65); dynObj->SetUInt32Value(DYNAMICOBJECT_BYTES, 0x80000002); m_caster->AddDynObject(dynObj); - dynObj->GetMap()->Add(dynObj); + m_caster->GetMap()->Add(dynObj); if(m_caster->GetTypeId() == TYPEID_PLAYER) ((Player*)m_caster)->SetFarSightGUID(dynObj->GetGUID()); } diff --git a/src/game/Transports.cpp b/src/game/Transports.cpp index 8ea355b8d..a338c7b0b 100644 --- a/src/game/Transports.cpp +++ b/src/game/Transports.cpp @@ -89,7 +89,7 @@ void MapManager::LoadTransports() uint32 mapid; x = t->m_WayPoints[0].x; y = t->m_WayPoints[0].y; z = t->m_WayPoints[0].z; mapid = t->m_WayPoints[0].mapid; o = 1; - // creates the Gameobject + // creates the Gameobject if(!t->Create(entry, mapid, x, y, z, o, 100, 0)) { delete t; diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 1a9a38748..d56f36a62 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -3229,12 +3229,12 @@ bool Unit::isInAccessablePlaceFor(Creature const* c) const bool Unit::IsInWater() const { - return MapManager::Instance().GetBaseMap(GetMapId())->IsInWater(GetPositionX(),GetPositionY(), GetPositionZ()); + return GetBaseMap()->IsInWater(GetPositionX(),GetPositionY(), GetPositionZ()); } bool Unit::IsUnderWater() const { - return MapManager::Instance().GetBaseMap(GetMapId())->IsUnderWater(GetPositionX(),GetPositionY(),GetPositionZ()); + return GetBaseMap()->IsUnderWater(GetPositionX(),GetPositionY(),GetPositionZ()); } void Unit::DeMorph() diff --git a/src/game/WaypointManager.cpp b/src/game/WaypointManager.cpp index cfb12eab1..2806bd73e 100644 --- a/src/game/WaypointManager.cpp +++ b/src/game/WaypointManager.cpp @@ -118,7 +118,7 @@ void WaypointManager::Load() MaNGOS::NormalizeMapCoord(node.y); if(result1) { - node.z = MapManager::Instance ().GetBaseMap(result1->Fetch()[1].GetUInt32())->GetHeight(node.x, node.y, node.z); + node.z = MapManager::Instance ().CreateBaseMap(result1->Fetch()[1].GetUInt32())->GetHeight(node.x, node.y, node.z); delete result1; } WorldDatabase.PExecute("UPDATE creature_movement SET position_x = '%f', position_y = '%f', position_z = '%f' WHERE id = '%u' AND point = '%u'", node.x, node.y, node.z, id, point); diff --git a/src/game/WaypointMovementGenerator.cpp b/src/game/WaypointMovementGenerator.cpp index 0aad5e4fb..71dd52599 100644 --- a/src/game/WaypointMovementGenerator.cpp +++ b/src/game/WaypointMovementGenerator.cpp @@ -249,7 +249,7 @@ void FlightPathMovementGenerator::Finalize(Player & player) player.clearUnitState(UNIT_STAT_IN_FLIGHT); float x, y, z; - i_destinationHolder.GetLocationNow(player.GetMapId(), x, y, z); + i_destinationHolder.GetLocationNow(player.GetBaseMap(), x, y, z); player.SetPosition(x, y, z, player.GetOrientation()); player.Unmount(); diff --git a/src/game/WorldSession.cpp b/src/game/WorldSession.cpp index 4f8340ad3..8927ee0ba 100644 --- a/src/game/WorldSession.cpp +++ b/src/game/WorldSession.cpp @@ -34,6 +34,7 @@ #include "World.h" #include "ObjectAccessor.h" #include "BattleGroundMgr.h" +#include "MapManager.h" #include "SocialMgr.h" #include "zlib/zlib.h" diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 52aa9ff37..d452beb12 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "8025" + #define REVISION_NR "8026" #endif // __REVISION_NR_H__