mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/AreaTriggers: Move ScriptName from areatrigger_template to areatrigger_create_properties and areatrigger tables
This commit is contained in:
7
sql/updates/world/master/2021_12_04_00_world.sql
Normal file
7
sql/updates/world/master/2021_12_04_00_world.sql
Normal file
@@ -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`;
|
||||
@@ -227,6 +227,8 @@ AreaTrigger* AreaTrigger::CreateAreaTrigger(uint32 areaTriggerCreatePropertiesId
|
||||
|
||||
bool AreaTrigger::LoadFromDB(ObjectGuid::LowType spawnId, Map* map, bool /*addToMap*/, bool /*allowDuplicate*/)
|
||||
{
|
||||
_spawnId = spawnId;
|
||||
|
||||
AreaTriggerSpawn const* position = sAreaTriggerDataStore->GetAreaTriggerSpawn(spawnId);
|
||||
if (!position)
|
||||
return false;
|
||||
@@ -512,7 +514,13 @@ AreaTriggerTemplate const* AreaTrigger::GetTemplate() const
|
||||
|
||||
uint32 AreaTrigger::GetScriptId() const
|
||||
{
|
||||
return GetTemplate() ? GetTemplate()->ScriptId : 0;
|
||||
if (_spawnId)
|
||||
return ASSERT_NOTNULL(sAreaTriggerDataStore->GetAreaTriggerSpawn(_spawnId))->ScriptId;
|
||||
|
||||
if (GetCreateProperties())
|
||||
return GetCreateProperties()->ScriptId;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Unit* AreaTrigger::GetCaster() const
|
||||
|
||||
@@ -142,6 +142,8 @@ class TC_GAME_API AreaTrigger : public WorldObject, public GridObject<AreaTrigge
|
||||
|
||||
void DebugVisualizePosition(); // Debug purpose only
|
||||
|
||||
ObjectGuid::LowType _spawnId;
|
||||
|
||||
ObjectGuid _targetGuid;
|
||||
|
||||
AuraEffect const* _aurEff;
|
||||
|
||||
@@ -53,7 +53,6 @@ AreaTriggerTemplate::AreaTriggerTemplate()
|
||||
{
|
||||
Id = { 0, false };
|
||||
Flags = 0;
|
||||
ScriptId = 0;
|
||||
}
|
||||
|
||||
AreaTriggerTemplate::~AreaTriggerTemplate()
|
||||
@@ -85,6 +84,8 @@ AreaTriggerCreateProperties::AreaTriggerCreateProperties()
|
||||
ExtraScale.Data.Structured.OverrideActive = 1;
|
||||
|
||||
Template = nullptr;
|
||||
|
||||
ScriptId = 0;
|
||||
}
|
||||
|
||||
AreaTriggerCreateProperties::~AreaTriggerCreateProperties()
|
||||
|
||||
@@ -193,7 +193,6 @@ public:
|
||||
|
||||
AreaTriggerId Id;
|
||||
uint32 Flags;
|
||||
uint32 ScriptId;
|
||||
std::vector<AreaTriggerAction> Actions;
|
||||
};
|
||||
|
||||
@@ -231,6 +230,8 @@ public:
|
||||
|
||||
std::vector<Position> SplinePoints;
|
||||
Optional<AreaTriggerOrbitInfo> OrbitInfo;
|
||||
|
||||
uint32 ScriptId;
|
||||
};
|
||||
|
||||
struct AreaTriggerSpawn
|
||||
@@ -243,6 +244,8 @@ struct AreaTriggerSpawn
|
||||
uint8 PhaseUseFlags = 0;
|
||||
|
||||
AreaTriggerShapeInfo Shape;
|
||||
|
||||
uint32 ScriptId = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -150,8 +150,8 @@ void AreaTriggerDataStore::LoadAreaTriggerTemplates()
|
||||
TC_LOG_INFO("server.loading", ">> Loaded 0 AreaTrigger splines. DB table `areatrigger_create_properties_spline_point` is empty.");
|
||||
}
|
||||
|
||||
// 0 1 2 3
|
||||
if (QueryResult templates = WorldDatabase.Query("SELECT Id, IsServerSide, Flags, ScriptName FROM `areatrigger_template`"))
|
||||
// 0 1 2
|
||||
if (QueryResult templates = WorldDatabase.Query("SELECT Id, IsServerSide, Flags FROM `areatrigger_template`"))
|
||||
{
|
||||
do
|
||||
{
|
||||
@@ -169,7 +169,6 @@ void AreaTriggerDataStore::LoadAreaTriggerTemplates()
|
||||
continue;
|
||||
}
|
||||
|
||||
areaTriggerTemplate.ScriptId = sObjectMgr->GetScriptId(fields[3].GetString());
|
||||
areaTriggerTemplate.Actions = std::move(actionsByAreaTrigger[areaTriggerTemplate.Id]);
|
||||
|
||||
_areaTriggerTemplateStore[areaTriggerTemplate.Id] = areaTriggerTemplate;
|
||||
@@ -179,8 +178,8 @@ void AreaTriggerDataStore::LoadAreaTriggerTemplates()
|
||||
|
||||
// 0 1 2 3 4 5 6 7 8 9 10
|
||||
if (QueryResult areatriggerCreateProperties = WorldDatabase.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`"))
|
||||
{
|
||||
do
|
||||
{
|
||||
@@ -235,6 +234,8 @@ void AreaTriggerDataStore::LoadAreaTriggerTemplates()
|
||||
for (uint8 i = 0; i < MAX_AREATRIGGER_ENTITY_DATA; ++i)
|
||||
createProperties.Shape.DefaultDatas.Data[i] = fields[12 + i].GetFloat();
|
||||
|
||||
createProperties.ScriptId = sObjectMgr->GetScriptId(fields[18].GetString());
|
||||
|
||||
if (shape == AREATRIGGER_TYPE_POLYGON)
|
||||
if (createProperties.Shape.PolygonDatas.Height <= 0.0f)
|
||||
createProperties.Shape.PolygonDatas.Height = 1.0f;
|
||||
@@ -306,8 +307,8 @@ void AreaTriggerDataStore::LoadAreaTriggerSpawns()
|
||||
// Load area trigger positions (to put them on the server)
|
||||
// 0 1 2 3 4 5 6 7 8 9 10
|
||||
if (QueryResult templates = WorldDatabase.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`"))
|
||||
{
|
||||
do
|
||||
{
|
||||
@@ -352,6 +353,8 @@ void AreaTriggerDataStore::LoadAreaTriggerSpawns()
|
||||
for (uint8 i = 0; i < MAX_AREATRIGGER_ENTITY_DATA; ++i)
|
||||
spawn.Shape.DefaultDatas.Data[i] = fields[12 + i].GetFloat();
|
||||
|
||||
spawn.ScriptId = sObjectMgr->GetScriptId(fields[18].GetString());
|
||||
|
||||
// Add the trigger to a map::cell map, which is later used by GridLoader to query
|
||||
CellCoord cellCoord = Trinity::ComputeCellCoord(spawn.Location.GetPositionX(), spawn.Location.GetPositionY());
|
||||
_areaTriggerSpawnsByLocation[{ spawn.Location.GetMapId(), cellCoord.GetId() }].insert(spawnId);
|
||||
|
||||
Reference in New Issue
Block a user