Core/Misc: Some refactoring
Port From (https://github.com/TrinityCore/TrinityCore/commit/94a79bac7a06aa0f931e9d651928de7eea0a8b5c)
This commit is contained in:
@@ -1034,12 +1034,13 @@ namespace Game.Entities
|
||||
// update in loaded data (changing data only in this place)
|
||||
GameObjectData data = Global.ObjectMgr.NewOrExistGameObjectData(m_spawnId);
|
||||
|
||||
if (data.spawnId == 0)
|
||||
data.spawnId = m_spawnId;
|
||||
Cypher.Assert(data.spawnId == m_spawnId);
|
||||
if (data.SpawnId == 0)
|
||||
data.SpawnId = m_spawnId;
|
||||
Cypher.Assert(data.SpawnId == m_spawnId);
|
||||
|
||||
data.Id = GetEntry();
|
||||
data.spawnPoint.WorldRelocate(this);
|
||||
data.MapId = GetMapId();
|
||||
data.SpawnPoint.Relocate(this);
|
||||
data.rotation = m_localRotation;
|
||||
data.spawntimesecs = (int)(m_spawnedByDefault ? m_respawnDelayTime : -m_respawnDelayTime);
|
||||
data.animprogress = GetGoAnimProgress();
|
||||
@@ -1049,8 +1050,8 @@ namespace Game.Entities
|
||||
if (data.spawnGroupData == null)
|
||||
data.spawnGroupData = Global.ObjectMgr.GetDefaultSpawnGroup();
|
||||
|
||||
data.phaseId = GetDBPhase() > 0 ? (uint)GetDBPhase() : data.phaseId;
|
||||
data.phaseGroup = GetDBPhase() < 0 ? (uint)-GetDBPhase() : data.phaseGroup;
|
||||
data.PhaseId = GetDBPhase() > 0 ? (uint)GetDBPhase() : data.PhaseId;
|
||||
data.PhaseGroup = GetDBPhase() < 0 ? (uint)-GetDBPhase() : data.PhaseGroup;
|
||||
|
||||
// Update in DB
|
||||
byte index = 0;
|
||||
@@ -1063,8 +1064,8 @@ namespace Game.Entities
|
||||
stmt.AddValue(index++, GetEntry());
|
||||
stmt.AddValue(index++, mapid);
|
||||
stmt.AddValue(index++, data.spawnDifficulties.Empty() ? "" : string.Join(",", data.spawnDifficulties));
|
||||
stmt.AddValue(index++, data.phaseId);
|
||||
stmt.AddValue(index++, data.phaseGroup);
|
||||
stmt.AddValue(index++, data.PhaseId);
|
||||
stmt.AddValue(index++, data.PhaseGroup);
|
||||
stmt.AddValue(index++, GetPositionX());
|
||||
stmt.AddValue(index++, GetPositionY());
|
||||
stmt.AddValue(index++, GetPositionZ());
|
||||
@@ -1096,10 +1097,10 @@ namespace Game.Entities
|
||||
|
||||
m_spawnId = spawnId;
|
||||
m_respawnCompatibilityMode = ((data.spawnGroupData.flags & SpawnGroupFlags.CompatibilityMode) != 0);
|
||||
if (!Create(entry, map, data.spawnPoint, data.rotation, animprogress, go_state, artKit, !m_respawnCompatibilityMode, spawnId))
|
||||
if (!Create(entry, map, data.SpawnPoint, data.rotation, animprogress, go_state, artKit, !m_respawnCompatibilityMode, spawnId))
|
||||
return false;
|
||||
|
||||
PhasingHandler.InitDbPhaseShift(GetPhaseShift(), data.phaseUseFlags, data.phaseId, data.phaseGroup);
|
||||
PhasingHandler.InitDbPhaseShift(GetPhaseShift(), data.PhaseUseFlags, data.PhaseId, data.PhaseGroup);
|
||||
PhasingHandler.InitDbVisibleMapId(GetPhaseShift(), data.terrainSwapMap);
|
||||
|
||||
if (data.spawntimesecs >= 0)
|
||||
@@ -1154,7 +1155,7 @@ namespace Game.Entities
|
||||
|
||||
SQLTransaction trans = new();
|
||||
|
||||
Global.MapMgr.DoForAllMapsWithMapId(data.spawnPoint.GetMapId(), map =>
|
||||
Global.MapMgr.DoForAllMapsWithMapId(data.MapId, map =>
|
||||
{
|
||||
// despawn all active objects, and remove their respawns
|
||||
List<GameObject> toUnload = new();
|
||||
@@ -2805,7 +2806,7 @@ namespace Game.Entities
|
||||
public void GetRespawnPosition(out float x, out float y, out float z, out float ori)
|
||||
{
|
||||
if (m_goData != null)
|
||||
m_goData.spawnPoint.GetPosition(out x, out y, out z, out ori);
|
||||
m_goData.SpawnPoint.GetPosition(out x, out y, out z, out ori);
|
||||
else
|
||||
GetPosition(out x, out y, out z, out ori);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user