Skip to content

Commit eba619d

Browse files
authored
Fix #2906: warpPedIntoVehicle causes a C++ runtime assertion failure (#2920)
1 parent 520314b commit eba619d

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4135,10 +4135,16 @@ bool CStaticFunctionDefinitions::WarpPedIntoVehicle(CPed* pPed, CVehicle* pVehic
41354135
assert(pPed);
41364136
assert(pVehicle);
41374137

4138+
if (uiSeat > pVehicle->GetMaxPassengers())
4139+
return false;
4140+
4141+
if (uiSeat > 0 && pVehicle->GetMaxPassengers() == VEHICLE_PASSENGERS_UNDEFINED)
4142+
return false;
4143+
41384144
// Valid seat id for that vehicle?
41394145
// Temp fix: Disable driver seat for train carriages since the whole vehicle sync logic is based on the the player on the first seat being the vehicle
41404146
// syncer (Todo)
4141-
if (uiSeat <= pVehicle->GetMaxPassengers() && (pVehicle->GetVehicleType() != VEHICLE_TRAIN || !pVehicle->GetTowedByVehicle()))
4147+
if (pVehicle->GetVehicleType() != VEHICLE_TRAIN || !pVehicle->GetTowedByVehicle())
41424148
{
41434149
if (!pPed->IsDead())
41444150
{

Server/mods/deathmatch/logic/CVehicle.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,9 @@ bool CVehicle::SetOccupant(CPed* pPed, unsigned int uiSeat)
618618
static bool bAlreadySetting = false;
619619
if (!bAlreadySetting)
620620
{
621+
if (uiSeat >= MAX_VEHICLE_SEATS)
622+
return false;
623+
621624
// Set the Player
622625
if (m_pOccupants[uiSeat] != pPed)
623626
{

0 commit comments

Comments
 (0)