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