Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #2906: warpPedIntoVehicle causes a C++ runtime assertion failure #2920

Merged
merged 13 commits into from May 18, 2023
3 changes: 3 additions & 0 deletions Server/mods/deathmatch/logic/CPed.cpp
Expand Up @@ -406,6 +406,9 @@ CVehicle* CPed::SetOccupiedVehicle(CVehicle* pVehicle, unsigned int uiSeat)
static bool bAlreadyIn = false;
if (!bAlreadyIn)
{
if (uiSeat < MAX_VEHICLE_SEATS)
return m_pVehicle;

TracerDS marked this conversation as resolved.
Show resolved Hide resolved
// Store it
m_pVehicle = pVehicle;
m_uiVehicleSeat = uiSeat;
Expand Down
3 changes: 3 additions & 0 deletions Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp
Expand Up @@ -4136,6 +4136,9 @@ bool CStaticFunctionDefinitions::WarpPedIntoVehicle(CPed* pPed, CVehicle* pVehic
assert(pPed);
assert(pVehicle);

if (pVehicle->GetMaxPassengers() == VEHICLE_PASSENGERS_UNDEFINED)
TracerDS marked this conversation as resolved.
Show resolved Hide resolved
return false;

// Valid seat id for that vehicle?
// 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
// syncer (Todo)
Expand Down
5 changes: 4 additions & 1 deletion Server/mods/deathmatch/logic/CVehicle.cpp
Expand Up @@ -618,6 +618,9 @@ bool CVehicle::SetOccupant(CPed* pPed, unsigned int uiSeat)
static bool bAlreadySetting = false;
if (!bAlreadySetting)
{
if (uiSeat < MAX_VEHICLE_SEATS)
TracerDS marked this conversation as resolved.
Show resolved Hide resolved
return false;

// Set the Player
if (m_pOccupants[uiSeat] != pPed)
{
Expand All @@ -644,7 +647,7 @@ bool CVehicle::SetOccupant(CPed* pPed, unsigned int uiSeat)
return true;
}

return true;
return true; // return true? even if function didn't end successfully?
TracerDS marked this conversation as resolved.
Show resolved Hide resolved
}

void CVehicle::SetSyncer(CPlayer* pPlayer)
Expand Down