diff options
Diffstat (limited to 'src/server/game/Globals/ObjectMgr.cpp')
-rw-r--r-- | src/server/game/Globals/ObjectMgr.cpp | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 7f34b710be1..f5e93ede9af 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -6176,10 +6176,10 @@ void ObjectMgr::LoadAreaTriggerTeleports() { uint32 oldMSTime = getMSTime(); - _areaTriggerStore.clear(); // need for reload case + _areaTriggerStore.clear(); // needed for reload case - // 0 1 2 3 4 5 - QueryResult result = WorldDatabase.Query("SELECT id, target_map, target_position_x, target_position_y, target_position_z, target_orientation FROM areatrigger_teleport"); + // 0 1 + QueryResult result = WorldDatabase.Query("SELECT ID, PortLocID FROM areatrigger_teleport"); if (!result) { TC_LOG_INFO("server.loading", ">> Loaded 0 area trigger teleport definitions. DB table `areatrigger_teleport` is empty."); @@ -6195,32 +6195,33 @@ void ObjectMgr::LoadAreaTriggerTeleports() ++count; uint32 Trigger_ID = fields[0].GetUInt32(); + uint32 PortLocID = fields[1].GetUInt32(); - AreaTriggerStruct at; - - at.target_mapId = fields[1].GetUInt16(); - at.target_X = fields[2].GetFloat(); - at.target_Y = fields[3].GetFloat(); - at.target_Z = fields[4].GetFloat(); - at.target_Orientation = fields[5].GetFloat(); - - AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(Trigger_ID); - if (!atEntry) + WorldSafeLocsEntry const* portLoc = sWorldSafeLocsStore.LookupEntry(PortLocID); + if (!portLoc) { - TC_LOG_ERROR("sql.sql", "Area trigger (ID:%u) does not exist in `AreaTrigger.dbc`.", Trigger_ID); + TC_LOG_ERROR("sql.sql", "Area Trigger (ID: %u) has a non-existing Port Loc (ID: %u) in WorldSafeLocs.dbc, skipped", Trigger_ID, PortLocID); continue; } - MapEntry const* mapEntry = sMapStore.LookupEntry(at.target_mapId); - if (!mapEntry) - { - TC_LOG_ERROR("sql.sql", "Area trigger (ID:%u) target map (ID: %u) does not exist in `Map.dbc`.", Trigger_ID, at.target_mapId); - continue; - } + WorldSafeLocsEntry const* MapID = sWorldSafeLocsStore.LookupEntry(PortLocID); + WorldSafeLocsEntry const* PositionX = sWorldSafeLocsStore.LookupEntry(PortLocID); + WorldSafeLocsEntry const* PositionY = sWorldSafeLocsStore.LookupEntry(PortLocID); + WorldSafeLocsEntry const* PositionZ = sWorldSafeLocsStore.LookupEntry(PortLocID); + WorldSafeLocsEntry const* Orientation = sWorldSafeLocsStore.LookupEntry(PortLocID); + + AreaTriggerStruct at; + + at.target_mapId = MapID->map_id; + at.target_X = PositionX->x; + at.target_Y = PositionY->y; + at.target_Z = PositionZ->z; + at.target_Orientation = ((Orientation->Facing) * M_PI) / 180; // Orientation is initially in degrees - if (at.target_X == 0 && at.target_Y == 0 && at.target_Z == 0) + AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(Trigger_ID); + if (!atEntry) { - TC_LOG_ERROR("sql.sql", "Area trigger (ID:%u) target coordinates not provided.", Trigger_ID); + TC_LOG_ERROR("sql.sql", "Area Trigger (ID: %u) does not exist in AreaTrigger.dbc.", Trigger_ID); continue; } |