mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-19 08:55:32 +01:00
Core/Vehicles: - Prevent client ejecting passengers from non-ejectable seats.
- Chart some more VehicleSeatFlags and VehicleSeatFlagsB. Research by linencloth
This commit is contained in:
@@ -1849,6 +1849,7 @@ struct VehicleSeatEntry
|
||||
|
||||
bool IsUsableByPlayer() const { return m_flags & VEHICLE_SEAT_FLAG_USABLE; }
|
||||
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; }
|
||||
};
|
||||
|
||||
struct WMOAreaTableEntry
|
||||
|
||||
@@ -423,6 +423,17 @@ 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();
|
||||
|
||||
@@ -50,7 +50,7 @@ enum VehicleFlags
|
||||
enum VehicleSeatFlags
|
||||
{
|
||||
VEHICLE_SEAT_FLAG_HIDE_PASSENGER = 0x00000200, // Passenger is hidden
|
||||
VEHICLE_SEAT_FLAG_UNK11 = 0x00000400,
|
||||
VEHICLE_SEAT_FLAG_UNK11 = 0x00000400, // needed for CGCamera__SyncFreeLookFacing
|
||||
VEHICLE_SEAT_FLAG_CAN_CONTROL = 0x00000800, // Lua_UnitInVehicleControlSeat
|
||||
VEHICLE_SEAT_FLAG_CAN_ATTACK = 0x00004000, // Can attack, cast spells and use items from vehicle?
|
||||
VEHICLE_SEAT_FLAG_USABLE = 0x02000000, // Lua_CanExitVehicle
|
||||
@@ -61,9 +61,13 @@ enum VehicleSeatFlags
|
||||
enum VehicleSeatFlagsB
|
||||
{
|
||||
VEHICLE_SEAT_FLAG_B_NONE = 0x00000000,
|
||||
VEHICLE_SEAT_FLAG_B_USABLE_FORCED = 0x00000002,
|
||||
VEHICLE_SEAT_FLAG_B_USABLE_FORCED = 0x00000002,
|
||||
VEHICLE_SEAT_FLAG_B_TARGETS_IN_RAIDUI = 0x00000008, // Lua_UnitTargetsVehicleInRaidUI
|
||||
VEHICLE_SEAT_FLAG_B_EJECTABLE = 0x00000020, // ejectable
|
||||
VEHICLE_SEAT_FLAG_B_USABLE_FORCED_2 = 0x00000040,
|
||||
VEHICLE_SEAT_FLAG_B_USABLE_FORCED_3 = 0x00000100,
|
||||
VEHICLE_SEAT_FLAG_B_CANSWITCH = 0x04000000, // can switch seats
|
||||
VEHICLE_SEAT_FLAG_B_VEHICLE_PLAYERFRAME_UI = 0x80000000, // Lua_UnitHasVehiclePlayerFrameUI - actually checked for flagsb &~ 0x80000000
|
||||
};
|
||||
|
||||
enum VehicleSpells
|
||||
@@ -119,7 +123,9 @@ class Vehicle
|
||||
bool HasEmptySeat(int8 seatId) const;
|
||||
Unit *GetPassenger(int8 seatId) const;
|
||||
int8 GetNextEmptySeat(int8 seatId, bool next, bool byAura = false) const;
|
||||
|
||||
bool AddPassenger(Unit *passenger, int8 seatId = -1, bool byAura = false);
|
||||
void EjectPassenger(Unit* passenger, Unit* controller);
|
||||
void RemovePassenger(Unit *passenger);
|
||||
void RelocatePassengers(float x, float y, float z, float ang);
|
||||
void RemoveAllPassengers();
|
||||
|
||||
@@ -623,18 +623,34 @@ void WorldSession::HandleEnterPlayerVehicle(WorldPacket &data)
|
||||
|
||||
void WorldSession::HandleEjectPassenger(WorldPacket &data)
|
||||
{
|
||||
if (_player->GetVehicleKit())
|
||||
if (Vehicle* vehicle = _player->GetVehicleKit())
|
||||
{
|
||||
uint64 guid;
|
||||
data >> guid;
|
||||
if (Player *plr = ObjectAccessor::FindPlayer(guid))
|
||||
plr->ExitVehicle();
|
||||
else if (Unit *unit = ObjectAccessor::GetUnit(*_player, guid)) // creatures can be ejected too from player mounts
|
||||
|
||||
if (IS_PLAYER_GUID(guid))
|
||||
{
|
||||
unit->ExitVehicle();
|
||||
unit->ToCreature()->ForcedDespawn(1000);
|
||||
if (Player *plr = ObjectAccessor::FindPlayer(guid))
|
||||
vehicle->EjectPassenger(plr);
|
||||
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));
|
||||
}
|
||||
|
||||
else if (IS_CREATURE_GUID(guid))
|
||||
{
|
||||
if (Unit *unit = ObjectAccessor::GetUnit(*_player, guid)) // creatures can be ejected too from player mounts
|
||||
{
|
||||
vehicle->EjectPassenger(unit);
|
||||
unit->ToCreature()->ForcedDespawn(1000);
|
||||
}
|
||||
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));
|
||||
}
|
||||
else
|
||||
sLog->outError("HandleEjectPassenger: Player %u tried to eject invalid GUID "UI64FMTD, GetPlayer()->GetGUIDLow(), guid);
|
||||
}
|
||||
else
|
||||
sLog->outError("HandleEjectPassenger: Player %u is not in a vehicle!", GetPlayer()->GetGUIDLow());
|
||||
}
|
||||
|
||||
void WorldSession::HandleRequestVehicleExit(WorldPacket &recv_data)
|
||||
|
||||
Reference in New Issue
Block a user