Core/GameObjects: Properly set GO_FLAG_MAP_OBJECT during gameobject creation

This commit is contained in:
Shauren
2020-07-27 08:58:40 +02:00
parent 97afa3a609
commit e3cf94d4fd
3 changed files with 10 additions and 13 deletions

View File

@@ -330,9 +330,7 @@ bool GameObject::Create(uint32 entry, Map* map, Position const& pos, QuaternionD
SetDisplayId(goInfo->displayId);
m_model = CreateModel();
if (m_model && m_model->isMapObject())
AddFlag(GO_FLAG_MAP_OBJECT);
CreateModel();
// GAMEOBJECT_BYTES_1, index at 0, 1, 2 and 3
SetGoType(GameobjectTypes(goInfo->type));
m_prevGoState = goState;
@@ -2504,15 +2502,12 @@ void GameObject::UpdateModel()
if (m_model)
if (GetMap()->ContainsGameObjectModel(*m_model))
GetMap()->RemoveGameObjectModel(*m_model);
RemoveFlag(GO_FLAG_MAP_OBJECT);
delete m_model;
m_model = CreateModel();
m_model = nullptr;
CreateModel();
if (m_model)
GetMap()->InsertGameObjectModel(*m_model);
if (m_model && m_model->isMapObject())
AddFlag(GO_FLAG_MAP_OBJECT);
else
RemoveFlag(GO_FLAG_MAP_OBJECT);
}
Player* GameObject::GetLootRecipient() const
@@ -2728,7 +2723,9 @@ private:
GameObject* _owner;
};
GameObjectModel* GameObject::CreateModel()
void GameObject::CreateModel()
{
return GameObjectModel::Create(std::make_unique<GameObjectModelOwnerImpl>(this), sWorld->GetDataPath());
m_model = GameObjectModel::Create(std::make_unique<GameObjectModelOwnerImpl>(this), sWorld->GetDataPath());
if (m_model && m_model->isMapObject())
AddFlag(GO_FLAG_MAP_OBJECT);
}

View File

@@ -319,7 +319,7 @@ class TC_GAME_API GameObject : public WorldObject, public GridObject<GameObject>
UF::UpdateField<UF::GameObjectData, 0, TYPEID_GAMEOBJECT> m_gameObjectData;
protected:
GameObjectModel* CreateModel();
void CreateModel();
void UpdateModel(); // updates model in case displayId were changed
uint32 m_spellId;
time_t m_respawnTime; // (secs) time of next respawn (or despawn if GO have owner()),

View File

@@ -104,7 +104,7 @@ bool Transport::Create(ObjectGuid::LowType guidlow, uint32 entry, uint32 mapid,
SetWorldRotation(0.0f, 0.0f, 0.0f, 1.0f);
SetParentRotation(QuaternionData());
m_model = CreateModel();
CreateModel();
return true;
}