diff options
Diffstat (limited to 'src/server')
| -rw-r--r-- | src/server/game/Entities/GameObject/GameObject.cpp | 19 | ||||
| -rw-r--r-- | src/server/game/Entities/GameObject/GameObject.h | 2 |
2 files changed, 14 insertions, 7 deletions
diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index b43c8c19049..e09930d9fd1 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -833,7 +833,7 @@ void SetControlZoneValue::Execute(GameObjectTypeBase& type) const } GameObject::GameObject() : WorldObject(false), MapObject(), - m_model(nullptr), m_goValue(), m_stringIds(), m_AI(nullptr), m_respawnCompatibilityMode(false), _animKitId(0), _worldEffectID(0) + m_goValue(), m_stringIds(), m_AI(nullptr), m_respawnCompatibilityMode(false), _animKitId(0), _worldEffectID(0) { m_objectType |= TYPEMASK_GAMEOBJECT; m_objectTypeId = TYPEID_GAMEOBJECT; @@ -868,7 +868,6 @@ GameObject::GameObject() : WorldObject(false), MapObject(), GameObject::~GameObject() { delete m_AI; - delete m_model; } void GameObject::AIM_Destroy() @@ -3744,7 +3743,6 @@ void GameObject::SetDestructibleState(GameObjectDestructibleState state, WorldOb m_goValue.Building.Health = m_goValue.Building.DestructibleHitpoint->GetMaxHealth(); SetGoAnimProgress(255); } - EnableCollision(true); break; case GO_DESTRUCTIBLE_DAMAGED: { @@ -3792,7 +3790,6 @@ void GameObject::SetDestructibleState(GameObjectDestructibleState state, WorldOb m_goValue.Building.Health = 0; SetGoAnimProgress(0); } - EnableCollision(false); break; } case GO_DESTRUCTIBLE_REBUILDING: @@ -3813,7 +3810,6 @@ void GameObject::SetDestructibleState(GameObjectDestructibleState state, WorldOb m_goValue.Building.Health = m_goValue.Building.DestructibleHitpoint->GetMaxHealth(); SetGoAnimProgress(255); } - EnableCollision(true); break; } } @@ -4007,15 +4003,26 @@ void GameObject::UpdateModel() { if (!IsInWorld()) return; + bool modelCollisionEnabled; if (m_model) + { + modelCollisionEnabled = m_model->IsCollisionEnabled(); if (GetMap()->ContainsGameObjectModel(*m_model)) GetMap()->RemoveGameObjectModel(*m_model); + } + else + modelCollisionEnabled = GetGoType() == GAMEOBJECT_TYPE_CHEST ? getLootState() == GO_READY : (GetGoState() == GO_STATE_READY || IsTransport()); + RemoveFlag(GO_FLAG_MAP_OBJECT); - delete m_model; m_model = nullptr; + CreateModel(); if (m_model) + { GetMap()->InsertGameObjectModel(*m_model); + if (modelCollisionEnabled) + m_model->EnableCollision(modelCollisionEnabled); + } } bool GameObject::IsLootAllowedFor(Player const* player) const diff --git a/src/server/game/Entities/GameObject/GameObject.h b/src/server/game/Entities/GameObject/GameObject.h index 40c38ac3518..800ef83a09e 100644 --- a/src/server/game/Entities/GameObject/GameObject.h +++ b/src/server/game/Entities/GameObject/GameObject.h @@ -396,7 +396,7 @@ class TC_GAME_API GameObject : public WorldObject, public GridObject<GameObject> uint32 GetFaction() const override { return m_gameObjectData->FactionTemplate; } void SetFaction(uint32 faction) override { SetUpdateFieldValue(m_values.ModifyValue(&GameObject::m_gameObjectData).ModifyValue(&UF::GameObjectData::FactionTemplate), faction); } - GameObjectModel* m_model; + std::unique_ptr<GameObjectModel> m_model; Position GetRespawnPosition() const; TransportBase* ToTransportBase() { return const_cast<TransportBase*>(const_cast<GameObject const*>(this)->ToTransportBase()); } |
