mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-20 01:15:35 +01:00
Do not allow an instance map to be created twice if it already exists. Fix #4018.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user