Core/Vehicles: Implement VEHICLE_SEAT_FLAG_B_CANSWITCH restriction, and do some cleanup.
This commit is contained in:
@@ -1848,6 +1848,7 @@ struct VehicleSeatEntry
|
||||
// 46-57 added in 3.1, floats mostly
|
||||
|
||||
bool CanEnterOrExit() const { return m_flags & VEHICLE_SEAT_FLAG_CAN_ENTER_OR_EXIT; }
|
||||
bool CanSwitchFromSeat() const { return m_flags & VEHICLE_SEAT_FLAG_B_CANSWITCH; }
|
||||
bool IsUsableByAura() const { return m_flagsB & (VEHICLE_SEAT_FLAG_B_USABLE_FORCED | VEHICLE_SEAT_FLAG_B_USABLE_FORCED_2 | VEHICLE_SEAT_FLAG_B_USABLE_FORCED_3); }
|
||||
bool IsEjectable() const { return m_flagsB & VEHICLE_SEAT_FLAG_B_EJECTABLE; }
|
||||
};
|
||||
|
||||
@@ -423,17 +423,6 @@ void Vehicle::RemovePassenger(Unit *unit)
|
||||
sScriptMgr->OnRemovePassenger(this, unit);
|
||||
}
|
||||
|
||||
void Vehicle::EjectPassenger(Unit* passenger, Unit* controller)
|
||||
{
|
||||
SeatMap::const_iterator m_SeatsItr;
|
||||
for (m_SeatsItr = m_Seats.begin(); m_SeatsItr != m_Seats.end(); ++m_SeatsItr)
|
||||
if (m_SeatsItr->second.passenger == passenger)
|
||||
if (m_SeatsItr->second.seatInfo->IsEjectable())
|
||||
return passenger->ExitVehicle();
|
||||
else
|
||||
sLog->outError("Player %u attempted to eject unit GUID "UI64FMTD" from non-ejectable seat.", controller->GetGUIDLow(), passenger->GetGUID());
|
||||
}
|
||||
|
||||
void Vehicle::RelocatePassengers(float x, float y, float z, float ang)
|
||||
{
|
||||
Map *map = me->GetMap();
|
||||
|
||||
@@ -548,6 +548,14 @@ void WorldSession::HandleChangeSeatsOnControlledVehicle(WorldPacket &recv_data)
|
||||
if (!vehicle_base)
|
||||
return;
|
||||
|
||||
VehicleSeatEntry const* seat = GetPlayer()->GetVehicle()->GetSeatForPassenger(GetPlayer());
|
||||
if (!seat->CanSwitchFromSeat())
|
||||
{
|
||||
sLog->outError("HandleChangeSeatsOnControlledVehicle, Opcode: %u, Player %u tried to switch seats but current seatflags %u don't permit that.",
|
||||
recv_data.GetOpcode(), GetPlayer()->GetGUIDLow(), seat->m_flags);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (recv_data.GetOpcode())
|
||||
{
|
||||
case CMSG_REQUEST_VEHICLE_PREV_SEAT:
|
||||
@@ -635,6 +643,8 @@ void WorldSession::HandleEjectPassenger(WorldPacket &data)
|
||||
VehicleSeatEntry const* seat = vehicle->GetSeatForPassenger(plr);
|
||||
if (seat->IsEjectable())
|
||||
plr->ExitVehicle();
|
||||
else
|
||||
sLog->outError("Player %u attempted to eject player %u from non-ejectable seat.", GetPlayer()->GetGUIDLow(), GUID_LOPART(guid));
|
||||
}
|
||||
else
|
||||
sLog->outError("Player %u tried to eject player %u from vehicle, but the latter was not found in world!", GetPlayer()->GetGUIDLow(), GUID_LOPART(guid));
|
||||
@@ -650,6 +660,8 @@ void WorldSession::HandleEjectPassenger(WorldPacket &data)
|
||||
unit->ExitVehicle();
|
||||
unit->ToCreature()->ForcedDespawn(1000);
|
||||
}
|
||||
else
|
||||
sLog->outError("Player %u attempted to eject creature GUID "UI64FMTD" from non-ejectable seat.", GetPlayer()->GetGUIDLow(), GUID_LOPART(guid));
|
||||
}
|
||||
else
|
||||
sLog->outError("Player %u tried to eject creature guid %u from vehicle, but the latter was not found in world!", GetPlayer()->GetGUIDLow(), GUID_LOPART(guid));
|
||||
|
||||
Reference in New Issue
Block a user