[8182] Store and use Map* pointer in WorldObject instead map ids for speedup Author: Ambal
Also some code logic cleanups.
Changes let make more cleanups in base map access and other places,
but this chnages not inlcuded in patch.
*This patch may cause crash.
--HG--
branch : trunk
This commit is contained in:
1 parent
762528c5dd
commit
208087ff6e
28 files changed
+151
-147
No files matched your search
@@ -116,15 +116,8 @@ 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::GetInstance(const WorldObject* obj)
|
||||
Map* MapInstanced::CreateInstance(const uint32 mapId, Player * player)
|
||||
{
|
||||
if(obj->GetTypeId() == TYPEID_UNIT)
|
||||
{
|
||||
assert(obj->GetMapId() == GetId() && obj->GetInstanceId());
|
||||
return _FindMap(obj->GetInstanceId());
|
||||
}
|
||||
|
||||
Player* player = (Player*)obj;
|
||||
uint32 instanceId = player->GetInstanceId();
|
||||
|
||||
if(instanceId)
|
||||
@@ -193,10 +186,10 @@ InstanceMap* MapInstanced::CreateInstance(uint32 InstanceId, InstanceSave *save,
|
||||
// some instances only have one difficulty
|
||||
if (entry && !entry->SupportsHeroicMode()) difficulty = DIFFICULTY_NORMAL;
|
||||
|
||||
sLog.outDebug("MapInstanced::CreateInstance: %smap instance %d for %d created with difficulty %s", save?"":"new ", InstanceId, GetId(), difficulty?"heroic":"normal");
|
||||
sLog.outDebug("MapInstanced::CreateInstance: %s map instance %d for %d created with difficulty %s", save?"":"new ", InstanceId, GetId(), difficulty?"heroic":"normal");
|
||||
|
||||
InstanceMap *map = new InstanceMap(GetId(), GetGridExpiry(), InstanceId, difficulty);
|
||||
assert(map->IsDungeon());
|
||||
InstanceMap *map = new InstanceMap(GetId(), GetGridExpiry(), InstanceId, difficulty, this);
|
||||
ASSERT(map->IsDungeon());
|
||||
|
||||
bool load_data = save != NULL;
|
||||
map->CreateInstanceData(load_data);
|
||||
@@ -212,8 +205,8 @@ BattleGroundMap* MapInstanced::CreateBattleGround(uint32 InstanceId)
|
||||
|
||||
sLog.outDebug("MapInstanced::CreateBattleGround: map bg %d for %d created.", InstanceId, GetId());
|
||||
|
||||
BattleGroundMap *map = new BattleGroundMap(GetId(), GetGridExpiry(), InstanceId);
|
||||
assert(map->IsBattleGroundOrArena());
|
||||
BattleGroundMap *map = new BattleGroundMap(GetId(), GetGridExpiry(), InstanceId, this);
|
||||
ASSERT(map->IsBattleGroundOrArena());
|
||||
|
||||
m_InstancedMaps[InstanceId] = map;
|
||||
return map;
|
||||
@@ -245,9 +238,7 @@ void MapInstanced::DestroyInstance(InstancedMaps::iterator &itr)
|
||||
|
||||
bool MapInstanced::CanEnter(Player *player)
|
||||
{
|
||||
if(Map* map = GetInstance(player))
|
||||
return map->CanEnter(player);
|
||||
|
||||
return false;
|
||||
//assert(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user