fix(Core/Vehicle): fix crash when using MC on a player riding a vehicle (#24551)

Co-authored-by: Shauren <shauren.trinity@gmail.com>
This commit is contained in:
sogladev
2026-01-29 18:15:43 +01:00
committed by GitHub
parent 0df7baabdc
commit e216838d54
3 changed files with 8 additions and 1 deletions
@@ -26,6 +26,7 @@
#include "TemporarySummon.h"
#include "Unit.h"
#include "Util.h"
#include <algorithm>
Vehicle::Vehicle(Unit* unit, VehicleEntry const* vehInfo, uint32 creatureEntry) :
_me(unit), _vehicleInfo(vehInfo), _usableSeatNum(0), _creatureEntry(creatureEntry), _status(STATUS_NONE)
@@ -562,6 +563,11 @@ bool Vehicle::IsVehicleInUse()
return false;
}
bool Vehicle::IsControllableVehicle() const
{
return std::ranges::any_of(Seats, [](auto const& seat) { return seat.second.SeatInfo->CanControl(); });
}
void Vehicle::TeleportVehicle(float x, float y, float z, float ang)
{
_me->GetMap()->LoadGrid(x, y);
@@ -51,6 +51,7 @@ public:
void RemoveAllPassengers();
void Dismiss();
bool IsVehicleInUse();
[[nodiscard]] bool IsControllableVehicle() const;
void TeleportVehicle(float x, float y, float z, float ang);
SeatMap Seats;