mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-02-07 21:01:37 +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());
|
ASSERT(type != CHARM_TYPE_POSSESS || charmer->IsPlayer());
|
||||||
if (type == CHARM_TYPE_VEHICLE && !IsVehicle()) // pussywizard
|
if (type == CHARM_TYPE_VEHICLE && !IsVehicle()) // pussywizard
|
||||||
throw 1;
|
throw 1;
|
||||||
ASSERT((type == CHARM_TYPE_VEHICLE) == IsVehicle());
|
ASSERT((type == CHARM_TYPE_VEHICLE) == (GetVehicleKit() && GetVehicleKit()->IsControllableVehicle()));
|
||||||
|
|
||||||
LOG_DEBUG("entities.unit", "SetCharmedBy: charmer {} ({}), charmed {} ({}), type {}.",
|
LOG_DEBUG("entities.unit", "SetCharmedBy: charmer {} ({}), charmed {} ({}), type {}.",
|
||||||
charmer->GetEntry(), charmer->GetGUID().ToString(), GetEntry(), GetGUID().ToString(), uint32(type));
|
charmer->GetEntry(), charmer->GetGUID().ToString(), GetEntry(), GetGUID().ToString(), uint32(type));
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
#include "TemporarySummon.h"
|
#include "TemporarySummon.h"
|
||||||
#include "Unit.h"
|
#include "Unit.h"
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
Vehicle::Vehicle(Unit* unit, VehicleEntry const* vehInfo, uint32 creatureEntry) :
|
Vehicle::Vehicle(Unit* unit, VehicleEntry const* vehInfo, uint32 creatureEntry) :
|
||||||
_me(unit), _vehicleInfo(vehInfo), _usableSeatNum(0), _creatureEntry(creatureEntry), _status(STATUS_NONE)
|
_me(unit), _vehicleInfo(vehInfo), _usableSeatNum(0), _creatureEntry(creatureEntry), _status(STATUS_NONE)
|
||||||
@@ -562,6 +563,11 @@ bool Vehicle::IsVehicleInUse()
|
|||||||
return false;
|
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)
|
void Vehicle::TeleportVehicle(float x, float y, float z, float ang)
|
||||||
{
|
{
|
||||||
_me->GetMap()->LoadGrid(x, y);
|
_me->GetMap()->LoadGrid(x, y);
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ public:
|
|||||||
void RemoveAllPassengers();
|
void RemoveAllPassengers();
|
||||||
void Dismiss();
|
void Dismiss();
|
||||||
bool IsVehicleInUse();
|
bool IsVehicleInUse();
|
||||||
|
[[nodiscard]] bool IsControllableVehicle() const;
|
||||||
void TeleportVehicle(float x, float y, float z, float ang);
|
void TeleportVehicle(float x, float y, float z, float ang);
|
||||||
|
|
||||||
SeatMap Seats;
|
SeatMap Seats;
|
||||||
|
|||||||
Reference in New Issue
Block a user