diff options
author | Kinzcool <kinzzcool@hotmail.com> | 2014-11-01 22:20:40 -0400 |
---|---|---|
committer | Kinzcool <kinzzcool@hotmail.com> | 2014-11-01 22:20:40 -0400 |
commit | 2a763cc175e17e14ccdc23a14847e29dde234bb1 (patch) | |
tree | 95c20772552814ab2661b86ebabd66c3cfaaee60 /src | |
parent | bb6f46b0fdbec8dae7691a855384fa33cf456f44 (diff) |
Core/AreaTriggers: Make the loading for areatrigger teleports from WorldSafeLocs.dbc
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/DataStores/DBCStructure.h | 3 | ||||
-rw-r--r-- | src/server/game/DataStores/DBCfmt.h | 2 | ||||
-rw-r--r-- | src/server/game/Globals/ObjectMgr.cpp | 45 |
3 files changed, 26 insertions, 24 deletions
diff --git a/src/server/game/DataStores/DBCStructure.h b/src/server/game/DataStores/DBCStructure.h index 001392aee4c..f13abe888ae 100644 --- a/src/server/game/DataStores/DBCStructure.h +++ b/src/server/game/DataStores/DBCStructure.h @@ -2426,7 +2426,8 @@ struct WorldSafeLocsEntry float x; // 2 float y; // 3 float z; // 4 - //char* name; // 5 m_AreaName_lang + float Facing; // 5 values are in degrees + //char* name; // 6 m_AreaName_lang }; /* diff --git a/src/server/game/DataStores/DBCfmt.h b/src/server/game/DataStores/DBCfmt.h index 3c2344c1d47..db6fd04d369 100644 --- a/src/server/game/DataStores/DBCfmt.h +++ b/src/server/game/DataStores/DBCfmt.h @@ -178,6 +178,6 @@ char const VehicleSeatEntryfmt[] = "niiffffffffffiiiiiifffffffiiifffiiiiiiiffiii char const WMOAreaTableEntryfmt[] = "niiixxxxxiixxxx"; char const WorldMapAreaEntryfmt[] = "xinxffffixxxxx"; char const WorldMapOverlayEntryfmt[] = "nxiiiixxxxxxxxx"; -char const WorldSafeLocsEntryfmt[] = "nifffx"; +char const WorldSafeLocsEntryfmt[] = "niffffx"; #endif 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; } |