diff options
author | megamage <none@none.none> | 2011-11-23 09:34:08 -0500 |
---|---|---|
committer | megamage <none@none.none> | 2011-11-23 09:34:08 -0500 |
commit | 298c162c86130d59c6c60f2fedc7a9b2af034a8d (patch) | |
tree | a9d678c04646a98aaf715d64252ab56411a1f0fd /src | |
parent | 1b3017472be902ddfb900230ea8efc07132927a1 (diff) |
Do not allow an instance map to be created twice if it already exists. Fix #4018.
Diffstat (limited to 'src')
-rwxr-xr-x | src/server/game/Instances/InstanceSaveMgr.cpp | 2 | ||||
-rwxr-xr-x | src/server/game/Maps/MapInstanced.cpp | 12 | ||||
-rwxr-xr-x | src/server/game/Maps/MapInstanced.h | 15 | ||||
-rwxr-xr-x | src/server/game/Maps/MapManager.cpp | 5 |
4 files changed, 18 insertions, 16 deletions
diff --git a/src/server/game/Instances/InstanceSaveMgr.cpp b/src/server/game/Instances/InstanceSaveMgr.cpp index bc2648ed02b..c4df7d647c3 100755 --- a/src/server/game/Instances/InstanceSaveMgr.cpp +++ b/src/server/game/Instances/InstanceSaveMgr.cpp @@ -521,7 +521,7 @@ void InstanceSaveManager::_ResetInstance(uint32 mapid, uint32 instanceId) DeleteInstanceFromDB(instanceId); // even if save not loaded - Map* iMap = ((MapInstanced*)map)->FindMap(instanceId); + Map* iMap = ((MapInstanced*)map)->FindInstanceMap(instanceId); if (iMap && iMap->IsDungeon()) ((InstanceMap*)iMap)->Reset(INSTANCE_RESET_RESPAWN_DELAY); diff --git a/src/server/game/Maps/MapInstanced.cpp b/src/server/game/Maps/MapInstanced.cpp index bbade4c9dc3..a56a193ba64 100755 --- a/src/server/game/Maps/MapInstanced.cpp +++ b/src/server/game/Maps/MapInstanced.cpp @@ -110,7 +110,7 @@ void MapInstanced::UnloadAll() - create the instance if it's not created already - the player is not actually added to the instance (only in InstanceMap::Add) */ -Map* MapInstanced::CreateInstance(const uint32 mapId, Player* player) +Map* MapInstanced::CreateInstanceForPlayer(const uint32 mapId, Player* player) { if (GetId() != mapId || !player) return NULL; @@ -124,7 +124,7 @@ Map* MapInstanced::CreateInstance(const uint32 mapId, Player* player) // the instance id is set in battlegroundid NewInstanceId = player->GetBattlegroundId(); if (!NewInstanceId) return NULL; - map = _FindMap(NewInstanceId); + map = FindInstanceMap(NewInstanceId); if (!map) map = CreateBattleground(NewInstanceId, player->GetBattleground()); } @@ -151,7 +151,7 @@ Map* MapInstanced::CreateInstance(const uint32 mapId, Player* player) { // solo/perm/group NewInstanceId = pSave->GetInstanceId(); - map = _FindMap(NewInstanceId); + map = FindInstanceMap(NewInstanceId); // it is possible that the save exists but the map doesn't if (!map) map = CreateInstance(NewInstanceId, pSave, pSave->GetDifficulty()); @@ -163,7 +163,11 @@ Map* MapInstanced::CreateInstance(const uint32 mapId, Player* player) NewInstanceId = sMapMgr->GenerateInstanceId(); Difficulty diff = player->GetGroup() ? player->GetGroup()->GetDifficulty(IsRaid()) : player->GetDifficulty(IsRaid()); - map = CreateInstance(NewInstanceId, NULL, diff); + //Seems it is now possible, but I do not know if it should be allowed + //ASSERT(!FindInstanceMap(NewInstanceId)); + map = FindInstanceMap(NewInstanceId); + if (!map) + map = CreateInstance(NewInstanceId, NULL, diff); } } diff --git a/src/server/game/Maps/MapInstanced.h b/src/server/game/Maps/MapInstanced.h index af303ed0e9e..9b714cb7fb3 100755 --- a/src/server/game/Maps/MapInstanced.h +++ b/src/server/game/Maps/MapInstanced.h @@ -39,8 +39,12 @@ class MapInstanced : public Map void UnloadAll(); bool CanEnter(Player* player); - Map* CreateInstance(const uint32 mapId, Player* player); - Map* FindMap(uint32 InstanceId) const { return _FindMap(InstanceId); } + Map* CreateInstanceForPlayer(const uint32 mapId, Player* player); + Map* FindInstanceMap(uint32 instanceId) const + { + InstancedMaps::const_iterator i = m_InstancedMaps.find(instanceId); + return(i == m_InstancedMaps.end() ? NULL : i->second); + } bool DestroyInstance(InstancedMaps::iterator &itr); void AddGridMapReference(const GridCoord &p) @@ -60,18 +64,11 @@ class MapInstanced : public Map virtual void InitVisibilityDistance(); private: - InstanceMap* CreateInstance(uint32 InstanceId, InstanceSave* save, Difficulty difficulty); BattlegroundMap* CreateBattleground(uint32 InstanceId, Battleground* bg); InstancedMaps m_InstancedMaps; - Map* _FindMap(uint32 InstanceId) const - { - InstancedMaps::const_iterator i = m_InstancedMaps.find(InstanceId); - return(i == m_InstancedMaps.end() ? NULL : i->second); - } - uint16 GridMapReference[MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS]; }; #endif diff --git a/src/server/game/Maps/MapManager.cpp b/src/server/game/Maps/MapManager.cpp index 22eaa77cc94..2533096cc22 100755 --- a/src/server/game/Maps/MapManager.cpp +++ b/src/server/game/Maps/MapManager.cpp @@ -125,7 +125,8 @@ Map* MapManager::CreateMap(uint32 id, const WorldObject* obj, uint32 /*instanceI //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 = _createBaseMap(id); - if (m && (obj->GetTypeId() == TYPEID_PLAYER) && m->Instanceable()) m = ((MapInstanced*)m)->CreateInstance(id, (Player*)obj); + if (m && obj->GetTypeId() == TYPEID_PLAYER && m->Instanceable()) + m = ((MapInstanced*)m)->CreateInstanceForPlayer(id, (Player*)obj); return m; } @@ -139,7 +140,7 @@ Map* MapManager::FindMap(uint32 mapid, uint32 instanceId) const if (!map->Instanceable()) return instanceId == 0 ? map : NULL; - return ((MapInstanced*)map)->FindMap(instanceId); + return ((MapInstanced*)map)->FindInstanceMap(instanceId); } bool MapManager::CanPlayerEnter(uint32 mapid, Player* player, bool loginCheck) |