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