mirror of
https://github.com/GTAmodding/re3.git
synced 2024-12-01 17:45:41 +00:00
Fix acceleration sound playing when exiting the vehicle, code fixes in ProcessPlayersVehicleEngine
This commit is contained in:
parent
296e7ed9ad
commit
2120d4d3ce
1 changed files with 41 additions and 78 deletions
|
@ -298,6 +298,7 @@ void
|
||||||
cAudioManager::ProcessSpecial()
|
cAudioManager::ProcessSpecial()
|
||||||
{
|
{
|
||||||
CPlayerPed *playerPed;
|
CPlayerPed *playerPed;
|
||||||
|
CVehicle *remoteVehicle;
|
||||||
|
|
||||||
if (m_nUserPause) {
|
if (m_nUserPause) {
|
||||||
if (!m_nPreviousUserPause) {
|
if (!m_nPreviousUserPause) {
|
||||||
|
@ -307,16 +308,15 @@ cAudioManager::ProcessSpecial()
|
||||||
} else {
|
} else {
|
||||||
if (!CReplay::IsPlayingBack())
|
if (!CReplay::IsPlayingBack())
|
||||||
ProcessPlayerMood();
|
ProcessPlayerMood();
|
||||||
|
remoteVehicle = CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle;
|
||||||
playerPed = FindPlayerPed();
|
playerPed = FindPlayerPed();
|
||||||
if (playerPed != nil) {
|
if (playerPed) {
|
||||||
if (playerPed->m_audioEntityId >= 0 && m_asAudioEntities[playerPed->m_audioEntityId].m_bIsUsed) {
|
if (playerPed->m_audioEntityId >= 0 && m_asAudioEntities[playerPed->m_audioEntityId].m_bIsUsed) {
|
||||||
if (playerPed->EnteringCar()) {
|
if(!playerPed->EnteringCar() && !playerPed->bInVehicle && !remoteVehicle)
|
||||||
if(!playerPed->bInVehicle && CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle == nil)
|
|
||||||
SampleManager.StopChannel(CHANNEL_PLAYER_VEHICLE_ENGINE);
|
SampleManager.StopChannel(CHANNEL_PLAYER_VEHICLE_ENGINE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1522,9 +1522,6 @@ cAudioManager::ProcessVehicleRoadNoise(cVehicleParams& params)
|
||||||
float velocity;
|
float velocity;
|
||||||
uint8 wheelsOnGround;
|
uint8 wheelsOnGround;
|
||||||
|
|
||||||
if (params.m_fDistance >= SQR(SOUND_INTENSITY))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
if (params.m_fDistance >= SQR(SOUND_INTENSITY))
|
if (params.m_fDistance >= SQR(SOUND_INTENSITY))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
switch (params.m_VehicleType) {
|
switch (params.m_VehicleType) {
|
||||||
|
@ -1980,8 +1977,8 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CVehicle* veh
|
||||||
CVector pos;
|
CVector pos;
|
||||||
float* gasPedalAudioPtr;
|
float* gasPedalAudioPtr;
|
||||||
|
|
||||||
int32 accelerateState;
|
int16 accelerateState;
|
||||||
int32 brakeState;
|
int16 brakeState;
|
||||||
int32 freq;
|
int32 freq;
|
||||||
int32 baseFreq;
|
int32 baseFreq;
|
||||||
int32 freqModifier;
|
int32 freqModifier;
|
||||||
|
@ -2015,7 +2012,7 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CVehicle* veh
|
||||||
static bool8 bAccelSampleStopped = TRUE;
|
static bool8 bAccelSampleStopped = TRUE;
|
||||||
|
|
||||||
lostTraction = FALSE;
|
lostTraction = FALSE;
|
||||||
isMoped = params.m_pVehicle->m_modelIndex == MI_PIZZABOY || params.m_pVehicle->m_modelIndex == MI_FAGGIO;
|
isMoped = FALSE;
|
||||||
processedAccelSampleStopped = FALSE;
|
processedAccelSampleStopped = FALSE;
|
||||||
if (bPlayerJustEnteredCar) {
|
if (bPlayerJustEnteredCar) {
|
||||||
bAccelSampleStopped = TRUE;
|
bAccelSampleStopped = TRUE;
|
||||||
|
@ -2034,7 +2031,7 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CVehicle* veh
|
||||||
brakeState = Pads[0].GetBrake();
|
brakeState = Pads[0].GetBrake();
|
||||||
}
|
}
|
||||||
channelUsed = SampleManager.GetChannelUsedFlag(CHANNEL_PLAYER_VEHICLE_ENGINE);
|
channelUsed = SampleManager.GetChannelUsedFlag(CHANNEL_PLAYER_VEHICLE_ENGINE);
|
||||||
if (isMoped) {
|
if (params.m_pVehicle->m_modelIndex == MI_PIZZABOY || params.m_pVehicle->m_modelIndex == MI_FAGGIO) {
|
||||||
CurrentPretendGear = params.m_pTransmission->nNumberOfGears;
|
CurrentPretendGear = params.m_pTransmission->nNumberOfGears;
|
||||||
currentGear = CurrentPretendGear;
|
currentGear = CurrentPretendGear;
|
||||||
if (params.m_pVehicle->bIsHandbrakeOn) {
|
if (params.m_pVehicle->bIsHandbrakeOn) {
|
||||||
|
@ -2045,6 +2042,7 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CVehicle* veh
|
||||||
} else {
|
} else {
|
||||||
nCruising = 1;
|
nCruising = 1;
|
||||||
}
|
}
|
||||||
|
isMoped = TRUE;
|
||||||
} else {
|
} else {
|
||||||
currentGear = params.m_pVehicle->m_nCurrentGear;
|
currentGear = params.m_pVehicle->m_nCurrentGear;
|
||||||
}
|
}
|
||||||
|
@ -2225,8 +2223,8 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CVehicle* veh
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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;
|
||||||
vol = (25.0f * (gasPedalAudio - 0.05f) * 20.f / 19) + 40;
|
vol = (25.0f * ((gasPedalAudio - 0.05f) * 20.f / 19)) + 40;
|
||||||
if (params.m_pVehicle->bIsDrowning)
|
if (params.m_pVehicle->bIsDrowning)
|
||||||
vol /= 4;
|
vol /= 4;
|
||||||
if (engineSoundType == SFX_BANK_TRUCK)
|
if (engineSoundType == SFX_BANK_TRUCK)
|
||||||
|
@ -2287,7 +2285,25 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CVehicle* veh
|
||||||
processedAccelSampleStopped = TRUE;
|
processedAccelSampleStopped = TRUE;
|
||||||
bAccelSampleStopped = FALSE;
|
bAccelSampleStopped = FALSE;
|
||||||
}
|
}
|
||||||
if (channelUsed) {
|
if (!channelUsed) {
|
||||||
|
if (!processedAccelSampleStopped) {
|
||||||
|
if (CurrentPretendGear < params.m_pTransmission->nNumberOfGears - 1)
|
||||||
|
++CurrentPretendGear;
|
||||||
|
else {
|
||||||
|
nCruising = 1;
|
||||||
|
params.m_pVehicle->bAudioChangingGear = TRUE;
|
||||||
|
//break; // while was used just for this fucking place
|
||||||
|
goto PlayCruising;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
gearSoundStartTime = CTimer::GetTimeInMilliseconds();
|
||||||
|
params.m_pVehicle->bAudioChangingGear = TRUE;
|
||||||
|
if (!SampleManager.InitialiseChannel(CHANNEL_PLAYER_VEHICLE_ENGINE, soundOffset + SFX_CAR_ACCEL_1, SFX_BANK_0))
|
||||||
|
return;
|
||||||
|
SampleManager.SetChannelLoopCount(CHANNEL_PLAYER_VEHICLE_ENGINE, 1);
|
||||||
|
SampleManager.SetChannelLoopPoints(CHANNEL_PLAYER_VEHICLE_ENGINE, 0, -1);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef EXTERNAL_3D_SOUND
|
#ifdef EXTERNAL_3D_SOUND
|
||||||
SampleManager.SetChannelEmittingVolume(CHANNEL_PLAYER_VEHICLE_ENGINE, 120);
|
SampleManager.SetChannelEmittingVolume(CHANNEL_PLAYER_VEHICLE_ENGINE, 120);
|
||||||
SampleManager.SetChannel3DPosition(CHANNEL_PLAYER_VEHICLE_ENGINE, pos.x, pos.y, pos.z);
|
SampleManager.SetChannel3DPosition(CHANNEL_PLAYER_VEHICLE_ENGINE, pos.x, pos.y, pos.z);
|
||||||
|
@ -2304,66 +2320,15 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CVehicle* veh
|
||||||
SampleManager.SetChannelReverbFlag(CHANNEL_PLAYER_VEHICLE_ENGINE, m_bDynamicAcousticModelingStatus != FALSE);
|
SampleManager.SetChannelReverbFlag(CHANNEL_PLAYER_VEHICLE_ENGINE, m_bDynamicAcousticModelingStatus != FALSE);
|
||||||
SampleManager.StartChannel(CHANNEL_PLAYER_VEHICLE_ENGINE);
|
SampleManager.StartChannel(CHANNEL_PLAYER_VEHICLE_ENGINE);
|
||||||
}
|
}
|
||||||
} else if (processedAccelSampleStopped) {
|
|
||||||
gearSoundStartTime = CTimer::GetTimeInMilliseconds();
|
|
||||||
params.m_pVehicle->bAudioChangingGear = TRUE;
|
|
||||||
if (!SampleManager.InitialiseChannel(CHANNEL_PLAYER_VEHICLE_ENGINE, soundOffset + SFX_CAR_ACCEL_1, SFX_BANK_0))
|
|
||||||
return;
|
|
||||||
SampleManager.SetChannelLoopCount(CHANNEL_PLAYER_VEHICLE_ENGINE, 1);
|
|
||||||
SampleManager.SetChannelLoopPoints(CHANNEL_PLAYER_VEHICLE_ENGINE, 0, -1);
|
|
||||||
|
|
||||||
#ifdef EXTERNAL_3D_SOUND
|
|
||||||
SampleManager.SetChannelEmittingVolume(CHANNEL_PLAYER_VEHICLE_ENGINE, 120);
|
|
||||||
SampleManager.SetChannel3DPosition(CHANNEL_PLAYER_VEHICLE_ENGINE, pos.x, pos.y, pos.z);
|
|
||||||
SampleManager.SetChannel3DDistances(CHANNEL_PLAYER_VEHICLE_ENGINE, 50.0f, 50.0f * 0.25f);
|
|
||||||
#else
|
|
||||||
SampleManager.SetChannelVolume(CHANNEL_PLAYER_VEHICLE_ENGINE, ComputeVolume(120, 50.0f, m_sQueueSample.m_fDistance));
|
|
||||||
SampleManager.SetChannelPan(CHANNEL_PLAYER_VEHICLE_ENGINE, m_sQueueSample.m_nOffset);
|
|
||||||
#endif
|
|
||||||
freq = (GearFreqAdj[CurrentPretendGear] + freqModifier + 22050);
|
|
||||||
if (engineSoundType == SFX_BANK_TRUCK)
|
|
||||||
freq /= 2;
|
|
||||||
SampleManager.SetChannelFrequency(CHANNEL_PLAYER_VEHICLE_ENGINE, freq);
|
|
||||||
if (!channelUsed) {
|
|
||||||
SampleManager.SetChannelReverbFlag(CHANNEL_PLAYER_VEHICLE_ENGINE, m_bDynamicAcousticModelingStatus != FALSE);
|
|
||||||
SampleManager.StartChannel(CHANNEL_PLAYER_VEHICLE_ENGINE);
|
|
||||||
}
|
|
||||||
} else if (CurrentPretendGear < params.m_pTransmission->nNumberOfGears - 1) {
|
|
||||||
++CurrentPretendGear;
|
|
||||||
gearSoundStartTime = CTimer::GetTimeInMilliseconds();
|
|
||||||
params.m_pVehicle->bAudioChangingGear = TRUE;
|
|
||||||
if (!SampleManager.InitialiseChannel(CHANNEL_PLAYER_VEHICLE_ENGINE, soundOffset + SFX_CAR_ACCEL_1, SFX_BANK_0))
|
|
||||||
return;
|
|
||||||
SampleManager.SetChannelLoopCount(CHANNEL_PLAYER_VEHICLE_ENGINE, 1);
|
|
||||||
SampleManager.SetChannelLoopPoints(CHANNEL_PLAYER_VEHICLE_ENGINE, 0, -1);
|
|
||||||
|
|
||||||
#ifdef EXTERNAL_3D_SOUND
|
|
||||||
SampleManager.SetChannelEmittingVolume(CHANNEL_PLAYER_VEHICLE_ENGINE, 120);
|
|
||||||
SampleManager.SetChannel3DPosition(CHANNEL_PLAYER_VEHICLE_ENGINE, pos.x, pos.y, pos.z);
|
|
||||||
SampleManager.SetChannel3DDistances(CHANNEL_PLAYER_VEHICLE_ENGINE, 50.0f, 50.0f * 0.25f);
|
|
||||||
#else
|
|
||||||
SampleManager.SetChannelVolume(CHANNEL_PLAYER_VEHICLE_ENGINE, ComputeVolume(120, 50.0f, m_sQueueSample.m_fDistance));
|
|
||||||
SampleManager.SetChannelPan(CHANNEL_PLAYER_VEHICLE_ENGINE, m_sQueueSample.m_nOffset);
|
|
||||||
#endif
|
|
||||||
freq = (GearFreqAdj[CurrentPretendGear] + freqModifier + 22050);
|
|
||||||
if (engineSoundType == SFX_BANK_TRUCK)
|
|
||||||
freq /= 2;
|
|
||||||
SampleManager.SetChannelFrequency(CHANNEL_PLAYER_VEHICLE_ENGINE, freq);
|
|
||||||
if (!channelUsed) {
|
|
||||||
SampleManager.SetChannelReverbFlag(CHANNEL_PLAYER_VEHICLE_ENGINE, m_bDynamicAcousticModelingStatus != FALSE);
|
|
||||||
SampleManager.StartChannel(CHANNEL_PLAYER_VEHICLE_ENGINE);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
nCruising = 1;
|
|
||||||
goto PlayCruising;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
PlayCruising:
|
PlayCruising:
|
||||||
bAccelSampleStopped = TRUE;
|
bAccelSampleStopped = TRUE;
|
||||||
SampleManager.StopChannel(CHANNEL_PLAYER_VEHICLE_ENGINE);
|
SampleManager.StopChannel(CHANNEL_PLAYER_VEHICLE_ENGINE);
|
||||||
if (isMoped || accelerateState >= 150 && wheelsOnGround && brakeState <= 0 && !params.m_pVehicle->bIsHandbrakeOn
|
if (!isMoped && (accelerateState < 150 || wheelsOnGround == 0 || brakeState > 0 || params.m_pVehicle->bIsHandbrakeOn
|
||||||
&& !lostTraction && currentGear >= params.m_pTransmission->nNumberOfGears - 1) {
|
|| lostTraction || currentGear < params.m_pTransmission->nNumberOfGears - 1)) {
|
||||||
|
nCruising = 0;
|
||||||
|
} else {
|
||||||
if (accelerateState >= 220 && params.m_fVelocityChange + 0.001f >= velocityChangeForAudio) {
|
if (accelerateState >= 220 && params.m_fVelocityChange + 0.001f >= velocityChangeForAudio) {
|
||||||
if (nCruising < 800)
|
if (nCruising < 800)
|
||||||
++nCruising;
|
++nCruising;
|
||||||
|
@ -2374,15 +2339,13 @@ PlayCruising:
|
||||||
if (engineSoundType == SFX_BANK_TRUCK)
|
if (engineSoundType == SFX_BANK_TRUCK)
|
||||||
freq /= 2;
|
freq /= 2;
|
||||||
AddPlayerCarSample(120, freq, soundOffset + SFX_CAR_AFTER_ACCEL_1, engineSoundType, 64, TRUE);
|
AddPlayerCarSample(120, freq, soundOffset + SFX_CAR_AFTER_ACCEL_1, engineSoundType, 64, TRUE);
|
||||||
} else {
|
|
||||||
nCruising = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LastAccel = accelerateState;
|
LastAccel = accelerateState;
|
||||||
|
|
||||||
bHandbrakeOnLastFrame = params.m_pVehicle->bIsHandbrakeOn;
|
bHandbrakeOnLastFrame = params.m_pVehicle->bIsHandbrakeOn;
|
||||||
bLostTractionLastFrame = lostTraction;
|
bLostTractionLastFrame = lostTraction;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool8
|
bool8
|
||||||
|
|
Loading…
Reference in a new issue