fix(Core/GameObject): load guid based scripts correctly (#18811)

- m_goData must be assigned before Create() is beeing called
- otherwise GetScriptId() can't load the correct scriptiD
  in Create()
- all in all this is now more in line with how it's beeing
  done in Creature.cpp
This commit is contained in:
sudlud
2024-04-27 01:56:46 +02:00
committed by GitHub
parent 1f5fe728c2
commit 0a376bdc76
@@ -406,7 +406,7 @@ bool GameObject::Create(ObjectGuid::LowType guidlow, uint32 name_id, Map* map, u
} }
} }
LastUsedScriptID = GetGOInfo()->ScriptId; LastUsedScriptID = GetScriptId();
AIM_Initialize(); AIM_Initialize();
if (uint32 linkedEntry = GetGOInfo()->GetLinkedGameObjectEntry()) if (uint32 linkedEntry = GetGOInfo()->GetLinkedGameObjectEntry())
@@ -1140,6 +1140,7 @@ bool GameObject::LoadGameObjectFromDB(ObjectGuid::LowType spawnId, Map* map, boo
GOState go_state = data->go_state; GOState go_state = data->go_state;
uint32 artKit = data->artKit; uint32 artKit = data->artKit;
m_goData = data;
m_spawnId = spawnId; m_spawnId = spawnId;
if (!Create(map->GenerateLowGuid<HighGuid::GameObject>(), entry, map, phaseMask, x, y, z, ang, data->rotation, animprogress, go_state, artKit)) if (!Create(map->GenerateLowGuid<HighGuid::GameObject>(), entry, map, phaseMask, x, y, z, ang, data->rotation, animprogress, go_state, artKit))
@@ -1175,8 +1176,6 @@ bool GameObject::LoadGameObjectFromDB(ObjectGuid::LowType spawnId, Map* map, boo
m_respawnTime = 0; m_respawnTime = 0;
} }
m_goData = data;
if (addToMap && !GetMap()->AddToMap(this)) if (addToMap && !GetMap()->AddToMap(this))
return false; return false;