Skip to content

Commit

Permalink
Ensure m_pDriver assignation on func_vehicle only (#853)
Browse files Browse the repository at this point in the history
  • Loading branch information
dystopm committed Sep 5, 2023
1 parent f441279 commit 2e6e779
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions regamedll/dlls/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -4653,12 +4652,17 @@ void EXT_FUNC CBasePlayer::__API_HOOK(PreThink)()
{
m_afPhysicsFlags &= ~PFLAG_ONTRAIN;
m_iTrain = (TRAIN_NEW | TRAIN_OFF);

#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)
((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;
}
}
Expand All @@ -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_FIXES
if (pTrain->Classify() == CLASS_VEHICLE) // ensure func_vehicle's m_pDriver assignation
#endif
{
#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;
}

Expand Down

0 comments on commit 2e6e779

Please sign in to comment.