Core/AreaTriggers: Move ScriptName from areatrigger_template to areatrigger_create_properties and areatrigger tables
Port From (https://github.com/TrinityCore/TrinityCore/commit/77ddb4da816b4dfc7ff03b79b88b5ca80918bc2d)
This commit is contained in:
@@ -120,8 +120,8 @@ namespace Game.DataStorage
|
||||
Log.outInfo(LogFilter.ServerLoading, "Loaded 0 AreaTrigger splines. DB table `areatrigger_create_properties_spline_point` is empty.");
|
||||
}
|
||||
|
||||
// 0 1 2 3
|
||||
SQLResult templates = DB.World.Query("SELECT Id, IsServerSide, Flags, ScriptName FROM `areatrigger_template`");
|
||||
// 0 1 2
|
||||
SQLResult templates = DB.World.Query("SELECT Id, IsServerSide, Flags FROM `areatrigger_template`");
|
||||
if (!templates.IsEmpty())
|
||||
{
|
||||
do
|
||||
@@ -137,7 +137,6 @@ namespace Game.DataStorage
|
||||
continue;
|
||||
}
|
||||
|
||||
areaTriggerTemplate.ScriptId = Global.ObjectMgr.GetScriptId(templates.Read<string>(3));
|
||||
areaTriggerTemplate.Actions = actionsByAreaTrigger[areaTriggerTemplate.Id];
|
||||
|
||||
_areaTriggerTemplateStore[areaTriggerTemplate.Id] = areaTriggerTemplate;
|
||||
@@ -147,8 +146,8 @@ namespace Game.DataStorage
|
||||
|
||||
// 0 1 2 3 4 5 6 7 8 9 10
|
||||
SQLResult areatriggerCreateProperties = DB.World.Query("SELECT Id, AreaTriggerId, MoveCurveId, ScaleCurveId, MorphCurveId, FacingCurveId, AnimId, AnimKitId, DecalPropertiesId, TimeToTarget, TimeToTargetScale, " +
|
||||
//11 12 13 14 15 16 17
|
||||
"Shape, ShapeData0, ShapeData1, ShapeData2, ShapeData3, ShapeData4, ShapeData5 FROM `areatrigger_create_properties`");
|
||||
//11 12 13 14 15 16 17 18
|
||||
"Shape, ShapeData0, ShapeData1, ShapeData2, ShapeData3, ShapeData4, ShapeData5, ScriptName FROM `areatrigger_create_properties`");
|
||||
if (!areatriggerCreateProperties.IsEmpty())
|
||||
{
|
||||
do
|
||||
@@ -203,6 +202,8 @@ namespace Game.DataStorage
|
||||
createProperties.Shape.DefaultDatas.Data[i] = areatriggerCreateProperties.Read<float>(12 + i);
|
||||
}
|
||||
|
||||
createProperties.ScriptId = Global.ObjectMgr.GetScriptId(areatriggerCreateProperties.Read<string>(18));
|
||||
|
||||
if (shape == AreaTriggerTypes.Polygon)
|
||||
if (createProperties.Shape.PolygonDatas.Height <= 0.0f)
|
||||
createProperties.Shape.PolygonDatas.Height = 1.0f;
|
||||
@@ -287,8 +288,8 @@ namespace Game.DataStorage
|
||||
// Load area trigger positions (to put them on the server)
|
||||
// 0 1 2 3 4 5 6 7 8 9 10
|
||||
SQLResult templates = DB.World.Query("SELECT SpawnId, AreaTriggerId, IsServerSide, MapId, PosX, PosY, PosZ, Orientation, PhaseUseFlags, PhaseId, PhaseGroup, " +
|
||||
//11 12 13 14 15 16 17
|
||||
"Shape, ShapeData0, ShapeData1, ShapeData2, ShapeData3, ShapeData4, ShapeData5 FROM `areatrigger`");
|
||||
//11 12 13 14 15 16 17 18
|
||||
"Shape, ShapeData0, ShapeData1, ShapeData2, ShapeData3, ShapeData4, ShapeData5, ScriptName FROM `areatrigger`");
|
||||
if (!templates.IsEmpty())
|
||||
{
|
||||
do
|
||||
@@ -332,6 +333,8 @@ namespace Game.DataStorage
|
||||
spawn.Shape.DefaultDatas.Data[i] = templates.Read<float>(12 + i);
|
||||
}
|
||||
|
||||
spawn.ScriptId = Global.ObjectMgr.GetScriptId(templates.Read<string>(18));
|
||||
|
||||
// Add the trigger to a map::cell map, which is later used by GridLoader to query
|
||||
CellCoord cellCoord = GridDefines.ComputeCellCoord(spawn.Location.GetPositionX(), spawn.Location.GetPositionY());
|
||||
if (!_areaTriggerSpawnsByLocation.ContainsKey((spawn.Location.GetMapId(), cellCoord.GetId())))
|
||||
|
||||
@@ -225,6 +225,8 @@ namespace Game.Entities
|
||||
|
||||
public override bool LoadFromDB(ulong spawnId, Map map, bool addToMap, bool allowDuplicate)
|
||||
{
|
||||
_spawnId = spawnId;
|
||||
|
||||
AreaTriggerSpawn position = Global.AreaTriggerDataStorage.GetAreaTriggerSpawn(spawnId);
|
||||
if (position == null)
|
||||
return false;
|
||||
@@ -499,7 +501,13 @@ namespace Game.Entities
|
||||
|
||||
public uint GetScriptId()
|
||||
{
|
||||
return GetTemplate() != null ? GetTemplate().ScriptId : 0;
|
||||
if (_spawnId != 0)
|
||||
return Global.AreaTriggerDataStorage.GetAreaTriggerSpawn(_spawnId).ScriptId;
|
||||
|
||||
if (GetCreateProperties() != null)
|
||||
return GetCreateProperties().ScriptId;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public Unit GetCaster()
|
||||
@@ -1051,6 +1059,8 @@ namespace Game.Entities
|
||||
|
||||
AreaTriggerFieldData m_areaTriggerData;
|
||||
|
||||
ulong _spawnId;
|
||||
|
||||
ObjectGuid _targetGuid;
|
||||
|
||||
AuraEffect _aurEff;
|
||||
|
||||
@@ -252,7 +252,6 @@ namespace Game.Entities
|
||||
{
|
||||
public AreaTriggerId Id;
|
||||
public AreaTriggerFlags Flags;
|
||||
public uint ScriptId;
|
||||
|
||||
public List<AreaTriggerAction> Actions = new();
|
||||
|
||||
@@ -316,6 +315,8 @@ namespace Game.Entities
|
||||
public List<Vector2> PolygonVerticesTarget = new();
|
||||
public List<Vector3> SplinePoints = new();
|
||||
public Optional<AreaTriggerOrbitInfo> OrbitInfo;
|
||||
|
||||
public uint ScriptId;
|
||||
}
|
||||
|
||||
public class AreaTriggerSpawn
|
||||
@@ -328,6 +329,8 @@ namespace Game.Entities
|
||||
public byte PhaseUseFlags;
|
||||
|
||||
public AreaTriggerShapeInfo Shape = new();
|
||||
|
||||
public uint ScriptId;
|
||||
}
|
||||
|
||||
public struct AreaTriggerAction
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
ALTER TABLE `areatrigger` ADD `ScriptName` varchar(64) NOT NULL DEFAULT '' AFTER `ShapeData5`;
|
||||
ALTER TABLE `areatrigger_create_properties` ADD `ScriptName` varchar(64) NOT NULL DEFAULT '' AFTER `ShapeData5`;
|
||||
|
||||
UPDATE `areatrigger` SET `ScriptName`=COALESCE((SELECT att.`ScriptName` FROM `areatrigger_template` att WHERE att.`Id`=`AreaTriggerId` AND att.`IsServerSide`=`IsServerSide`), '');
|
||||
UPDATE `areatrigger_create_properties` SET `ScriptName`=COALESCE((SELECT att.`ScriptName` FROM `areatrigger_template` att WHERE att.`Id`=`AreaTriggerId` AND att.`IsServerSide`=0), '');
|
||||
|
||||
ALTER TABLE `areatrigger_template` DROP `ScriptName`;
|
||||
Reference in New Issue
Block a user