Core/Vehicle: Fix an assertion when applying SPELL_AURA_SET_VEHICLE_ID on creatures that are already vehicles (#30102)

This commit is contained in:
Jeremy
2024-07-19 11:39:29 +02:00
committed by GitHub
parent 0d95856c1a
commit 53f0f2e5da
2 changed files with 9 additions and 3 deletions

View File

@@ -52,7 +52,7 @@ UsableSeatNum(0), _me(unit), _vehicleInfo(vehInfo), _creatureEntry(creatureEntry
// Set or remove correct flags based on available seats. Will overwrite db data (if wrong).
if (UsableSeatNum)
_me->SetNpcFlag((_me->GetTypeId() == TYPEID_PLAYER ? UNIT_NPC_FLAG_PLAYER_VEHICLE : UNIT_NPC_FLAG_SPELLCLICK));
else
else if (!unit->m_unitData->InteractSpellID)
_me->RemoveNpcFlag((_me->GetTypeId() == TYPEID_PLAYER ? UNIT_NPC_FLAG_PLAYER_VEHICLE : UNIT_NPC_FLAG_SPELLCLICK));
InitMovementInfoForBase();

View File

@@ -5309,13 +5309,19 @@ void AuraEffect::HandleAuraSetVehicle(AuraApplication const* aurApp, uint8 mode,
uint32 vehicleId = GetMiscValue();
target->RemoveVehicleKit();
if (apply)
{
if (!target->CreateVehicleKit(vehicleId, 0))
return;
}
else if (target->GetVehicleKit())
target->RemoveVehicleKit();
else
{
if (Creature* creature = target->ToCreature())
if (uint32 originalVehicleId = creature->GetCreatureTemplate()->VehicleId)
creature->CreateVehicleKit(originalVehicleId, creature->GetEntry());
}
if (target->GetTypeId() != TYPEID_PLAYER)
return;