diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp index 6238c4010..0ac2218c9 100644 --- a/src/game/GameObject.cpp +++ b/src/game/GameObject.cpp @@ -39,7 +39,9 @@ #include "Util.h" #include "ScriptMgr.h" -GameObject::GameObject() : WorldObject() +GameObject::GameObject() : WorldObject(), + m_goInfo(NULL), + m_displayInfo(NULL) { m_objectType |= TYPEMASK_GAMEOBJECT; m_objectTypeId = TYPEID_GAMEOBJECT; @@ -54,7 +56,6 @@ GameObject::GameObject() : WorldObject() m_useTimes = 0; m_spellId = 0; m_cooldownTime = 0; - m_goInfo = NULL; m_rotation = 0; } @@ -140,8 +141,7 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map *map, uint32 phaseMa SetFlag(GAMEOBJECT_FLAGS, (GO_FLAG_TRANSPORT | GO_FLAG_NODESPAWN)); SetEntry(goinfo->id); - - SetUInt32Value(GAMEOBJECT_DISPLAYID, goinfo->displayId); + SetDisplayId(goinfo->displayId); // GAMEOBJECT_BYTES_1, index at 0, 1, 2 and 3 SetGoState(go_state); @@ -1749,13 +1749,19 @@ bool GameObject::IsFriendlyTo(Unit const* unit) const return tester_faction->IsFriendlyTo(*target_faction); } +void GameObject::SetDisplayId(uint32 modelId) +{ + SetUInt32Value(GAMEOBJECT_DISPLAYID, modelId); + m_displayInfo = sGameObjectDisplayInfoStore.LookupEntry(modelId); +} + float GameObject::GetObjectBoundingRadius() const { //FIXME: // 1. This is clearly hack way because GameObjectDisplayInfoEntry have 6 floats related to GO sizes, but better that use DEFAULT_WORLD_OBJECT_SIZE // 2. In some cases this must be only interactive size, not GO size, current way can affect creature target point auto-selection in strange ways for big underground/virtual GOs - if (GameObjectDisplayInfoEntry const* dispEntry = sGameObjectDisplayInfoStore.LookupEntry(GetGOInfo()->displayId)) - return fabs(dispEntry->unknown12) * GetObjectScale(); + if (m_displayInfo) + return fabs(m_displayInfo->unknown12) * GetObjectScale(); return DEFAULT_WORLD_OBJECT_SIZE; } diff --git a/src/game/GameObject.h b/src/game/GameObject.h index 6237e48b4..01791ab39 100644 --- a/src/game/GameObject.h +++ b/src/game/GameObject.h @@ -670,6 +670,8 @@ class MANGOS_DLL_SPEC GameObject : public WorldObject void SetGoArtKit(uint8 artkit) { SetByteValue(GAMEOBJECT_BYTES_1, 2, artkit); } uint8 GetGoAnimProgress() const { return GetByteValue(GAMEOBJECT_BYTES_1, 3); } void SetGoAnimProgress(uint8 animprogress) { SetByteValue(GAMEOBJECT_BYTES_1, 3, animprogress); } + uint32 GetDisplayId() const { return GetUInt32Value(GAMEOBJECT_DISPLAYID); } + void SetDisplayId(uint32 modelId); float GetObjectBoundingRadius() const; // overwrite WorldObject version @@ -739,6 +741,7 @@ class MANGOS_DLL_SPEC GameObject : public WorldObject GuidsSet m_UniqueUsers; // all players who use item, some items activated after specific amount unique uses GameObjectInfo const* m_goInfo; + GameObjectDisplayInfoEntry const* m_displayInfo; uint64 m_rotation; private: void SwitchDoorOrButton(bool activate, bool alternative = false); diff --git a/src/game/Transports.cpp b/src/game/Transports.cpp index 08af53d74..9e3b7e40b 100644 --- a/src/game/Transports.cpp +++ b/src/game/Transports.cpp @@ -178,7 +178,7 @@ bool Transport::Create(uint32 guidlow, uint32 mapid, float x, float y, float z, SetUInt32Value(GAMEOBJECT_LEVEL, m_period); SetEntry(goinfo->id); - SetUInt32Value(GAMEOBJECT_DISPLAYID, goinfo->displayId); + SetDisplayId(goinfo->displayId); SetGoState(GO_STATE_READY); SetGoType(GameobjectTypes(goinfo->type)); diff --git a/src/game/Unit.h b/src/game/Unit.h index 66b865fb6..7f9123e6e 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -1781,9 +1781,9 @@ class MANGOS_DLL_SPEC Unit : public WorldObject uint32 m_AuraFlags; - uint32 GetDisplayId() { return GetUInt32Value(UNIT_FIELD_DISPLAYID); } + uint32 GetDisplayId() const { return GetUInt32Value(UNIT_FIELD_DISPLAYID); } void SetDisplayId(uint32 modelId); - uint32 GetNativeDisplayId() { return GetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID); } + uint32 GetNativeDisplayId() const { return GetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID); } void SetNativeDisplayId(uint32 modelId) { SetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID, modelId); } void setTransForm(uint32 spellid) { m_transform = spellid;} uint32 getTransForm() const { return m_transform;} diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 090373a72..74ef789b4 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "11380" + #define REVISION_NR "11381" #endif // __REVISION_NR_H__