diff options
author | Ovah <dreadkiller@gmx.de> | 2020-02-08 20:47:46 +0100 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2021-12-21 15:32:49 +0100 |
commit | a91be4995b45695d8585068d0c5e955b93027d89 (patch) | |
tree | f470f67f694ee44b7a94d6ac3e290af9854d05fb /src/server/game/Globals/ObjectMgr.cpp | |
parent | eae73794177f88cff626984b866d33e97b1d208c (diff) |
Core/Vehicles: implement vehicle seat addon table to specify seat ori… (#24112)
* Core/Vehicles: implement vehicle seat addon table to specify seat orientation offsets and exit positions in form of offsets or absolute positions
* converted Traveler's Tundra Mammoth to seat addon table data
* first follow batch
* whoopsie
* Core/Vehicles: go from local copies to pointers
* Update and rename 2020_99_99_99_world.sql to 2020_02_08_01_world.sql
Co-authored-by: Giacomo Pozzoni <giacomopoz@gmail.com>
(cherry picked from commit 98d6c501d7c1a7a632c6ff8b1d46c7d0d4ae5b37)
Diffstat (limited to 'src/server/game/Globals/ObjectMgr.cpp')
-rw-r--r-- | src/server/game/Globals/ObjectMgr.cpp | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index f9e20a9a420..289437620e1 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -3495,6 +3495,62 @@ void ObjectMgr::LoadVehicleAccessories() TC_LOG_INFO("server.loading", ">> Loaded %u Vehicle Accessories in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); } +void ObjectMgr::LoadVehicleSeatAddon() +{ + uint32 oldMSTime = getMSTime(); + + _vehicleSeatAddonStore.clear(); // needed for reload case + + uint32 count = 0; + + // 0 1 2 3 4 5 6 + QueryResult result = WorldDatabase.Query("SELECT `SeatEntry`, `SeatOrientation`, `ExitParamX`, `ExitParamY`, `ExitParamZ`, `ExitParamO`, `ExitParamValue` FROM `vehicle_seat_addon`"); + + if (!result) + { + TC_LOG_ERROR("server.loading", ">> Loaded 0 vehicle seat addons. DB table `vehicle_seat_addon` is empty."); + return; + } + + do + { + Field* fields = result->Fetch(); + + uint32 seatID = fields[0].GetUInt32(); + float orientation = fields[1].GetFloat(); + float exitX = fields[2].GetFloat(); + float exitY = fields[3].GetFloat(); + float exitZ = fields[4].GetFloat(); + float exitO = fields[5].GetFloat(); + uint8 exitParam = fields[6].GetUInt8(); + + if (!sVehicleSeatStore.LookupEntry(seatID)) + { + TC_LOG_ERROR("sql.sql", "Table `vehicle_seat_addon`: SeatID: %u does not exist in VehicleSeat.dbc. Skipping entry.", seatID); + continue; + } + + // Sanitizing values + if (orientation > float(M_PI * 2)) + { + TC_LOG_ERROR("sql.sql", "Table `vehicle_seat_addon`: SeatID: %u is using invalid angle offset value (%f). Set Value to 0.", seatID, orientation); + orientation = 0.0f; + } + + if (exitParam >= AsUnderlyingType(VehicleExitParameters::VehicleExitParamMax)) + { + TC_LOG_ERROR("sql.sql", "Table `vehicle_seat_addon`: SeatID: %u is using invalid exit parameter value (%u). Setting to 0 (none).", seatID, exitParam); + continue; + } + + _vehicleSeatAddonStore[seatID] = VehicleSeatAddon(orientation, exitX, exitY, exitZ, exitO, exitParam); + + ++count; + } while (result->NextRow()); + + TC_LOG_INFO("server.loading", ">> Loaded %u Vehicle Seat Addon entries in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); +} + void ObjectMgr::LoadPetLevelInfo() { uint32 oldMSTime = getMSTime(); |