mirror of
https://git.rip/DMCA_FUCKER/re3.git
synced 2025-01-11 09:44:30 +00:00
cleanup processPlayerVehicleEngine
This commit is contained in:
parent
3ab01fa6a3
commit
7f77e8a441
|
@ -1370,60 +1370,51 @@ cAudioManager::ProcessCesna(cVehicleParams *params)
|
||||||
void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle* veh)
|
void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle* veh)
|
||||||
{
|
{
|
||||||
static int32 GearFreqAdj[] = { 6000, 6000, 3400, 1200, 0, -1000 };
|
static int32 GearFreqAdj[] = { 6000, 6000, 3400, 1200, 0, -1000 };
|
||||||
double gasPedal; // st6
|
|
||||||
tWheelState* wheelState;
|
tWheelState* wheelState;
|
||||||
CAutomobile* automobile; // ebp
|
CAutomobile* automobile;
|
||||||
CBike* bike; // edx
|
CBike* bike;
|
||||||
float* gasPedalAudioPtr; // edi
|
CVector pos;
|
||||||
uint8 wheelInUseCounter; // cl
|
float* gasPedalAudioPtr;
|
||||||
int freqModifier; // [esp+Ch] [ebp-74h]
|
|
||||||
signed int accelerateState; // [esp+20h] [ebp-60h]
|
int32 accelerateState;
|
||||||
bool channelUsed; // [esp+2Ch] [ebp-54h]
|
int32 brakeState;
|
||||||
bool lostTraction; // [esp+30h] [ebp-50h]
|
int32 freq;
|
||||||
int engineSoundType; // [esp+1Ch] [ebp-64h]
|
int32 baseFreq;
|
||||||
signed int brakeState; // [esp+24h] [ebp-5Ch]
|
int32 freqModifier;
|
||||||
uint8 wheelsOnGround; // [esp+3Ch] [ebp-44h]
|
uint32 tmp;
|
||||||
|
uint32 soundOffset;
|
||||||
|
uint8 engineSoundType;
|
||||||
|
uint8 wheelInUseCounter;
|
||||||
|
uint8 wheelsOnGround;
|
||||||
|
uint8 vol;
|
||||||
|
uint8 currentGear;
|
||||||
|
uint8 wheelsOnGroundPrev;
|
||||||
|
|
||||||
|
float accelerationMultipler;
|
||||||
float gasPedalAudio;
|
float gasPedalAudio;
|
||||||
double relativeVelocityChange; // st6
|
|
||||||
float accelerationMultipler; // [esp+50h] [ebp-30h]
|
|
||||||
float velocityChangeForAudio;
|
float velocityChangeForAudio;
|
||||||
int baseFreq; // ebp
|
float relativeVelocityChange;
|
||||||
uint8 vol; // bl
|
float time;
|
||||||
|
bool channelUsed;
|
||||||
double time; // st7
|
bool lostTraction;
|
||||||
|
bool err;
|
||||||
double timeClip; // st4
|
bool stuckInSand;
|
||||||
int tmp; // edx
|
bool processedAccelSampleStopped;
|
||||||
int soundOffset; // ebx
|
bool PizzaFaggBool;
|
||||||
char err; // al
|
|
||||||
|
|
||||||
unsigned int freq_2; // edi
|
|
||||||
bool stuckInSand; // cl
|
|
||||||
|
|
||||||
|
|
||||||
unsigned int freq; // edi
|
static uint32 curTime = CTimer::GetTimeInMilliseconds();
|
||||||
|
static int32 nCruising = 0;
|
||||||
bool speedBool; // [esp+28h] [ebp-58h]
|
|
||||||
|
|
||||||
unsigned __int8 currentGear; // [esp+34h] [ebp-4Ch]
|
|
||||||
char processedAccelSampleStopped; // [esp+38h] [ebp-48h]
|
|
||||||
char wheelsOnGroundPrev; // [esp+40h] [ebp-40h]
|
|
||||||
bool PizzaFaggBool; // [esp+44h] [ebp-3Ch]
|
|
||||||
|
|
||||||
CVector pos; // [esp+64h] [ebp-1Ch]
|
|
||||||
|
|
||||||
//67-105
|
|
||||||
static int16 LastAccel = 0;
|
static int16 LastAccel = 0;
|
||||||
static uint8 CurrentPretendGear = 1;
|
static uint8 CurrentPretendGear = 1;
|
||||||
static bool bLostTractionLastFrame = false;
|
static bool bLostTractionLastFrame = false;
|
||||||
static bool bHandbrakeOnLastFrame = false;
|
static bool bHandbrakeOnLastFrame = false;
|
||||||
static int32 nCruising = 0;
|
|
||||||
static bool bAccelSampleStopped = true;
|
static bool bAccelSampleStopped = true;
|
||||||
static uint32 curTime = CTimer::GetTimeInMilliseconds();
|
|
||||||
|
|
||||||
lostTraction = 0;
|
lostTraction = false;
|
||||||
PizzaFaggBool = 0;
|
PizzaFaggBool = params->m_pVehicle->m_modelIndex == MI_PIZZABOY || params->m_pVehicle->m_modelIndex == MI_FAGGIO;
|
||||||
processedAccelSampleStopped = 0;
|
processedAccelSampleStopped = false;
|
||||||
if (bPlayerJustEnteredCar) {
|
if (bPlayerJustEnteredCar) {
|
||||||
bAccelSampleStopped = 1;
|
bAccelSampleStopped = 1;
|
||||||
bPlayerJustEnteredCar = 0;
|
bPlayerJustEnteredCar = 0;
|
||||||
|
@ -1433,7 +1424,6 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle
|
||||||
CurrentPretendGear = 1;
|
CurrentPretendGear = 1;
|
||||||
bHandbrakeOnLastFrame = 0;
|
bHandbrakeOnLastFrame = 0;
|
||||||
}
|
}
|
||||||
//106-157
|
|
||||||
if (CReplay::IsPlayingBack()) {
|
if (CReplay::IsPlayingBack()) {
|
||||||
accelerateState = (signed int)(255.0 * clamp(params->m_pVehicle->m_fGasPedal, 0.0, 1.0));
|
accelerateState = (signed int)(255.0 * clamp(params->m_pVehicle->m_fGasPedal, 0.0, 1.0));
|
||||||
brakeState = (signed int)(255.0 * clamp(params->m_pVehicle->m_fBrakePedal, 0.0, 1.0));
|
brakeState = (signed int)(255.0 * clamp(params->m_pVehicle->m_fBrakePedal, 0.0, 1.0));
|
||||||
|
@ -1441,14 +1431,8 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle
|
||||||
accelerateState = Pads[0].GetAccelerate();
|
accelerateState = Pads[0].GetAccelerate();
|
||||||
brakeState = Pads[0].GetBrake();
|
brakeState = Pads[0].GetBrake();
|
||||||
}
|
}
|
||||||
//158-162
|
|
||||||
speedBool = params->m_fVelocityChange >= -0.001;
|
|
||||||
channelUsed = SampleManager.GetChannelUsedFlag(m_nActiveSamples);
|
channelUsed = SampleManager.GetChannelUsedFlag(m_nActiveSamples);
|
||||||
//163-184
|
if (PizzaFaggBool) {
|
||||||
if (params->m_pVehicle->m_modelIndex != MI_PIZZABOY
|
|
||||||
&& params->m_pVehicle->m_modelIndex != MI_FAGGIO) {
|
|
||||||
currentGear = params->m_pVehicle->m_nCurrentGear;
|
|
||||||
} else {
|
|
||||||
CurrentPretendGear = params->m_pTransmission->nNumberOfGears;
|
CurrentPretendGear = params->m_pTransmission->nNumberOfGears;
|
||||||
currentGear = CurrentPretendGear;
|
currentGear = CurrentPretendGear;
|
||||||
if (params->m_pVehicle->bIsHandbrakeOn) {
|
if (params->m_pVehicle->bIsHandbrakeOn) {
|
||||||
|
@ -1459,16 +1443,16 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle
|
||||||
} else {
|
} else {
|
||||||
nCruising = 1;
|
nCruising = 1;
|
||||||
}
|
}
|
||||||
PizzaFaggBool = true;
|
} else {
|
||||||
|
currentGear = params->m_pVehicle->m_nCurrentGear;
|
||||||
}
|
}
|
||||||
|
|
||||||
//185-205
|
|
||||||
switch (params->m_VehicleType) {
|
switch (params->m_VehicleType) {
|
||||||
case VEHICLE_TYPE_CAR:
|
case VEHICLE_TYPE_CAR:
|
||||||
automobile = (CAutomobile*)params->m_pVehicle;
|
automobile = (CAutomobile*)params->m_pVehicle;
|
||||||
wheelsOnGround = automobile->m_nDriveWheelsOnGround;
|
wheelsOnGround = automobile->m_nDriveWheelsOnGround;
|
||||||
wheelsOnGroundPrev = automobile->m_nDriveWheelsOnGroundPrev;
|
wheelsOnGroundPrev = automobile->m_nDriveWheelsOnGroundPrev;
|
||||||
gasPedalAudioPtr = (float*)&automobile->m_fGasPedalAudio;
|
gasPedalAudioPtr = &automobile->m_fGasPedalAudio;
|
||||||
wheelState = automobile->m_aWheelState;
|
wheelState = automobile->m_aWheelState;
|
||||||
velocityChangeForAudio = automobile->m_fVelocityChangeForAudio;
|
velocityChangeForAudio = automobile->m_fVelocityChangeForAudio;
|
||||||
break;
|
break;
|
||||||
|
@ -1480,13 +1464,11 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle
|
||||||
wheelState = bike->m_aWheelState;
|
wheelState = bike->m_aWheelState;
|
||||||
velocityChangeForAudio = bike->m_fVelocityChangeForAudio;
|
velocityChangeForAudio = bike->m_fVelocityChangeForAudio;
|
||||||
break;
|
break;
|
||||||
//641-644
|
|
||||||
default:
|
default:
|
||||||
//dbgprint(" ** AUDIOLOG: Unrecognised vehicle type %d in ProcessVehicleEngine() * \n", vehType);
|
debug(" ** AUDIOLOG: Unrecognised vehicle type %d in ProcessVehicleEngine() * \n", params->m_VehicleType);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!PizzaFaggBool) {
|
if (!PizzaFaggBool) {
|
||||||
//208-253
|
|
||||||
switch (params->m_pTransmission->nDriveType) {
|
switch (params->m_pTransmission->nDriveType) {
|
||||||
case '4':
|
case '4':
|
||||||
if (params->m_VehicleType != VEHICLE_TYPE_BIKE) {
|
if (params->m_VehicleType != VEHICLE_TYPE_BIKE) {
|
||||||
|
@ -1522,7 +1504,6 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//254-281
|
|
||||||
if (params->m_fVelocityChange != 0.0f) {
|
if (params->m_fVelocityChange != 0.0f) {
|
||||||
time = params->m_pVehicle->m_vecMoveSpeed.z / params->m_fVelocityChange;
|
time = params->m_pVehicle->m_vecMoveSpeed.z / params->m_fVelocityChange;
|
||||||
if (time > 0.0f)
|
if (time > 0.0f)
|
||||||
|
@ -1533,15 +1514,12 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle
|
||||||
freqModifier = -freqModifier;
|
freqModifier = -freqModifier;
|
||||||
} else
|
} else
|
||||||
freqModifier = 0;
|
freqModifier = 0;
|
||||||
//282-283
|
|
||||||
if (params->m_VehicleType == VEHICLE_TYPE_BIKE && bike->bExtraSpeed)
|
if (params->m_VehicleType == VEHICLE_TYPE_BIKE && bike->bExtraSpeed)
|
||||||
freqModifier += 1400;
|
freqModifier += 1400;
|
||||||
//TODO rewtire this part
|
|
||||||
//284-349
|
|
||||||
tmp = 0;
|
tmp = 0;
|
||||||
engineSoundType = aVehicleSettings[params->m_nIndex].m_nBank;
|
engineSoundType = aVehicleSettings[params->m_nIndex].m_nBank;
|
||||||
soundOffset = 3 * (engineSoundType - 4);
|
soundOffset = 3 * (engineSoundType - 4);
|
||||||
err = 0;
|
err = false;
|
||||||
switch (soundOffset) {
|
switch (soundOffset) {
|
||||||
case 0:
|
case 0:
|
||||||
tmp = 2526;
|
tmp = 2526;
|
||||||
|
@ -1586,7 +1564,7 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle
|
||||||
tmp = 2410;
|
tmp = 2410;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
err = 1;
|
err = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!channelUsed || nCruising || err) {
|
if (!channelUsed || nCruising || err) {
|
||||||
|
@ -1594,15 +1572,13 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle
|
||||||
} else {
|
} else {
|
||||||
tmp -= 1000;
|
tmp -= 1000;
|
||||||
if (CTimer::GetTimeInMilliseconds() - curTime > tmp) {
|
if (CTimer::GetTimeInMilliseconds() - curTime > tmp) {
|
||||||
channelUsed = 0;
|
channelUsed = false;
|
||||||
curTime = CTimer::GetTimeInMilliseconds();
|
curTime = CTimer::GetTimeInMilliseconds();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//349-366
|
|
||||||
relativeVelocityChange = 2.0 * params->m_fVelocityChange / params->m_pTransmission->fMaxVelocity;
|
relativeVelocityChange = 2.0 * params->m_fVelocityChange / params->m_pTransmission->fMaxVelocity;
|
||||||
accelerationMultipler = clamp(relativeVelocityChange, 0.0, 1.0);
|
accelerationMultipler = clamp(relativeVelocityChange, 0.0, 1.0);
|
||||||
gasPedalAudio = accelerationMultipler;
|
gasPedalAudio = accelerationMultipler;
|
||||||
//367-380
|
|
||||||
switch (engineSoundType) {
|
switch (engineSoundType) {
|
||||||
case 21:
|
case 21:
|
||||||
++soundOffset;
|
++soundOffset;
|
||||||
|
@ -1616,7 +1592,6 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//381-476
|
|
||||||
if (accelerateState <= 0) {
|
if (accelerateState <= 0) {
|
||||||
if (params->m_fVelocityChange < -0.001f) {
|
if (params->m_fVelocityChange < -0.001f) {
|
||||||
if (channelUsed) {
|
if (channelUsed) {
|
||||||
|
@ -1640,11 +1615,12 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle
|
||||||
|| params->m_pVehicle->bIsHandbrakeOn
|
|| params->m_pVehicle->bIsHandbrakeOn
|
||||||
|| lostTraction
|
|| lostTraction
|
||||||
|| params->m_fVelocityChange < 0.01f && *gasPedalAudioPtr > 0.2f) {
|
|| params->m_fVelocityChange < 0.01f && *gasPedalAudioPtr > 0.2f) {
|
||||||
if (!PizzaFaggBool) {
|
if (PizzaFaggBool) {
|
||||||
|
gasPedalAudio = 0.0f;
|
||||||
|
} else {
|
||||||
*gasPedalAudioPtr *= 0.6f;
|
*gasPedalAudioPtr *= 0.6f;
|
||||||
gasPedalAudio = *gasPedalAudioPtr;
|
gasPedalAudio = *gasPedalAudioPtr;
|
||||||
} else
|
}
|
||||||
gasPedalAudio = 0.0f;
|
|
||||||
}
|
}
|
||||||
if (gasPedalAudio > 0.05f) {
|
if (gasPedalAudio > 0.05f) {
|
||||||
freq = (5000.f * (gasPedalAudio - 0.05f) * 20.f / 19) + 19000;
|
freq = (5000.f * (gasPedalAudio - 0.05f) * 20.f / 19) + 19000;
|
||||||
|
@ -1666,7 +1642,6 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle
|
||||||
|
|
||||||
CurrentPretendGear = Max(1, currentGear);
|
CurrentPretendGear = Max(1, currentGear);
|
||||||
}
|
}
|
||||||
//477-515
|
|
||||||
else {
|
else {
|
||||||
if (nCruising == 0){
|
if (nCruising == 0){
|
||||||
stuckInSand = params->m_VehicleType == VEHICLE_TYPE_CAR && ((CAutomobile*)params->m_pVehicle)->bStuckInSand;
|
stuckInSand = params->m_VehicleType == VEHICLE_TYPE_CAR && ((CAutomobile*)params->m_pVehicle)->bStuckInSand;
|
||||||
|
@ -1689,7 +1664,6 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle
|
||||||
baseFreq = (15000.0f * *gasPedalAudioPtr) + 14000;
|
baseFreq = (15000.0f * *gasPedalAudioPtr) + 14000;
|
||||||
vol = (25.0f * *gasPedalAudioPtr) + 60;
|
vol = (25.0f * *gasPedalAudioPtr) + 60;
|
||||||
}
|
}
|
||||||
//516-535
|
|
||||||
freq = freqModifier + baseFreq;
|
freq = freqModifier + baseFreq;
|
||||||
if (engineSoundType == SAMPLEBANK_CAR_COBRA)
|
if (engineSoundType == SAMPLEBANK_CAR_COBRA)
|
||||||
freq /= 2;
|
freq /= 2;
|
||||||
|
@ -1701,7 +1675,6 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle
|
||||||
vol /= 4;
|
vol /= 4;
|
||||||
AddPlayerCarSample(vol, freq, engineSoundType + SFX_CAR_REV_1 - 4, SAMPLEBANK_MAIN, 2, true);
|
AddPlayerCarSample(vol, freq, engineSoundType + SFX_CAR_REV_1 - 4, SAMPLEBANK_MAIN, 2, true);
|
||||||
} else {
|
} else {
|
||||||
//536-548
|
|
||||||
cAudioManager::TranslateEntity(&m_sQueueSample.m_vecPos, &pos);
|
cAudioManager::TranslateEntity(&m_sQueueSample.m_vecPos, &pos);
|
||||||
if (bAccelSampleStopped) {
|
if (bAccelSampleStopped) {
|
||||||
if (CurrentPretendGear != 1 || currentGear != 2)
|
if (CurrentPretendGear != 1 || currentGear != 2)
|
||||||
|
@ -1709,7 +1682,6 @@ void cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams* params, CVehicle
|
||||||
processedAccelSampleStopped = true;
|
processedAccelSampleStopped = true;
|
||||||
bAccelSampleStopped = false;
|
bAccelSampleStopped = false;
|
||||||
}
|
}
|
||||||
//549-
|
|
||||||
if (channelUsed) {
|
if (channelUsed) {
|
||||||
SampleManager.SetChannelEmittingVolume(m_nActiveSamples, 120);
|
SampleManager.SetChannelEmittingVolume(m_nActiveSamples, 120);
|
||||||
SampleManager.SetChannel3DPosition(m_nActiveSamples, pos.x, pos.y, pos.z);
|
SampleManager.SetChannel3DPosition(m_nActiveSamples, pos.x, pos.y, pos.z);
|
||||||
|
|
Loading…
Reference in a new issue