Skip to content

Commit

Permalink
Vehicles: Fix switching seats
Browse files Browse the repository at this point in the history
  • Loading branch information
insunaa committed Jan 28, 2024
1 parent a89c0bd commit f4e615d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/game/Entities/Vehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,12 +389,15 @@ void VehicleInfo::SwitchSeat(Unit* passenger, uint8 seat)
MANGOS_ASSERT(seatEntry);

// Switching seats is only allowed if this flag is set
if (seatEntry->CanSwitchFromSeat())
if (!seatEntry->CanSwitchFromSeat())
return;

// Remove passenger modifications of the old seat
RemoveSeatMods(passenger, seatEntry->m_flags);

// Get seatEntry of new seat
seatEntry = GetSeatEntry(seat);

float lx = 0.f, ly = 0.f, lz = 0.f, lo = 0.f;
GetSeatCoordinates(seatEntry, lx, ly, lz);

Expand All @@ -409,8 +412,6 @@ void VehicleInfo::SwitchSeat(Unit* passenger, uint8 seat)
// It seems that Seat switching is sent without SplineFlag BoardVehicle
init.Launch();

// Get seatEntry of new seat
seatEntry = GetSeatEntry(seat);
MANGOS_ASSERT(seatEntry);

// Apply passenger modifications of the new seat
Expand Down
6 changes: 3 additions & 3 deletions src/game/Entities/VehicleHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ void WorldSession::HandleRequestVehicleSwitchSeat(WorldPacket& recvPacket)
if (!transportInfo || !transportInfo->IsOnVehicle())
return;

Unit* vehicle = (Unit*)transportInfo->GetTransport();
Unit* vehicle = static_cast<Unit*>(transportInfo->GetTransport());

if (vehicleGuid != vehicle->GetObjectGuid())
{
Expand All @@ -141,7 +141,7 @@ void WorldSession::HandleRequestVehicleSwitchSeat(WorldPacket& recvPacket)

SpellClickInfoMapBounds clickPair = sObjectMgr.GetSpellClickInfoMapBounds(destVehicle->GetEntry());
for (SpellClickInfoMap::const_iterator itr = clickPair.first; itr != clickPair.second; ++itr)
if (itr->second.IsFitToRequirements(_player, destVehicle->GetTypeId() == TYPEID_UNIT ? (Creature*)destVehicle : nullptr))
if (itr->second.IsFitToRequirements(_player, destVehicle->GetTypeId() == TYPEID_UNIT ? static_cast<Creature*>(destVehicle) : nullptr))
_player->CastSpell(destVehicle, itr->second.spellId, TRIGGERED_OLD_TRIGGERED);
}
else
Expand All @@ -167,7 +167,7 @@ void WorldSession::HandleChangeSeatsOnControlledVehicle(WorldPacket& recvPacket)
if (!transportInfo || !transportInfo->IsOnVehicle())
return;

Unit* srcVehicle = (Unit*)transportInfo->GetTransport();
Unit* srcVehicle = static_cast<Unit*>(transportInfo->GetTransport());

// Something went wrong
if (srcVehicleGuid != srcVehicle->GetObjectGuid())
Expand Down

0 comments on commit f4e615d

Please sign in to comment.