diff --git a/GTAFmod/GTAFmod.cpp b/GTAFmod/GTAFmod.cpp index 0ab9117..193a55a 100644 --- a/GTAFmod/GTAFmod.cpp +++ b/GTAFmod/GTAFmod.cpp @@ -189,6 +189,7 @@ class GTAFmod { } static void _stdcall ProcessVehicleEngine(cVehicleParams* params) { + if (lastVehicle && !CTimer::m_UserPause && audio) { //Set 3D space position @@ -257,27 +258,30 @@ class GTAFmod { nLastGearChangeTime = CTimer::m_snTimeInMilliseconds; } - //Gear relation - float relation[] = { - iniConfig->m_fRalationR, - iniConfig->m_fRalation1, - iniConfig->m_fRalation2, - iniConfig->m_fRalation3, - iniConfig->m_fRalation4, - iniConfig->m_fRalation5 - }; - - //Calculate target RPM - float targetRpm = 400 + (lastVehicle->m_vecMoveSpeed.Magnitude() * abs(relation[nGear])) * (iniConfig->m_fFinalRPM - 1500); + //Calculate target RPM + float speed = fabs(params->m_fVelocity); + float ratio = (speed- params->m_pTransmission->m_aGears[nGear].m_fChangeDownVelocity) + / (*(float*)¶ms->m_pTransmission->m_aGears[nGear].m_fMaxVelocity + - params->m_pTransmission->m_aGears[nGear].m_fChangeDownVelocity); + if (ratio > 1.0 || ratio >= 0.0) + { + if (ratio > 1.0) + ratio = 1.0; + } + else + { + ratio = 0.0; + } + float targetRpm = iniConfig->m_fMinRPM + (iniConfig->m_fMaxRPM * ratio); if (clutch > 0) { fRPM += (gasPedal * CTimer::ms_fTimeStep) * 200 * clutch; - if (fRPM > iniConfig->m_fFinalRPM) + if (fRPM > iniConfig->m_fMaxRPM) { - fRPM = iniConfig->m_fFinalRPM; + fRPM = iniConfig->m_fMaxRPM; } - if (gasPedal == 0 && fRPM > 800) + if (gasPedal == 0 && fRPM > iniConfig->m_fMinRPM) { fRPM -= (CTimer::ms_fTimeStep) * 20; } diff --git a/GTAFmod/INIConfig.h b/GTAFmod/INIConfig.h index 9308ca8..462ee2b 100644 --- a/GTAFmod/INIConfig.h +++ b/GTAFmod/INIConfig.h @@ -5,32 +5,18 @@ class INIConfig { public: //Audio - float m_fFinalRPM; + float m_fMinRPM; + float m_fMaxRPM; float m_fRPMAcceleration; float m_fRPMDesaceleration; - //GearRatio - float m_fRalationR; - float m_fRalation1; - float m_fRalation2; - float m_fRalation3; - float m_fRalation4; - float m_fRalation5; - float m_fRalation6; INIConfig(std::string iniPath) { CIniReader ini(iniPath); - m_fFinalRPM = ini.ReadFloat("Audio", "FinalRPM", 8000); + m_fMinRPM = ini.ReadFloat("Audio", "FinalRPM", 800); + m_fMaxRPM = ini.ReadFloat("Audio", "FinalRPM", 6200); m_fRPMAcceleration = ini.ReadFloat("Audio", "RPMAcceleration", 50); m_fRPMDesaceleration = ini.ReadFloat("Audio", "RPMDesaceleration", 60); - - m_fRalationR = ini.ReadFloat("GearRatio", "RelationR", -1); - m_fRalation1 = ini.ReadFloat("GearRatio", "Relation1", 3); - m_fRalation2 = ini.ReadFloat("GearRatio", "Relation2", 2); - m_fRalation3 = ini.ReadFloat("GearRatio", "Relation3", 1.6); - m_fRalation4 = ini.ReadFloat("GearRatio", "Relation4", 1.2); - m_fRalation5 = ini.ReadFloat("GearRatio", "Relation5", 0.9); - m_fRalation6 = ini.ReadFloat("GearRatio", "Relation6", 0.7); } };