Core/Objects: Preserve phaseUseFlags, terrainSwapMap, ScriptName and StringId columns when saving creature and gameobject spawns in database

Port From (https://github.com/TrinityCore/TrinityCore/commit/203ad17560057b3bf70a1632f3d715e429512701)
This commit is contained in:
Hondacrx
2025-12-08 10:05:57 -05:00
parent e353cf5497
commit 464609d5eb
3 changed files with 23 additions and 4 deletions
@@ -51,10 +51,10 @@ namespace Framework.Database
PrepareStatement(WorldStatements.SEL_CREATURE_BY_ID, "SELECT guid FROM creature WHERE id = ?"); PrepareStatement(WorldStatements.SEL_CREATURE_BY_ID, "SELECT guid FROM creature WHERE id = ?");
PrepareStatement(WorldStatements.SEL_GAMEOBJECT_NEAREST, "SELECT guid, id, position_x, position_y, position_z, map, (POW(position_x - ?, 2) + POW(position_y - ?, 2) + POW(position_z - ?, 2)) AS order_ FROM gameobject WHERE map = ? AND (POW(position_x - ?, 2) + POW(position_y - ?, 2) + POW(position_z - ?, 2)) <= ? ORDER BY order_"); PrepareStatement(WorldStatements.SEL_GAMEOBJECT_NEAREST, "SELECT guid, id, position_x, position_y, position_z, map, (POW(position_x - ?, 2) + POW(position_y - ?, 2) + POW(position_z - ?, 2)) AS order_ FROM gameobject WHERE map = ? AND (POW(position_x - ?, 2) + POW(position_y - ?, 2) + POW(position_z - ?, 2)) <= ? ORDER BY order_");
PrepareStatement(WorldStatements.SEL_CREATURE_NEAREST, "SELECT guid, id, position_x, position_y, position_z, map, (POW(position_x - ?, 2) + POW(position_y - ?, 2) + POW(position_z - ?, 2)) AS order_ FROM creature WHERE map = ? AND (POW(position_x - ?, 2) + POW(position_y - ?, 2) + POW(position_z - ?, 2)) <= ? ORDER BY order_"); PrepareStatement(WorldStatements.SEL_CREATURE_NEAREST, "SELECT guid, id, position_x, position_y, position_z, map, (POW(position_x - ?, 2) + POW(position_y - ?, 2) + POW(position_z - ?, 2)) AS order_ FROM creature WHERE map = ? AND (POW(position_x - ?, 2) + POW(position_y - ?, 2) + POW(position_z - ?, 2)) <= ? ORDER BY order_");
PrepareStatement(WorldStatements.INS_CREATURE, "INSERT INTO creature(guid, id, map, spawnDifficulties, PhaseId, PhaseGroup, modelid, equipment_id, position_x, position_y, position_z, orientation, spawntimesecs, wander_distance, currentwaypoint, curHealthPct, MovementType, npcflag, unit_flags, unit_flags2, unit_flags3) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); PrepareStatement(WorldStatements.INS_CREATURE, "INSERT INTO creature (guid, id , map, spawnDifficulties, phaseUseFlags, PhaseId, PhaseGroup, terrainSwapMap, modelid, equipment_id, position_x, position_y, position_z, orientation, spawntimesecs, wander_distance, currentwaypoint, curHealthPct, MovementType, npcflag, unit_flags, unit_flags2, unit_flags3, ScriptName, StringId) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
PrepareStatement(WorldStatements.DEL_GAME_EVENT_CREATURE, "DELETE FROM game_event_creature WHERE guid = ?"); PrepareStatement(WorldStatements.DEL_GAME_EVENT_CREATURE, "DELETE FROM game_event_creature WHERE guid = ?");
PrepareStatement(WorldStatements.DEL_GAME_EVENT_MODEL_EQUIP, "DELETE FROM game_event_model_equip WHERE guid = ?"); PrepareStatement(WorldStatements.DEL_GAME_EVENT_MODEL_EQUIP, "DELETE FROM game_event_model_equip WHERE guid = ?");
PrepareStatement(WorldStatements.INS_GAMEOBJECT, "INSERT INTO gameobject (guid, id, map, spawnDifficulties, PhaseId, PhaseGroup, position_x, position_y, position_z, orientation, rotation0, rotation1, rotation2, rotation3, spawntimesecs, animprogress, state) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); PrepareStatement(WorldStatements.INS_GAMEOBJECT, "INSERT INTO gameobject (guid, id, map, spawnDifficulties, phaseUseFlags, PhaseId, PhaseGroup, terrainSwapMap, position_x, position_y, position_z, orientation, rotation0, rotation1, rotation2, rotation3, spawntimesecs, animprogress, state, ScriptName, StringId) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
PrepareStatement(WorldStatements.INS_DISABLES, "INSERT INTO disables (entry, sourceType, flags, comment) VALUES (?, ?, ?, ?)"); PrepareStatement(WorldStatements.INS_DISABLES, "INSERT INTO disables (entry, sourceType, flags, comment) VALUES (?, ?, ?, ?)");
PrepareStatement(WorldStatements.SEL_DISABLES, "SELECT entry FROM disables WHERE entry = ? AND sourceType = ?"); PrepareStatement(WorldStatements.SEL_DISABLES, "SELECT entry FROM disables WHERE entry = ? AND sourceType = ?");
PrepareStatement(WorldStatements.DEL_DISABLES, "DELETE FROM disables WHERE entry = ? AND sourceType = ?"); PrepareStatement(WorldStatements.DEL_DISABLES, "DELETE FROM disables WHERE entry = ? AND sourceType = ?");
+12 -2
View File
@@ -1500,8 +1500,10 @@ namespace Game.Entities
stmt.AddValue(index++, GetEntry()); stmt.AddValue(index++, GetEntry());
stmt.AddValue(index++, mapid); stmt.AddValue(index++, mapid);
stmt.AddValue(index++, data.SpawnDifficulties.Empty() ? "" : string.Join(',', data.SpawnDifficulties)); stmt.AddValue(index++, data.SpawnDifficulties.Empty() ? "" : string.Join(',', data.SpawnDifficulties));
stmt.AddValue(index++, (byte)data.PhaseUseFlags);
stmt.AddValue(index++, data.PhaseId); stmt.AddValue(index++, data.PhaseId);
stmt.AddValue(index++, data.PhaseGroup); stmt.AddValue(index++, data.PhaseGroup);
stmt.AddValue(index++, data.terrainSwapMap);
stmt.AddValue(index++, displayId); stmt.AddValue(index++, displayId);
stmt.AddValue(index++, GetCurrentEquipmentId()); stmt.AddValue(index++, GetCurrentEquipmentId());
stmt.AddValue(index++, GetPositionX()); stmt.AddValue(index++, GetPositionX());
@@ -1532,6 +1534,14 @@ namespace Game.Entities
stmt.AddValue(index++, unitFlags3.Value); stmt.AddValue(index++, unitFlags3.Value);
else else
stmt.AddNull(index++); stmt.AddNull(index++);
stmt.AddValue(index++, Global.ObjectMgr.GetScriptName(data.ScriptId));
var stringId = GetStringId(StringIdType.Spawn);
if (!stringId.IsEmpty())
stmt.AddValue(index++, stringId);
else
stmt.AddNull(index++);
trans.Append(stmt); trans.Append(stmt);
DB.World.CommitTransaction(trans); DB.World.CommitTransaction(trans);
@@ -2877,9 +2887,9 @@ namespace Game.Entities
{ {
CreatureTemplate cInfo = GetCreatureTemplate(); CreatureTemplate cInfo = GetCreatureTemplate();
CreatureDifficulty creatureDifficulty = GetCreatureDifficulty(); CreatureDifficulty creatureDifficulty = GetCreatureDifficulty();
float baseHealth = Global.DB2Mgr.EvaluateExpectedStat(ExpectedStatType.CreatureHealth, level, creatureDifficulty.GetHealthScalingExpansion(), creatureDifficulty.ContentTuningID, (Class)cInfo.UnitClass, 0); double baseHealth = Global.DB2Mgr.EvaluateExpectedStat(ExpectedStatType.CreatureHealth, level, creatureDifficulty.GetHealthScalingExpansion(), creatureDifficulty.ContentTuningID, (Class)cInfo.UnitClass, 0);
return (ulong)Math.Max(baseHealth * creatureDifficulty.HealthModifier, 1.0f); return (ulong)Math.Max(baseHealth * creatureDifficulty.HealthModifier, 1.0);
} }
public override float GetHealthMultiplierForTarget(WorldObject target) public override float GetHealthMultiplierForTarget(WorldObject target)
@@ -1085,8 +1085,10 @@ namespace Game.Entities
stmt.AddValue(index++, GetEntry()); stmt.AddValue(index++, GetEntry());
stmt.AddValue(index++, mapid); stmt.AddValue(index++, mapid);
stmt.AddValue(index++, data.SpawnDifficulties.Empty() ? "" : string.Join(",", data.SpawnDifficulties)); stmt.AddValue(index++, data.SpawnDifficulties.Empty() ? "" : string.Join(",", data.SpawnDifficulties));
stmt.AddValue(index++, (byte)data.PhaseUseFlags);
stmt.AddValue(index++, data.PhaseId); stmt.AddValue(index++, data.PhaseId);
stmt.AddValue(index++, data.PhaseGroup); stmt.AddValue(index++, data.PhaseGroup);
stmt.AddValue(index++, data.terrainSwapMap);
stmt.AddValue(index++, GetPositionX()); stmt.AddValue(index++, GetPositionX());
stmt.AddValue(index++, GetPositionY()); stmt.AddValue(index++, GetPositionY());
stmt.AddValue(index++, GetPositionZ()); stmt.AddValue(index++, GetPositionZ());
@@ -1098,6 +1100,13 @@ namespace Game.Entities
stmt.AddValue(index++, m_respawnDelayTime); stmt.AddValue(index++, m_respawnDelayTime);
stmt.AddValue(index++, GetGoAnimProgress()); stmt.AddValue(index++, GetGoAnimProgress());
stmt.AddValue(index++, (byte)GetGoState()); stmt.AddValue(index++, (byte)GetGoState());
stmt.AddValue(index++, Global.ObjectMgr.GetScriptName(data.ScriptId));
var stringId = GetStringId(StringIdType.Spawn);
if (!stringId.IsEmpty())
stmt.AddValue(index++, stringId);
else
stmt.AddNull(index++);
DB.World.Execute(stmt); DB.World.Execute(stmt);
} }