diff options
author | megamage <none@none> | 2009-08-25 11:42:18 -0500 |
---|---|---|
committer | megamage <none@none> | 2009-08-25 11:42:18 -0500 |
commit | 8cedad1a0f1e8f58b1b0ff1195fed790e66b6408 (patch) | |
tree | 7e6dd781a51a9a47fc71db289a5ba0c0ff9706d1 | |
parent | ba78dd144114806d28a8d9615bc7c84623a26989 (diff) |
*Do not make getmapid virtual function to improve speed.
--HG--
branch : trunk
-rw-r--r-- | src/game/Corpse.cpp | 11 | ||||
-rw-r--r-- | src/game/Corpse.h | 9 | ||||
-rw-r--r-- | src/game/Object.cpp | 6 | ||||
-rw-r--r-- | src/game/Object.h | 13 |
4 files changed, 22 insertions, 17 deletions
diff --git a/src/game/Corpse.cpp b/src/game/Corpse.cpp index 6aec1da7ef9..16e52ef46aa 100644 --- a/src/game/Corpse.cpp +++ b/src/game/Corpse.cpp @@ -38,8 +38,6 @@ Corpse::Corpse(CorpseType type) : WorldObject() m_valuesCount = CORPSE_END; - m_mapId = 0; - m_time = time(NULL); lootForBody = false; @@ -193,6 +191,7 @@ bool Corpse::LoadFromDB(uint32 guid, Field *fields) float positionY = fields[1].GetFloat(); float positionZ = fields[2].GetFloat(); float ort = fields[3].GetFloat(); + uint32 mapid = fields[4].GetUInt32(); Object::_Create(guid, 0, HIGHGUID_CORPSE); @@ -202,9 +201,6 @@ bool Corpse::LoadFromDB(uint32 guid, Field *fields) return false; } - SetMapId(fields[4].GetUInt32()); - SetInstanceId(fields[8].GetUInt32()); - m_time = time_t(fields[6].GetUInt64()); m_type = CorpseType(fields[7].GetUInt32()); @@ -217,11 +213,16 @@ bool Corpse::LoadFromDB(uint32 guid, Field *fields) if(m_type != CORPSE_BONES) m_isWorldObject = true; + uint32 instanceid = fields[8].GetUInt32(); + uint32 phaseMask = fields[9].GetUInt32(); // overwrite possible wrong/corrupted guid SetUInt64Value(OBJECT_FIELD_GUID, MAKE_NEW_GUID(guid, 0, HIGHGUID_CORPSE)); + // place + SetLocationInstanceId(instanceid); + SetLocationMapId(mapid); SetPhaseMask(phaseMask, false); Relocate(positionX, positionY, positionZ, ort); diff --git a/src/game/Corpse.h b/src/game/Corpse.h index 2a6ebc71809..e0374a03470 100644 --- a/src/game/Corpse.h +++ b/src/game/Corpse.h @@ -67,13 +67,6 @@ class Corpse : public WorldObject void DeleteBonesFromWorld(); void DeleteFromDB(); - void SetMap (Map * map) {WorldObject::SetMap(map); m_mapId = map->GetId(); SetInstanceId(map->GetInstanceId());} - // Used to check object existence in unloaded grids - uint32 GetMapId() const {return m_mapId;} - void SetMapId (uint32 id) {m_mapId = id;} - uint32 GetInstanceId() const {return m_instanceId;} - void SetInstanceId (uint32 id) {m_instanceId = id;} - uint64 const& GetOwnerGUID() const { return GetUInt64Value(CORPSE_FIELD_OWNER); } time_t const& GetGhostTime() const { return m_time; } @@ -102,8 +95,6 @@ class Corpse : public WorldObject CorpseType m_type; time_t m_time; GridPair m_grid; // gride for corpse position for fast search - uint32 m_mapId; // map id for fast corpse check at packet requests and in other situations with unloaded map of corpse. - uint32 m_instanceId; }; #endif diff --git a/src/game/Object.cpp b/src/game/Object.cpp index e6027f6d5a4..411114aeb65 100644 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -1080,7 +1080,7 @@ bool Object::PrintIndexError(uint32 index, bool set) const } WorldObject::WorldObject() - : m_phaseMask(PHASEMASK_NORMAL), + : m_mapId(0), m_InstanceId(0), m_phaseMask(PHASEMASK_NORMAL), m_positionX(0.0f), m_positionY(0.0f), m_positionZ(0.0f), m_orientation(0.0f), m_currMap(NULL) , m_zoneScript(NULL) , m_isActive(false), m_isWorldObject(false) @@ -1713,6 +1713,8 @@ void WorldObject::SetMap(Map * map) ASSERT(!m_currMap); m_currMap = map; + m_mapId = map->GetId(); + m_InstanceId = map->GetInstanceId(); if(m_isWorldObject) m_currMap->AddWorldObject(this); } @@ -1724,6 +1726,8 @@ void WorldObject::ResetMap() if(m_isWorldObject) m_currMap->RemoveWorldObject(this); m_currMap = NULL; + m_mapId = 0; + m_InstanceId = 0; } Map const* WorldObject::GetBaseMap() const diff --git a/src/game/Object.h b/src/game/Object.h index 3688f37c882..3b568ef225f 100644 --- a/src/game/Object.h +++ b/src/game/Object.h @@ -439,8 +439,8 @@ class TRINITY_DLL_SPEC WorldObject : public Object void GetRandomPoint( float x, float y, float z, float distance, float &rand_x, float &rand_y, float &rand_z ) const; - virtual uint32 GetMapId() const { return m_currMap ? m_currMap->GetId() : 0; } - virtual uint32 GetInstanceId() const { return m_currMap ? m_currMap->GetInstanceId() : 0; } + uint32 GetMapId() const { return m_mapId; } + uint32 GetInstanceId() const { return m_InstanceId; } virtual void SetPhaseMask(uint32 newPhaseMask, bool update); uint32 GetPhaseMask() const { return m_phaseMask; } @@ -578,8 +578,17 @@ class TRINITY_DLL_SPEC WorldObject : public Object bool m_isActive; ZoneScript *m_zoneScript; + //these functions are used mostly for Relocate() and Corpse/Player specific stuff... + //use them ONLY in LoadFromDB()/Create() funcs and nowhere else! + //mapId/instanceId should be set in SetMap() function! + void SetLocationMapId(uint32 _mapId) { m_mapId = _mapId; } + void SetLocationInstanceId(uint32 _instanceId) { m_InstanceId = _instanceId; } + private: Map * m_currMap; //current object's Map location + + uint32 m_mapId; // object at map with map_id + uint32 m_InstanceId; // in map copy with instance id uint32 m_phaseMask; // in area phase state float m_positionX; |