Do not allow an instance map to be created twice if it already exists. Fix #4018.

This commit is contained in:
megamage
2011-11-23 09:34:08 -05:00
parent 1b3017472b
commit 298c162c86
4 changed files with 18 additions and 16 deletions

View File

@@ -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);
}
}