From f4e615dc5ca5f8ef4b4d499ebe72c2fb1d45aa61 Mon Sep 17 00:00:00 2001 From: insunaa Date: Sun, 28 Jan 2024 10:09:47 +0100 Subject: [PATCH] Vehicles: Fix switching seats --- src/game/Entities/Vehicle.cpp | 7 ++++--- src/game/Entities/VehicleHandler.cpp | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/game/Entities/Vehicle.cpp b/src/game/Entities/Vehicle.cpp index 606d69a490a..6afd65f4018 100644 --- a/src/game/Entities/Vehicle.cpp +++ b/src/game/Entities/Vehicle.cpp @@ -389,12 +389,15 @@ void VehicleInfo::SwitchSeat(Unit* passenger, uint8 seat) MANGOS_ASSERT(seatEntry); // Switching seats is only allowed if this flag is set - if (seatEntry->CanSwitchFromSeat()) + if (!seatEntry->CanSwitchFromSeat()) return; // Remove passenger modifications of the old seat RemoveSeatMods(passenger, seatEntry->m_flags); + // Get seatEntry of new seat + seatEntry = GetSeatEntry(seat); + float lx = 0.f, ly = 0.f, lz = 0.f, lo = 0.f; GetSeatCoordinates(seatEntry, lx, ly, lz); @@ -409,8 +412,6 @@ void VehicleInfo::SwitchSeat(Unit* passenger, uint8 seat) // It seems that Seat switching is sent without SplineFlag BoardVehicle init.Launch(); - // Get seatEntry of new seat - seatEntry = GetSeatEntry(seat); MANGOS_ASSERT(seatEntry); // Apply passenger modifications of the new seat diff --git a/src/game/Entities/VehicleHandler.cpp b/src/game/Entities/VehicleHandler.cpp index f44b6d84561..867f9ef6fdf 100644 --- a/src/game/Entities/VehicleHandler.cpp +++ b/src/game/Entities/VehicleHandler.cpp @@ -126,7 +126,7 @@ void WorldSession::HandleRequestVehicleSwitchSeat(WorldPacket& recvPacket) if (!transportInfo || !transportInfo->IsOnVehicle()) return; - Unit* vehicle = (Unit*)transportInfo->GetTransport(); + Unit* vehicle = static_cast(transportInfo->GetTransport()); if (vehicleGuid != vehicle->GetObjectGuid()) { @@ -141,7 +141,7 @@ void WorldSession::HandleRequestVehicleSwitchSeat(WorldPacket& recvPacket) SpellClickInfoMapBounds clickPair = sObjectMgr.GetSpellClickInfoMapBounds(destVehicle->GetEntry()); for (SpellClickInfoMap::const_iterator itr = clickPair.first; itr != clickPair.second; ++itr) - if (itr->second.IsFitToRequirements(_player, destVehicle->GetTypeId() == TYPEID_UNIT ? (Creature*)destVehicle : nullptr)) + if (itr->second.IsFitToRequirements(_player, destVehicle->GetTypeId() == TYPEID_UNIT ? static_cast(destVehicle) : nullptr)) _player->CastSpell(destVehicle, itr->second.spellId, TRIGGERED_OLD_TRIGGERED); } else @@ -167,7 +167,7 @@ void WorldSession::HandleChangeSeatsOnControlledVehicle(WorldPacket& recvPacket) if (!transportInfo || !transportInfo->IsOnVehicle()) return; - Unit* srcVehicle = (Unit*)transportInfo->GetTransport(); + Unit* srcVehicle = static_cast(transportInfo->GetTransport()); // Something went wrong if (srcVehicleGuid != srcVehicle->GetObjectGuid())