diff --git a/Source/Game/Chat/Commands/GoCommands.cs b/Source/Game/Chat/Commands/GoCommands.cs index 8a0b4ebb9..8e4c1d36d 100644 --- a/Source/Game/Chat/Commands/GoCommands.cs +++ b/Source/Game/Chat/Commands/GoCommands.cs @@ -249,7 +249,7 @@ namespace Game.Chat.Commands player.SaveRecallPosition(); // try going to entrance - AreaTriggerStruct exit = Global.ObjectMgr.GetGoBackTrigger(mapId); + AreaTriggerTeleport exit = Global.ObjectMgr.GetGoBackTrigger(mapId); if (exit != null) { if (player.TeleportTo(exit.target_mapId, exit.target_X, exit.target_Y, exit.target_Z, exit.target_Orientation + MathF.PI)) @@ -268,7 +268,7 @@ namespace Game.Chat.Commands handler.SendSysMessage(CypherStrings.CommandInstanceNoExit, mapName, mapId); // try going to start - AreaTriggerStruct entrance = Global.ObjectMgr.GetMapEntranceTrigger(mapId); + AreaTriggerTeleport entrance = Global.ObjectMgr.GetMapEntranceTrigger(mapId); if (entrance != null) { if (player.TeleportTo(entrance.target_mapId, entrance.target_X, entrance.target_Y, entrance.target_Z, entrance.target_Orientation)) diff --git a/Source/Game/DungeonFinding/LFGManager.cs b/Source/Game/DungeonFinding/LFGManager.cs index 2d1afa8c5..9e3702ce4 100644 --- a/Source/Game/DungeonFinding/LFGManager.cs +++ b/Source/Game/DungeonFinding/LFGManager.cs @@ -216,7 +216,7 @@ namespace Game.DungeonFinding // No teleport coords in database, load from areatriggers if (dungeon.type != LfgType.Random && dungeon.x == 0.0f && dungeon.y == 0.0f && dungeon.z == 0.0f) { - AreaTriggerStruct at = Global.ObjectMgr.GetMapEntranceTrigger(dungeon.map); + AreaTriggerTeleport at = Global.ObjectMgr.GetMapEntranceTrigger(dungeon.map); if (at == null) { Log.outError(LogFilter.Lfg, "LoadLFGDungeons: Failed to load dungeon {0} (Id: {1}), cant find areatrigger for map {2}", dungeon.name, dungeon.id, dungeon.map); diff --git a/Source/Game/Entities/Player/Player.DB.cs b/Source/Game/Entities/Player/Player.DB.cs index 75dd2081e..d319296d3 100644 --- a/Source/Game/Entities/Player/Player.DB.cs +++ b/Source/Game/Entities/Player/Player.DB.cs @@ -3390,7 +3390,7 @@ namespace Game.Entities if (map == null) map = Global.MapMgr.CreateMap(mapId, this); - AreaTriggerStruct areaTrigger = null; + AreaTriggerTeleport areaTrigger = null; bool check = false; if (map == null) diff --git a/Source/Game/Globals/ObjectManager.cs b/Source/Game/Globals/ObjectManager.cs index 0b2f47d2a..59f4b2e00 100644 --- a/Source/Game/Globals/ObjectManager.cs +++ b/Source/Game/Globals/ObjectManager.cs @@ -5464,17 +5464,24 @@ namespace Game { ++count; - uint Trigger_ID = result.Read(0); - uint PortLocID = result.Read(1); + uint triggerId = result.Read(0); + uint portLocId = result.Read(1); - WorldSafeLocsEntry portLoc = GetWorldSafeLoc(PortLocID); - if (portLoc == null) + var atEntry = CliDB.AreaTriggerStorage.LookupByKey(triggerId); + if (atEntry == null) { - Log.outError(LogFilter.Sql, "Area Trigger (ID: {0}) has a non-existing Port Loc (ID: {1}) in WorldSafeLocs.dbc, skipped", Trigger_ID, PortLocID); + Log.outError(LogFilter.Sql, $"Area Trigger (ID: {triggerId}) does not exist in AreaTrigger.dbc."); continue; } - AreaTriggerStruct at = new(); + WorldSafeLocsEntry portLoc = GetWorldSafeLoc(portLocId); + if (portLoc == null) + { + Log.outError(LogFilter.Sql, "Area Trigger (ID: {0}) has a non-existing Port Loc (ID: {1}) in WorldSafeLocs.dbc, skipped", triggerId, portLocId); + continue; + } + + AreaTriggerTeleport at = new(); at.target_mapId = portLoc.Loc.GetMapId(); at.target_X = portLoc.Loc.GetPositionX(); at.target_Y = portLoc.Loc.GetPositionY(); @@ -5482,14 +5489,7 @@ namespace Game at.target_Orientation = portLoc.Loc.GetOrientation(); at.PortLocId = portLoc.Id; - AreaTriggerRecord atEntry = CliDB.AreaTriggerStorage.LookupByKey(Trigger_ID); - if (atEntry == null) - { - Log.outError(LogFilter.Sql, "Area trigger (ID: {0}) does not exist in `AreaTrigger.dbc`.", Trigger_ID); - continue; - } - - _areaTriggerStorage[Trigger_ID] = at; + _areaTriggerStorage[triggerId] = at; } while (result.NextRow()); @@ -11277,7 +11277,7 @@ namespace Game return mountModel.CreatureDisplayID; } - public AreaTriggerStruct GetAreaTrigger(uint trigger) + public AreaTriggerTeleport GetAreaTrigger(uint trigger) { return _areaTriggerStorage.LookupByKey(trigger); } @@ -11292,7 +11292,7 @@ namespace Game return _tavernAreaTriggerStorage.Contains(Trigger_ID); } - public AreaTriggerStruct GetGoBackTrigger(uint Map) + public AreaTriggerTeleport GetGoBackTrigger(uint Map) { uint? parentId = null; MapRecord mapEntry = CliDB.MapStorage.LookupByKey(Map); @@ -11319,7 +11319,7 @@ namespace Game return null; } - public AreaTriggerStruct GetMapEntranceTrigger(uint Map) + public AreaTriggerTeleport GetMapEntranceTrigger(uint Map) { foreach (var pair in _areaTriggerStorage) { @@ -11783,7 +11783,7 @@ namespace Game Dictionary _playerChoiceLocales = new(); List _tavernAreaTriggerStorage = new(); - Dictionary _areaTriggerStorage = new(); + Dictionary _areaTriggerStorage = new(); Dictionary _accessRequirementStorage = new(); Dictionary _worldSafeLocs = new(); @@ -12312,7 +12312,7 @@ namespace Game } } - public class AreaTriggerStruct + public class AreaTriggerTeleport { public uint target_mapId; public float target_X; diff --git a/Source/Game/Handlers/MiscHandler.cs b/Source/Game/Handlers/MiscHandler.cs index 1e77c8fb2..df0473227 100644 --- a/Source/Game/Handlers/MiscHandler.cs +++ b/Source/Game/Handlers/MiscHandler.cs @@ -288,7 +288,7 @@ namespace Game if (!packet.Entered) return; - AreaTriggerStruct at = Global.ObjectMgr.GetAreaTrigger(packet.AreaTriggerID); + AreaTriggerTeleport at = Global.ObjectMgr.GetAreaTrigger(packet.AreaTriggerID); if (at == null) return;