fix(Core/Vehicles): Prevent accessory double-install and respawn orphans (#25499)

Co-authored-by: blinkysc <blinkysc@users.noreply.github.com>
This commit is contained in:
blinkysc
2026-04-19 10:09:51 -05:00
committed by GitHub
parent b53e1b8eac
commit 687ceeea70
5 changed files with 24 additions and 8 deletions

View File

@@ -29,7 +29,8 @@
#include <algorithm>
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),
_accessoriesInstalled(false)
{
for (uint32 i = 0; i < MAX_VEHICLE_SEATS; ++i)
{
@@ -87,8 +88,16 @@ void Vehicle::Install()
void Vehicle::InstallAllAccessories(bool evading)
{
if (GetBase()->IsPlayer() || !evading)
RemoveAllPassengers(); // We might have aura's saved in the DB with now invalid casters - remove
// Clear stale control-vehicle auras only on the first non-evade reset;
// a re-Reset would otherwise eject a just-seated passenger and, for
// accessories, fire a spurious SMART_EVENT_PASSENGER_REMOVED.
if (GetBase()->IsPlayer() || (!evading && !_accessoriesInstalled))
RemoveAllPassengers();
// Mark the initial reset as done even if this vehicle has no accessory
// list, so subsequent Resets don't eject passengers on vehicles without
// accessories (e.g. WG demolisher/catapult).
_accessoriesInstalled = true;
VehicleAccessoryList const* accessories = sObjectMgr->GetVehicleAccessoryList(this);
if (!accessories)
@@ -111,6 +120,7 @@ void Vehicle::Uninstall()
_status = STATUS_UNINSTALLING;
LOG_DEBUG("vehicles", "Vehicle::Uninstall {}", _me->GetGUID().ToString());
RemoveAllPassengers();
_accessoriesInstalled = false;
if (_me && _me->IsCreature())
{