Ensure m_pDriver assignation on func_vehicle only (#853)

This commit is contained in:
Francisco Muñoz 2023-09-05 00:52:30 -03:00 committed by GitHub
parent f441279294
commit 2e6e77906f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4107,11 +4107,10 @@ void CBasePlayer::PlayerUse()
if (pTrain && pTrain->Classify() == CLASS_VEHICLE)
{
#ifdef REGAMEDLL_ADD
if (legacy_vehicle_block.value)
((CFuncVehicle *)pTrain)->m_pDriver = nullptr;
#else
((CFuncVehicle *)pTrain)->m_pDriver = nullptr;
if (legacy_vehicle_block.value == 0)
return;
#endif
((CFuncVehicle *)pTrain)->m_pDriver = nullptr;
}
return;
}
@ -4653,12 +4652,17 @@ void EXT_FUNC CBasePlayer::__API_HOOK(PreThink)()
{
m_afPhysicsFlags &= ~PFLAG_ONTRAIN;
m_iTrain = (TRAIN_NEW | TRAIN_OFF);
#ifdef REGAMEDLL_ADD
if (legacy_vehicle_block.value)
((CFuncVehicle *)pTrain)->m_pDriver = nullptr;
#else
((CFuncVehicle *)pTrain)->m_pDriver = nullptr;
#ifdef REGAMEDLL_FIXES
if (pTrain && pTrain->Classify() == CLASS_VEHICLE) // ensure func_vehicle's m_pDriver assignation
#endif
{
#ifdef REGAMEDLL_ADD
if (legacy_vehicle_block.value == 0)
return;
#endif
((CFuncVehicle *)pTrain)->m_pDriver = nullptr;
}
return;
}
}
@ -4667,12 +4671,17 @@ void EXT_FUNC CBasePlayer::__API_HOOK(PreThink)()
// Turn off the train if you jump, strafe, or the train controls go dead
m_afPhysicsFlags &= ~PFLAG_ONTRAIN;
m_iTrain = (TRAIN_NEW | TRAIN_OFF);
#ifdef REGAMEDLL_ADD
if (legacy_vehicle_block.value)
((CFuncVehicle *)pTrain)->m_pDriver = nullptr;
#else
((CFuncVehicle *)pTrain)->m_pDriver = nullptr;
#ifdef REGAMEDLL_FIXES
if (pTrain->Classify() == CLASS_VEHICLE) // ensure func_vehicle's m_pDriver assignation
#endif
{
#ifdef REGAMEDLL_ADD
if (legacy_vehicle_block.value == 0)
return;
#endif
((CFuncVehicle *)pTrain)->m_pDriver = nullptr;
}
return;
}