Fix sound when "up" and "down" are pressed together

This commit is contained in:
Filip Gawin 2019-11-30 23:52:57 +01:00
parent 37a7c48e63
commit 41c9e66382

View File

@ -6492,7 +6492,6 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile *
float relativeVelocityChange;
float accelerationMultipler;
uint8 wheelInUseCounter;
uint8 i;
float time;
int baseFreq;
uint8 vol;
@ -6540,19 +6539,15 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile *
velocityChange = params->m_fVelocityChange;
relativeVelocityChange = 2.0f * velocityChange / transmission->fMaxVelocity;
accelerationMultipler = 0.0f;
if(relativeVelocityChange > 1.0f) accelerationMultipler = relativeVelocityChange;
accelerationMultipler = min(min(1.f, relativeVelocityChange), 0.f);
gasPedalAudio = accelerationMultipler;
currentGear = params->m_pVehicle->m_nCurrentGear;
if(transmission->nDriveType == '4') {
wheelInUseCounter = 0;
i = 0;
do {
for (uint8 i = 0; i < 4; i++){
if(automobile->m_aWheelState[i]) ++wheelInUseCounter;
++i;
} while(i < 4);
}
if(wheelInUseCounter > 2) lostTraction = 1;
} else if(transmission->nDriveType == 'F') {
if((automobile->m_aWheelState[0] || automobile->m_aWheelState[2]) &&
@ -6623,7 +6618,8 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams *params, CAutomobile *
if(!nCruising) {
if(accelerateState < 150 || !automobile->m_nWheelsOnGround || automobile->bIsHandbrakeOn ||
lostTraction ||
currentGear < 2u && velocityChange - automobile->m_fVelocityChangeForAudio >= 0.01f) {
currentGear < 2 &&
velocityChange - automobile->m_fVelocityChangeForAudio < 0.01f) { // here could be used abs
if(!automobile->m_nWheelsOnGround || automobile->bIsHandbrakeOn || lostTraction) {
if(!automobile->m_nWheelsOnGround && automobile->m_nDriveWheelsOnGround ||
(automobile->bIsHandbrakeOn && !bHandbrakeOnLastFrame ||