diff --git a/Source/Game/DataStorage/AreaTriggerDataStorage.cs b/Source/Game/DataStorage/AreaTriggerDataStorage.cs index 1a5eefdf1..bd31f7ea7 100644 --- a/Source/Game/DataStorage/AreaTriggerDataStorage.cs +++ b/Source/Game/DataStorage/AreaTriggerDataStorage.cs @@ -28,64 +28,45 @@ namespace Game.DataStorage { AreaTriggerDataStorage() { } - public AreaTriggerTemplate GetAreaTriggerServerTemplate(uint areaTriggerId) - { - return _areaTriggerTemplateMap.LookupByKey(new AreaTriggerTemplateKey(areaTriggerId, true)); - } - - public SortedSet GetAreaTriggersForMapAndCell(uint mapId, uint cellId) - { - if (!_areaTriggersGrid.ContainsKey(mapId)) - return null; - - return _areaTriggersGrid[mapId].LookupByKey(cellId); - } - - public AreaTriggerServerPosition GetAreaTriggerServerPosition(uint spawnId) - { - return _areaTriggerSpawnMap.LookupByKey(spawnId); - } - public void LoadAreaTriggerTemplates() { uint oldMSTime = Time.GetMSTime(); MultiMap verticesByAreaTrigger = new MultiMap(); MultiMap verticesTargetByAreaTrigger = new MultiMap(); MultiMap splinesBySpellMisc = new MultiMap(); - MultiMap actionsByAreaTrigger = new MultiMap(); + MultiMap actionsByAreaTrigger = new MultiMap(); - // 0 1 2 3 - SQLResult templateActions = DB.World.Query("SELECT AreaTriggerId, ActionType, ActionParam, TargetType FROM `areatrigger_template_actions`"); + // 0 1 2 3 4 + SQLResult templateActions = DB.World.Query("SELECT AreaTriggerId, IsServerSide, ActionType, ActionParam, TargetType FROM `areatrigger_template_actions`"); if (!templateActions.IsEmpty()) { do { - uint areaTriggerId = templateActions.Read(0); + AreaTriggerId areaTriggerId = new() { Id = templateActions.Read(0), IsServerSide = templateActions.Read(1) == 1 }; AreaTriggerAction action; - action.Param = templateActions.Read(2); - action.ActionType = (AreaTriggerActionTypes)templateActions.Read(1); - action.TargetType = (AreaTriggerActionUserTypes)templateActions.Read(3); + action.Param = templateActions.Read(3); + action.ActionType = (AreaTriggerActionTypes)templateActions.Read(2); + action.TargetType = (AreaTriggerActionUserTypes)templateActions.Read(4); if (action.ActionType >= AreaTriggerActionTypes.Max) { - Log.outError(LogFilter.Sql, "Table `areatrigger_template_actions` has invalid ActionType ({0}) for AreaTriggerId {1} and Param {2}", action.ActionType, areaTriggerId, action.Param); + Log.outError(LogFilter.Sql, $"Table `areatrigger_template_actions` has invalid ActionType ({action.ActionType}, IsServerSide: {areaTriggerId.IsServerSide}) for AreaTriggerId {areaTriggerId.Id} and Param {action.Param}"); continue; } if (action.TargetType >= AreaTriggerActionUserTypes.Max) { - Log.outError(LogFilter.Sql, "Table `areatrigger_template_actions` has invalid TargetType ({0}) for AreaTriggerId {1} and Param {2}", action.TargetType, areaTriggerId, action.Param); + Log.outError(LogFilter.Sql, $"Table `areatrigger_template_actions` has invalid TargetType ({action.TargetType}, IsServerSide: {areaTriggerId.IsServerSide}) for AreaTriggerId {areaTriggerId} and Param {action.Param}"); continue; } if (action.ActionType == AreaTriggerActionTypes.Teleport) { - WorldSafeLocsEntry safeLoc = Global.ObjectMgr.GetWorldSafeLoc(action.Param); - if (safeLoc == null) + if (Global.ObjectMgr.GetWorldSafeLoc(action.Param) == null) { - Log.outError(LogFilter.Sql, $"Table `areatrigger_template_actions` has invalid entry ({areaTriggerId}) with TargetType=Teleport and Param ({action.Param}) not a valid world safe loc entry"); + Log.outError(LogFilter.Sql, $"Table `areatrigger_template_actions` has invalid (Id: {areaTriggerId}, IsServerSide: {areaTriggerId.IsServerSide}) with TargetType=Teleport and Param ({action.Param}) not a valid world safe loc entry"); continue; } } @@ -140,29 +121,28 @@ namespace Game.DataStorage Log.outInfo(LogFilter.ServerLoading, "Loaded 0 AreaTrigger templates splines. DB table `spell_areatrigger_splines` is empty."); } - // 0 1 2 3 4 5 6 7 8 9 10 - SQLResult templates = DB.World.Query("SELECT Id, IsServer, Type, Flags, Data0, Data1, Data2, Data3, Data4, Data5, ScriptName FROM `areatrigger_template`"); + // 0 1 2 3 4 5 6 7 8 9 10 + SQLResult templates = DB.World.Query("SELECT Id, IsServerSide, Type, Flags, Data0, Data1, Data2, Data3, Data4, Data5, ScriptName FROM `areatrigger_template`"); if (!templates.IsEmpty()) { do { AreaTriggerTemplate areaTriggerTemplate = new AreaTriggerTemplate(); - areaTriggerTemplate.Id = templates.Read(0); - bool isServer = templates.Read(1) == 1; + areaTriggerTemplate.Id = new() { Id = templates.Read(0), IsServerSide = templates.Read(1) == 1 }; AreaTriggerTypes type = (AreaTriggerTypes)templates.Read(2); if (type >= AreaTriggerTypes.Max) { - Log.outError(LogFilter.Sql, "Table `areatrigger_template` has listed areatrigger (Id: {0}) with invalid type {1}.", areaTriggerTemplate.Id, type); + Log.outError(LogFilter.Sql, $"Table `areatrigger_template` has listed areatrigger (Id: {areaTriggerTemplate.Id.Id}, IsServerSide: {areaTriggerTemplate.Id.IsServerSide}) with invalid type {type}."); continue; } areaTriggerTemplate.TriggerType = type; areaTriggerTemplate.Flags = (AreaTriggerFlags)templates.Read(3); - if (isServer && areaTriggerTemplate.Flags != 0) + if (areaTriggerTemplate.Id.IsServerSide && areaTriggerTemplate.Flags != 0) { - Log.outError(LogFilter.Sql, $"Table `areatrigger_template` has listed server-side areatrigger (Id: {areaTriggerTemplate.Id}) with none-zero flags"); + Log.outError(LogFilter.Sql, $"Table `areatrigger_template` has listed server-side areatrigger (Id: {areaTriggerTemplate.Id.Id}, IsServerSide: {areaTriggerTemplate.Id.IsServerSide}) with none-zero flags"); continue; } @@ -173,67 +153,19 @@ namespace Game.DataStorage } areaTriggerTemplate.ScriptId = Global.ObjectMgr.GetScriptId(templates.Read(10)); - areaTriggerTemplate.PolygonVertices = verticesByAreaTrigger[areaTriggerTemplate.Id]; - areaTriggerTemplate.PolygonVerticesTarget = verticesTargetByAreaTrigger[areaTriggerTemplate.Id]; + if (!areaTriggerTemplate.Id.IsServerSide) + { + areaTriggerTemplate.PolygonVertices = verticesByAreaTrigger[areaTriggerTemplate.Id.Id]; + areaTriggerTemplate.PolygonVerticesTarget = verticesTargetByAreaTrigger[areaTriggerTemplate.Id.Id]; + } areaTriggerTemplate.Actions = actionsByAreaTrigger[areaTriggerTemplate.Id]; - areaTriggerTemplate.IsServerSide = isServer; areaTriggerTemplate.InitMaxSearchRadius(); - _areaTriggerTemplateMap[new AreaTriggerTemplateKey(areaTriggerTemplate.Id, isServer)] = areaTriggerTemplate; + _areaTriggerTemplateStore[areaTriggerTemplate.Id] = areaTriggerTemplate; } while (templates.NextRow()); } - // Load area trigger positions (to put them on the server) - // 0 1 2 3 4 5 6 7 8 9 10 - SQLResult templatePos = DB.World.Query("SELECT SpawnId, Id, IsServer, MapId, PosX, PosY, PosZ, PhaseId, PhaseGroup, PhaseUseFlags, Comment FROM `areatrigger_positions`"); - if (!templatePos.IsEmpty()) - { - do - { - AreaTriggerServerPosition position = new AreaTriggerServerPosition(); - position.SpawnId = templatePos.Read(0); - position.Id = templatePos.Read(1); - position.IsServer = templatePos.Read(2) == 1; - uint mapId = templatePos.Read(3); - - float posX = templatePos.Read(4); - float posY = templatePos.Read(5); - float posZ = templatePos.Read(6); - position.Location = new WorldLocation(mapId, posX, posY, posZ); - - if (!GridDefines.IsValidMapCoord(position.Location)) - { - Log.outError(LogFilter.Sql, $"Table `areatrigger_srv_position` has listed an invalid position: Id: {position.Id}, IsServer: {position.IsServer}. MapId ({mapId}), Position ({posX}, {posY}, {posZ})"); - continue; - } - - position.PhaseId = templatePos.Read(7); - position.PhaseGroup = templatePos.Read(8); - position.PhaseUseFlags = templatePos.Read(9); - - var template = _areaTriggerTemplateMap.LookupByKey(new AreaTriggerTemplateKey(position.Id, position.IsServer)); - if (template == null) - { - Log.outError(LogFilter.Sql, $"Table `areatrigger_srv_position` has listed areatrigger that doesn't exist: Id: {position.Id}, IsServer: {position.IsServer}"); - continue; - } - - // Add the trigger to a map::cell map, which is later used by GridLoader to query - CellCoord cellCoord = GridDefines.ComputeCellCoord(position.Location.GetPositionX(), position.Location.GetPositionY()); - if (!_areaTriggersGrid.ContainsKey(mapId)) - _areaTriggersGrid[mapId] = new Dictionary>(); - - if (!_areaTriggersGrid[mapId].ContainsKey(cellCoord.GetId())) - _areaTriggersGrid[mapId][cellCoord.GetId()] = new SortedSet(); - - _areaTriggersGrid[mapId][cellCoord.GetId()].Add(position.SpawnId); - - // add the position to the map - _areaTriggerSpawnMap[(uint)position.SpawnId] = position; - } while (templates.NextRow()); - } - // 0 1 2 3 4 5 6 7 8 9 10 SQLResult areatriggerSpellMiscs = DB.World.Query("SELECT SpellMiscId, AreaTriggerId, MoveCurveId, ScaleCurveId, MorphCurveId, FacingCurveId, AnimId, AnimKitId, DecalPropertiesId, TimeToTarget, TimeToTargetScale FROM `spell_areatrigger`"); if (!areatriggerSpellMiscs.IsEmpty()) @@ -244,7 +176,7 @@ namespace Game.DataStorage miscTemplate.MiscId = areatriggerSpellMiscs.Read(0); uint areatriggerId = areatriggerSpellMiscs.Read(1); - miscTemplate.Template = GetAreaTriggerTemplate(areatriggerId); + miscTemplate.Template = GetAreaTriggerTemplate(new AreaTriggerId() { Id = areatriggerId, IsServerSide = false }); if (miscTemplate.Template == null) { @@ -344,12 +276,62 @@ namespace Game.DataStorage Log.outInfo(LogFilter.ServerLoading, "Loaded 0 AreaTrigger templates circular movement infos. DB table `spell_areatrigger_circular` is empty."); } - Log.outInfo(LogFilter.ServerLoading, "Loaded {0} spell areatrigger templates in {1} ms.", _areaTriggerTemplateMap.Count, Time.GetMSTimeDiffToNow(oldMSTime)); + Log.outInfo(LogFilter.ServerLoading, $"Loaded {_areaTriggerTemplateStore.Count} spell areatrigger templates in {Time.GetMSTimeDiffToNow(oldMSTime)} ms."); } - public AreaTriggerTemplate GetAreaTriggerTemplate(uint areaTriggerId) + public void LoadAreaTriggerSpawns() { - return _areaTriggerTemplateMap.LookupByKey(new AreaTriggerTemplateKey(areaTriggerId, false)); + uint oldMSTime = Time.GetMSTime(); + // 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 FROM `areatrigger`"); + if (!templates.IsEmpty()) + { + do + { + ulong spawnId = templates.Read(0); + AreaTriggerId areaTriggerId = new() { Id = templates.Read(1), IsServerSide = templates.Read(2) == 1 }; + WorldLocation location = new(templates.Read(3), templates.Read(4), templates.Read(5), templates.Read(6), templates.Read(7)); + + if (GetAreaTriggerTemplate(areaTriggerId) == null) + { + Log.outError(LogFilter.Sql, $"Table `areatrigger` has listed areatrigger that doesn't exist: Id: {areaTriggerId.Id}, IsServerSide: {areaTriggerId.IsServerSide} for SpawnId {spawnId}"); + continue; + } + + if (!GridDefines.IsValidMapCoord(location)) + { + Log.outError(LogFilter.Sql, $"Table `areatrigger` has listed an invalid position: SpawnId: {spawnId}, MapId: {location.GetMapId()}, Position: {location}"); + continue; + } + + AreaTriggerSpawn spawn = new AreaTriggerSpawn(); + spawn.SpawnId = spawnId; + spawn.Id = areaTriggerId; + spawn.Location.WorldRelocate(location); + + spawn.PhaseUseFlags = templates.Read(8); + spawn.PhaseId = templates.Read(9); + spawn.PhaseGroup = templates.Read(10); + + // 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()))) + _areaTriggerSpawnsByLocation[(spawn.Location.GetMapId(), cellCoord.GetId())] = new SortedSet(); + + _areaTriggerSpawnsByLocation[(spawn.Location.GetMapId(), cellCoord.GetId())].Add(spawnId); + + // add the position to the map + _areaTriggerSpawnsBySpawnId[spawnId] = spawn; + } while (templates.NextRow()); + } + + Log.outInfo(LogFilter.ServerLoading, $"Loaded {_areaTriggerSpawnsBySpawnId.Count} areatrigger spawns in {Time.GetMSTimeDiffToNow(oldMSTime)} ms."); + } + + public AreaTriggerTemplate GetAreaTriggerTemplate(AreaTriggerId areaTriggerId) + { + return _areaTriggerTemplateStore.LookupByKey(areaTriggerId); } public AreaTriggerMiscTemplate GetAreaTriggerMiscTemplate(uint spellMiscValue) @@ -357,9 +339,19 @@ namespace Game.DataStorage return _areaTriggerTemplateSpellMisc.LookupByKey(spellMiscValue); } - Dictionary>> _areaTriggersGrid = new Dictionary>>(); - Dictionary _areaTriggerSpawnMap = new Dictionary(); - Dictionary _areaTriggerTemplateMap = new Dictionary(); + public SortedSet GetAreaTriggersForMapAndCell(uint mapId, uint cellId) + { + return _areaTriggerSpawnsByLocation.LookupByKey((mapId, cellId)); + } + + public AreaTriggerSpawn GetAreaTriggerSpawn(ulong spawnId) + { + return _areaTriggerSpawnsBySpawnId.LookupByKey(spawnId); + } + + Dictionary<(uint mapId, uint cellId), SortedSet> _areaTriggerSpawnsByLocation = new Dictionary<(uint mapId, uint cellId), SortedSet>(); + Dictionary _areaTriggerSpawnsBySpawnId = new Dictionary(); + Dictionary _areaTriggerTemplateStore = new Dictionary(); Dictionary _areaTriggerTemplateSpellMisc = new Dictionary(); } } diff --git a/Source/Game/Entities/AreaTrigger/AreaTrigger.cs b/Source/Game/Entities/AreaTrigger/AreaTrigger.cs index e086c031a..98e32c2db 100644 --- a/Source/Game/Entities/AreaTrigger/AreaTrigger.cs +++ b/Source/Game/Entities/AreaTrigger/AreaTrigger.cs @@ -100,9 +100,9 @@ namespace Game.Entities _areaTriggerTemplate = _areaTriggerMiscTemplate.Template; - _Create(ObjectGuid.Create(HighGuid.AreaTrigger, GetMapId(), GetTemplate().Id, caster.GetMap().GenerateLowGuid(HighGuid.AreaTrigger))); + _Create(ObjectGuid.Create(HighGuid.AreaTrigger, GetMapId(), GetTemplate().Id.Id, caster.GetMap().GenerateLowGuid(HighGuid.AreaTrigger))); - SetEntry(GetTemplate().Id); + SetEntry(GetTemplate().Id.Id); SetDuration(duration); SetObjectScale(1.0f); @@ -212,20 +212,20 @@ namespace Game.Entities return at; } - bool LoadFromDB(uint spawnId, Map map, bool addToMap, bool allowDuplicate) + public override bool LoadFromDB(ulong spawnId, Map map, bool addToMap, bool allowDuplicate) { - AreaTriggerServerPosition position = Global.AreaTriggerDataStorage.GetAreaTriggerServerPosition(spawnId); + AreaTriggerSpawn position = Global.AreaTriggerDataStorage.GetAreaTriggerSpawn(spawnId); if (position == null) return false; - AreaTriggerTemplate areaTriggerTemplate = Global.AreaTriggerDataStorage.GetAreaTriggerServerTemplate(position.Id); + AreaTriggerTemplate areaTriggerTemplate = Global.AreaTriggerDataStorage.GetAreaTriggerTemplate(position.Id); if (areaTriggerTemplate == null) return false; return CreateServer(map, areaTriggerTemplate, position); } - bool CreateServer(Map map, AreaTriggerTemplate areaTriggerTemplate, AreaTriggerServerPosition position) + bool CreateServer(Map map, AreaTriggerTemplate areaTriggerTemplate, AreaTriggerSpawn position) { SetMap(map); Relocate(position.Location); @@ -237,19 +237,21 @@ namespace Game.Entities _areaTriggerTemplate = areaTriggerTemplate; - _Create(ObjectGuid.Create(HighGuid.AreaTrigger, GetMapId(), areaTriggerTemplate.Id, GetMap().GenerateLowGuid(HighGuid.AreaTrigger))); + _Create(ObjectGuid.Create(HighGuid.AreaTrigger, GetMapId(), areaTriggerTemplate.Id.Id, GetMap().GenerateLowGuid(HighGuid.AreaTrigger))); - SetEntry(areaTriggerTemplate.Id); + SetEntry(areaTriggerTemplate.Id.Id); SetObjectScale(1.0f); - if (position.PhaseId != 0 || position.PhaseGroup != 0 || position.PhaseUseFlags != 0) + if (position.PhaseUseFlags != 0 || position.PhaseId != 0 || position.PhaseGroup != 0) PhasingHandler.InitDbPhaseShift(GetPhaseShift(), (PhaseUseFlagsValues)position.PhaseUseFlags, position.PhaseId, position.PhaseGroup); UpdateShape(); AI_Initialize(); + _ai.OnCreate(); + return true; } @@ -258,34 +260,31 @@ namespace Game.Entities base.Update(diff); _timeSinceCreated += diff; - if (IsServerSide()) + if (!IsServerSide()) { - UpdateTargetList(); - return; - } - - // "If" order matter here, Orbit > Attached > Splines - if (HasOrbit()) - { - UpdateOrbitPosition(diff); - } - else if(GetTemplate().HasFlag(AreaTriggerFlags.HasAttached)) - { - Unit target = GetTarget(); - if (target) - GetMap().AreaTriggerRelocation(this, target.GetPositionX(), target.GetPositionY(), target.GetPositionZ(), target.GetOrientation()); - } - else - UpdateSplinePosition(diff); - - if (GetDuration() != -1) - { - if (GetDuration() > diff) - _UpdateDuration((int)(_duration - diff)); - else + // "If" order matter here, Orbit > Attached > Splines + if (HasOrbit()) { - Remove(); // expired - return; + UpdateOrbitPosition(diff); + } + else if (GetTemplate().HasFlag(AreaTriggerFlags.HasAttached)) + { + Unit target = GetTarget(); + if (target) + GetMap().AreaTriggerRelocation(this, target.GetPositionX(), target.GetPositionY(), target.GetPositionZ(), target.GetOrientation()); + } + else + UpdateSplinePosition(diff); + + if (GetDuration() != -1) + { + if (GetDuration() > diff) + _UpdateDuration((int)(_duration - diff)); + else + { + Remove(); // expired + return; + } } } @@ -967,7 +966,7 @@ namespace Game.Entities AreaTriggerAI GetAI() { return _ai; } - public bool IsServerSide() { return _areaTriggerTemplate.IsServerSide; } + public bool IsServerSide() { return _areaTriggerTemplate.Id.IsServerSide; } public override bool IsNeverVisibleFor(WorldObject seer) { return IsServerSide(); } @@ -1034,10 +1033,9 @@ namespace Game.Entities Optional _orbitInfo; AreaTriggerMiscTemplate _areaTriggerMiscTemplate; + AreaTriggerTemplate _areaTriggerTemplate; List _insideUnits = new List(); AreaTriggerAI _ai; - - AreaTriggerTemplate _areaTriggerTemplate; } } diff --git a/Source/Game/Entities/AreaTrigger/AreaTriggerTemplate.cs b/Source/Game/Entities/AreaTrigger/AreaTriggerTemplate.cs index c18d42cbf..3fb70713e 100644 --- a/Source/Game/Entities/AreaTrigger/AreaTriggerTemplate.cs +++ b/Source/Game/Entities/AreaTrigger/AreaTriggerTemplate.cs @@ -187,24 +187,28 @@ namespace Game.Entities } } - struct AreaTriggerTemplateKey + public struct AreaTriggerId { public uint Id; - public bool IsServer; + public bool IsServerSide; - public AreaTriggerTemplateKey(uint id, bool isServer) + public override int GetHashCode() { - Id = id; - IsServer = isServer; + return Id.GetHashCode() ^ IsServerSide.GetHashCode(); } - public static bool operator ==(AreaTriggerTemplateKey A, AreaTriggerTemplateKey B) + public override bool Equals(object obj) { - return A.Id == B.Id && A.IsServer == B.IsServer; + return Equals((AreaTriggerId)obj); } - public static bool operator !=(AreaTriggerTemplateKey A, AreaTriggerTemplateKey B) + + public static bool operator ==(AreaTriggerId left, AreaTriggerId right) { - return A.Id != B.Id && A.IsServer != B.IsServer; + return left.Id == right.Id && left.IsServerSide == right.IsServerSide; + } + public static bool operator !=(AreaTriggerId left, AreaTriggerId right) + { + return !(left == right); } } @@ -256,7 +260,7 @@ namespace Game.Entities public bool IsPolygon() { return TriggerType == AreaTriggerTypes.Polygon; } public bool IsCylinder() { return TriggerType == AreaTriggerTypes.Cylinder; } - public uint Id; + public AreaTriggerId Id; public AreaTriggerTypes TriggerType; public AreaTriggerFlags Flags; public uint ScriptId; @@ -265,7 +269,6 @@ namespace Game.Entities public List PolygonVertices = new List(); public List PolygonVerticesTarget = new List(); public List Actions = new List(); - public bool IsServerSide; } public unsafe class AreaTriggerMiscTemplate @@ -305,11 +308,10 @@ namespace Game.Entities public List SplinePoints = new List(); } - public class AreaTriggerServerPosition + public class AreaTriggerSpawn { public ulong SpawnId; - public uint Id; - public bool IsServer; + public AreaTriggerId Id; public WorldLocation Location; public uint PhaseId; public uint PhaseGroup; diff --git a/Source/Game/Scripting/CoreScripts.cs b/Source/Game/Scripting/CoreScripts.cs index 332023dac..5c8577c8b 100644 --- a/Source/Game/Scripting/CoreScripts.cs +++ b/Source/Game/Scripting/CoreScripts.cs @@ -364,7 +364,6 @@ namespace Game.Scripting // Called when the area trigger is activated by a player. public virtual bool OnTrigger(Player player, AreaTriggerRecord trigger, bool entered) { return false; } - public virtual bool OnTriggerServer(Player player, AreaTriggerTemplate triggerTemplate, bool entered) { return false; } } public class OnlyOnceAreaTriggerScript : AreaTriggerScript diff --git a/Source/Game/Server/WorldManager.cs b/Source/Game/Server/WorldManager.cs index 165d1c61e..0ddbd4b7f 100644 --- a/Source/Game/Server/WorldManager.cs +++ b/Source/Game/Server/WorldManager.cs @@ -718,6 +718,9 @@ namespace Game Log.outInfo(LogFilter.ServerLoading, "Loading AreaTrigger Templates..."); Global.AreaTriggerDataStorage.LoadAreaTriggerTemplates(); + Log.outInfo(LogFilter.ServerLoading, "Loading AreaTrigger Spawns..."); + Global.AreaTriggerDataStorage.LoadAreaTriggerSpawns(); + Log.outInfo(LogFilter.ServerLoading, "Loading Conversation Templates..."); Global.ConversationDataStorage.LoadConversationTemplates(); diff --git a/sql/updates/world/master/2021_01_30_01_world_serverside_areatriggers.sql b/sql/updates/world/master/2021_01_30_01_world_serverside_areatriggers.sql new file mode 100644 index 000000000..22abd6250 --- /dev/null +++ b/sql/updates/world/master/2021_01_30_01_world_serverside_areatriggers.sql @@ -0,0 +1,42 @@ +ALTER TABLE `areatrigger_template` + DROP PRIMARY KEY, + ADD COLUMN `IsServerSide` tinyint(1) unsigned NOT NULL AFTER `Id`, + ADD PRIMARY KEY (`Id`, `IsServerSide`); + +ALTER TABLE `areatrigger_template_actions` + DROP PRIMARY KEY, + ADD COLUMN `IsServerSide` tinyint(1) unsigned NOT NULL AFTER `AreaTriggerId`, + ADD PRIMARY KEY (`AreaTriggerId`, `IsServerSide`); + +CREATE TABLE `areatrigger` ( + `SpawnId` bigint(20) unsigned NOT NULL, + `AreaTriggerId` int(10) unsigned NOT NULL, + `IsServerSide` tinyint(1) unsigned NOT NULL, + `MapId` int(10) unsigned NOT NULL, + `PosX` float NOT NULL, + `PosY` float NOT NULL, + `PosZ` float NOT NULL, + `Orientation` float NOT NULL, + `PhaseUseFlags` tinyint(3) unsigned DEFAULT '0', + `PhaseId` int(10) unsigned DEFAULT '0', + `PhaseGroup` int(10) unsigned DEFAULT '0', + `Comment` varchar(255) DEFAULT NULL, + PRIMARY KEY (`SpawnId`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +DELETE FROM `areatrigger` WHERE `SpawnId` IN (1, 2); +INSERT INTO `areatrigger` (`SpawnId`, `AreaTriggerId`, `IsServerSide`, `MapId`, `PosX`, `PosY`, `PosZ`, `Orientation`, `PhaseUseFlags`, `PhaseId`, `PhaseGroup`, `Comment`) VALUES +(1, 1, 1, 0, -9016.11, 876.142, 148.617, 0.7259, 1, 0, 0, 'Stormwind Mage Portal Entrance'), +(2, 2, 1, 0, -8999.866, 864.13995, 65.88978, 0, 1, 0, 0, 'Stormwind Mage Portal Exit'); + +DELETE FROM `areatrigger_template` WHERE `Id` in (1, 2) AND `IsServerSide` = 1; +INSERT INTO `areatrigger_template` (`Id`, `IsServerSide`, `Type`, `Flags`, `Data0`, `Data1`, `Data2`, `Data3`, `Data4`, `Data5`, `ScriptName`, `VerifiedBuild`) VALUES +(1, 1, 1, 0, 3, 1, 3, 0, 0, 0, '', 0), +(2, 1, 1, 0, 1.2597655, 1.2792665, 3.7021635, 0, 0, 0, '', 0); + +DELETE FROM `areatrigger_template_actions` WHERE `AreaTriggerId` IN (1, 2) AND `IsServerSide` = 1; +INSERT INTO `areatrigger_template_actions` (`AreaTriggerId`, `IsServerSide`, `ActionType`, `ActionParam`, `TargetType`) VALUES +(1, 1, 2, 3631, 5), +(2, 1, 2, 3630, 5); + +UPDATE `world_safe_locs` SET LocX=-9014.864258, LocY=874.324890, LocZ=148.618713 WHERE `id`=3630;