Vehicle: Automobile: fixes and style things

This commit is contained in:
erorcun 2021-01-02 14:41:53 +03:00
parent e7c46ac658
commit 2268365c3b
4 changed files with 20 additions and 11 deletions

View File

@ -252,6 +252,8 @@ CVector vecHunterRocketPos(2.5f, 1.0f, -0.5f);
CVector vecDAMAGE_ENGINE_POS_SMALL(-0.1f, -0.1f, 0.0f); CVector vecDAMAGE_ENGINE_POS_SMALL(-0.1f, -0.1f, 0.0f);
CVector vecDAMAGE_ENGINE_POS_BIG(-0.5f, -0.3f, 0.0f); CVector vecDAMAGE_ENGINE_POS_BIG(-0.5f, -0.3f, 0.0f);
#pragma optimize("", off) // a workaround for another compiler bug
void void
CAutomobile::ProcessControl(void) CAutomobile::ProcessControl(void)
{ {
@ -835,11 +837,16 @@ CAutomobile::ProcessControl(void)
if(bAudioChangingGear && m_fGasPedal > 0.4f && m_fBrakePedal < 0.1f && fwdSpeed > 0.15f && if(bAudioChangingGear && m_fGasPedal > 0.4f && m_fBrakePedal < 0.1f && fwdSpeed > 0.15f &&
this == FindPlayerVehicle() && TheCamera.Cams[TheCamera.ActiveCam].Mode != CCam::MODE_1STPERSON){ this == FindPlayerVehicle() && TheCamera.Cams[TheCamera.ActiveCam].Mode != CCam::MODE_1STPERSON){
if(GetStatus() == STATUS_PLAYER && pHandling->Flags & HANDLING_IS_BUS){ if(GetStatus() == STATUS_PLAYER && !(pHandling->Flags & HANDLING_IS_BUS)){
if(m_nBusDoorTimerEnd == 0) if(m_nBusDoorTimerEnd == 0)
m_nBusDoorTimerEnd = 1000; m_nBusDoorTimerEnd = 1000;
else if(m_nBusDoorTimerEnd > CTimer::GetTimeStepInMilliseconds()) else {
m_nBusDoorTimerEnd -= CTimer::GetTimeStepInMilliseconds(); uint32 timeStepInMs = CTimer::GetTimeStepInMilliseconds();
if(m_nBusDoorTimerEnd > timeStepInMs)
m_nBusDoorTimerEnd -= timeStepInMs;
else
m_nBusDoorTimerEnd = 0;
}
} }
if((m_aSuspensionSpringRatio[0] < 1.0f || m_aSuspensionSpringRatio[2] < 1.0f) && if((m_aSuspensionSpringRatio[0] < 1.0f || m_aSuspensionSpringRatio[2] < 1.0f) &&
@ -1676,8 +1683,8 @@ CAutomobile::ProcessControl(void)
Abs(m_vecMoveSpeed.y) < 0.005f && Abs(m_vecMoveSpeed.y) < 0.005f &&
Abs(m_vecMoveSpeed.z) < 0.005f && Abs(m_vecMoveSpeed.z) < 0.005f &&
!(m_fDamageImpulse > 0.0f && m_pDamageEntity == FindPlayerPed()) && !(m_fDamageImpulse > 0.0f && m_pDamageEntity == FindPlayerPed()) &&
(m_aSuspensionSpringRatioPrev[0] < 1.0f && m_aSuspensionSpringRatioPrev[1] < 1.0f && (m_aSuspensionSpringRatioPrev[0] < 1.0f || m_aSuspensionSpringRatioPrev[1] < 1.0f ||
m_aSuspensionSpringRatioPrev[2] < 1.0f && m_aSuspensionSpringRatioPrev[3] < 1.0f)){ m_aSuspensionSpringRatioPrev[2] < 1.0f || m_aSuspensionSpringRatioPrev[3] < 1.0f)){
m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f);
m_vecTurnSpeed.z = 0.0f; m_vecTurnSpeed.z = 0.0f;
} }
@ -1701,6 +1708,8 @@ CAutomobile::ProcessControl(void)
} }
} }
#pragma optimize("", on)
void void
CAutomobile::Teleport(CVector pos) CAutomobile::Teleport(CVector pos)
{ {

View File

@ -300,7 +300,7 @@ cHandlingDataMgr::LoadHandlingData(void)
case 11: handling->fTractionBias = atof(word); break; case 11: handling->fTractionBias = atof(word); break;
case 12: handling->Transmission.nNumberOfGears = atoi(word); break; case 12: handling->Transmission.nNumberOfGears = atoi(word); break;
case 13: handling->Transmission.fMaxVelocity = atof(word); break; case 13: handling->Transmission.fMaxVelocity = atof(word); break;
case 14: handling->Transmission.fEngineAcceleration = atof(word) * 0.4f; break; case 14: handling->Transmission.fEngineAcceleration = atof(word) * 0.4; break;
case 15: handling->Transmission.nDriveType = word[0]; break; case 15: handling->Transmission.nDriveType = word[0]; break;
case 16: handling->Transmission.nEngineType = word[0]; break; case 16: handling->Transmission.nEngineType = word[0]; break;
case 17: handling->fBrakeDeceleration = atof(word); break; case 17: handling->fBrakeDeceleration = atof(word); break;
@ -363,7 +363,7 @@ cHandlingDataMgr::ConvertDataToGameUnits(tHandlingData *handling)
handling->fBuoyancy = 100.0f/handling->nPercentSubmerged * GRAVITY*handling->fMass; handling->fBuoyancy = 100.0f/handling->nPercentSubmerged * GRAVITY*handling->fMass;
// What the hell is going on here? // What the hell is going on here?
specificVolume = handling->Dimension.x*handling->Dimension.z*0.5f / handling->fMass; // ? specificVolume = handling->Dimension.z * (handling->Dimension.x / 2.f) / handling->fMass; // ?
a = 0.0f; a = 0.0f;
b = 100.0f; b = 100.0f;
velocity = handling->Transmission.fMaxVelocity; velocity = handling->Transmission.fMaxVelocity;

View File

@ -123,7 +123,7 @@ cTransmission::CalculateDriveAcceleration(const float &gasPedal, uint8 &gear, fl
else else
fCheat = 1.0f; fCheat = 1.0f;
float targetVelocity = Gears[gear].fMaxVelocity*speedMul*fCheat; float targetVelocity = Gears[gear].fMaxVelocity*speedMul*fCheat;
float accel = fEngineAcceleration*accelMul * (targetVelocity - fVelocity)/Abs(targetVelocity); float accel = (targetVelocity - fVelocity) * (fEngineAcceleration*accelMul) / Abs(targetVelocity);
if(Abs(fVelocity) < Abs(Gears[gear].fMaxVelocity*fCheat)) if(Abs(fVelocity) < Abs(Gears[gear].fMaxVelocity*fCheat))
fAcceleration = gasPedal * accel * CTimer::GetTimeStep(); fAcceleration = gasPedal * accel * CTimer::GetTimeStep();
else else

View File

@ -836,11 +836,11 @@ CVehicle::ProcessWheel(CVector &wheelFwd, CVector &wheelRight, CVector &wheelCon
if(IsBike()) if(IsBike())
brake = 0.6f * mod_HandlingManager.fWheelFriction / (pHandling->fMass + 200.0f); brake = 0.6f * mod_HandlingManager.fWheelFriction / (pHandling->fMass + 200.0f);
else if(pHandling->fMass < 500.0f) else if(pHandling->fMass < 500.0f)
brake = mod_HandlingManager.fWheelFriction / m_fMass; brake = mod_HandlingManager.fWheelFriction / pHandling->fMass;
else if(GetModelIndex() == MI_RCBANDIT) else if(GetModelIndex() == MI_RCBANDIT)
brake = 0.2f * mod_HandlingManager.fWheelFriction / m_fMass; brake = 0.2f * mod_HandlingManager.fWheelFriction / pHandling->fMass;
else else
brake = mod_HandlingManager.fWheelFriction / m_fMass; brake = mod_HandlingManager.fWheelFriction / pHandling->fMass;
#ifdef FIX_BUGS #ifdef FIX_BUGS
brake *= CTimer::GetTimeStepFix(); brake *= CTimer::GetTimeStepFix();
#endif #endif