mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 22:37:03 +00:00
[8182] Store and use Map* pointer in WorldObject instead map ids for speedup
Also some code logic cleanups. Changes let make more cleanups in base map access and other places, but this chnages not inlcuded in patch. Signed-off-by: VladimirMangos <vladimir@getmangos.com>
This commit is contained in:
parent
fcb34b3928
commit
58209ee79a
25 changed files with 180 additions and 193 deletions
|
|
@ -540,7 +540,7 @@ bool Player::Create( uint32 guidlow, const std::string& name, uint8 race, uint8
|
|||
for (int i = 0; i < PLAYER_SLOTS_COUNT; ++i)
|
||||
m_items[i] = NULL;
|
||||
|
||||
SetMapId(info->mapId);
|
||||
SetLocationMapId(info->mapId);
|
||||
Relocate(info->positionX,info->positionY,info->positionZ);
|
||||
|
||||
ChrClassesEntry const* cEntry = sChrClassesStore.LookupEntry(class_);
|
||||
|
|
@ -550,6 +550,8 @@ bool Player::Create( uint32 guidlow, const std::string& name, uint8 race, uint8
|
|||
return false;
|
||||
}
|
||||
|
||||
SetMap(MapManager::Instance().CreateMap(info->mapId, this));
|
||||
|
||||
uint8 powertype = cEntry->powerType;
|
||||
|
||||
SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, DEFAULT_WORLD_OBJECT_SIZE);
|
||||
|
|
@ -12031,7 +12033,11 @@ void Player::PrepareQuestMenu( uint64 guid )
|
|||
}
|
||||
else
|
||||
{
|
||||
GameObject *pGameObject = GetMap()->GetGameObject(guid);
|
||||
//we should obtain map pointer from GetMap() in 99% of cases. Special case
|
||||
//only for quests which cast teleport spells on player
|
||||
Map * _map = IsInWorld() ? GetMap() : MapManager::Instance().FindMap(GetMapId(), GetInstanceId());
|
||||
ASSERT(_map);
|
||||
GameObject *pGameObject = _map->GetGameObject(guid);
|
||||
if( pGameObject )
|
||||
{
|
||||
pObject = (Object*)pGameObject;
|
||||
|
|
@ -13829,7 +13835,8 @@ bool Player::MinimalLoadFromDB( QueryResult *result, uint32 guid )
|
|||
m_name = fields[2].GetCppString();
|
||||
|
||||
Relocate(fields[3].GetFloat(),fields[4].GetFloat(),fields[5].GetFloat());
|
||||
SetMapId(fields[6].GetUInt32());
|
||||
SetLocationMapId(fields[6].GetUInt32());
|
||||
|
||||
// the instance id is not needed at character enum
|
||||
|
||||
m_Played_time[0] = fields[7].GetUInt32();
|
||||
|
|
@ -14108,7 +14115,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
|
|||
// init saved position, and fix it later if problematic
|
||||
uint32 transGUID = fields[31].GetUInt32();
|
||||
Relocate(fields[13].GetFloat(),fields[14].GetFloat(),fields[15].GetFloat(),fields[17].GetFloat());
|
||||
SetMapId(fields[16].GetUInt32());
|
||||
SetLocationMapId(fields[16].GetUInt32());
|
||||
SetDifficulty(fields[39].GetUInt32()); // may be changed in _LoadGroup
|
||||
|
||||
_LoadGroup(holder->GetResult(PLAYER_LOGIN_QUERY_LOADGROUP));
|
||||
|
|
@ -14183,7 +14190,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
|
|||
else
|
||||
{
|
||||
const WorldLocation& _loc = GetBattleGroundEntryPoint();
|
||||
SetMapId(_loc.mapid);
|
||||
SetLocationMapId(_loc.mapid);
|
||||
Relocate(_loc.coord_x, _loc.coord_y, _loc.coord_z, _loc.orientation);
|
||||
//RemoveArenaAuras(true);
|
||||
}
|
||||
|
|
@ -14196,7 +14203,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
|
|||
if(!mapEntry || mapEntry->IsBattleGroundOrArena())
|
||||
{
|
||||
// return to BG master
|
||||
SetMapId(fields[43].GetUInt32());
|
||||
SetLocationMapId(fields[43].GetUInt32());
|
||||
Relocate(fields[44].GetFloat(),fields[45].GetFloat(),fields[46].GetFloat(),fields[47].GetFloat());
|
||||
|
||||
// check entry point and fix to homebind if need
|
||||
|
|
@ -14250,7 +14257,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
|
|||
|
||||
m_transport = *iter;
|
||||
m_transport->AddPassenger(this);
|
||||
SetMapId(m_transport->GetMapId());
|
||||
SetLocationMapId(m_transport->GetMapId());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -14283,11 +14290,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
|
|||
|
||||
// NOW player must have valid map
|
||||
// load the player's map here if it's not already loaded
|
||||
Map *map = GetMap();
|
||||
|
||||
// since the player may not be bound to the map yet, make sure subsequent
|
||||
// getmap calls won't create new maps
|
||||
SetInstanceId(map->GetInstanceId());
|
||||
SetMap(MapManager::Instance().CreateMap(GetMapId(), this));
|
||||
|
||||
// if the player is in an instance and it has been reset in the meantime teleport him to the entrance
|
||||
if(GetInstanceId() && !sInstanceSaveManager.GetInstanceSave(GetInstanceId()))
|
||||
|
|
@ -14465,15 +14468,19 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
|
|||
{
|
||||
sLog.outError("Character %u have wrong data in taxi destination list, teleport to homebind.",GetGUIDLow());
|
||||
RelocateToHomebind();
|
||||
SaveRecallPosition(); // save as recall also to prevent recall and fall from sky
|
||||
}
|
||||
else // have start node, to it
|
||||
{
|
||||
sLog.outError("Character %u have too short taxi destination list, teleport to original node.",GetGUIDLow());
|
||||
SetMapId(nodeEntry->map_id);
|
||||
SetLocationMapId(nodeEntry->map_id);
|
||||
Relocate(nodeEntry->x, nodeEntry->y, nodeEntry->z,0.0f);
|
||||
SaveRecallPosition(); // save as recall also to prevent recall and fall from sky
|
||||
}
|
||||
|
||||
//we can be relocated from taxi and still have an outdated Map pointer!
|
||||
//so we need to get a new Map pointer!
|
||||
SetMap(MapManager::Instance().CreateMap(GetMapId(), this));
|
||||
SaveRecallPosition(); // save as recall also to prevent recall and fall from sky
|
||||
|
||||
m_taxi.ClearTaxiDestinations();
|
||||
}
|
||||
else if(uint32 node_id = m_taxi.GetTaxiSource())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue