flat tyre and minimal refractoring

This commit is contained in:
Roman Masanin 2020-09-25 23:27:28 +03:00
parent 4d1023ca30
commit 6e3523d594
2 changed files with 138 additions and 50 deletions

View file

@ -748,7 +748,7 @@ void cAudioManager::ProcessVehicle(CVehicle* veh)
switch (veh->GetVehicleAppearance()) { switch (veh->GetVehicleAppearance()) {
case VEHICLE_APPEARANCE_HELI: case VEHICLE_APPEARANCE_HELI:
ProcessCarHeli(&params); ProcessCarHeli(&params);
//ProcessVehicleFlatTyre(&params); ProcessVehicleFlatTyre(&params);
ProcessEngineDamage(&params); ProcessEngineDamage(&params);
break; break;
case VEHICLE_APPEARANCE_BOAT: case VEHICLE_APPEARANCE_BOAT:
@ -760,7 +760,7 @@ void cAudioManager::ProcessVehicle(CVehicle* veh)
if (CWeather::WetRoads > 0.0) if (CWeather::WetRoads > 0.0)
ProcessWetRoadNoise(&params); ProcessWetRoadNoise(&params);
ProcessVehicleSkidding(&params); ProcessVehicleSkidding(&params);
//ProcessVehicleFlatTyre(params); ProcessVehicleFlatTyre(&params);
ProcessVehicleHorn(&params); ProcessVehicleHorn(&params);
ProcessVehicleSirenOrAlarm(&params); ProcessVehicleSirenOrAlarm(&params);
if (UsesReverseWarning(params.m_nIndex)) if (UsesReverseWarning(params.m_nIndex))
@ -793,7 +793,7 @@ void cAudioManager::ProcessVehicle(CVehicle* veh)
case VEHICLE_TYPE_PLANE: case VEHICLE_TYPE_PLANE:
ProcessPlane(&params); ProcessPlane(&params);
ProcessVehicleOneShots(&params); ProcessVehicleOneShots(&params);
//ProcessVehicleFlatType(&params); ProcessVehicleFlatTyre(&params);
break; break;
case VEHICLE_TYPE_BIKE: case VEHICLE_TYPE_BIKE:
bike = (CBike*)veh; bike = (CBike*)veh;
@ -807,7 +807,7 @@ void cAudioManager::ProcessVehicle(CVehicle* veh)
ProcessCarBombTick(&params); ProcessCarBombTick(&params);
ProcessEngineDamage(&params); ProcessEngineDamage(&params);
ProcessVehicleEngine(&params); ProcessVehicleEngine(&params);
//ProcessVehicleFlatTyre(); ProcessVehicleFlatTyre(&params);
} }
ProcessVehicleOneShots(&params); ProcessVehicleOneShots(&params);
bike->m_fVelocityChangeForAudio = params.m_fVelocityChange; bike->m_fVelocityChangeForAudio = params.m_fVelocityChange;
@ -3071,27 +3071,28 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params)
CAutomobile* automobile; // [esp+10h] [ebp-CCh] CAutomobile* automobile; // [esp+10h] [ebp-CCh]
CBoat* boat; // [esp+1Ch] [ebp-C0h] CBoat* boat; // [esp+1Ch] [ebp-C0h]
signed int volume_5; // ebx
unsigned int freqModifier; // eax
signed int volume; // ebx signed int volume; // ebx
uint32 freq_6; // eax signed int volume_5; // ebx
signed int volume_3; // ebx signed int volume_3; // ebx
signed int volume_2; // ebx signed int volume_2; // ebx
char distCalcBool; // [esp+Ch] [ebp-D0h] signed int volume_4; // [esp+28h] [ebp-B4h]
signed int volume_1; // [esp+2Ch] [ebp-B0h]
float volumeModifier; // [esp+40h] [ebp-9Ch]
uint32 freq_6; // eax
unsigned int freqModifier; // eax
signed int freqModifier_2; // [esp+14h] [ebp-C8h] signed int freqModifier_2; // [esp+14h] [ebp-C8h]
bool distCalcBool; // [esp+Ch] [ebp-D0h]
char hunterBool; // [esp+18h] [ebp-C4h] char hunterBool; // [esp+18h] [ebp-C4h]
signed int brake; // [esp+20h] [ebp-BCh] signed int brake; // [esp+20h] [ebp-BCh]
signed int accelerate; // [esp+24h] [ebp-B8h] signed int accelerate; // [esp+24h] [ebp-B8h]
signed int volume_4; // [esp+28h] [ebp-B4h]
signed int volume_1; // [esp+2Ch] [ebp-B0h]
float vehAtYAbs; // [esp+34h] [ebp-A8h] float vehAtYAbs; // [esp+34h] [ebp-A8h]
float vehCameraDot; // [esp+38h] [ebp-A4h] float vehCameraDot; // [esp+38h] [ebp-A4h]
float speedMultiplied; // [esp+3Ch] [ebp-A0h] float speedMultiplied; // [esp+3Ch] [ebp-A0h]
float volumeModifier; // [esp+40h] [ebp-9Ch]
float distance_3; // [esp+44h] [ebp-98h] float distance_3; // [esp+44h] [ebp-98h]
CVector posBackup; // [esp+48h] [ebp-94h]
CVector posBackup; // [esp+48h] [ebp-94h]
CMatrix cameraMatrix; // [esp+60h] [ebp-7Ch] CMatrix cameraMatrix; // [esp+60h] [ebp-7Ch]
CVector pos; // [esp+A8h] [ebp-34h] CVector pos; // [esp+A8h] [ebp-34h]
//CVector multipliedVector; // [esp+B4h] [ebp-28h] //CVector multipliedVector; // [esp+B4h] [ebp-28h]
@ -3186,6 +3187,9 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params)
AddSampleToRequestedQueue(); AddSampleToRequestedQueue();
} }
} }
//244- //244-
if (automobile) { //!! if (automobile) { //!!
automobile->GetComponentWorldPosition(CAR_BOOT, pos); automobile->GetComponentWorldPosition(CAR_BOOT, pos);
@ -3194,6 +3198,7 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params)
//MatrixMultiplier.x = 0.0; //MatrixMultiplier.x = 0.0;
//MatrixMultiplier.y = -10.0; //MatrixMultiplier.y = -10.0;
//multipliedVector = params->m_pVehicle->m_matrix * MatrixMultiplier; //multipliedVector = params->m_pVehicle->m_matrix * MatrixMultiplier;
pos = { 0.0f, -10.0f, 0.0f };
} else { } else {
pos = m_sQueueSample.m_vecPos; pos = m_sQueueSample.m_vecPos;
} }
@ -3217,32 +3222,10 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params)
if (veh->m_modelIndex == MI_HUNTER) //!! if (veh->m_modelIndex == MI_HUNTER) //!!
hunterBool = true; hunterBool = true;
} }
volume_1 = (1.0f - vehCameraDot) * volumeModifier * 127.0f;
//288-339
if (boat) { //!!
if (accelerate <= 0 && brake <= 0) { //!!
//freqModifier_4 = 3713.0 * vehAtYAbs;
//if (freqModifier_4 > 3713)//!!
// freqModifier_4 = 3713;
m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, vehAtYAbs) * 3713; //???
} else {
m_sQueueSample.m_nFrequency = 18000 + Min(1.0f, vehAtYAbs * (Max(accelerate, brake) / 255)) * 2204;
}
if (speedMultiplied < 1.0) { //??
//v27 = (double)(this_1->m_sQueueSample.m_nFrequency >> 1);
//this_1->m_sQueueSample.m_nFrequency = (signed __int64)(v27 * speedMultiplied + v27);
m_sQueueSample.m_nFrequency = (speedMultiplied + 1.0f) * m_sQueueSample.m_nFrequency / 2.0f;
}
m_sQueueSample.m_nFrequency = m_sQueueSample.m_nFrequency < freqPrev ?
Max(m_sQueueSample.m_nFrequency, freqPrev - 197) : Min(m_sQueueSample.m_nFrequency, freqPrev + 197);
freqPrev = m_sQueueSample.m_nFrequency;
//TODO maybe clamp!!!
}
//sound from front of helicopter //sound from front of helicopter
volume_1 = (1.0f - vehCameraDot) * volumeModifier * 127.0f;
m_sQueueSample.m_nVolume = ComputeVolume(volume_1, 140.0f, m_sQueueSample.m_fDistance); m_sQueueSample.m_nVolume = ComputeVolume(volume_1, 140.0f, m_sQueueSample.m_fDistance);
if (m_sQueueSample.m_nVolume != 0) { if (m_sQueueSample.m_nVolume != 0) {
m_sQueueSample.m_nCounter = 3; //347 andro m_sQueueSample.m_nCounter = 3; //347 andro
@ -3266,6 +3249,27 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params)
} else if (boat) { //!! } else if (boat) { //!!
m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO1; m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO1;
m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nBankIndex = SFX_BANK_0;
if (accelerate <= 0 && brake <= 0) { //!!
//freqModifier_4 = 3713.0 * vehAtYAbs;
//if (freqModifier_4 > 3713)//!!
// freqModifier_4 = 3713;
m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, vehAtYAbs) * 3713; //???
} else {
m_sQueueSample.m_nFrequency = 18000 + Min(1.0f, vehAtYAbs * (Max(accelerate, brake) / 255)) * 2204;
}
if (speedMultiplied < 1.0) { //??
//v27 = (double)(this_1->m_sQueueSample.m_nFrequency >> 1);
//this_1->m_sQueueSample.m_nFrequency = (signed __int64)(v27 * speedMultiplied + v27);
m_sQueueSample.m_nFrequency = (speedMultiplied + 1.0f) * m_sQueueSample.m_nFrequency / 2.0f;
}
m_sQueueSample.m_nFrequency = m_sQueueSample.m_nFrequency < freqPrev ?
Max(m_sQueueSample.m_nFrequency, freqPrev - 197) : Min(m_sQueueSample.m_nFrequency, freqPrev + 197);
freqPrev = m_sQueueSample.m_nFrequency;
//TODO maybe clamp!!!
m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nReleasingVolumeModificator = 1; m_sQueueSample.m_nReleasingVolumeModificator = 1;
m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nLoopCount = 0;
@ -3299,6 +3303,8 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params)
} }
} }
if (!boat && params->m_VehicleType != VEHICLE_TYPE_HELI && m_sQueueSample.m_fDistance < 30.0f) { //!! if (!boat && params->m_VehicleType != VEHICLE_TYPE_HELI && m_sQueueSample.m_fDistance < 30.0f) { //!!
//engine starting sound //engine starting sound
if (automobile->bEngineOn) { if (automobile->bEngineOn) {
@ -3337,20 +3343,8 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params)
if (boat) {
if (accelerate <= 0 && brake <= 0) //!!
m_sQueueSample.m_nFrequency = 7143 + Min(1.0f, vehAtYAbs) * 1857;
else
m_sQueueSample.m_nFrequency = 9000 + Min(1.0f, (Max(accelerate, brake) / 255) * vehAtYAbs) * 1102;
if (speedMultiplied < 1.0) //??
m_sQueueSample.m_nFrequency = (speedMultiplied + 1) * (m_sQueueSample.m_nFrequency / 2);
m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqPrev_1 - 98, freqPrev_1 + 98);
freqPrev_1 = m_sQueueSample.m_nFrequency;
}
//after accel rotor sound //after accel rotor sound
volume_4 = ((0.5 * vehCameraDot + 0.5) * volumeModifier * 127.0); volume_4 = ((vehCameraDot + 1) * volumeModifier * 127.0f) / 2;
m_sQueueSample.m_nVolume = ComputeVolume(volume_4, 140.0, m_sQueueSample.m_fDistance); m_sQueueSample.m_nVolume = ComputeVolume(volume_4, 140.0, m_sQueueSample.m_fDistance);
if (m_sQueueSample.m_nVolume != 0) { if (m_sQueueSample.m_nVolume != 0) {
m_sQueueSample.m_nCounter = 1; m_sQueueSample.m_nCounter = 1;
@ -3361,6 +3355,17 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params)
} else if (boat) { } else if (boat) {
m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO2; m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO2;
m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nBankIndex = SFX_BANK_0;
if (accelerate <= 0 && brake <= 0) //!!
m_sQueueSample.m_nFrequency = 7143 + Min(1.0f, vehAtYAbs) * 1857;
else
m_sQueueSample.m_nFrequency = 9000 + Min(1.0f, (Max(accelerate, brake) / 255) * vehAtYAbs) * 1102;
if (speedMultiplied < 1.0) //??
m_sQueueSample.m_nFrequency = (speedMultiplied + 1) * (m_sQueueSample.m_nFrequency / 2);
m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqPrev_1 - 98, freqPrev_1 + 98);
freqPrev_1 = m_sQueueSample.m_nFrequency;
} else { } else {
m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_MAI2; m_sQueueSample.m_nSampleIndex = SFX_CAR_HELI_MAI2;
m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nBankIndex = SFX_BANK_0;
@ -3383,12 +3388,12 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params)
if (boat) { if (boat) {
//489-568 //489-568
if (TheCamera.Cams[TheCamera.ActiveCam].Mode == 15 && m_sQueueSample.m_fDistance < 20.0f && speedMultiplied > 0.0f) { //?? 525 andro if (TheCamera.Cams[TheCamera.ActiveCam].Mode == 15 && m_sQueueSample.m_fDistance < 20.0f && speedMultiplied > 0.0f) { //?? 525 andro
volume_3 = speedMultiplied * 100.0f; volume_3 = speedMultiplied * 100.0f;
m_sQueueSample.m_nVolume = ComputeVolume(volume_3, 20.0f, m_sQueueSample.m_fDistance); m_sQueueSample.m_nVolume = ComputeVolume(volume_3, 20.0f, m_sQueueSample.m_fDistance);
if (accelerate <= 0 && brake <= 0)//!! if (accelerate <= 0 && brake <= 0)//!!
m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, vehAtYAbs) * 3713; m_sQueueSample.m_nFrequency = 14287 + Min(1.0f, vehAtYAbs) * 3713;
else else
@ -3397,6 +3402,7 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params)
m_sQueueSample.m_nFrequency = (speedMultiplied + 1) * (m_sQueueSample.m_nFrequency / 2); m_sQueueSample.m_nFrequency = (speedMultiplied + 1) * (m_sQueueSample.m_nFrequency / 2);
m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqPrev_0 - 197, freqPrev_0 + 197); m_sQueueSample.m_nFrequency = clamp(m_sQueueSample.m_nFrequency, freqPrev_0 - 197, freqPrev_0 + 197);
freqPrev_0 = m_sQueueSample.m_nFrequency; freqPrev_0 = m_sQueueSample.m_nFrequency;
if (m_sQueueSample.m_nVolume) { if (m_sQueueSample.m_nVolume) {
m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO4; m_sQueueSample.m_nSampleIndex = SFX_SEAPLANE_PRO4;
m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nBankIndex = SFX_BANK_0;
@ -3461,6 +3467,87 @@ void cAudioManager::ProcessCarHeli(cVehicleParams* params)
return; return;
} }
void
cAudioManager::ProcessVehicleFlatTyre(cVehicleParams* params)
{
CAutomobile* automobile;
CBike* bike;
cAudioManager* this_1; // ebp
int vehType; // edx
unsigned __int8 j; // dl
float tmp_2; // ST1C_4
double tmp_4; // st6
float tmp_3;
signed int volume; // ebx
bool someBool; // [esp+4h] [ebp-20h]
float modifier; // [esp+Ch] [ebp-18h]
this_1 = this;
someBool = 0;
if (params->m_fDistance >= 3600.0)
return;
vehType = params->m_VehicleType;
switch (params->m_VehicleType) {
case 0:
automobile = (CAutomobile*)params->m_pVehicle;
someBool = false;
for (int i = 0; i < 4; i++)
if (automobile->Damage.GetWheelStatus(i) == 1 && automobile->m_aWheelTimer[i] > 0.0)
someBool = true;
if (!someBool)
//return;
break;
case 5:
bike = (CBike*)params->m_pVehicle;
someBool = false;
for(int i = 0; i < 2; i++)
if (bike->m_wheelStatus[i] == 1 && bike->m_aWheelTimer[i] > 0.0)
someBool = true;
if (!someBool)
return;
break;
default:
return;
}
tmp_2 = fabs(params->m_fVelocityChange);
if (tmp_2 / (0.3 * params->m_pTransmission->fMaxVelocity) <= 1.0) { //!!
tmp_3 = fabs(params->m_fVelocityChange);
tmp_4 = tmp_3 / (0.3 * params->m_pTransmission->fMaxVelocity);
} else {
tmp_4 = 1.0;
}
modifier = tmp_4+0.5f;
if (modifier > 0.01) { //!!
CalculateDistance(params->m_bDistanceCalculated, params->m_fDistance);
volume = (100.0 * modifier);
this_1->m_sQueueSample.m_nVolume = ComputeVolume(volume, 60.0, m_sQueueSample.m_fDistance);
if (m_sQueueSample.m_nVolume) {
m_sQueueSample.m_nCounter = 95;
m_sQueueSample.m_nBankIndex = 0;
m_sQueueSample.m_bIs2D = 0;
m_sQueueSample.m_nReleasingVolumeModificator = 5;
m_sQueueSample.m_nSampleIndex = SFX_TYRE_BURST_L;
m_sQueueSample.m_nFrequency = (5500.0f * modifier)
+ 8000;
m_sQueueSample.m_nLoopCount = 0;
m_sQueueSample.m_nEmittingVolume = volume;
m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(SFX_TYRE_BURST_L);
m_sQueueSample.m_nLoopEnd = SampleManager.GetSampleLoopEndOffset(SFX_TYRE_BURST_L);
m_sQueueSample.m_fSpeedMultiplier = 2.0;
m_sQueueSample.m_fSoundIntensity = 60.0;
m_sQueueSample.m_bReleasingSoundFlag = 0;
m_sQueueSample.m_nReleasingVolumeDivider = 3;
m_sQueueSample.m_bReverbFlag = 1;
m_sQueueSample.m_bRequireReflection = 0;
AddSampleToRequestedQueue();
}
}
}
//TODO use it in ProcessVehicle //TODO use it in ProcessVehicle
void void
cAudioManager::ProcessPlane(cVehicleParams *params) cAudioManager::ProcessPlane(cVehicleParams *params)

View file

@ -332,6 +332,7 @@ public:
void ProcessGarages(); void ProcessGarages();
bool ProcessHelicopter(cVehicleParams *params); bool ProcessHelicopter(cVehicleParams *params);
void ProcessCarHeli(cVehicleParams* params); void ProcessCarHeli(cVehicleParams* params);
void ProcessVehicleFlatTyre(cVehicleParams* params);
void ProcessJumbo(cVehicleParams *); void ProcessJumbo(cVehicleParams *);
void ProcessJumboAccel(CPlane *plane); void ProcessJumboAccel(CPlane *plane);
void ProcessJumboDecel(CPlane *plane); void ProcessJumboDecel(CPlane *plane);