mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-31 17:43:47 +00:00
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:
@@ -18618,7 +18618,7 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au
|
||||
ASSERT(type != CHARM_TYPE_POSSESS || charmer->IsPlayer());
|
||||
if (type == CHARM_TYPE_VEHICLE && !IsVehicle()) // pussywizard
|
||||
throw 1;
|
||||
ASSERT((type == CHARM_TYPE_VEHICLE) == IsVehicle());
|
||||
ASSERT((type == CHARM_TYPE_VEHICLE) == (GetVehicleKit() && GetVehicleKit()->IsControllableVehicle()));
|
||||
|
||||
LOG_DEBUG("entities.unit", "SetCharmedBy: charmer {} ({}), charmed {} ({}), type {}.",
|
||||
charmer->GetEntry(), charmer->GetGUID().ToString(), GetEntry(), GetGUID().ToString(), uint32(type));
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user