mirror of
https://github.com/GTAmodding/re3.git
synced 2024-12-27 22:05:47 +00:00
Audio: refactoring, type fixes, renaming cAudioManager fields
This commit is contained in:
parent
d4a2113a8a
commit
c8492ab5e0
8 changed files with 189 additions and 192 deletions
|
@ -18,7 +18,7 @@ cAudioManager::ReportCollision(CEntity *entity1, CEntity *entity2, uint8 surface
|
|||
CVector v1;
|
||||
CVector v2;
|
||||
|
||||
if(!m_bIsInitialised || m_nCollisionEntity < 0 || m_nUserPause ||
|
||||
if(!m_bIsInitialised || m_nCollisionEntity < 0 || m_bIsPaused ||
|
||||
(velocity < 0.0016f && collisionPower < 0.01f))
|
||||
return;
|
||||
|
||||
|
|
|
@ -229,9 +229,9 @@ cAudioManager::PostTerminateGameSpecificShutdown()
|
|||
void
|
||||
cAudioManager::ResetAudioLogicTimers(uint32 timer)
|
||||
{
|
||||
for (int32 i = 0; i < m_nAudioEntitiesTotal; i++) {
|
||||
if (m_asAudioEntities[m_anAudioEntityIndices[i]].m_nType == AUDIOTYPE_PHYSICAL) {
|
||||
CPed *ped = (CPed *)m_asAudioEntities[m_anAudioEntityIndices[i]].m_pEntity;
|
||||
for (uint32 i = 0; i < m_nAudioEntitiesCount; i++) {
|
||||
if (m_asAudioEntities[m_aAudioEntityOrderList[i]].m_nType == AUDIOTYPE_PHYSICAL) {
|
||||
CPed *ped = (CPed *)m_asAudioEntities[m_aAudioEntityOrderList[i]].m_pEntity;
|
||||
if (ped->IsPed()) {
|
||||
ped->m_lastSoundStart = timer;
|
||||
ped->m_soundStart = timer + m_anRandomTable[0] % 3000;
|
||||
|
@ -299,8 +299,8 @@ cAudioManager::ProcessSpecial()
|
|||
CPlayerPed *playerPed;
|
||||
CVehicle *remoteVehicle;
|
||||
|
||||
if (m_nUserPause) {
|
||||
if (!m_nPreviousUserPause) {
|
||||
if (m_bIsPaused) {
|
||||
if (!m_bWasPaused) {
|
||||
SampleManager.SetEffectsFadeVolume(MAX_VOLUME);
|
||||
SampleManager.SetMusicFadeVolume(MAX_VOLUME);
|
||||
}
|
||||
|
@ -325,45 +325,45 @@ cAudioManager::ProcessEntity(int32 id)
|
|||
m_sQueueSample.m_nEntityIndex = id;
|
||||
switch (m_asAudioEntities[id].m_nType) {
|
||||
case AUDIOTYPE_PHYSICAL:
|
||||
if (!m_nUserPause) {
|
||||
if (!m_bIsPaused) {
|
||||
SET_SOUND_REVERB(TRUE);
|
||||
ProcessPhysical(id);
|
||||
}
|
||||
break;
|
||||
case AUDIOTYPE_EXPLOSION:
|
||||
if (!m_nUserPause) {
|
||||
if (!m_bIsPaused) {
|
||||
SET_SOUND_REVERB(TRUE);
|
||||
ProcessExplosions(id);
|
||||
}
|
||||
break;
|
||||
case AUDIOTYPE_FIRE:
|
||||
if (!m_nUserPause) {
|
||||
if (!m_bIsPaused) {
|
||||
SET_SOUND_REVERB(TRUE);
|
||||
ProcessFires(id);
|
||||
}
|
||||
break;
|
||||
case AUDIOTYPE_WEATHER:
|
||||
if (!m_nUserPause) {
|
||||
if (!m_bIsPaused) {
|
||||
SET_SOUND_REVERB(TRUE);
|
||||
if(CGame::currArea == AREA_MAIN_MAP || CGame::currArea == AREA_EVERYWHERE)
|
||||
ProcessWeather(id);
|
||||
}
|
||||
break;
|
||||
/* case AUDIOTYPE_CRANE:
|
||||
if (!m_nUserPause) {
|
||||
if (!m_bIsPaused) {
|
||||
SET_SOUND_REVERB(TRUE);
|
||||
ProcessCrane();
|
||||
}
|
||||
break;*/
|
||||
case AUDIOTYPE_SCRIPTOBJECT:
|
||||
if (!m_nUserPause) {
|
||||
if (!m_bIsPaused) {
|
||||
SET_SOUND_REVERB(TRUE);
|
||||
ProcessScriptObject(id);
|
||||
}
|
||||
break;
|
||||
#ifdef GTA_BRIDGE
|
||||
case AUDIOTYPE_BRIDGE:
|
||||
if (!m_nUserPause) {
|
||||
if (!m_bIsPaused) {
|
||||
SET_SOUND_REVERB(TRUE);
|
||||
ProcessBridge();
|
||||
}
|
||||
|
@ -374,35 +374,35 @@ cAudioManager::ProcessEntity(int32 id)
|
|||
ProcessFrontEnd();
|
||||
break;
|
||||
case AUDIOTYPE_PROJECTILE:
|
||||
if (!m_nUserPause) {
|
||||
if (!m_bIsPaused) {
|
||||
SET_SOUND_REVERB(TRUE);
|
||||
ProcessProjectiles();
|
||||
}
|
||||
break;
|
||||
case AUDIOTYPE_GARAGE:
|
||||
if (!m_nUserPause)
|
||||
if (!m_bIsPaused)
|
||||
ProcessGarages();
|
||||
break;
|
||||
case AUDIOTYPE_FIREHYDRANT:
|
||||
if (!m_nUserPause) {
|
||||
if (!m_bIsPaused) {
|
||||
SET_SOUND_REVERB(TRUE);
|
||||
ProcessFireHydrant();
|
||||
}
|
||||
break;
|
||||
case AUDIOTYPE_WATERCANNON:
|
||||
if (!m_nUserPause) {
|
||||
if (!m_bIsPaused) {
|
||||
SET_SOUND_REVERB(TRUE);
|
||||
ProcessWaterCannon(id);
|
||||
}
|
||||
break;
|
||||
case AUDIOTYPE_ESCALATOR:
|
||||
if (!m_nUserPause) {
|
||||
if (!m_bIsPaused) {
|
||||
SET_SOUND_REVERB(TRUE);
|
||||
ProcessEscalators();
|
||||
}
|
||||
break;
|
||||
case AUDIOTYPE_EXTRA_SOUNDS:
|
||||
if (!m_nUserPause) {
|
||||
if (!m_bIsPaused) {
|
||||
SET_SOUND_REVERB(TRUE);
|
||||
ProcessExtraSounds();
|
||||
}
|
||||
|
@ -683,7 +683,7 @@ const tVehicleSampleData aVehicleSettings[MAX_CARS] = {
|
|||
|
||||
bool8 bPlayerJustEnteredCar;
|
||||
|
||||
const bool8 hornPatternsArray[8][44] = {
|
||||
const bool8 HornPattern[8][44] = {
|
||||
{FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE,
|
||||
FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE},
|
||||
{FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
|
||||
|
@ -1717,11 +1717,11 @@ cAudioManager::ProcessVehicleEngine(cVehicleParams& params)
|
|||
switch (transmission->nDriveType) {
|
||||
case '4':
|
||||
if (params.m_VehicleType == VEHICLE_TYPE_BIKE) {
|
||||
for (int i = 0; i < 2; i++)
|
||||
for (uint8 i = 0; i < 2; i++)
|
||||
if (wheelState[i] == WHEEL_STATE_SPINNING)
|
||||
traction += 0.1f;
|
||||
} else {
|
||||
for (int i = 0; i < 4; i++)
|
||||
for (uint8 i = 0; i < 4; i++)
|
||||
if (wheelState[i] == WHEEL_STATE_SPINNING)
|
||||
traction += 0.05f;
|
||||
}
|
||||
|
@ -2004,7 +2004,7 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CVehicle* veh
|
|||
static uint8 CurrentPretendGear = 1;
|
||||
static bool8 bLostTractionLastFrame = FALSE;
|
||||
static bool8 bHandbrakeOnLastFrame = FALSE;
|
||||
static int32 nCruising = 0;
|
||||
static uint32 nCruising = 0;
|
||||
static bool8 bAccelSampleStopped = TRUE;
|
||||
|
||||
bool8 lostTraction = FALSE;
|
||||
|
@ -2078,7 +2078,7 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CVehicle* veh
|
|||
wheelInUseCounter = 0;
|
||||
for (uint8 i = 0; i < 4; i++) {
|
||||
if (wheelState[i] != WHEEL_STATE_NORMAL)
|
||||
++wheelInUseCounter;
|
||||
wheelInUseCounter++;
|
||||
}
|
||||
if (wheelInUseCounter > 2)
|
||||
lostTraction = TRUE;
|
||||
|
@ -2184,7 +2184,7 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CVehicle* veh
|
|||
gasPedalAudio = accelerationMultipler;
|
||||
switch (engineSoundType) {
|
||||
case SFX_BANK_MOPED:
|
||||
++soundOffset;
|
||||
soundOffset++;
|
||||
break;
|
||||
case SFX_BANK_HONDA250:
|
||||
soundOffset += 2;
|
||||
|
@ -2244,38 +2244,54 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CVehicle* veh
|
|||
AddPlayerCarSample(vol, freq, engineSoundType - CAR_SFX_BANKS_OFFSET + SFX_CAR_IDLE_1, SFX_BANK_0, 52, TRUE);
|
||||
|
||||
CurrentPretendGear = Max(1, currentGear);
|
||||
}
|
||||
else {
|
||||
if (nCruising == 0){
|
||||
} else {
|
||||
if (nCruising > 0) {
|
||||
PlayCruising:
|
||||
bAccelSampleStopped = TRUE;
|
||||
SampleManager.StopChannel(nChannel);
|
||||
if (!isMoped && (accelerateState < 150 || wheelsOnGround == 0 || brakeState > 0 || params.m_pVehicle->bIsHandbrakeOn
|
||||
|| lostTraction || currentGear < params.m_pTransmission->nNumberOfGears - 1)) {
|
||||
nCruising = 0;
|
||||
} else {
|
||||
if (accelerateState >= 220 && params.m_fVelocityChange + 0.001f >= velocityChangeForAudio) {
|
||||
if (nCruising < 800)
|
||||
nCruising++;
|
||||
} else if (nCruising > 3)
|
||||
nCruising--;
|
||||
freq = 27 * nCruising + freqModifier + 22050;
|
||||
if (engineSoundType == SFX_BANK_TRUCK)
|
||||
freq >>= 1;
|
||||
AddPlayerCarSample(120, freq, soundOffset + SFX_CAR_AFTER_ACCEL_1, engineSoundType, 64, TRUE);
|
||||
}
|
||||
} else {
|
||||
stuckInSand = params.m_VehicleType == VEHICLE_TYPE_CAR && ((CAutomobile*)params.m_pVehicle)->bStuckInSand;
|
||||
if (accelerateState < 150 || wheelsOnGround == 0 || params.m_pVehicle->bIsHandbrakeOn || lostTraction
|
||||
|| (currentGear < 2 && params.m_fVelocityChange - velocityChangeForAudio < 0.01f) || brakeState > 0) {
|
||||
|
||||
if (((wheelsOnGround && !params.m_pVehicle->bIsHandbrakeOn && !lostTraction ) || stuckInSand) && brakeState <= 0) {
|
||||
baseFreq = (8000.0f * accelerationMultipler) + 16000;
|
||||
vol = (25.0f * accelerationMultipler) + 60;
|
||||
*gasPedalAudioPtr = accelerationMultipler;
|
||||
} else {
|
||||
if (((wheelsOnGround == 0 || params.m_pVehicle->bIsHandbrakeOn || lostTraction) && !stuckInSand) || brakeState > 0) {
|
||||
if (wheelsOnGround == 0 && wheelsOnGroundPrev != 0 || (params.m_pVehicle->bIsHandbrakeOn && !bHandbrakeOnLastFrame || lostTraction && !bLostTractionLastFrame)
|
||||
&& wheelsOnGround != 0) {
|
||||
*gasPedalAudioPtr *= 0.6f;
|
||||
}
|
||||
freqModifier = 0;
|
||||
if (engineSoundType != SFX_BANK_GOLF_CART && engineSoundType != SFX_BANK_CAR_CHAINSAW)
|
||||
baseFreq = (25000.0f * *gasPedalAudioPtr) + 14000;
|
||||
if (engineSoundType == SFX_BANK_GOLF_CART || engineSoundType == SFX_BANK_CAR_CHAINSAW)
|
||||
baseFreq = (15000 * *gasPedalAudioPtr) + 14000;
|
||||
else
|
||||
baseFreq = (15000.0f * *gasPedalAudioPtr) + 14000;
|
||||
baseFreq = (25000 * *gasPedalAudioPtr) + 14000;
|
||||
vol = (25.0f * *gasPedalAudioPtr) + 60;
|
||||
} else {
|
||||
baseFreq = (8000 * accelerationMultipler) + 16000;
|
||||
vol = (25.0f * accelerationMultipler) + 60;
|
||||
*gasPedalAudioPtr = accelerationMultipler;
|
||||
}
|
||||
freq = freqModifier + baseFreq;
|
||||
if (engineSoundType == SFX_BANK_TRUCK)
|
||||
freq /= 2;
|
||||
freq >>= 1;
|
||||
if (channelUsed) {
|
||||
SampleManager.StopChannel(nChannel);
|
||||
bAccelSampleStopped = TRUE;
|
||||
}
|
||||
if (params.m_pVehicle->bIsDrowning)
|
||||
vol /= 4;
|
||||
vol >>= 2;
|
||||
AddPlayerCarSample(vol, freq, engineSoundType - CAR_SFX_BANKS_OFFSET + SFX_CAR_REV_1, SFX_BANK_0, 2, TRUE);
|
||||
} else {
|
||||
TranslateEntity(&m_sQueueSample.m_vecPos, &pos);
|
||||
|
@ -2288,16 +2304,18 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CVehicle* veh
|
|||
processedAccelSampleStopped = TRUE;
|
||||
bAccelSampleStopped = FALSE;
|
||||
}
|
||||
|
||||
if (!channelUsed) {
|
||||
if (!processedAccelSampleStopped) {
|
||||
if (CurrentPretendGear < params.m_pTransmission->nNumberOfGears - 1)
|
||||
++CurrentPretendGear;
|
||||
CurrentPretendGear++;
|
||||
else {
|
||||
nCruising = 1;
|
||||
params.m_pVehicle->bAudioChangingGear = TRUE;
|
||||
goto PlayCruising;
|
||||
}
|
||||
}
|
||||
|
||||
gearSoundStartTime = CTimer::GetTimeInMilliseconds();
|
||||
params.m_pVehicle->bAudioChangingGear = TRUE;
|
||||
#ifdef GTA_PS2
|
||||
|
@ -2322,7 +2340,7 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CVehicle* veh
|
|||
#endif
|
||||
freq = GearFreqAdj[CurrentPretendGear] + freqModifier + 22050;
|
||||
if (engineSoundType == SFX_BANK_TRUCK)
|
||||
freq /= 2;
|
||||
freq >>= 1;
|
||||
#ifdef USE_TIME_SCALE_FOR_AUDIO
|
||||
SampleManager.SetChannelFrequency(nChannel, freq * CTimer::GetTimeScale());
|
||||
#else
|
||||
|
@ -2335,30 +2353,11 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CVehicle* veh
|
|||
SampleManager.StartChannel(nChannel);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
PlayCruising:
|
||||
bAccelSampleStopped = TRUE;
|
||||
SampleManager.StopChannel(nChannel);
|
||||
if (!isMoped && (accelerateState < 150 || wheelsOnGround == 0 || brakeState > 0 || params.m_pVehicle->bIsHandbrakeOn
|
||||
|| lostTraction || currentGear < params.m_pTransmission->nNumberOfGears - 1)) {
|
||||
nCruising = 0;
|
||||
} else {
|
||||
if (accelerateState >= 220 && params.m_fVelocityChange + 0.001f >= velocityChangeForAudio) {
|
||||
if (nCruising < 800)
|
||||
++nCruising;
|
||||
} else if (nCruising > 3) {
|
||||
--nCruising;
|
||||
}
|
||||
freq = 27 * nCruising + freqModifier + 22050;
|
||||
if (engineSoundType == SFX_BANK_TRUCK)
|
||||
freq /= 2;
|
||||
AddPlayerCarSample(120, freq, soundOffset + SFX_CAR_AFTER_ACCEL_1, engineSoundType, 64, TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
LastAccel = accelerateState;
|
||||
|
||||
bHandbrakeOnLastFrame = params.m_pVehicle->bIsHandbrakeOn;
|
||||
bHandbrakeOnLastFrame = !!params.m_pVehicle->bIsHandbrakeOn;
|
||||
bLostTractionLastFrame = lostTraction;
|
||||
}
|
||||
|
||||
|
@ -2405,7 +2404,7 @@ cAudioManager::ProcessVehicleSkidding(cVehicleParams& params)
|
|||
return TRUE;
|
||||
CalculateDistance(params.m_bDistanceCalculated, params.m_fDistance);
|
||||
|
||||
for (int32 i = 0; i < numWheels; i++) {
|
||||
for (uint8 i = 0; i < numWheels; i++) {
|
||||
if (wheelStateArr[i] == WHEEL_STATE_NORMAL)
|
||||
continue;
|
||||
transmission = params.m_pTransmission;
|
||||
|
@ -2554,7 +2553,7 @@ cAudioManager::ProcessVehicleHorn(cVehicleParams& params)
|
|||
if (veh->m_nCarHornTimer == 44)
|
||||
veh->m_nCarHornPattern = (m_FrameCounter + m_sQueueSample.m_nEntityIndex) & 7;
|
||||
|
||||
if (!hornPatternsArray[veh->m_nCarHornPattern][44 - veh->m_nCarHornTimer])
|
||||
if (!HornPattern[veh->m_nCarHornPattern][44 - veh->m_nCarHornTimer])
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -2729,7 +2728,7 @@ cAudioManager::ProcessVehicleDoors(cVehicleParams& params)
|
|||
|
||||
automobile = (CAutomobile *)params.m_pVehicle;
|
||||
CalculateDistance(params.m_bDistanceCalculated, params.m_fDistance);
|
||||
for (int32 i = 0; i < ARRAY_SIZE(automobile->Doors); i++) {
|
||||
for (uint8 i = 0; i < ARRAY_SIZE(automobile->Doors); i++) {
|
||||
if (automobile->Damage.GetDoorStatus(i) == DOOR_STATUS_SWINGING) {
|
||||
doorState = automobile->Doors[i].m_nDoorState;
|
||||
if (doorState == DOORST_OPEN || doorState == DOORST_CLOSED) {
|
||||
|
@ -3448,7 +3447,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams& params)
|
|||
m_sQueueSample.m_nPriority = 1;
|
||||
m_sQueueSample.m_fSpeedMultiplier = 0.0f;
|
||||
m_sQueueSample.m_MaxDistance = SOUND_INTENSITY;
|
||||
++CrunchOffset;
|
||||
CrunchOffset++;
|
||||
maxDist = SQR(SOUND_INTENSITY);
|
||||
emittingVol = m_anRandomTable[4] % 20 + 55;
|
||||
CrunchOffset %= 2;
|
||||
|
@ -4299,7 +4298,7 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms)
|
|||
m_sQueueSample.m_nBankIndex = SFX_BANK_0;
|
||||
m_sQueueSample.m_nCounter = iSound;
|
||||
narrowSoundRange = TRUE;
|
||||
++iSound;
|
||||
iSound++;
|
||||
m_sQueueSample.m_nPriority = 3;
|
||||
m_sQueueSample.m_fSpeedMultiplier = 0.0f;
|
||||
m_sQueueSample.m_MaxDistance = 30.0f;
|
||||
|
@ -4944,7 +4943,7 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms)
|
|||
m_sQueueSample.m_nBankIndex = SFX_BANK_0;
|
||||
m_sQueueSample.m_nCounter = iSound;
|
||||
stereo = TRUE;
|
||||
++iSound;
|
||||
iSound++;
|
||||
m_sQueueSample.m_nFrequency = m_anRandomTable[1] % 1000 + 17000;
|
||||
if (param2 == 0)
|
||||
m_sQueueSample.m_nFrequency = (3 * m_sQueueSample.m_nFrequency) / 4;
|
||||
|
@ -5079,15 +5078,14 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms)
|
|||
AddSampleToRequestedQueue();
|
||||
if (stereo) {
|
||||
m_sQueueSample.m_nPan = 127;
|
||||
++m_sQueueSample.m_nSampleIndex;
|
||||
m_sQueueSample.m_nSampleIndex++;
|
||||
if (m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_awAudioEvent[i] != SOUND_WEAPON_SHOT_FIRED ||
|
||||
weapon->m_eWeaponType != WEAPONTYPE_FLAMETHROWER) {
|
||||
m_sQueueSample.m_nCounter = iSound++;
|
||||
if (iSound > 60)
|
||||
iSound = 21;
|
||||
} else {
|
||||
++m_sQueueSample.m_nCounter;
|
||||
}
|
||||
} else
|
||||
m_sQueueSample.m_nCounter++;
|
||||
AddSampleToRequestedQueue();
|
||||
}
|
||||
}
|
||||
|
@ -7808,18 +7806,16 @@ cPedComments::Add(tPedComment *com)
|
|||
index = m_nIndexMap[m_nActiveBank][NUM_PED_COMMENTS_SLOTS - 1];
|
||||
if (m_asPedComments[m_nActiveBank][index].m_nVolume > com->m_nVolume)
|
||||
return;
|
||||
} else {
|
||||
} else
|
||||
index = m_nCommentsInBank[m_nActiveBank]++;
|
||||
}
|
||||
|
||||
m_asPedComments[m_nActiveBank][index] = *com;
|
||||
|
||||
uint32 i = 0;
|
||||
uint8 i = 0;
|
||||
if (index != 0) {
|
||||
for (i = 0; i < index; i++) {
|
||||
if (m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][i]].m_nVolume < m_asPedComments[m_nActiveBank][index].m_nVolume) {
|
||||
if (m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][i]].m_nVolume < m_asPedComments[m_nActiveBank][index].m_nVolume)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i < index)
|
||||
|
@ -7838,7 +7834,7 @@ cPedComments::Process()
|
|||
static uint8 counter = 0;
|
||||
static int32 prevSamples[10] = { NO_SAMPLE, NO_SAMPLE, NO_SAMPLE, NO_SAMPLE, NO_SAMPLE, NO_SAMPLE, NO_SAMPLE, NO_SAMPLE, NO_SAMPLE, NO_SAMPLE };
|
||||
|
||||
if(AudioManager.m_nUserPause) return;
|
||||
if(AudioManager.m_bIsPaused) return;
|
||||
|
||||
if(m_nCommentsInBank[m_nActiveBank]) {
|
||||
for(int i = 0; i < ARRAY_SIZE(prevSamples); i++) {
|
||||
|
@ -7935,7 +7931,7 @@ PedCommentAlreadyAdded:
|
|||
comment = m_asPedComments[actualUsedBank];
|
||||
for (uint32 i = 0; i < m_nCommentsInBank[actualUsedBank]; i++) {
|
||||
if (m_asPedComments[actualUsedBank][m_nIndexMap[actualUsedBank][i]].m_nProcess > 0) {
|
||||
--m_asPedComments[actualUsedBank][m_nIndexMap[actualUsedBank][i]].m_nProcess;
|
||||
m_asPedComments[actualUsedBank][m_nIndexMap[actualUsedBank][i]].m_nProcess--;
|
||||
Add(&comment[m_nIndexMap[actualUsedBank][i]]);
|
||||
}
|
||||
}
|
||||
|
@ -8124,7 +8120,7 @@ cAudioManager::ProcessWaterCannon(int32)
|
|||
{
|
||||
const float SOUND_INTENSITY = 30.0f;
|
||||
|
||||
for (int32 i = 0; i < NUM_WATERCANNONS; i++) {
|
||||
for (uint32 i = 0; i < NUM_WATERCANNONS; i++) {
|
||||
if (CWaterCannons::aCannons[i].m_nId) {
|
||||
m_sQueueSample.m_vecPos = CWaterCannons::aCannons[0].m_avecPos[CWaterCannons::aCannons[i].m_nCur];
|
||||
float distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos);
|
||||
|
@ -8949,13 +8945,13 @@ cAudioManager::ProcessFrontEnd()
|
|||
SET_SOUND_REFLECTION(FALSE);
|
||||
AddSampleToRequestedQueue();
|
||||
if (stereo) {
|
||||
++m_sQueueSample.m_nSampleIndex;
|
||||
m_sQueueSample.m_nSampleIndex++;
|
||||
m_sQueueSample.m_nCounter = iSound++;
|
||||
m_sQueueSample.m_nPan = 127 - m_sQueueSample.m_nPan;
|
||||
AddSampleToRequestedQueue();
|
||||
}
|
||||
if (center) {
|
||||
++m_sQueueSample.m_nSampleIndex;
|
||||
m_sQueueSample.m_nSampleIndex++;
|
||||
m_sQueueSample.m_nCounter = iSound++;
|
||||
m_sQueueSample.m_nPan = 63;
|
||||
m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex);
|
||||
|
@ -9020,7 +9016,7 @@ cAudioManager::ProcessProjectiles()
|
|||
uint8 emittingVol;
|
||||
float distSquared;
|
||||
|
||||
for (int32 i = 0; i < NUM_PROJECTILES; i++) {
|
||||
for (uint8 i = 0; i < NUM_PROJECTILES; i++) {
|
||||
if (CProjectileInfo::GetProjectileInfo(i)->m_bInUse) {
|
||||
switch (CProjectileInfo::GetProjectileInfo(i)->m_eWeaponType) {
|
||||
case WEAPONTYPE_TEARGAS:
|
||||
|
@ -9164,7 +9160,11 @@ cAudioManager::ProcessGarages()
|
|||
|
||||
static uint8 iSound = 32;
|
||||
|
||||
for (uint32 i = 0; i < CGarages::NumGarages; ++i) {
|
||||
#ifdef FIX_BUGS
|
||||
for (uint32 i = 0; i < CGarages::NumGarages; i++) {
|
||||
#else
|
||||
for (uint8 i = 0; i < CGarages::NumGarages; i++) {
|
||||
#endif
|
||||
if (CGarages::aGarages[i].m_eGarageType == GARAGE_NONE)
|
||||
continue;
|
||||
entity = CGarages::aGarages[i].m_pDoor1;
|
||||
|
@ -9229,7 +9229,7 @@ cAudioManager::ProcessGarages()
|
|||
break;
|
||||
}
|
||||
}
|
||||
for (j = 0; j < m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_AudioEvents; ++j) {
|
||||
for (j = 0; j < m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_AudioEvents; j++) {
|
||||
switch (m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_awAudioEvent[j]) {
|
||||
case SOUND_GARAGE_DOOR_CLOSED:
|
||||
case SOUND_GARAGE_DOOR_OPENED:
|
||||
|
@ -9813,7 +9813,7 @@ const MissionAudioData MissionAudioNameSfxAssoc[] = {
|
|||
int32
|
||||
FindMissionAudioSfx(const char *name)
|
||||
{
|
||||
for (uint32 i = 0; MissionAudioNameSfxAssoc[i].m_pName != nil; ++i) {
|
||||
for (uint32 i = 0; MissionAudioNameSfxAssoc[i].m_pName != nil; i++) {
|
||||
if (!CGeneral::faststricmp(MissionAudioNameSfxAssoc[i].m_pName, name))
|
||||
return MissionAudioNameSfxAssoc[i].m_nId;
|
||||
}
|
||||
|
@ -9825,7 +9825,7 @@ const char *
|
|||
cAudioManager::GetMissionAudioLoadedLabel(uint8 slot)
|
||||
{
|
||||
if (m_bIsInitialised && slot < MISSION_AUDIO_SLOTS && m_nMissionAudioSampleIndex[slot] != NO_SAMPLE) {
|
||||
for (uint32 i = 0; MissionAudioNameSfxAssoc[i].m_pName != nil; ++i) {
|
||||
for (uint32 i = 0; MissionAudioNameSfxAssoc[i].m_pName != nil; i++) {
|
||||
if (m_nMissionAudioSampleIndex[slot] == MissionAudioNameSfxAssoc[i].m_nId)
|
||||
return MissionAudioNameSfxAssoc[i].m_pName;
|
||||
}
|
||||
|
@ -9974,7 +9974,7 @@ cAudioManager::ProcessMissionAudioSlot(uint8 slot)
|
|||
nFramesForPretendPlaying[slot] = 0;
|
||||
nCheckPlayingDelay[slot] = 0;
|
||||
nFramesUntilFailedLoad[slot] = 0;
|
||||
} else if (!m_nUserPause) {
|
||||
} else if (!m_bIsPaused) {
|
||||
if (++nFramesForPretendPlaying[slot] < 90) {
|
||||
m_nMissionAudioPlayStatus[slot] = PLAY_STATUS_PLAYING;
|
||||
} else {
|
||||
|
@ -9989,7 +9989,7 @@ cAudioManager::ProcessMissionAudioSlot(uint8 slot)
|
|||
if (MissionScriptAudioUsesPoliceChannel(m_nMissionAudioSampleIndex[slot])) {
|
||||
SetMissionScriptPoliceAudio(m_nMissionAudioSampleIndex[slot]);
|
||||
} else {
|
||||
if (m_nUserPause)
|
||||
if (m_bIsPaused)
|
||||
SampleManager.PauseStream(TRUE, slot + 1);
|
||||
if (m_bIsMissionAudio2D[slot]) {
|
||||
if (m_nMissionAudioSampleIndex[slot] == STREAMED_SOUND_MISSION_CAMERAL)
|
||||
|
@ -10028,7 +10028,7 @@ cAudioManager::ProcessMissionAudioSlot(uint8 slot)
|
|||
break;
|
||||
}
|
||||
if (MissionScriptAudioUsesPoliceChannel(m_nMissionAudioSampleIndex[slot])) {
|
||||
if (!m_nUserPause) {
|
||||
if (!m_bIsPaused) {
|
||||
if (nCheckPlayingDelay[slot]) {
|
||||
--nCheckPlayingDelay[slot];
|
||||
} else if ((g_bMissionAudioLoadFailed[slot] && m_nMissionAudioFramesToPlay[slot]-- == 0) || GetMissionScriptPoliceAudioPlayingStatus() == PLAY_STATUS_FINISHED) {
|
||||
|
@ -10041,8 +10041,8 @@ cAudioManager::ProcessMissionAudioSlot(uint8 slot)
|
|||
}
|
||||
}
|
||||
} else if (m_bIsMissionAudioPlaying[slot]) {
|
||||
if (SampleManager.IsStreamPlaying(slot + 1) || m_nUserPause || m_nPreviousUserPause) {
|
||||
if (m_nUserPause)
|
||||
if (SampleManager.IsStreamPlaying(slot + 1) || m_bIsPaused || m_bWasPaused) {
|
||||
if (m_bIsPaused)
|
||||
SampleManager.PauseStream(TRUE, slot + 1);
|
||||
else
|
||||
{
|
||||
|
@ -10075,7 +10075,7 @@ cAudioManager::ProcessMissionAudioSlot(uint8 slot)
|
|||
m_nMissionAudioFramesToPlay[slot] = 0;
|
||||
}
|
||||
} else {
|
||||
if (m_nUserPause)
|
||||
if (m_bIsPaused)
|
||||
break;
|
||||
if (nCheckPlayingDelay[slot]--) {
|
||||
if (!SampleManager.IsStreamPlaying(slot + 1))
|
||||
|
|
|
@ -25,9 +25,9 @@ cAudioManager::cAudioManager()
|
|||
m_fSpeedOfSound = SPEED_OF_SOUND / TIME_SPENT;
|
||||
m_nTimeSpent = TIME_SPENT;
|
||||
m_nActiveSamples = NUM_CHANNELS_GENERIC;
|
||||
m_nActiveSampleQueue = 1;
|
||||
m_nActiveQueue = 1;
|
||||
ClearRequestedQueue();
|
||||
m_nActiveSampleQueue = 0;
|
||||
m_nActiveQueue = 0;
|
||||
ClearRequestedQueue();
|
||||
ClearActiveSamples();
|
||||
GenerateIntegerRandomNumberTable();
|
||||
|
@ -36,11 +36,11 @@ cAudioManager::cAudioManager()
|
|||
m_bDynamicAcousticModelingStatus = TRUE;
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < NUM_AUDIOENTITIES; i++) {
|
||||
for (uint32 i = 0; i < NUM_AUDIOENTITIES; i++) {
|
||||
m_asAudioEntities[i].m_bIsUsed = FALSE;
|
||||
m_anAudioEntityIndices[i] = NUM_AUDIOENTITIES;
|
||||
m_aAudioEntityOrderList[i] = NUM_AUDIOENTITIES;
|
||||
}
|
||||
m_nAudioEntitiesTotal = 0;
|
||||
m_nAudioEntitiesCount = 0;
|
||||
m_FrameCounter = 0;
|
||||
m_bReduceReleasingPriority = FALSE;
|
||||
m_bTimerJustReset = FALSE;
|
||||
|
@ -65,7 +65,7 @@ cAudioManager::Initialise()
|
|||
if (m_nActiveSamples <= 1) {
|
||||
Terminate();
|
||||
} else {
|
||||
--m_nActiveSamples;
|
||||
m_nActiveSamples--;
|
||||
#else
|
||||
{
|
||||
m_nActiveSamples = NUM_CHANNELS_GENERIC;
|
||||
|
@ -87,10 +87,10 @@ cAudioManager::Terminate()
|
|||
|
||||
for (uint32 i = 0; i < NUM_AUDIOENTITIES; i++) {
|
||||
m_asAudioEntities[i].m_bIsUsed = FALSE;
|
||||
m_anAudioEntityIndices[i] = ARRAY_SIZE(m_anAudioEntityIndices);
|
||||
m_aAudioEntityOrderList[i] = ARRAY_SIZE(m_aAudioEntityOrderList);
|
||||
}
|
||||
|
||||
m_nAudioEntitiesTotal = 0;
|
||||
m_nAudioEntitiesCount = 0;
|
||||
m_sAudioScriptObjectManager.m_nScriptObjectEntityTotal = 0;
|
||||
PreTerminateGameSpecificShutdown();
|
||||
|
||||
|
@ -116,8 +116,8 @@ cAudioManager::Service()
|
|||
m_bTimerJustReset = FALSE;
|
||||
}
|
||||
if (m_bIsInitialised) {
|
||||
m_nPreviousUserPause = m_nUserPause;
|
||||
m_nUserPause = CTimer::GetIsUserPaused();
|
||||
m_bWasPaused = m_bIsPaused;
|
||||
m_bIsPaused = CTimer::GetIsUserPaused();
|
||||
#ifdef AUDIO_REFLECTIONS
|
||||
UpdateReflections();
|
||||
#endif
|
||||
|
@ -139,12 +139,12 @@ cAudioManager::CreateEntity(eAudioType type, void *entity)
|
|||
#ifdef FIX_BUGS
|
||||
// since sound could still play after entity deletion let's make sure we don't override one that is in use
|
||||
// find all the free entity IDs that are being used by queued samples
|
||||
int32 stillUsedEntities[NUM_CHANNELS_GENERIC * NUM_SOUNDS_SAMPLES_BANKS];
|
||||
int32 stillUsedEntities[NUM_CHANNELS_GENERIC * NUM_SOUND_QUEUES];
|
||||
uint32 stillUsedEntitiesCount = 0;
|
||||
|
||||
for (uint8 i = 0; i < NUM_SOUNDS_SAMPLES_BANKS; i++)
|
||||
for (uint8 j = 0; j < m_SampleRequestQueuesStatus[i]; j++) {
|
||||
tSound &sound = m_asSamples[i][m_abSampleQueueIndexTable[i][j]];
|
||||
for (uint8 i = 0; i < NUM_SOUND_QUEUES; i++)
|
||||
for (uint8 j = 0; j < m_nRequestedCount[i]; j++) {
|
||||
tSound &sound = m_aRequestedQueue[i][m_aRequestedOrderList[i][j]];
|
||||
if (sound.m_nEntityIndex < 0) continue;
|
||||
if (!m_asAudioEntities[sound.m_nEntityIndex].m_bIsUsed) {
|
||||
bool found = false;
|
||||
|
@ -160,7 +160,7 @@ cAudioManager::CreateEntity(eAudioType type, void *entity)
|
|||
}
|
||||
#endif
|
||||
|
||||
for (uint32 i = 0; i < ARRAY_SIZE(m_asAudioEntities); i++) {
|
||||
for (uint32 i = 0; i < NUM_AUDIOENTITIES; i++) {
|
||||
if (!m_asAudioEntities[i].m_bIsUsed) {
|
||||
#ifdef FIX_BUGS
|
||||
// skip if ID is still used by queued sample
|
||||
|
@ -185,7 +185,7 @@ cAudioManager::CreateEntity(eAudioType type, void *entity)
|
|||
m_asAudioEntities[i].m_awAudioEvent[2] = SOUND_NO_SOUND;
|
||||
m_asAudioEntities[i].m_awAudioEvent[3] = SOUND_NO_SOUND;
|
||||
m_asAudioEntities[i].m_AudioEvents = 0;
|
||||
m_anAudioEntityIndices[m_nAudioEntitiesTotal++] = i;
|
||||
m_aAudioEntityOrderList[m_nAudioEntitiesCount++] = i;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
@ -197,11 +197,11 @@ cAudioManager::DestroyEntity(int32 id)
|
|||
{
|
||||
if (m_bIsInitialised && id >= 0 && id < NUM_AUDIOENTITIES && m_asAudioEntities[id].m_bIsUsed) {
|
||||
m_asAudioEntities[id].m_bIsUsed = FALSE;
|
||||
for (int32 i = 0; i < m_nAudioEntitiesTotal; ++i) {
|
||||
if (id == m_anAudioEntityIndices[i]) {
|
||||
for (uint32 i = 0; i < m_nAudioEntitiesCount; ++i) {
|
||||
if (id == m_aAudioEntityOrderList[i]) {
|
||||
if (i < NUM_AUDIOENTITIES - 1)
|
||||
memmove(&m_anAudioEntityIndices[i], &m_anAudioEntityIndices[i + 1], NUM_AUDIOENTITY_EVENTS * (m_nAudioEntitiesTotal - (i + 1)));
|
||||
m_anAudioEntityIndices[--m_nAudioEntitiesTotal] = NUM_AUDIOENTITIES;
|
||||
memmove(&m_aAudioEntityOrderList[i], &m_aAudioEntityOrderList[i + 1], NUM_AUDIOENTITY_EVENTS * (m_nAudioEntitiesCount - (i + 1)));
|
||||
m_aAudioEntityOrderList[--m_nAudioEntitiesCount] = NUM_AUDIOENTITIES;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -258,13 +258,13 @@ cAudioManager::PlayOneShot(int32 index, uint16 sound, float vol)
|
|||
if (entity.m_AudioEvents < ARRAY_SIZE(entity.m_awAudioEvent)) {
|
||||
entity.m_awAudioEvent[i] = sound;
|
||||
entity.m_afVolume[i] = vol;
|
||||
++entity.m_AudioEvents;
|
||||
entity.m_AudioEvents++;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (OneShotPriority[entity.m_awAudioEvent[i]] > OneShotPriority[sound])
|
||||
break;
|
||||
++i;
|
||||
i++;
|
||||
}
|
||||
if (i < NUM_AUDIOENTITY_EVENTS - 1) {
|
||||
memmove(&entity.m_awAudioEvent[i + 1], &entity.m_awAudioEvent[i], (NUM_AUDIOENTITY_EVENTS - 1 - i) * NUM_AUDIOENTITY_EVENTS / 2);
|
||||
|
@ -273,7 +273,7 @@ cAudioManager::PlayOneShot(int32 index, uint16 sound, float vol)
|
|||
entity.m_awAudioEvent[i] = sound;
|
||||
entity.m_afVolume[i] = vol;
|
||||
if (entity.m_AudioEvents < ARRAY_SIZE(entity.m_awAudioEvent))
|
||||
++entity.m_AudioEvents;
|
||||
entity.m_AudioEvents++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -324,14 +324,14 @@ cAudioManager::ResetTimers(uint32 time)
|
|||
m_bTimerJustReset = TRUE;
|
||||
m_nTimer = time;
|
||||
ClearRequestedQueue();
|
||||
if (m_nActiveSampleQueue) {
|
||||
m_nActiveSampleQueue = 0;
|
||||
if (m_nActiveQueue) {
|
||||
m_nActiveQueue = 0;
|
||||
ClearRequestedQueue();
|
||||
m_nActiveSampleQueue = 1;
|
||||
m_nActiveQueue = 1;
|
||||
} else {
|
||||
m_nActiveSampleQueue = 1;
|
||||
m_nActiveQueue = 1;
|
||||
ClearRequestedQueue();
|
||||
m_nActiveSampleQueue = 0;
|
||||
m_nActiveQueue = 0;
|
||||
}
|
||||
ClearActiveSamples();
|
||||
ClearMissionAudio(0);
|
||||
|
@ -353,7 +353,7 @@ cAudioManager::DestroyAllGameCreatedEntities()
|
|||
cAudioScriptObject *entity;
|
||||
|
||||
if (m_bIsInitialised) {
|
||||
for (uint32 i = 0; i < ARRAY_SIZE(m_asAudioEntities); i++) {
|
||||
for (uint32 i = 0; i < NUM_AUDIOENTITIES; i++) {
|
||||
if (m_asAudioEntities[i].m_bIsUsed) {
|
||||
switch (m_asAudioEntities[i].m_nType) {
|
||||
case AUDIOTYPE_PHYSICAL:
|
||||
|
@ -442,20 +442,20 @@ cAudioManager::SetCurrent3DProvider(uint8 which)
|
|||
#else
|
||||
if (!m_bIsInitialised)
|
||||
return -1;
|
||||
for (uint8 i = 0; i < m_nActiveSamples + 1; ++i)
|
||||
for (uint8 i = 0; i < m_nActiveSamples + 1; i++)
|
||||
SampleManager.StopChannel(i);
|
||||
ClearRequestedQueue();
|
||||
if (m_nActiveSampleQueue == 0)
|
||||
m_nActiveSampleQueue = 1;
|
||||
if (m_nActiveQueue == 0)
|
||||
m_nActiveQueue = 1;
|
||||
else
|
||||
m_nActiveSampleQueue = 0;
|
||||
m_nActiveQueue = 0;
|
||||
ClearRequestedQueue();
|
||||
ClearActiveSamples();
|
||||
int8 current = SampleManager.SetCurrent3DProvider(which);
|
||||
if (current > 0) {
|
||||
m_nActiveSamples = SampleManager.GetMaximumSupportedChannels();
|
||||
if (m_nActiveSamples > 1)
|
||||
--m_nActiveSamples;
|
||||
m_nActiveSamples--;
|
||||
}
|
||||
return current;
|
||||
#endif
|
||||
|
@ -531,7 +531,7 @@ cAudioManager::ServiceSoundEffects()
|
|||
if(CTimer::GetLogicalFramesPassed() != 0)
|
||||
#endif
|
||||
m_bReduceReleasingPriority = (m_FrameCounter++ % 5) == 0;
|
||||
if (m_nUserPause && !m_nPreviousUserPause) {
|
||||
if (m_bIsPaused && !m_bWasPaused) {
|
||||
#ifdef GTA_PS2
|
||||
if (m_bIsSurround) {
|
||||
for (uint32 i = 0; i < NUM_CHANNELS_DTS_GENERIC; i++)
|
||||
|
@ -555,18 +555,18 @@ cAudioManager::ServiceSoundEffects()
|
|||
SampleManager.StopChannel(i);
|
||||
#endif
|
||||
ClearRequestedQueue();
|
||||
if (m_nActiveSampleQueue) {
|
||||
m_nActiveSampleQueue = 0;
|
||||
if (m_nActiveQueue) {
|
||||
m_nActiveQueue = 0;
|
||||
ClearRequestedQueue();
|
||||
m_nActiveSampleQueue = 1;
|
||||
m_nActiveQueue = 1;
|
||||
} else {
|
||||
m_nActiveSampleQueue = 1;
|
||||
m_nActiveQueue = 1;
|
||||
ClearRequestedQueue();
|
||||
m_nActiveSampleQueue = 0;
|
||||
m_nActiveQueue = 0;
|
||||
}
|
||||
ClearActiveSamples();
|
||||
}
|
||||
m_nActiveSampleQueue = m_nActiveSampleQueue == 1 ? 0 : 1;
|
||||
m_nActiveQueue = m_nActiveQueue == 1 ? 0 : 1;
|
||||
#ifdef AUDIO_REVERB
|
||||
if(m_bIsSurround) ProcessReverb();
|
||||
#endif
|
||||
|
@ -585,7 +585,7 @@ cAudioManager::ServiceSoundEffects()
|
|||
#ifdef AUDIO_OAL
|
||||
SampleManager.Service();
|
||||
#endif
|
||||
for (int32 i = 0; i < m_sAudioScriptObjectManager.m_nScriptObjectEntityTotal; ++i) {
|
||||
for (int32 i = 0; i < m_sAudioScriptObjectManager.m_nScriptObjectEntityTotal; i++) {
|
||||
cAudioScriptObject *object = (cAudioScriptObject *)m_asAudioEntities[m_sAudioScriptObjectManager.m_anScriptObjectEntityIndices[i]].m_pEntity;
|
||||
delete object;
|
||||
m_asAudioEntities[m_sAudioScriptObjectManager.m_anScriptObjectEntityIndices[i]].m_pEntity = nil;
|
||||
|
@ -685,9 +685,9 @@ cAudioManager::RandomDisplacement(uint32 seed)
|
|||
void
|
||||
cAudioManager::InterrogateAudioEntities()
|
||||
{
|
||||
for (int32 i = 0; i < m_nAudioEntitiesTotal; i++) {
|
||||
ProcessEntity(m_anAudioEntityIndices[i]);
|
||||
m_asAudioEntities[m_anAudioEntityIndices[i]].m_AudioEvents = 0;
|
||||
for (uint32 i = 0; i < m_nAudioEntitiesCount; i++) {
|
||||
ProcessEntity(m_aAudioEntityOrderList[i]);
|
||||
m_asAudioEntities[m_aAudioEntityOrderList[i]].m_AudioEvents = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -702,14 +702,13 @@ cAudioManager::AddSampleToRequestedQueue()
|
|||
|
||||
if (m_sQueueSample.m_nSampleIndex < TOTAL_AUDIO_SAMPLES) {
|
||||
finalPriority = m_sQueueSample.m_nPriority * (MAX_VOLUME - m_sQueueSample.m_nVolume);
|
||||
sampleIndex = m_SampleRequestQueuesStatus[m_nActiveSampleQueue];
|
||||
sampleIndex = m_nRequestedCount[m_nActiveQueue];
|
||||
if (sampleIndex >= m_nActiveSamples) {
|
||||
sampleIndex = m_abSampleQueueIndexTable[m_nActiveSampleQueue][m_nActiveSamples - 1];
|
||||
if (m_asSamples[m_nActiveSampleQueue][sampleIndex].m_nFinalPriority <= finalPriority)
|
||||
sampleIndex = m_aRequestedOrderList[m_nActiveQueue][m_nActiveSamples - 1];
|
||||
if (m_aRequestedQueue[m_nActiveQueue][sampleIndex].m_nFinalPriority <= finalPriority)
|
||||
return;
|
||||
} else {
|
||||
++m_SampleRequestQueuesStatus[m_nActiveSampleQueue];
|
||||
}
|
||||
} else
|
||||
m_nRequestedCount[m_nActiveQueue]++;
|
||||
m_sQueueSample.m_nFinalPriority = finalPriority;
|
||||
m_sQueueSample.m_bIsPlayingFinished = FALSE;
|
||||
#ifdef AUDIO_REFLECTIONS
|
||||
|
@ -733,7 +732,7 @@ cAudioManager::AddSampleToRequestedQueue()
|
|||
#endif
|
||||
#endif
|
||||
|
||||
m_asSamples[m_nActiveSampleQueue][sampleIndex] = m_sQueueSample;
|
||||
m_aRequestedQueue[m_nActiveQueue][sampleIndex] = m_sQueueSample;
|
||||
|
||||
AddDetailsToRequestedOrderList(sampleIndex);
|
||||
#ifdef AUDIO_REFLECTIONS
|
||||
|
@ -749,15 +748,15 @@ cAudioManager::AddDetailsToRequestedOrderList(uint8 sample)
|
|||
uint32 i = 0;
|
||||
if (sample > 0) {
|
||||
for (; i < sample; i++) {
|
||||
if (m_asSamples[m_nActiveSampleQueue][m_abSampleQueueIndexTable[m_nActiveSampleQueue][i]].m_nFinalPriority >
|
||||
m_asSamples[m_nActiveSampleQueue][sample].m_nFinalPriority)
|
||||
if (m_aRequestedQueue[m_nActiveQueue][m_aRequestedOrderList[m_nActiveQueue][i]].m_nFinalPriority >
|
||||
m_aRequestedQueue[m_nActiveQueue][sample].m_nFinalPriority)
|
||||
break;
|
||||
}
|
||||
if (i < sample) {
|
||||
memmove(&m_abSampleQueueIndexTable[m_nActiveSampleQueue][i + 1], &m_abSampleQueueIndexTable[m_nActiveSampleQueue][i], m_nActiveSamples - i - 1);
|
||||
memmove(&m_aRequestedOrderList[m_nActiveQueue][i + 1], &m_aRequestedOrderList[m_nActiveQueue][i], m_nActiveSamples - i - 1);
|
||||
}
|
||||
}
|
||||
m_abSampleQueueIndexTable[m_nActiveSampleQueue][i] = sample;
|
||||
m_aRequestedOrderList[m_nActiveQueue][i] = sample;
|
||||
}
|
||||
|
||||
#ifdef AUDIO_REFLECTIONS
|
||||
|
@ -955,17 +954,17 @@ cAudioManager::AddReleasingSounds()
|
|||
bool8 toProcess[44];
|
||||
#endif
|
||||
|
||||
int8 queue = m_nActiveSampleQueue == 0 ? 1 : 0;
|
||||
uint8 queue = m_nActiveQueue == 0 ? 1 : 0;
|
||||
|
||||
for (int32 i = 0; i < m_SampleRequestQueuesStatus[queue]; i++) {
|
||||
tSound &sample = m_asSamples[queue][m_abSampleQueueIndexTable[queue][i]];
|
||||
for (uint8 i = 0; i < m_nRequestedCount[queue]; i++) {
|
||||
tSound &sample = m_aRequestedQueue[queue][m_aRequestedOrderList[queue][i]];
|
||||
if (sample.m_bIsPlayingFinished)
|
||||
continue;
|
||||
|
||||
toProcess[i] = FALSE;
|
||||
for (int32 j = 0; j < m_SampleRequestQueuesStatus[m_nActiveSampleQueue]; j++) {
|
||||
if (sample.m_nEntityIndex == m_asSamples[m_nActiveSampleQueue][m_abSampleQueueIndexTable[m_nActiveSampleQueue][j]].m_nEntityIndex &&
|
||||
sample.m_nCounter == m_asSamples[m_nActiveSampleQueue][m_abSampleQueueIndexTable[m_nActiveSampleQueue][j]].m_nCounter) {
|
||||
for (uint8 j = 0; j < m_nRequestedCount[m_nActiveQueue]; j++) {
|
||||
if (sample.m_nEntityIndex == m_aRequestedQueue[m_nActiveQueue][m_aRequestedOrderList[m_nActiveQueue][j]].m_nEntityIndex &&
|
||||
sample.m_nCounter == m_aRequestedQueue[m_nActiveQueue][m_aRequestedOrderList[m_nActiveQueue][j]].m_nCounter) {
|
||||
toProcess[i] = TRUE;
|
||||
break;
|
||||
}
|
||||
|
@ -1101,18 +1100,18 @@ cAudioManager::ProcessActiveQueues()
|
|||
#endif
|
||||
|
||||
#ifdef USE_TIME_SCALE_FOR_AUDIO
|
||||
float timeScale = m_nUserPause ? 1.0f : CTimer::GetTimeScale();
|
||||
float timeScale = m_bIsPaused ? 1.0f : CTimer::GetTimeScale();
|
||||
#endif
|
||||
|
||||
for (int32 i = 0; i < m_nActiveSamples; i++) {
|
||||
m_asSamples[m_nActiveSampleQueue][i].m_bIsBeingPlayed = FALSE;
|
||||
for (uint8 i = 0; i < m_nActiveSamples; i++) {
|
||||
m_aRequestedQueue[m_nActiveQueue][i].m_bIsBeingPlayed = FALSE;
|
||||
m_asActiveSamples[i].m_bIsBeingPlayed = FALSE;
|
||||
}
|
||||
|
||||
for (int32 i = 0; i < m_SampleRequestQueuesStatus[m_nActiveSampleQueue]; i++) {
|
||||
tSound &sample = m_asSamples[m_nActiveSampleQueue][m_abSampleQueueIndexTable[m_nActiveSampleQueue][i]];
|
||||
for (uint8 i = 0; i < m_nRequestedCount[m_nActiveQueue]; i++) {
|
||||
tSound &sample = m_aRequestedQueue[m_nActiveQueue][m_aRequestedOrderList[m_nActiveQueue][i]];
|
||||
if (sample.m_nSampleIndex != NO_SAMPLE) {
|
||||
for (int32 j = 0; j < m_nActiveSamples; j++) {
|
||||
for (uint8 j = 0; j < m_nActiveSamples; j++) {
|
||||
if (sample.m_nEntityIndex == m_asActiveSamples[j].m_nEntityIndex && sample.m_nCounter == m_asActiveSamples[j].m_nCounter &&
|
||||
sample.m_nSampleIndex == m_asActiveSamples[j].m_nSampleIndex) {
|
||||
if (sample.m_nLoopCount > 0) {
|
||||
|
@ -1214,15 +1213,15 @@ cAudioManager::ProcessActiveQueues()
|
|||
}
|
||||
}
|
||||
}
|
||||
for (int32 i = 0; i < m_nActiveSamples; i++) {
|
||||
for (uint8 i = 0; i < m_nActiveSamples; i++) {
|
||||
if (m_asActiveSamples[i].m_nSampleIndex != NO_SAMPLE && !m_asActiveSamples[i].m_bIsBeingPlayed) {
|
||||
SampleManager.StopChannel(i);
|
||||
m_asActiveSamples[i].m_nSampleIndex = NO_SAMPLE;
|
||||
m_asActiveSamples[i].m_nEntityIndex = AEHANDLE_NONE;
|
||||
}
|
||||
}
|
||||
for (uint8 i = 0; i < m_SampleRequestQueuesStatus[m_nActiveSampleQueue]; i++) {
|
||||
tSound &sample = m_asSamples[m_nActiveSampleQueue][m_abSampleQueueIndexTable[m_nActiveSampleQueue][i]];
|
||||
for (uint8 i = 0; i < m_nRequestedCount[m_nActiveQueue]; i++) {
|
||||
tSound &sample = m_aRequestedQueue[m_nActiveQueue][m_aRequestedOrderList[m_nActiveQueue][i]];
|
||||
if (!sample.m_bIsBeingPlayed && !sample.m_bIsPlayingFinished && m_asAudioEntities[sample.m_nEntityIndex].m_bIsUsed && sample.m_nSampleIndex < NO_SAMPLE) {
|
||||
#ifdef AUDIO_REFLECTIONS
|
||||
if (sample.m_nCounter > 255 && sample.m_nLoopCount > 0 && sample.m_nReflectionDelay > 0) { // check if reflection
|
||||
|
@ -1339,10 +1338,9 @@ cAudioManager::ProcessActiveQueues()
|
|||
void
|
||||
cAudioManager::ClearRequestedQueue()
|
||||
{
|
||||
for (int32 i = 0; i < m_nActiveSamples; i++) {
|
||||
m_abSampleQueueIndexTable[m_nActiveSampleQueue][i] = m_nActiveSamples;
|
||||
}
|
||||
m_SampleRequestQueuesStatus[m_nActiveSampleQueue] = 0;
|
||||
for (uint8 i = 0; i < m_nActiveSamples; i++)
|
||||
m_aRequestedOrderList[m_nActiveQueue][i] = m_nActiveSamples;
|
||||
m_nRequestedCount[m_nActiveQueue] = 0;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1396,17 +1394,16 @@ cAudioManager::LoadBankIfNecessary(uint8 bank)
|
|||
void
|
||||
cAudioManager::GenerateIntegerRandomNumberTable()
|
||||
{
|
||||
for (int32 i = 0; i < ARRAY_SIZE(m_anRandomTable); i++) {
|
||||
for (uint32 i = 0; i < ARRAY_SIZE(m_anRandomTable); i++)
|
||||
m_anRandomTable[i] = myrand();
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef EXTERNAL_3D_SOUND
|
||||
void
|
||||
cAudioManager::AdjustSamplesVolume()
|
||||
{
|
||||
for (int i = 0; i < m_SampleRequestQueuesStatus[m_nActiveSampleQueue]; i++) {
|
||||
tSound *pSample = &m_asSamples[m_nActiveSampleQueue][m_abSampleQueueIndexTable[m_nActiveSampleQueue][i]];
|
||||
for (uint8 i = 0; i < m_nRequestedCount[m_nActiveQueue]; i++) {
|
||||
tSound *pSample = &m_aRequestedQueue[m_nActiveQueue][m_aRequestedOrderList[m_nActiveQueue][i]];
|
||||
|
||||
if (!pSample->m_bIs2D)
|
||||
pSample->m_nEmittingVolume = ComputeEmittingVolume(pSample->m_nEmittingVolume, pSample->m_MaxDistance, pSample->m_fDistance);
|
||||
|
|
|
@ -232,16 +232,16 @@ public:
|
|||
uint8 m_nChannelOffset;
|
||||
float m_fSpeedOfSound;
|
||||
bool8 m_bTimerJustReset;
|
||||
int32 m_nTimer;
|
||||
uint32 m_nTimer;
|
||||
tSound m_sQueueSample;
|
||||
uint8 m_nActiveSampleQueue;
|
||||
tSound m_asSamples[NUM_SOUNDS_SAMPLES_BANKS][NUM_CHANNELS_GENERIC];
|
||||
uint8 m_abSampleQueueIndexTable[NUM_SOUNDS_SAMPLES_BANKS][NUM_CHANNELS_GENERIC];
|
||||
uint8 m_SampleRequestQueuesStatus[NUM_SOUNDS_SAMPLES_BANKS];
|
||||
uint8 m_nActiveQueue;
|
||||
tSound m_aRequestedQueue[NUM_SOUND_QUEUES][NUM_CHANNELS_GENERIC];
|
||||
uint8 m_aRequestedOrderList[NUM_SOUND_QUEUES][NUM_CHANNELS_GENERIC];
|
||||
uint8 m_nRequestedCount[NUM_SOUND_QUEUES];
|
||||
tSound m_asActiveSamples[NUM_CHANNELS_GENERIC];
|
||||
tAudioEntity m_asAudioEntities[NUM_AUDIOENTITIES];
|
||||
int32 m_anAudioEntityIndices[NUM_AUDIOENTITIES];
|
||||
int32 m_nAudioEntitiesTotal;
|
||||
uint32 m_aAudioEntityOrderList[NUM_AUDIOENTITIES];
|
||||
uint32 m_nAudioEntitiesCount;
|
||||
#ifdef AUDIO_REFLECTIONS
|
||||
CVector m_avecReflectionsPos[MAX_REFLECTIONS];
|
||||
float m_afReflectionsDistances[MAX_REFLECTIONS];
|
||||
|
@ -280,15 +280,15 @@ public:
|
|||
uint8 m_nMissionAudioLoadingStatus[MISSION_AUDIO_SLOTS];
|
||||
uint8 m_nMissionAudioPlayStatus[MISSION_AUDIO_SLOTS];
|
||||
bool8 m_bIsMissionAudioPlaying[MISSION_AUDIO_SLOTS];
|
||||
int32 m_nMissionAudioFramesToPlay[MISSION_AUDIO_SLOTS];
|
||||
int32 m_nMissionAudioFramesToPlay[MISSION_AUDIO_SLOTS]; // possibly unsigned
|
||||
bool8 m_bIsMissionAudioAllowedToPlay[MISSION_AUDIO_SLOTS];
|
||||
bool8 m_bIsMissionAudioPhoneCall[MISSION_AUDIO_SLOTS];
|
||||
uint8 m_nGlobalSfxVolumeMultiplier; // used to lower sfx volume during phone calls
|
||||
|
||||
int32 m_anRandomTable[5];
|
||||
uint8 m_nTimeSpent;
|
||||
bool8 m_nUserPause;
|
||||
bool8 m_nPreviousUserPause;
|
||||
bool8 m_bIsPaused;
|
||||
bool8 m_bWasPaused;
|
||||
uint32 m_FrameCounter;
|
||||
|
||||
cAudioManager();
|
||||
|
|
|
@ -263,7 +263,7 @@ cMusicManager::GetRadioInCar(void)
|
|||
CVehicle* veh = AudioManager.FindVehicleOfPlayer();
|
||||
if (veh != nil) {
|
||||
if (UsesPoliceRadio(veh) || UsesTaxiRadio(veh)) {
|
||||
if (m_nRadioInCar == NO_TRACK || (CReplay::IsPlayingBack() && !AudioManager.m_nUserPause))
|
||||
if (m_nRadioInCar == NO_TRACK || (CReplay::IsPlayingBack() && !AudioManager.m_bIsPaused))
|
||||
return STREAMED_SOUND_RADIO_POLICE;
|
||||
return m_nRadioInCar;
|
||||
}
|
||||
|
@ -271,7 +271,7 @@ cMusicManager::GetRadioInCar(void)
|
|||
}
|
||||
}
|
||||
|
||||
if (m_nRadioInCar == NO_TRACK || (CReplay::IsPlayingBack() && !AudioManager.m_nUserPause))
|
||||
if (m_nRadioInCar == NO_TRACK || (CReplay::IsPlayingBack() && !AudioManager.m_bIsPaused))
|
||||
return RADIO_OFF;
|
||||
return m_nRadioInCar;
|
||||
}
|
||||
|
@ -353,7 +353,7 @@ cMusicManager::ChangeMusicMode(uint8 mode)
|
|||
}
|
||||
|
||||
void
|
||||
cMusicManager::ResetTimers(int32 time)
|
||||
cMusicManager::ResetTimers(uint32 time)
|
||||
{
|
||||
m_bResetTimers = TRUE;
|
||||
m_nResetTime = time;
|
||||
|
@ -374,7 +374,7 @@ cMusicManager::Service()
|
|||
if (!m_bMusicModeChangeStarted)
|
||||
m_nMusicModeToBeSet = m_nUpcomingMusicMode;
|
||||
if (m_nMusicModeToBeSet == m_nMusicMode) {
|
||||
if (!AudioManager.m_nUserPause || AudioManager.m_nPreviousUserPause || m_nMusicMode != MUSICMODE_FRONTEND)
|
||||
if (!AudioManager.m_bIsPaused || AudioManager.m_bWasPaused || m_nMusicMode != MUSICMODE_FRONTEND)
|
||||
{
|
||||
switch (m_nMusicMode)
|
||||
{
|
||||
|
@ -387,7 +387,7 @@ cMusicManager::Service()
|
|||
m_nMusicMode = MUSICMODE_DISABLED;
|
||||
} else {
|
||||
m_bMusicModeChangeStarted = TRUE;
|
||||
if (!m_bUserResumedGame && !AudioManager.m_nUserPause && AudioManager.m_nPreviousUserPause)
|
||||
if (!m_bUserResumedGame && !AudioManager.m_bIsPaused && AudioManager.m_bWasPaused)
|
||||
m_bUserResumedGame = TRUE;
|
||||
if (AudioManager.m_FrameCounter % 4 == 0) {
|
||||
gNumRetunePresses = 0;
|
||||
|
@ -461,7 +461,7 @@ cMusicManager::ServiceFrontEndMode()
|
|||
} else {
|
||||
if (m_nPlayingTrack == STREAMED_SOUND_RADIO_MP3_PLAYER)
|
||||
SampleManager.StartStreamedFile(STREAMED_SOUND_RADIO_MP3_PLAYER, 0);
|
||||
else if (m_nPlayingTrack == STREAMED_SOUND_MISSION_COMPLETED && !AudioManager.m_nUserPause)
|
||||
else if (m_nPlayingTrack == STREAMED_SOUND_MISSION_COMPLETED && !AudioManager.m_bIsPaused)
|
||||
ChangeMusicMode(MUSICMODE_GAME);
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -76,7 +76,7 @@ public:
|
|||
void SetRadioInCar(uint32);
|
||||
void SetRadioChannelByScript(uint32, int32);
|
||||
|
||||
void ResetTimers(int32);
|
||||
void ResetTimers(uint32);
|
||||
void Service();
|
||||
void ServiceFrontEndMode();
|
||||
void ServiceGameMode();
|
||||
|
|
|
@ -124,7 +124,7 @@ cAudioManager::ServicePoliceRadio()
|
|||
|
||||
if(!m_bIsInitialised) return;
|
||||
|
||||
if(!m_nUserPause) {
|
||||
if(!m_bIsPaused) {
|
||||
bool8 crimeReport = SetupCrimeReport();
|
||||
#ifdef FIX_BUGS // Crash at 0x5fe6ef
|
||||
if(CReplay::IsPlayingBack() || !FindPlayerPed() || !FindPlayerPed()->m_pWanted)
|
||||
|
@ -166,14 +166,14 @@ cAudioManager::ServicePoliceRadioChannel(uint8 wantedLevel)
|
|||
|
||||
if (!m_bIsInitialised) return;
|
||||
|
||||
if (m_nUserPause) {
|
||||
if (m_bIsPaused) {
|
||||
if (SampleManager.GetChannelUsedFlag(CHANNEL_POLICE_RADIO)) SampleManager.StopChannel(CHANNEL_POLICE_RADIO);
|
||||
if (g_nMissionAudioSfx != NO_SAMPLE && bMissionAudioPhysicalPlayingStatus == PLAY_STATUS_PLAYING &&
|
||||
SampleManager.IsStreamPlaying(1)) {
|
||||
SampleManager.PauseStream(TRUE, 1);
|
||||
}
|
||||
} else {
|
||||
if (m_nPreviousUserPause && g_nMissionAudioSfx != NO_SAMPLE &&
|
||||
if (m_bWasPaused && g_nMissionAudioSfx != NO_SAMPLE &&
|
||||
bMissionAudioPhysicalPlayingStatus == PLAY_STATUS_PLAYING) {
|
||||
SampleManager.PauseStream(FALSE, 1);
|
||||
}
|
||||
|
|
|
@ -132,7 +132,7 @@ enum Config {
|
|||
NUM_PED_COMMENTS_BANKS = 2,
|
||||
NUM_PED_COMMENTS_SLOTS = 20,
|
||||
|
||||
NUM_SOUNDS_SAMPLES_BANKS = 2,
|
||||
NUM_SOUND_QUEUES = 2,
|
||||
NUM_AUDIOENTITIES = 250,
|
||||
|
||||
NUM_SCRIPT_MAX_ENTITIES = 40,
|
||||
|
|
Loading…
Reference in a new issue