mirror of
https://github.com/halpz/re3.git
synced 2025-02-23 09:42:11 +00:00
Merge branch 'miami' into lcs
# Conflicts: # premake5.lua # src/audio/AudioLogic.cpp # src/audio/AudioManager.cpp
This commit is contained in:
commit
800ab92960
@ -384,7 +384,7 @@ project "reLCS"
|
|||||||
-- iterates all configs and runs on them
|
-- iterates all configs and runs on them
|
||||||
["dontWrite"] = function (cfg)
|
["dontWrite"] = function (cfg)
|
||||||
check_symbol_exists(cfg, "haveX11", "glfwGetX11Display", { "X11/Xlib.h", "X11/XKBlib.h", "GLFW/glfw3.h", "GLFW/glfw3native.h" }, "GLFW_EXPOSE_NATIVE_X11")
|
check_symbol_exists(cfg, "haveX11", "glfwGetX11Display", { "X11/Xlib.h", "X11/XKBlib.h", "GLFW/glfw3.h", "GLFW/glfw3native.h" }, "GLFW_EXPOSE_NATIVE_X11")
|
||||||
if cfg.autoconf["haveX11"] then
|
if cfg.autoconf["haveX11"] ~= nil and cfg.autoconf["haveX11"] == 1 then
|
||||||
table.insert(cfg.links, "X11")
|
table.insert(cfg.links, "X11")
|
||||||
table.insert(cfg.defines, "GET_KEYBOARD_INPUT_FROM_X11")
|
table.insert(cfg.defines, "GET_KEYBOARD_INPUT_FROM_X11")
|
||||||
end
|
end
|
||||||
|
@ -18,7 +18,7 @@ cAudioManager::ReportCollision(CEntity *entity1, CEntity *entity2, uint8 surface
|
|||||||
CVector v1;
|
CVector v1;
|
||||||
CVector v2;
|
CVector v2;
|
||||||
|
|
||||||
if(!m_bIsInitialised || m_nCollisionEntity < 0 || m_nUserPause ||
|
if(!m_bIsInitialised || m_nCollisionEntity < 0 || m_bIsPaused ||
|
||||||
(velocity < 0.0016f && collisionPower < 0.01f))
|
(velocity < 0.0016f && collisionPower < 0.01f))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -226,9 +226,9 @@ cAudioManager::PostTerminateGameSpecificShutdown()
|
|||||||
void
|
void
|
||||||
cAudioManager::ResetAudioLogicTimers(uint32 timer)
|
cAudioManager::ResetAudioLogicTimers(uint32 timer)
|
||||||
{
|
{
|
||||||
for (int32 i = 0; i < m_nAudioEntitiesTotal; i++) {
|
for (uint32 i = 0; i < m_nAudioEntitiesCount; i++) {
|
||||||
if (m_asAudioEntities[m_anAudioEntityIndices[i]].m_nType == AUDIOTYPE_PHYSICAL) {
|
if (m_asAudioEntities[m_aAudioEntityOrderList[i]].m_nType == AUDIOTYPE_PHYSICAL) {
|
||||||
CPed *ped = (CPed *)m_asAudioEntities[m_anAudioEntityIndices[i]].m_pEntity;
|
CPed *ped = (CPed *)m_asAudioEntities[m_aAudioEntityOrderList[i]].m_pEntity;
|
||||||
if (ped->IsPed()) {
|
if (ped->IsPed()) {
|
||||||
ped->m_lastSoundStart = timer;
|
ped->m_lastSoundStart = timer;
|
||||||
ped->m_soundStart = timer + m_anRandomTable[0] % 3000;
|
ped->m_soundStart = timer + m_anRandomTable[0] % 3000;
|
||||||
@ -296,8 +296,8 @@ cAudioManager::ProcessSpecial()
|
|||||||
CPlayerPed *playerPed;
|
CPlayerPed *playerPed;
|
||||||
CVehicle *remoteVehicle;
|
CVehicle *remoteVehicle;
|
||||||
|
|
||||||
if (m_nUserPause) {
|
if (m_bIsPaused) {
|
||||||
if (!m_nPreviousUserPause) {
|
if (!m_bWasPaused) {
|
||||||
SampleManager.SetEffectsFadeVolume(MAX_VOLUME);
|
SampleManager.SetEffectsFadeVolume(MAX_VOLUME);
|
||||||
SampleManager.SetMusicFadeVolume(MAX_VOLUME);
|
SampleManager.SetMusicFadeVolume(MAX_VOLUME);
|
||||||
}
|
}
|
||||||
@ -322,45 +322,45 @@ cAudioManager::ProcessEntity(int32 id)
|
|||||||
m_sQueueSample.m_nEntityIndex = id;
|
m_sQueueSample.m_nEntityIndex = id;
|
||||||
switch (m_asAudioEntities[id].m_nType) {
|
switch (m_asAudioEntities[id].m_nType) {
|
||||||
case AUDIOTYPE_PHYSICAL:
|
case AUDIOTYPE_PHYSICAL:
|
||||||
if (!m_nUserPause) {
|
if (!m_bIsPaused) {
|
||||||
SET_SOUND_REVERB(TRUE);
|
SET_SOUND_REVERB(TRUE);
|
||||||
ProcessPhysical(id);
|
ProcessPhysical(id);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case AUDIOTYPE_EXPLOSION:
|
case AUDIOTYPE_EXPLOSION:
|
||||||
if (!m_nUserPause) {
|
if (!m_bIsPaused) {
|
||||||
SET_SOUND_REVERB(TRUE);
|
SET_SOUND_REVERB(TRUE);
|
||||||
ProcessExplosions(id);
|
ProcessExplosions(id);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case AUDIOTYPE_FIRE:
|
case AUDIOTYPE_FIRE:
|
||||||
if (!m_nUserPause) {
|
if (!m_bIsPaused) {
|
||||||
SET_SOUND_REVERB(TRUE);
|
SET_SOUND_REVERB(TRUE);
|
||||||
ProcessFires(id);
|
ProcessFires(id);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case AUDIOTYPE_WEATHER:
|
case AUDIOTYPE_WEATHER:
|
||||||
if (!m_nUserPause) {
|
if (!m_bIsPaused) {
|
||||||
SET_SOUND_REVERB(TRUE);
|
SET_SOUND_REVERB(TRUE);
|
||||||
if(CGame::currArea == AREA_MAIN_MAP || CGame::currArea == AREA_EVERYWHERE)
|
if(CGame::currArea == AREA_MAIN_MAP || CGame::currArea == AREA_EVERYWHERE)
|
||||||
ProcessWeather(id);
|
ProcessWeather(id);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
/* case AUDIOTYPE_CRANE:
|
/* case AUDIOTYPE_CRANE:
|
||||||
if (!m_nUserPause) {
|
if (!m_bIsPaused) {
|
||||||
SET_SOUND_REVERB(TRUE);
|
SET_SOUND_REVERB(TRUE);
|
||||||
ProcessCrane();
|
ProcessCrane();
|
||||||
}
|
}
|
||||||
break;*/
|
break;*/
|
||||||
case AUDIOTYPE_SCRIPTOBJECT:
|
case AUDIOTYPE_SCRIPTOBJECT:
|
||||||
if (!m_nUserPause) {
|
if (!m_bIsPaused) {
|
||||||
SET_SOUND_REVERB(TRUE);
|
SET_SOUND_REVERB(TRUE);
|
||||||
ProcessScriptObject(id);
|
ProcessScriptObject(id);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#ifdef GTA_BRIDGE
|
#ifdef GTA_BRIDGE
|
||||||
case AUDIOTYPE_BRIDGE:
|
case AUDIOTYPE_BRIDGE:
|
||||||
if (!m_nUserPause) {
|
if (!m_bIsPaused) {
|
||||||
SET_SOUND_REVERB(TRUE);
|
SET_SOUND_REVERB(TRUE);
|
||||||
ProcessBridge();
|
ProcessBridge();
|
||||||
}
|
}
|
||||||
@ -371,35 +371,35 @@ cAudioManager::ProcessEntity(int32 id)
|
|||||||
ProcessFrontEnd();
|
ProcessFrontEnd();
|
||||||
break;
|
break;
|
||||||
case AUDIOTYPE_PROJECTILE:
|
case AUDIOTYPE_PROJECTILE:
|
||||||
if (!m_nUserPause) {
|
if (!m_bIsPaused) {
|
||||||
SET_SOUND_REVERB(TRUE);
|
SET_SOUND_REVERB(TRUE);
|
||||||
ProcessProjectiles();
|
ProcessProjectiles();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case AUDIOTYPE_GARAGE:
|
case AUDIOTYPE_GARAGE:
|
||||||
if (!m_nUserPause)
|
if (!m_bIsPaused)
|
||||||
ProcessGarages();
|
ProcessGarages();
|
||||||
break;
|
break;
|
||||||
case AUDIOTYPE_FIREHYDRANT:
|
case AUDIOTYPE_FIREHYDRANT:
|
||||||
if (!m_nUserPause) {
|
if (!m_bIsPaused) {
|
||||||
SET_SOUND_REVERB(TRUE);
|
SET_SOUND_REVERB(TRUE);
|
||||||
ProcessFireHydrant();
|
ProcessFireHydrant();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case AUDIOTYPE_WATERCANNON:
|
case AUDIOTYPE_WATERCANNON:
|
||||||
if (!m_nUserPause) {
|
if (!m_bIsPaused) {
|
||||||
SET_SOUND_REVERB(TRUE);
|
SET_SOUND_REVERB(TRUE);
|
||||||
ProcessWaterCannon(id);
|
ProcessWaterCannon(id);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case AUDIOTYPE_ESCALATOR:
|
case AUDIOTYPE_ESCALATOR:
|
||||||
if (!m_nUserPause) {
|
if (!m_bIsPaused) {
|
||||||
SET_SOUND_REVERB(TRUE);
|
SET_SOUND_REVERB(TRUE);
|
||||||
ProcessEscalators();
|
ProcessEscalators();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case AUDIOTYPE_EXTRA_SOUNDS:
|
case AUDIOTYPE_EXTRA_SOUNDS:
|
||||||
if (!m_nUserPause) {
|
if (!m_bIsPaused) {
|
||||||
SET_SOUND_REVERB(TRUE);
|
SET_SOUND_REVERB(TRUE);
|
||||||
ProcessExtraSounds();
|
ProcessExtraSounds();
|
||||||
}
|
}
|
||||||
@ -683,7 +683,7 @@ const eSfxSample aEngineSounds[][2] = {
|
|||||||
};
|
};
|
||||||
bool8 bPlayerJustEnteredCar;
|
bool8 bPlayerJustEnteredCar;
|
||||||
|
|
||||||
const bool8 hornPatternsArray[8][44] = {
|
const bool8 HornPattern[8][44] = {
|
||||||
{FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
|
{FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
|
||||||
FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE},
|
FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE},
|
||||||
{FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE,
|
{FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE,
|
||||||
@ -1723,11 +1723,11 @@ cAudioManager::ProcessVehicleEngine(cVehicleParams& params)
|
|||||||
switch (transmission->nDriveType) {
|
switch (transmission->nDriveType) {
|
||||||
case '4':
|
case '4':
|
||||||
if (params.m_VehicleType == VEHICLE_TYPE_BIKE) {
|
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)
|
if (wheelState[i] == WHEEL_STATE_SPINNING)
|
||||||
traction += 0.1f;
|
traction += 0.1f;
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < 4; i++)
|
for (uint8 i = 0; i < 4; i++)
|
||||||
if (wheelState[i] == WHEEL_STATE_SPINNING)
|
if (wheelState[i] == WHEEL_STATE_SPINNING)
|
||||||
traction += 0.05f;
|
traction += 0.05f;
|
||||||
}
|
}
|
||||||
@ -2010,7 +2010,7 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CVehicle* veh
|
|||||||
static uint8 CurrentPretendGear = 1;
|
static uint8 CurrentPretendGear = 1;
|
||||||
static bool8 bLostTractionLastFrame = FALSE;
|
static bool8 bLostTractionLastFrame = FALSE;
|
||||||
static bool8 bHandbrakeOnLastFrame = FALSE;
|
static bool8 bHandbrakeOnLastFrame = FALSE;
|
||||||
static int32 nCruising = 0;
|
static uint32 nCruising = 0;
|
||||||
static bool8 bAccelSampleStopped = TRUE;
|
static bool8 bAccelSampleStopped = TRUE;
|
||||||
|
|
||||||
bool8 lostTraction = FALSE;
|
bool8 lostTraction = FALSE;
|
||||||
@ -2084,7 +2084,7 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CVehicle* veh
|
|||||||
wheelInUseCounter = 0;
|
wheelInUseCounter = 0;
|
||||||
for (uint8 i = 0; i < 4; i++) {
|
for (uint8 i = 0; i < 4; i++) {
|
||||||
if (wheelState[i] != WHEEL_STATE_NORMAL)
|
if (wheelState[i] != WHEEL_STATE_NORMAL)
|
||||||
++wheelInUseCounter;
|
wheelInUseCounter++;
|
||||||
}
|
}
|
||||||
if (wheelInUseCounter > 2)
|
if (wheelInUseCounter > 2)
|
||||||
lostTraction = TRUE;
|
lostTraction = TRUE;
|
||||||
@ -2191,7 +2191,7 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CVehicle* veh
|
|||||||
gasPedalAudio = accelerationMultipler;
|
gasPedalAudio = accelerationMultipler;
|
||||||
/*switch (engineSoundType) {
|
/*switch (engineSoundType) {
|
||||||
case SFX_BANK_MOPED:
|
case SFX_BANK_MOPED:
|
||||||
++soundOffset;
|
soundOffset++;
|
||||||
break;
|
break;
|
||||||
case SFX_BANK_HONDA250:
|
case SFX_BANK_HONDA250:
|
||||||
soundOffset += 2;
|
soundOffset += 2;
|
||||||
@ -2251,38 +2251,54 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CVehicle* veh
|
|||||||
AddPlayerCarSample(vol, freq, aEngineSounds[engineSoundType - CAR_SFX_BANKS_OFFSET][0], SFX_BANK_0, 52, TRUE);
|
AddPlayerCarSample(vol, freq, aEngineSounds[engineSoundType - CAR_SFX_BANKS_OFFSET][0], SFX_BANK_0, 52, TRUE);
|
||||||
|
|
||||||
CurrentPretendGear = Max(1, currentGear);
|
CurrentPretendGear = Max(1, currentGear);
|
||||||
}
|
} else {
|
||||||
else {
|
if (nCruising > 0) {
|
||||||
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;
|
stuckInSand = params.m_VehicleType == VEHICLE_TYPE_CAR && ((CAutomobile*)params.m_pVehicle)->bStuckInSand;
|
||||||
if (accelerateState < 150 || wheelsOnGround == 0 || params.m_pVehicle->bIsHandbrakeOn || lostTraction
|
if (accelerateState < 150 || wheelsOnGround == 0 || params.m_pVehicle->bIsHandbrakeOn || lostTraction
|
||||||
|| (currentGear < 2 && params.m_fVelocityChange - velocityChangeForAudio < 0.01f) || brakeState > 0) {
|
|| (currentGear < 2 && params.m_fVelocityChange - velocityChangeForAudio < 0.01f) || brakeState > 0) {
|
||||||
|
if (((wheelsOnGround == 0 || params.m_pVehicle->bIsHandbrakeOn || lostTraction) && !stuckInSand) || 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 && wheelsOnGroundPrev != 0 || (params.m_pVehicle->bIsHandbrakeOn && !bHandbrakeOnLastFrame || lostTraction && !bLostTractionLastFrame)
|
if (wheelsOnGround == 0 && wheelsOnGroundPrev != 0 || (params.m_pVehicle->bIsHandbrakeOn && !bHandbrakeOnLastFrame || lostTraction && !bLostTractionLastFrame)
|
||||||
&& wheelsOnGround != 0) {
|
&& wheelsOnGround != 0) {
|
||||||
*gasPedalAudioPtr *= 0.6f;
|
*gasPedalAudioPtr *= 0.6f;
|
||||||
}
|
}
|
||||||
freqModifier = 0;
|
freqModifier = 0;
|
||||||
if (engineSoundType != SFX_BANK_GOLF_CART && engineSoundType != SFX_BANK_CAR_CHAINSAW)
|
if (engineSoundType == SFX_BANK_GOLF_CART || engineSoundType == SFX_BANK_CAR_CHAINSAW)
|
||||||
baseFreq = (25000.0f * *gasPedalAudioPtr) + 14000;
|
baseFreq = (15000 * *gasPedalAudioPtr) + 14000;
|
||||||
else
|
else
|
||||||
baseFreq = (15000.0f * *gasPedalAudioPtr) + 14000;
|
baseFreq = (25000 * *gasPedalAudioPtr) + 14000;
|
||||||
vol = (25.0f * *gasPedalAudioPtr) + 60;
|
vol = (25.0f * *gasPedalAudioPtr) + 60;
|
||||||
|
} else {
|
||||||
|
baseFreq = (8000 * accelerationMultipler) + 16000;
|
||||||
|
vol = (25.0f * accelerationMultipler) + 60;
|
||||||
|
*gasPedalAudioPtr = accelerationMultipler;
|
||||||
}
|
}
|
||||||
freq = freqModifier + baseFreq;
|
freq = freqModifier + baseFreq;
|
||||||
if (engineSoundType == SFX_BANK_TRUCK)
|
if (engineSoundType == SFX_BANK_TRUCK)
|
||||||
freq /= 2;
|
freq >>= 1;
|
||||||
if (channelUsed) {
|
if (channelUsed) {
|
||||||
SampleManager.StopChannel(nChannel);
|
SampleManager.StopChannel(nChannel);
|
||||||
bAccelSampleStopped = TRUE;
|
bAccelSampleStopped = TRUE;
|
||||||
}
|
}
|
||||||
if (params.m_pVehicle->bIsDrowning)
|
if (params.m_pVehicle->bIsDrowning)
|
||||||
vol /= 4;
|
vol >>= 2;
|
||||||
AddPlayerCarSample(vol, freq, aEngineSounds[engineSoundType - CAR_SFX_BANKS_OFFSET][1], SFX_BANK_0, 2, TRUE);
|
AddPlayerCarSample(vol, freq, aEngineSounds[engineSoundType - CAR_SFX_BANKS_OFFSET][1], SFX_BANK_0, 2, TRUE);
|
||||||
} else {
|
} else {
|
||||||
TranslateEntity(&m_sQueueSample.m_vecPos, &pos);
|
TranslateEntity(&m_sQueueSample.m_vecPos, &pos);
|
||||||
@ -2295,16 +2311,18 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CVehicle* veh
|
|||||||
processedAccelSampleStopped = TRUE;
|
processedAccelSampleStopped = TRUE;
|
||||||
bAccelSampleStopped = FALSE;
|
bAccelSampleStopped = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!channelUsed) {
|
if (!channelUsed) {
|
||||||
if (!processedAccelSampleStopped) {
|
if (!processedAccelSampleStopped) {
|
||||||
if (CurrentPretendGear < params.m_pTransmission->nNumberOfGears - 1)
|
if (CurrentPretendGear < params.m_pTransmission->nNumberOfGears - 1)
|
||||||
++CurrentPretendGear;
|
CurrentPretendGear++;
|
||||||
else {
|
else {
|
||||||
nCruising = 1;
|
nCruising = 1;
|
||||||
params.m_pVehicle->bAudioChangingGear = TRUE;
|
params.m_pVehicle->bAudioChangingGear = TRUE;
|
||||||
goto PlayCruising;
|
goto PlayCruising;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gearSoundStartTime = CTimer::GetTimeInMilliseconds();
|
gearSoundStartTime = CTimer::GetTimeInMilliseconds();
|
||||||
params.m_pVehicle->bAudioChangingGear = TRUE;
|
params.m_pVehicle->bAudioChangingGear = TRUE;
|
||||||
#ifdef GTA_PS2
|
#ifdef GTA_PS2
|
||||||
@ -2312,7 +2330,9 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CVehicle* veh
|
|||||||
#else
|
#else
|
||||||
if (!SampleManager.InitialiseChannel(CHANNEL_PLAYER_VEHICLE_ENGINE, soundOffset + SFX_CAR_ACCEL_1, SFX_BANK_0))
|
if (!SampleManager.InitialiseChannel(CHANNEL_PLAYER_VEHICLE_ENGINE, soundOffset + SFX_CAR_ACCEL_1, SFX_BANK_0))
|
||||||
return;
|
return;
|
||||||
|
#endif
|
||||||
SampleManager.SetChannelLoopCount(CHANNEL_PLAYER_VEHICLE_ENGINE, 1);
|
SampleManager.SetChannelLoopCount(CHANNEL_PLAYER_VEHICLE_ENGINE, 1);
|
||||||
|
#ifndef GTA_PS2
|
||||||
SampleManager.SetChannelLoopPoints(CHANNEL_PLAYER_VEHICLE_ENGINE, 0, -1);
|
SampleManager.SetChannelLoopPoints(CHANNEL_PLAYER_VEHICLE_ENGINE, 0, -1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -2327,8 +2347,12 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CVehicle* veh
|
|||||||
#endif
|
#endif
|
||||||
freq = GearFreqAdj[CurrentPretendGear] + freqModifier + 22050;
|
freq = GearFreqAdj[CurrentPretendGear] + freqModifier + 22050;
|
||||||
if (engineSoundType == SFX_BANK_TRUCK)
|
if (engineSoundType == SFX_BANK_TRUCK)
|
||||||
freq /= 2;
|
freq >>= 1;
|
||||||
|
#ifdef USE_TIME_SCALE_FOR_AUDIO
|
||||||
|
SampleManager.SetChannelFrequency(nChannel, freq * CTimer::GetTimeScale());
|
||||||
|
#else
|
||||||
SampleManager.SetChannelFrequency(nChannel, freq);
|
SampleManager.SetChannelFrequency(nChannel, freq);
|
||||||
|
#endif
|
||||||
if (!channelUsed) {
|
if (!channelUsed) {
|
||||||
#ifdef AUDIO_REVERB
|
#ifdef AUDIO_REVERB
|
||||||
SampleManager.SetChannelReverbFlag(nChannel, m_bDynamicAcousticModelingStatus != FALSE);
|
SampleManager.SetChannelReverbFlag(nChannel, m_bDynamicAcousticModelingStatus != FALSE);
|
||||||
@ -2336,30 +2360,11 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CVehicle* veh
|
|||||||
SampleManager.StartChannel(nChannel);
|
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;
|
LastAccel = accelerateState;
|
||||||
|
|
||||||
bHandbrakeOnLastFrame = params.m_pVehicle->bIsHandbrakeOn;
|
bHandbrakeOnLastFrame = !!params.m_pVehicle->bIsHandbrakeOn;
|
||||||
bLostTractionLastFrame = lostTraction;
|
bLostTractionLastFrame = lostTraction;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2406,7 +2411,7 @@ cAudioManager::ProcessVehicleSkidding(cVehicleParams& params)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
CalculateDistance(params.m_bDistanceCalculated, params.m_fDistance);
|
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)
|
if (wheelStateArr[i] == WHEEL_STATE_NORMAL)
|
||||||
continue;
|
continue;
|
||||||
transmission = params.m_pTransmission;
|
transmission = params.m_pTransmission;
|
||||||
@ -2555,7 +2560,7 @@ cAudioManager::ProcessVehicleHorn(cVehicleParams& params)
|
|||||||
if (veh->m_nCarHornTimer == 44)
|
if (veh->m_nCarHornTimer == 44)
|
||||||
veh->m_nCarHornPattern = (m_FrameCounter + m_sQueueSample.m_nEntityIndex) & 7;
|
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;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2730,7 +2735,7 @@ cAudioManager::ProcessVehicleDoors(cVehicleParams& params)
|
|||||||
|
|
||||||
automobile = (CAutomobile *)params.m_pVehicle;
|
automobile = (CAutomobile *)params.m_pVehicle;
|
||||||
CalculateDistance(params.m_bDistanceCalculated, params.m_fDistance);
|
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) {
|
if (automobile->Damage.GetDoorStatus(i) == DOOR_STATUS_SWINGING) {
|
||||||
doorState = automobile->Doors[i].m_nDoorState;
|
doorState = automobile->Doors[i].m_nDoorState;
|
||||||
if (doorState == DOORST_OPEN || doorState == DOORST_CLOSED) {
|
if (doorState == DOORST_OPEN || doorState == DOORST_CLOSED) {
|
||||||
@ -3449,7 +3454,7 @@ cAudioManager::ProcessVehicleOneShots(cVehicleParams& params)
|
|||||||
m_sQueueSample.m_nPriority = 1;
|
m_sQueueSample.m_nPriority = 1;
|
||||||
m_sQueueSample.m_fSpeedMultiplier = 0.0f;
|
m_sQueueSample.m_fSpeedMultiplier = 0.0f;
|
||||||
m_sQueueSample.m_MaxDistance = SOUND_INTENSITY;
|
m_sQueueSample.m_MaxDistance = SOUND_INTENSITY;
|
||||||
++CrunchOffset;
|
CrunchOffset++;
|
||||||
maxDist = SQR(SOUND_INTENSITY);
|
maxDist = SQR(SOUND_INTENSITY);
|
||||||
emittingVol = m_anRandomTable[4] % 20 + 55;
|
emittingVol = m_anRandomTable[4] % 20 + 55;
|
||||||
CrunchOffset %= 2;
|
CrunchOffset %= 2;
|
||||||
@ -4321,7 +4326,7 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms)
|
|||||||
m_sQueueSample.m_nBankIndex = SFX_BANK_0;
|
m_sQueueSample.m_nBankIndex = SFX_BANK_0;
|
||||||
m_sQueueSample.m_nCounter = iSound;
|
m_sQueueSample.m_nCounter = iSound;
|
||||||
narrowSoundRange = TRUE;
|
narrowSoundRange = TRUE;
|
||||||
++iSound;
|
iSound++;
|
||||||
m_sQueueSample.m_nPriority = 3;
|
m_sQueueSample.m_nPriority = 3;
|
||||||
m_sQueueSample.m_fSpeedMultiplier = 0.0f;
|
m_sQueueSample.m_fSpeedMultiplier = 0.0f;
|
||||||
m_sQueueSample.m_MaxDistance = 30.0f;
|
m_sQueueSample.m_MaxDistance = 30.0f;
|
||||||
@ -4966,7 +4971,7 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms)
|
|||||||
m_sQueueSample.m_nBankIndex = SFX_BANK_0;
|
m_sQueueSample.m_nBankIndex = SFX_BANK_0;
|
||||||
m_sQueueSample.m_nCounter = iSound;
|
m_sQueueSample.m_nCounter = iSound;
|
||||||
stereo = TRUE;
|
stereo = TRUE;
|
||||||
++iSound;
|
iSound++;
|
||||||
m_sQueueSample.m_nFrequency = m_anRandomTable[1] % 1000 + 17000;
|
m_sQueueSample.m_nFrequency = m_anRandomTable[1] % 1000 + 17000;
|
||||||
if (param2 == 0)
|
if (param2 == 0)
|
||||||
m_sQueueSample.m_nFrequency = (3 * m_sQueueSample.m_nFrequency) / 4;
|
m_sQueueSample.m_nFrequency = (3 * m_sQueueSample.m_nFrequency) / 4;
|
||||||
@ -5101,15 +5106,14 @@ cAudioManager::ProcessPedOneShots(cPedParams ¶ms)
|
|||||||
AddSampleToRequestedQueue();
|
AddSampleToRequestedQueue();
|
||||||
if (stereo) {
|
if (stereo) {
|
||||||
m_sQueueSample.m_nPan = 127;
|
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 ||
|
if (m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_awAudioEvent[i] != SOUND_WEAPON_SHOT_FIRED ||
|
||||||
weapon->m_eWeaponType != WEAPONTYPE_FLAMETHROWER) {
|
weapon->m_eWeaponType != WEAPONTYPE_FLAMETHROWER) {
|
||||||
m_sQueueSample.m_nCounter = iSound++;
|
m_sQueueSample.m_nCounter = iSound++;
|
||||||
if (iSound > 60)
|
if (iSound > 60)
|
||||||
iSound = 21;
|
iSound = 21;
|
||||||
} else {
|
} else
|
||||||
++m_sQueueSample.m_nCounter;
|
m_sQueueSample.m_nCounter++;
|
||||||
}
|
|
||||||
AddSampleToRequestedQueue();
|
AddSampleToRequestedQueue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -8030,18 +8034,16 @@ cPedComments::Add(tPedComment *com)
|
|||||||
index = m_nIndexMap[m_nActiveBank][NUM_PED_COMMENTS_SLOTS - 1];
|
index = m_nIndexMap[m_nActiveBank][NUM_PED_COMMENTS_SLOTS - 1];
|
||||||
if (m_asPedComments[m_nActiveBank][index].m_nVolume > com->m_nVolume)
|
if (m_asPedComments[m_nActiveBank][index].m_nVolume > com->m_nVolume)
|
||||||
return;
|
return;
|
||||||
} else {
|
} else
|
||||||
index = m_nCommentsInBank[m_nActiveBank]++;
|
index = m_nCommentsInBank[m_nActiveBank]++;
|
||||||
}
|
|
||||||
|
|
||||||
m_asPedComments[m_nActiveBank][index] = *com;
|
m_asPedComments[m_nActiveBank][index] = *com;
|
||||||
|
|
||||||
uint32 i = 0;
|
uint8 i = 0;
|
||||||
if (index != 0) {
|
if (index != 0) {
|
||||||
for (i = 0; i < index; i++) {
|
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;
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i < index)
|
if (i < index)
|
||||||
@ -8057,80 +8059,92 @@ cPedComments::Process()
|
|||||||
uint32 sampleIndex;
|
uint32 sampleIndex;
|
||||||
uint8 actualUsedBank;
|
uint8 actualUsedBank;
|
||||||
tPedComment *comment;
|
tPedComment *comment;
|
||||||
bool8 prevUsed = FALSE;
|
|
||||||
static uint8 counter = 0;
|
static uint8 counter = 0;
|
||||||
static int32 prevSamples[10];
|
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]) {
|
if(m_nCommentsInBank[m_nActiveBank]) {
|
||||||
for(int i = 0; i < ARRAY_SIZE(prevSamples); i++) {
|
for(int i = 0; i < ARRAY_SIZE(prevSamples); i++) {
|
||||||
if(m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nSampleIndex ==
|
if(m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nSampleIndex ==
|
||||||
prevSamples[(counter + 1 + i) % ARRAY_SIZE(prevSamples)]) {
|
prevSamples[(counter + 1 + i) % ARRAY_SIZE(prevSamples)]) {
|
||||||
m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nProcess = -1;
|
m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nProcess = -1;
|
||||||
prevUsed = TRUE;
|
goto PedCommentAlreadyAdded;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!prevUsed) {
|
sampleIndex = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nSampleIndex;
|
||||||
sampleIndex = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nSampleIndex;
|
switch(SampleManager.IsPedCommentLoaded(sampleIndex)) { // yes, this was a switch
|
||||||
if(!SampleManager.IsPedCommentLoaded(sampleIndex)) {
|
case FALSE:
|
||||||
#if defined(GTA_PC) && !defined(FIX_BUGS)
|
#if defined(GTA_PC) && !defined(FIX_BUGS)
|
||||||
if(!m_bDelay)
|
if(!m_bDelay)
|
||||||
#endif
|
#endif
|
||||||
SampleManager.LoadPedComment(sampleIndex);
|
SampleManager.LoadPedComment(sampleIndex);
|
||||||
} else {
|
break;
|
||||||
AudioManager.m_sQueueSample.m_nEntityIndex = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nEntityIndex;
|
case TRUE:
|
||||||
AudioManager.m_sQueueSample.m_nCounter = 0;
|
AudioManager.m_sQueueSample.m_nEntityIndex = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nEntityIndex;
|
||||||
AudioManager.m_sQueueSample.m_nSampleIndex = sampleIndex;
|
AudioManager.m_sQueueSample.m_nCounter = 0;
|
||||||
AudioManager.m_sQueueSample.m_nBankIndex = SFX_BANK_PED_COMMENTS;
|
AudioManager.m_sQueueSample.m_nSampleIndex = sampleIndex;
|
||||||
AudioManager.m_sQueueSample.m_nPriority = 3;
|
AudioManager.m_sQueueSample.m_nBankIndex = SFX_BANK_PED_COMMENTS;
|
||||||
AudioManager.m_sQueueSample.m_nVolume = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nVolume;
|
AudioManager.m_sQueueSample.m_nPriority = 3;
|
||||||
AudioManager.m_sQueueSample.m_fDistance = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_fDistance;
|
AudioManager.m_sQueueSample.m_nVolume = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nVolume;
|
||||||
AudioManager.m_sQueueSample.m_nLoopCount = 1;
|
AudioManager.m_sQueueSample.m_fDistance = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_fDistance;
|
||||||
|
AudioManager.m_sQueueSample.m_nLoopCount = 1;
|
||||||
#ifndef GTA_PS2
|
#ifndef GTA_PS2
|
||||||
AudioManager.m_sQueueSample.m_nLoopStart = 0;
|
AudioManager.m_sQueueSample.m_nLoopStart = 0;
|
||||||
AudioManager.m_sQueueSample.m_nLoopEnd = -1;
|
AudioManager.m_sQueueSample.m_nLoopEnd = -1;
|
||||||
#endif
|
#endif
|
||||||
#ifdef EXTERNAL_3D_SOUND
|
#ifdef EXTERNAL_3D_SOUND
|
||||||
#ifdef FIX_BUGS
|
#ifdef FIX_BUGS
|
||||||
AudioManager.m_sQueueSample.m_nEmittingVolume = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nEmittingVolume;
|
AudioManager.m_sQueueSample.m_nEmittingVolume = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nEmittingVolume;
|
||||||
#else
|
#else
|
||||||
AudioManager.m_sQueueSample.m_nEmittingVolume = MAX_VOLUME;
|
AudioManager.m_sQueueSample.m_nEmittingVolume = MAX_VOLUME;
|
||||||
#endif // FIX_BUGS
|
#endif // FIX_BUGS
|
||||||
#endif // EXTERNAL_3D_SOUND
|
#endif // EXTERNAL_3D_SOUND
|
||||||
AudioManager.m_sQueueSample.m_fSpeedMultiplier = 3.0f;
|
#ifdef ATTACH_RELEASING_SOUNDS_TO_ENTITIES
|
||||||
AudioManager.m_sQueueSample.m_MaxDistance = 40.0f;
|
// let's disable doppler because if sounds funny as the sound moves
|
||||||
AudioManager.m_sQueueSample.m_bStatic = TRUE;
|
// originally position of ped comment doesn't change so this has no effect anyway
|
||||||
AudioManager.m_sQueueSample.m_vecPos = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_vecPos;
|
AudioManager.m_sQueueSample.m_fSpeedMultiplier = 0.0f;
|
||||||
|
#else
|
||||||
|
AudioManager.m_sQueueSample.m_fSpeedMultiplier = 3.0f;
|
||||||
|
#endif
|
||||||
|
AudioManager.m_sQueueSample.m_MaxDistance = 40.0f;
|
||||||
|
AudioManager.m_sQueueSample.m_bStatic = TRUE;
|
||||||
|
AudioManager.m_sQueueSample.m_vecPos = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_vecPos;
|
||||||
#ifdef AUDIO_REVERB
|
#ifdef AUDIO_REVERB
|
||||||
AudioManager.m_sQueueSample.m_bReverb = TRUE;
|
AudioManager.m_sQueueSample.m_bReverb = TRUE;
|
||||||
#endif // AUDIO_REVERB
|
#endif // AUDIO_REVERB
|
||||||
#ifdef AUDIO_REFLECTIONS
|
#ifdef AUDIO_REFLECTIONS
|
||||||
AudioManager.m_sQueueSample.m_bReflections = TRUE;
|
AudioManager.m_sQueueSample.m_bReflections = TRUE;
|
||||||
#endif // AUDIO_REFLECTIONS
|
#endif // AUDIO_REFLECTIONS
|
||||||
AudioManager.m_sQueueSample.m_bIs2D = FALSE;
|
AudioManager.m_sQueueSample.m_bIs2D = FALSE;
|
||||||
#ifdef FIX_BUGS
|
#ifdef FIX_BUGS
|
||||||
if (sampleIndex >= SFX_TONI_ANGRY_BUSTED_01 && sampleIndex <= SFX_TONI_WISECRACKING_SHOOT_26) { // check if player sfx
|
#ifndef ATTACH_RELEASING_SOUNDS_TO_ENTITIES
|
||||||
AudioManager.m_sQueueSample.m_bIs2D = TRUE;
|
else if (sampleIndex >= SFX_TONI_ANGRY_BUSTED_01 && sampleIndex <= SFX_TONI_WISECRACKING_SHOOT_26) { // check if player sfx
|
||||||
AudioManager.m_sQueueSample.m_nPan = 63;
|
AudioManager.m_sQueueSample.m_bIs2D = TRUE;
|
||||||
}
|
AudioManager.m_sQueueSample.m_nPan = 63;
|
||||||
#endif // FIX_BUGS
|
|
||||||
AudioManager.m_sQueueSample.m_nFrequency =
|
|
||||||
SampleManager.GetSampleBaseFrequency(AudioManager.m_sQueueSample.m_nSampleIndex) + AudioManager.RandomDisplacement(750);
|
|
||||||
if(CTimer::GetIsSlowMotionActive()) AudioManager.m_sQueueSample.m_nFrequency /= 2;
|
|
||||||
m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nProcess = -1;
|
|
||||||
prevSamples[counter++] = sampleIndex;
|
|
||||||
if(counter == 10) counter = 0;
|
|
||||||
AudioManager.AddSampleToRequestedQueue();
|
|
||||||
#if defined(GTA_PC) && !defined(FIX_BUGS)
|
|
||||||
m_nDelayTimer = CTimer::GetTimeInMilliseconds();
|
|
||||||
m_bDelay = TRUE;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif // ATTACH_RELEASING_SOUNDS_TO_ENTITIES
|
||||||
|
#endif // FIX_BUGS
|
||||||
|
AudioManager.m_sQueueSample.m_nFrequency =
|
||||||
|
SampleManager.GetSampleBaseFrequency(AudioManager.m_sQueueSample.m_nSampleIndex) + AudioManager.RandomDisplacement(750);
|
||||||
|
#ifndef USE_TIME_SCALE_FOR_AUDIO
|
||||||
|
if (CTimer::GetIsSlowMotionActive())
|
||||||
|
AudioManager.m_sQueueSample.m_nFrequency >>= 1;
|
||||||
|
#endif
|
||||||
|
m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nProcess = -1;
|
||||||
|
prevSamples[counter++] = sampleIndex;
|
||||||
|
if(counter == 10) counter = 0;
|
||||||
|
AudioManager.AddSampleToRequestedQueue();
|
||||||
|
#if defined(GTA_PC) && !defined(FIX_BUGS)
|
||||||
|
m_nDelayTimer = CTimer::GetTimeInMilliseconds();
|
||||||
|
m_bDelay = TRUE;
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
PedCommentAlreadyAdded:
|
||||||
// Switch bank
|
// Switch bank
|
||||||
if (m_nActiveBank == 0) {
|
if (m_nActiveBank == 0) {
|
||||||
actualUsedBank = 0;
|
actualUsedBank = 0;
|
||||||
@ -8142,7 +8156,7 @@ cPedComments::Process()
|
|||||||
comment = m_asPedComments[actualUsedBank];
|
comment = m_asPedComments[actualUsedBank];
|
||||||
for (uint32 i = 0; i < m_nCommentsInBank[actualUsedBank]; i++) {
|
for (uint32 i = 0; i < m_nCommentsInBank[actualUsedBank]; i++) {
|
||||||
if (m_asPedComments[actualUsedBank][m_nIndexMap[actualUsedBank][i]].m_nProcess > 0) {
|
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]]);
|
Add(&comment[m_nIndexMap[actualUsedBank][i]]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -8331,7 +8345,7 @@ cAudioManager::ProcessWaterCannon(int32)
|
|||||||
{
|
{
|
||||||
const float SOUND_INTENSITY = 30.0f;
|
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) {
|
if (CWaterCannons::aCannons[i].m_nId) {
|
||||||
m_sQueueSample.m_vecPos = CWaterCannons::aCannons[0].m_avecPos[CWaterCannons::aCannons[i].m_nCur];
|
m_sQueueSample.m_vecPos = CWaterCannons::aCannons[0].m_avecPos[CWaterCannons::aCannons[i].m_nCur];
|
||||||
float distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos);
|
float distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos);
|
||||||
@ -9156,13 +9170,13 @@ cAudioManager::ProcessFrontEnd()
|
|||||||
SET_SOUND_REFLECTION(FALSE);
|
SET_SOUND_REFLECTION(FALSE);
|
||||||
AddSampleToRequestedQueue();
|
AddSampleToRequestedQueue();
|
||||||
if (stereo) {
|
if (stereo) {
|
||||||
++m_sQueueSample.m_nSampleIndex;
|
m_sQueueSample.m_nSampleIndex++;
|
||||||
m_sQueueSample.m_nCounter = iSound++;
|
m_sQueueSample.m_nCounter = iSound++;
|
||||||
m_sQueueSample.m_nPan = 127 - m_sQueueSample.m_nPan;
|
m_sQueueSample.m_nPan = 127 - m_sQueueSample.m_nPan;
|
||||||
AddSampleToRequestedQueue();
|
AddSampleToRequestedQueue();
|
||||||
}
|
}
|
||||||
if (center) {
|
if (center) {
|
||||||
++m_sQueueSample.m_nSampleIndex;
|
m_sQueueSample.m_nSampleIndex++;
|
||||||
m_sQueueSample.m_nCounter = iSound++;
|
m_sQueueSample.m_nCounter = iSound++;
|
||||||
m_sQueueSample.m_nPan = 63;
|
m_sQueueSample.m_nPan = 63;
|
||||||
m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex);
|
m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex);
|
||||||
@ -9227,7 +9241,7 @@ cAudioManager::ProcessProjectiles()
|
|||||||
uint8 emittingVol;
|
uint8 emittingVol;
|
||||||
float distSquared;
|
float distSquared;
|
||||||
|
|
||||||
for (int32 i = 0; i < NUM_PROJECTILES; i++) {
|
for (uint8 i = 0; i < NUM_PROJECTILES; i++) {
|
||||||
if (CProjectileInfo::GetProjectileInfo(i)->m_bInUse) {
|
if (CProjectileInfo::GetProjectileInfo(i)->m_bInUse) {
|
||||||
switch (CProjectileInfo::GetProjectileInfo(i)->m_eWeaponType) {
|
switch (CProjectileInfo::GetProjectileInfo(i)->m_eWeaponType) {
|
||||||
case WEAPONTYPE_TEARGAS:
|
case WEAPONTYPE_TEARGAS:
|
||||||
@ -9371,7 +9385,11 @@ cAudioManager::ProcessGarages()
|
|||||||
|
|
||||||
static uint8 iSound = 32;
|
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)
|
if (CGarages::aGarages[i].m_eGarageType == GARAGE_NONE)
|
||||||
continue;
|
continue;
|
||||||
entity = CGarages::aGarages[i].m_pDoor1;
|
entity = CGarages::aGarages[i].m_pDoor1;
|
||||||
@ -9436,7 +9454,7 @@ cAudioManager::ProcessGarages()
|
|||||||
break;
|
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]) {
|
switch (m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_awAudioEvent[j]) {
|
||||||
case SOUND_GARAGE_DOOR_CLOSED:
|
case SOUND_GARAGE_DOOR_CLOSED:
|
||||||
case SOUND_GARAGE_DOOR_OPENED:
|
case SOUND_GARAGE_DOOR_OPENED:
|
||||||
@ -11515,7 +11533,7 @@ const MissionAudioData MissionAudioNameSfxAssoc[] = {
|
|||||||
int32
|
int32
|
||||||
FindMissionAudioSfx(const char *name)
|
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))
|
if (!CGeneral::faststricmp(MissionAudioNameSfxAssoc[i].m_pName, name))
|
||||||
return MissionAudioNameSfxAssoc[i].m_nId;
|
return MissionAudioNameSfxAssoc[i].m_nId;
|
||||||
}
|
}
|
||||||
@ -11527,7 +11545,7 @@ const char *
|
|||||||
cAudioManager::GetMissionAudioLoadedLabel(uint8 slot)
|
cAudioManager::GetMissionAudioLoadedLabel(uint8 slot)
|
||||||
{
|
{
|
||||||
if (m_bIsInitialised && slot < MISSION_AUDIO_SLOTS && m_nMissionAudioSampleIndex[slot] != NO_SAMPLE) {
|
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)
|
if (m_nMissionAudioSampleIndex[slot] == MissionAudioNameSfxAssoc[i].m_nId)
|
||||||
return MissionAudioNameSfxAssoc[i].m_pName;
|
return MissionAudioNameSfxAssoc[i].m_pName;
|
||||||
}
|
}
|
||||||
@ -11681,7 +11699,7 @@ cAudioManager::ProcessMissionAudioSlot(uint8 slot)
|
|||||||
nFramesForPretendPlaying[slot] = 0;
|
nFramesForPretendPlaying[slot] = 0;
|
||||||
nCheckPlayingDelay[slot] = 0;
|
nCheckPlayingDelay[slot] = 0;
|
||||||
nFramesUntilFailedLoad[slot] = 0;
|
nFramesUntilFailedLoad[slot] = 0;
|
||||||
} else if (!m_nUserPause) {
|
} else if (!m_bIsPaused) {
|
||||||
if (++nFramesForPretendPlaying[slot] < 90) {
|
if (++nFramesForPretendPlaying[slot] < 90) {
|
||||||
m_nMissionAudioPlayStatus[slot] = PLAY_STATUS_PLAYING;
|
m_nMissionAudioPlayStatus[slot] = PLAY_STATUS_PLAYING;
|
||||||
} else {
|
} else {
|
||||||
@ -11697,7 +11715,7 @@ cAudioManager::ProcessMissionAudioSlot(uint8 slot)
|
|||||||
SetMissionScriptPoliceAudio(m_nMissionAudioSampleIndex[slot]);
|
SetMissionScriptPoliceAudio(m_nMissionAudioSampleIndex[slot]);
|
||||||
} else {
|
} else {
|
||||||
SampleManager.InitialiseChannel(slot + CHANNEL_MISSION_AUDIO_1, m_nMissionAudioSampleIndex[slot], SFX_BANK_PED_COMMENTS);
|
SampleManager.InitialiseChannel(slot + CHANNEL_MISSION_AUDIO_1, m_nMissionAudioSampleIndex[slot], SFX_BANK_PED_COMMENTS);
|
||||||
if(m_nUserPause)
|
if (m_bIsPaused)
|
||||||
SampleManager.SetChannelFrequency(slot + CHANNEL_MISSION_AUDIO_1, 0);
|
SampleManager.SetChannelFrequency(slot + CHANNEL_MISSION_AUDIO_1, 0);
|
||||||
else
|
else
|
||||||
SampleManager.SetChannelFrequency(slot + CHANNEL_MISSION_AUDIO_1, SampleManager.GetSampleBaseFrequency(m_nMissionAudioSampleIndex[slot]));
|
SampleManager.SetChannelFrequency(slot + CHANNEL_MISSION_AUDIO_1, SampleManager.GetSampleBaseFrequency(m_nMissionAudioSampleIndex[slot]));
|
||||||
@ -11740,7 +11758,7 @@ cAudioManager::ProcessMissionAudioSlot(uint8 slot)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (MissionScriptAudioUsesPoliceChannel(m_nMissionAudioSampleIndex[slot])) {
|
if (MissionScriptAudioUsesPoliceChannel(m_nMissionAudioSampleIndex[slot])) {
|
||||||
if (!m_nUserPause) {
|
if (!m_bIsPaused) {
|
||||||
if (nCheckPlayingDelay[slot]) {
|
if (nCheckPlayingDelay[slot]) {
|
||||||
--nCheckPlayingDelay[slot];
|
--nCheckPlayingDelay[slot];
|
||||||
} else if ((g_bMissionAudioLoadFailed[slot] && m_nMissionAudioFramesToPlay[slot]-- == 0) || GetMissionScriptPoliceAudioPlayingStatus() == PLAY_STATUS_FINISHED) {
|
} else if ((g_bMissionAudioLoadFailed[slot] && m_nMissionAudioFramesToPlay[slot]-- == 0) || GetMissionScriptPoliceAudioPlayingStatus() == PLAY_STATUS_FINISHED) {
|
||||||
@ -11753,8 +11771,8 @@ cAudioManager::ProcessMissionAudioSlot(uint8 slot)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (m_bIsMissionAudioPlaying[slot]) {
|
} else if (m_bIsMissionAudioPlaying[slot]) {
|
||||||
if(SampleManager.GetChannelUsedFlag(slot + CHANNEL_MISSION_AUDIO_1) || m_nUserPause || m_nPreviousUserPause) {
|
if (SampleManager.GetChannelUsedFlag(slot + CHANNEL_MISSION_AUDIO_1) || m_bIsPaused || m_bWasPaused) {
|
||||||
if(m_nUserPause)
|
if (m_bIsPaused)
|
||||||
SampleManager.SetChannelFrequency(slot + CHANNEL_MISSION_AUDIO_1, 0);
|
SampleManager.SetChannelFrequency(slot + CHANNEL_MISSION_AUDIO_1, 0);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -11784,7 +11802,7 @@ cAudioManager::ProcessMissionAudioSlot(uint8 slot)
|
|||||||
m_nMissionAudioFramesToPlay[slot] = 0;
|
m_nMissionAudioFramesToPlay[slot] = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (m_nUserPause)
|
if (m_bIsPaused)
|
||||||
break;
|
break;
|
||||||
if (nCheckPlayingDelay[slot]--) {
|
if (nCheckPlayingDelay[slot]--) {
|
||||||
if (!SampleManager.GetChannelUsedFlag(slot + CHANNEL_MISSION_AUDIO_1))
|
if (!SampleManager.GetChannelUsedFlag(slot + CHANNEL_MISSION_AUDIO_1))
|
||||||
|
@ -25,9 +25,9 @@ cAudioManager::cAudioManager()
|
|||||||
m_fSpeedOfSound = SPEED_OF_SOUND / TIME_SPENT;
|
m_fSpeedOfSound = SPEED_OF_SOUND / TIME_SPENT;
|
||||||
m_nTimeSpent = TIME_SPENT;
|
m_nTimeSpent = TIME_SPENT;
|
||||||
m_nActiveSamples = NUM_CHANNELS_GENERIC;
|
m_nActiveSamples = NUM_CHANNELS_GENERIC;
|
||||||
m_nActiveSampleQueue = 1;
|
m_nActiveQueue = 1;
|
||||||
ClearRequestedQueue();
|
ClearRequestedQueue();
|
||||||
m_nActiveSampleQueue = 0;
|
m_nActiveQueue = 0;
|
||||||
ClearRequestedQueue();
|
ClearRequestedQueue();
|
||||||
ClearActiveSamples();
|
ClearActiveSamples();
|
||||||
GenerateIntegerRandomNumberTable();
|
GenerateIntegerRandomNumberTable();
|
||||||
@ -36,11 +36,11 @@ cAudioManager::cAudioManager()
|
|||||||
m_bDynamicAcousticModelingStatus = TRUE;
|
m_bDynamicAcousticModelingStatus = TRUE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (int i = 0; i < NUM_AUDIOENTITIES; i++) {
|
for (uint32 i = 0; i < NUM_AUDIOENTITIES; i++) {
|
||||||
m_asAudioEntities[i].m_bIsUsed = FALSE;
|
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_FrameCounter = 0;
|
||||||
m_bReduceReleasingPriority = FALSE;
|
m_bReduceReleasingPriority = FALSE;
|
||||||
m_bTimerJustReset = FALSE;
|
m_bTimerJustReset = FALSE;
|
||||||
@ -65,7 +65,7 @@ cAudioManager::Initialise()
|
|||||||
if (m_nActiveSamples <= 1) {
|
if (m_nActiveSamples <= 1) {
|
||||||
Terminate();
|
Terminate();
|
||||||
} else {
|
} else {
|
||||||
--m_nActiveSamples;
|
m_nActiveSamples--;
|
||||||
#else
|
#else
|
||||||
{
|
{
|
||||||
m_nActiveSamples = NUM_CHANNELS_GENERIC;
|
m_nActiveSamples = NUM_CHANNELS_GENERIC;
|
||||||
@ -87,10 +87,10 @@ cAudioManager::Terminate()
|
|||||||
|
|
||||||
for (uint32 i = 0; i < NUM_AUDIOENTITIES; i++) {
|
for (uint32 i = 0; i < NUM_AUDIOENTITIES; i++) {
|
||||||
m_asAudioEntities[i].m_bIsUsed = FALSE;
|
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;
|
m_sAudioScriptObjectManager.m_nScriptObjectEntityTotal = 0;
|
||||||
PreTerminateGameSpecificShutdown();
|
PreTerminateGameSpecificShutdown();
|
||||||
|
|
||||||
@ -116,8 +116,8 @@ cAudioManager::Service()
|
|||||||
m_bTimerJustReset = FALSE;
|
m_bTimerJustReset = FALSE;
|
||||||
}
|
}
|
||||||
if (m_bIsInitialised) {
|
if (m_bIsInitialised) {
|
||||||
m_nPreviousUserPause = m_nUserPause;
|
m_bWasPaused = m_bIsPaused;
|
||||||
m_nUserPause = CTimer::GetIsUserPaused();
|
m_bIsPaused = CTimer::GetIsUserPaused();
|
||||||
#ifdef AUDIO_REFLECTIONS
|
#ifdef AUDIO_REFLECTIONS
|
||||||
UpdateReflections();
|
UpdateReflections();
|
||||||
#endif
|
#endif
|
||||||
@ -135,8 +135,47 @@ cAudioManager::CreateEntity(eAudioType type, void *entity)
|
|||||||
return AEHANDLE_ERROR_NOENTITY;
|
return AEHANDLE_ERROR_NOENTITY;
|
||||||
if (type >= TOTAL_AUDIO_TYPES)
|
if (type >= TOTAL_AUDIO_TYPES)
|
||||||
return AEHANDLE_ERROR_BADAUDIOTYPE;
|
return AEHANDLE_ERROR_BADAUDIOTYPE;
|
||||||
for (uint32 i = 0; i < ARRAY_SIZE(m_asAudioEntities); i++) {
|
|
||||||
|
#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_SOUND_QUEUES];
|
||||||
|
uint32 stillUsedEntitiesCount = 0;
|
||||||
|
|
||||||
|
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;
|
||||||
|
for (uint8 k = 0; k < stillUsedEntitiesCount; k++) {
|
||||||
|
if (stillUsedEntities[k] == sound.m_nEntityIndex) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found)
|
||||||
|
stillUsedEntities[stillUsedEntitiesCount++] = sound.m_nEntityIndex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (uint32 i = 0; i < NUM_AUDIOENTITIES; i++) {
|
||||||
if (!m_asAudioEntities[i].m_bIsUsed) {
|
if (!m_asAudioEntities[i].m_bIsUsed) {
|
||||||
|
#ifdef FIX_BUGS
|
||||||
|
// skip if ID is still used by queued sample
|
||||||
|
bool skip = false;
|
||||||
|
for (uint8 j = 0; j < stillUsedEntitiesCount; j++) {
|
||||||
|
if (stillUsedEntities[j] == i) {
|
||||||
|
//debug("audio entity %i still used, skipping\n", i);
|
||||||
|
skip = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (skip)
|
||||||
|
continue;
|
||||||
|
#endif
|
||||||
|
|
||||||
m_asAudioEntities[i].m_bIsUsed = TRUE;
|
m_asAudioEntities[i].m_bIsUsed = TRUE;
|
||||||
m_asAudioEntities[i].m_bStatus = FALSE;
|
m_asAudioEntities[i].m_bStatus = FALSE;
|
||||||
m_asAudioEntities[i].m_nType = type;
|
m_asAudioEntities[i].m_nType = type;
|
||||||
@ -146,7 +185,7 @@ cAudioManager::CreateEntity(eAudioType type, void *entity)
|
|||||||
m_asAudioEntities[i].m_awAudioEvent[2] = SOUND_NO_SOUND;
|
m_asAudioEntities[i].m_awAudioEvent[2] = SOUND_NO_SOUND;
|
||||||
m_asAudioEntities[i].m_awAudioEvent[3] = SOUND_NO_SOUND;
|
m_asAudioEntities[i].m_awAudioEvent[3] = SOUND_NO_SOUND;
|
||||||
m_asAudioEntities[i].m_AudioEvents = 0;
|
m_asAudioEntities[i].m_AudioEvents = 0;
|
||||||
m_anAudioEntityIndices[m_nAudioEntitiesTotal++] = i;
|
m_aAudioEntityOrderList[m_nAudioEntitiesCount++] = i;
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -158,11 +197,11 @@ cAudioManager::DestroyEntity(int32 id)
|
|||||||
{
|
{
|
||||||
if (m_bIsInitialised && id >= 0 && id < NUM_AUDIOENTITIES && m_asAudioEntities[id].m_bIsUsed) {
|
if (m_bIsInitialised && id >= 0 && id < NUM_AUDIOENTITIES && m_asAudioEntities[id].m_bIsUsed) {
|
||||||
m_asAudioEntities[id].m_bIsUsed = FALSE;
|
m_asAudioEntities[id].m_bIsUsed = FALSE;
|
||||||
for (int32 i = 0; i < m_nAudioEntitiesTotal; ++i) {
|
for (uint32 i = 0; i < m_nAudioEntitiesCount; ++i) {
|
||||||
if (id == m_anAudioEntityIndices[i]) {
|
if (id == m_aAudioEntityOrderList[i]) {
|
||||||
if (i < NUM_AUDIOENTITIES - 1)
|
if (i < NUM_AUDIOENTITIES - 1)
|
||||||
memmove(&m_anAudioEntityIndices[i], &m_anAudioEntityIndices[i + 1], NUM_AUDIOENTITY_EVENTS * (m_nAudioEntitiesTotal - (i + 1)));
|
memmove(&m_aAudioEntityOrderList[i], &m_aAudioEntityOrderList[i + 1], NUM_AUDIOENTITY_EVENTS * (m_nAudioEntitiesCount - (i + 1)));
|
||||||
m_anAudioEntityIndices[--m_nAudioEntitiesTotal] = NUM_AUDIOENTITIES;
|
m_aAudioEntityOrderList[--m_nAudioEntitiesCount] = NUM_AUDIOENTITIES;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -219,13 +258,13 @@ cAudioManager::PlayOneShot(int32 index, uint16 sound, float vol)
|
|||||||
if (entity.m_AudioEvents < ARRAY_SIZE(entity.m_awAudioEvent)) {
|
if (entity.m_AudioEvents < ARRAY_SIZE(entity.m_awAudioEvent)) {
|
||||||
entity.m_awAudioEvent[i] = sound;
|
entity.m_awAudioEvent[i] = sound;
|
||||||
entity.m_afVolume[i] = vol;
|
entity.m_afVolume[i] = vol;
|
||||||
++entity.m_AudioEvents;
|
entity.m_AudioEvents++;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (OneShotPriority[entity.m_awAudioEvent[i]] > OneShotPriority[sound])
|
if (OneShotPriority[entity.m_awAudioEvent[i]] > OneShotPriority[sound])
|
||||||
break;
|
break;
|
||||||
++i;
|
i++;
|
||||||
}
|
}
|
||||||
if (i < NUM_AUDIOENTITY_EVENTS - 1) {
|
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);
|
memmove(&entity.m_awAudioEvent[i + 1], &entity.m_awAudioEvent[i], (NUM_AUDIOENTITY_EVENTS - 1 - i) * NUM_AUDIOENTITY_EVENTS / 2);
|
||||||
@ -234,7 +273,7 @@ cAudioManager::PlayOneShot(int32 index, uint16 sound, float vol)
|
|||||||
entity.m_awAudioEvent[i] = sound;
|
entity.m_awAudioEvent[i] = sound;
|
||||||
entity.m_afVolume[i] = vol;
|
entity.m_afVolume[i] = vol;
|
||||||
if (entity.m_AudioEvents < ARRAY_SIZE(entity.m_awAudioEvent))
|
if (entity.m_AudioEvents < ARRAY_SIZE(entity.m_awAudioEvent))
|
||||||
++entity.m_AudioEvents;
|
entity.m_AudioEvents++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -285,14 +324,14 @@ cAudioManager::ResetTimers(uint32 time)
|
|||||||
m_bTimerJustReset = TRUE;
|
m_bTimerJustReset = TRUE;
|
||||||
m_nTimer = time;
|
m_nTimer = time;
|
||||||
ClearRequestedQueue();
|
ClearRequestedQueue();
|
||||||
if (m_nActiveSampleQueue) {
|
if (m_nActiveQueue) {
|
||||||
m_nActiveSampleQueue = 0;
|
m_nActiveQueue = 0;
|
||||||
ClearRequestedQueue();
|
ClearRequestedQueue();
|
||||||
m_nActiveSampleQueue = 1;
|
m_nActiveQueue = 1;
|
||||||
} else {
|
} else {
|
||||||
m_nActiveSampleQueue = 1;
|
m_nActiveQueue = 1;
|
||||||
ClearRequestedQueue();
|
ClearRequestedQueue();
|
||||||
m_nActiveSampleQueue = 0;
|
m_nActiveQueue = 0;
|
||||||
}
|
}
|
||||||
ClearActiveSamples();
|
ClearActiveSamples();
|
||||||
ClearMissionAudio(0);
|
ClearMissionAudio(0);
|
||||||
@ -316,7 +355,7 @@ cAudioManager::DestroyAllGameCreatedEntities()
|
|||||||
cAudioScriptObject *entity;
|
cAudioScriptObject *entity;
|
||||||
|
|
||||||
if (m_bIsInitialised) {
|
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) {
|
if (m_asAudioEntities[i].m_bIsUsed) {
|
||||||
switch (m_asAudioEntities[i].m_nType) {
|
switch (m_asAudioEntities[i].m_nType) {
|
||||||
case AUDIOTYPE_PHYSICAL:
|
case AUDIOTYPE_PHYSICAL:
|
||||||
@ -405,20 +444,20 @@ cAudioManager::SetCurrent3DProvider(uint8 which)
|
|||||||
#else
|
#else
|
||||||
if (!m_bIsInitialised)
|
if (!m_bIsInitialised)
|
||||||
return -1;
|
return -1;
|
||||||
for (uint8 i = 0; i < m_nActiveSamples + 1; ++i)
|
for (uint8 i = 0; i < m_nActiveSamples + 1; i++)
|
||||||
SampleManager.StopChannel(i);
|
SampleManager.StopChannel(i);
|
||||||
ClearRequestedQueue();
|
ClearRequestedQueue();
|
||||||
if (m_nActiveSampleQueue == 0)
|
if (m_nActiveQueue == 0)
|
||||||
m_nActiveSampleQueue = 1;
|
m_nActiveQueue = 1;
|
||||||
else
|
else
|
||||||
m_nActiveSampleQueue = 0;
|
m_nActiveQueue = 0;
|
||||||
ClearRequestedQueue();
|
ClearRequestedQueue();
|
||||||
ClearActiveSamples();
|
ClearActiveSamples();
|
||||||
int8 current = SampleManager.SetCurrent3DProvider(which);
|
int8 current = SampleManager.SetCurrent3DProvider(which);
|
||||||
if (current > 0) {
|
if (current > 0) {
|
||||||
m_nActiveSamples = SampleManager.GetMaximumSupportedChannels();
|
m_nActiveSamples = SampleManager.GetMaximumSupportedChannels();
|
||||||
if (m_nActiveSamples > 1)
|
if (m_nActiveSamples > 1)
|
||||||
--m_nActiveSamples;
|
m_nActiveSamples--;
|
||||||
}
|
}
|
||||||
return current;
|
return current;
|
||||||
#endif
|
#endif
|
||||||
@ -494,7 +533,7 @@ cAudioManager::ServiceSoundEffects()
|
|||||||
if(CTimer::GetLogicalFramesPassed() != 0)
|
if(CTimer::GetLogicalFramesPassed() != 0)
|
||||||
#endif
|
#endif
|
||||||
m_bReduceReleasingPriority = (m_FrameCounter++ % 5) == 0;
|
m_bReduceReleasingPriority = (m_FrameCounter++ % 5) == 0;
|
||||||
if (m_nUserPause && !m_nPreviousUserPause) {
|
if (m_bIsPaused && !m_bWasPaused) {
|
||||||
for (uint32 i = 0; i < NUM_CHANNELS_GENERIC; i++)
|
for (uint32 i = 0; i < NUM_CHANNELS_GENERIC; i++)
|
||||||
SampleManager.StopChannel(i);
|
SampleManager.StopChannel(i);
|
||||||
SampleManager.SetChannelFrequency(CHANNEL_POLICE_RADIO, 0);
|
SampleManager.SetChannelFrequency(CHANNEL_POLICE_RADIO, 0);
|
||||||
@ -508,31 +547,31 @@ cAudioManager::ServiceSoundEffects()
|
|||||||
SampleManager.StopChannel(missionAudioChannel+1);
|
SampleManager.StopChannel(missionAudioChannel+1);
|
||||||
#endif
|
#endif
|
||||||
ClearRequestedQueue();
|
ClearRequestedQueue();
|
||||||
if (m_nActiveSampleQueue) {
|
if (m_nActiveQueue) {
|
||||||
m_nActiveSampleQueue = 0;
|
m_nActiveQueue = 0;
|
||||||
ClearRequestedQueue();
|
ClearRequestedQueue();
|
||||||
m_nActiveSampleQueue = 1;
|
m_nActiveQueue = 1;
|
||||||
} else {
|
} else {
|
||||||
m_nActiveSampleQueue = 1;
|
m_nActiveQueue = 1;
|
||||||
ClearRequestedQueue();
|
ClearRequestedQueue();
|
||||||
m_nActiveSampleQueue = 0;
|
m_nActiveQueue = 0;
|
||||||
}
|
}
|
||||||
ClearActiveSamples();
|
ClearActiveSamples();
|
||||||
}
|
}
|
||||||
m_nActiveSampleQueue = m_nActiveSampleQueue == 1 ? 0 : 1;
|
m_nActiveQueue = m_nActiveQueue == 1 ? 0 : 1;
|
||||||
#ifdef AUDIO_REVERB
|
#ifdef AUDIO_REVERB
|
||||||
if(m_bIsSurround) ProcessReverb();
|
if(m_bIsSurround) ProcessReverb();
|
||||||
#endif
|
#endif
|
||||||
ProcessSpecial();
|
ProcessSpecial();
|
||||||
ClearRequestedQueue();
|
ClearRequestedQueue();
|
||||||
InterrogateAudioEntities();
|
InterrogateAudioEntities();
|
||||||
if (!m_nUserPause) {
|
if (!m_bIsPaused) {
|
||||||
m_sPedComments.Process();
|
m_sPedComments.Process();
|
||||||
//ServicePoliceRadio(); // LCS: removed
|
//ServicePoliceRadio(); // LCS: removed
|
||||||
ServiceCollisions();
|
ServiceCollisions();
|
||||||
}
|
}
|
||||||
AddReleasingSounds();
|
AddReleasingSounds();
|
||||||
if (!m_nUserPause)
|
if (!m_bIsPaused)
|
||||||
ProcessMissionAudio();
|
ProcessMissionAudio();
|
||||||
#ifdef EXTERNAL_3D_SOUND
|
#ifdef EXTERNAL_3D_SOUND
|
||||||
AdjustSamplesVolume();
|
AdjustSamplesVolume();
|
||||||
@ -541,7 +580,7 @@ cAudioManager::ServiceSoundEffects()
|
|||||||
#ifdef AUDIO_OAL
|
#ifdef AUDIO_OAL
|
||||||
SampleManager.Service();
|
SampleManager.Service();
|
||||||
#endif
|
#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;
|
cAudioScriptObject *object = (cAudioScriptObject *)m_asAudioEntities[m_sAudioScriptObjectManager.m_anScriptObjectEntityIndices[i]].m_pEntity;
|
||||||
delete object;
|
delete object;
|
||||||
m_asAudioEntities[m_sAudioScriptObjectManager.m_anScriptObjectEntityIndices[i]].m_pEntity = nil;
|
m_asAudioEntities[m_sAudioScriptObjectManager.m_anScriptObjectEntityIndices[i]].m_pEntity = nil;
|
||||||
@ -641,9 +680,9 @@ cAudioManager::RandomDisplacement(uint32 seed)
|
|||||||
void
|
void
|
||||||
cAudioManager::InterrogateAudioEntities()
|
cAudioManager::InterrogateAudioEntities()
|
||||||
{
|
{
|
||||||
for (int32 i = 0; i < m_nAudioEntitiesTotal; i++) {
|
for (uint32 i = 0; i < m_nAudioEntitiesCount; i++) {
|
||||||
ProcessEntity(m_anAudioEntityIndices[i]);
|
ProcessEntity(m_aAudioEntityOrderList[i]);
|
||||||
m_asAudioEntities[m_anAudioEntityIndices[i]].m_AudioEvents = 0;
|
m_asAudioEntities[m_aAudioEntityOrderList[i]].m_AudioEvents = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -658,14 +697,13 @@ cAudioManager::AddSampleToRequestedQueue()
|
|||||||
|
|
||||||
if (m_sQueueSample.m_nSampleIndex < TOTAL_AUDIO_SAMPLES) {
|
if (m_sQueueSample.m_nSampleIndex < TOTAL_AUDIO_SAMPLES) {
|
||||||
finalPriority = m_sQueueSample.m_nPriority * (MAX_VOLUME - m_sQueueSample.m_nVolume);
|
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) {
|
if (sampleIndex >= m_nActiveSamples) {
|
||||||
sampleIndex = m_abSampleQueueIndexTable[m_nActiveSampleQueue][m_nActiveSamples - 1];
|
sampleIndex = m_aRequestedOrderList[m_nActiveQueue][m_nActiveSamples - 1];
|
||||||
if (m_asSamples[m_nActiveSampleQueue][sampleIndex].m_nFinalPriority <= finalPriority)
|
if (m_aRequestedQueue[m_nActiveQueue][sampleIndex].m_nFinalPriority <= finalPriority)
|
||||||
return;
|
return;
|
||||||
} else {
|
} else
|
||||||
++m_SampleRequestQueuesStatus[m_nActiveSampleQueue];
|
m_nRequestedCount[m_nActiveQueue]++;
|
||||||
}
|
|
||||||
m_sQueueSample.m_nFinalPriority = finalPriority;
|
m_sQueueSample.m_nFinalPriority = finalPriority;
|
||||||
m_sQueueSample.m_bIsPlayingFinished = FALSE;
|
m_sQueueSample.m_bIsPlayingFinished = FALSE;
|
||||||
#ifdef AUDIO_REFLECTIONS
|
#ifdef AUDIO_REFLECTIONS
|
||||||
@ -689,7 +727,7 @@ cAudioManager::AddSampleToRequestedQueue()
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_asSamples[m_nActiveSampleQueue][sampleIndex] = m_sQueueSample;
|
m_aRequestedQueue[m_nActiveQueue][sampleIndex] = m_sQueueSample;
|
||||||
|
|
||||||
AddDetailsToRequestedOrderList(sampleIndex);
|
AddDetailsToRequestedOrderList(sampleIndex);
|
||||||
#ifdef AUDIO_REFLECTIONS
|
#ifdef AUDIO_REFLECTIONS
|
||||||
@ -705,15 +743,15 @@ cAudioManager::AddDetailsToRequestedOrderList(uint8 sample)
|
|||||||
uint32 i = 0;
|
uint32 i = 0;
|
||||||
if (sample > 0) {
|
if (sample > 0) {
|
||||||
for (; i < sample; i++) {
|
for (; i < sample; i++) {
|
||||||
if (m_asSamples[m_nActiveSampleQueue][m_abSampleQueueIndexTable[m_nActiveSampleQueue][i]].m_nFinalPriority >
|
if (m_aRequestedQueue[m_nActiveQueue][m_aRequestedOrderList[m_nActiveQueue][i]].m_nFinalPriority >
|
||||||
m_asSamples[m_nActiveSampleQueue][sample].m_nFinalPriority)
|
m_aRequestedQueue[m_nActiveQueue][sample].m_nFinalPriority)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (i < sample) {
|
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
|
#ifdef AUDIO_REFLECTIONS
|
||||||
@ -911,17 +949,17 @@ cAudioManager::AddReleasingSounds()
|
|||||||
bool8 toProcess[44];
|
bool8 toProcess[44];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int8 queue = m_nActiveSampleQueue == 0 ? 1 : 0;
|
uint8 queue = m_nActiveQueue == 0 ? 1 : 0;
|
||||||
|
|
||||||
for (int32 i = 0; i < m_SampleRequestQueuesStatus[queue]; i++) {
|
for (uint8 i = 0; i < m_nRequestedCount[queue]; i++) {
|
||||||
tSound &sample = m_asSamples[queue][m_abSampleQueueIndexTable[queue][i]];
|
tSound &sample = m_aRequestedQueue[queue][m_aRequestedOrderList[queue][i]];
|
||||||
if (sample.m_bIsPlayingFinished)
|
if (sample.m_bIsPlayingFinished)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
toProcess[i] = FALSE;
|
toProcess[i] = FALSE;
|
||||||
for (int32 j = 0; j < m_SampleRequestQueuesStatus[m_nActiveSampleQueue]; j++) {
|
for (uint8 j = 0; j < m_nRequestedCount[m_nActiveQueue]; j++) {
|
||||||
if (sample.m_nEntityIndex == m_asSamples[m_nActiveSampleQueue][m_abSampleQueueIndexTable[m_nActiveSampleQueue][j]].m_nEntityIndex &&
|
if (sample.m_nEntityIndex == m_aRequestedQueue[m_nActiveQueue][m_aRequestedOrderList[m_nActiveQueue][j]].m_nEntityIndex &&
|
||||||
sample.m_nCounter == m_asSamples[m_nActiveSampleQueue][m_abSampleQueueIndexTable[m_nActiveSampleQueue][j]].m_nCounter) {
|
sample.m_nCounter == m_aRequestedQueue[m_nActiveQueue][m_aRequestedOrderList[m_nActiveQueue][j]].m_nCounter) {
|
||||||
toProcess[i] = TRUE;
|
toProcess[i] = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -931,39 +969,92 @@ cAudioManager::AddReleasingSounds()
|
|||||||
if(sample.m_nCounter <= 255 || sample.m_nReflectionDelay == 0) // check if not delayed reflection
|
if(sample.m_nCounter <= 255 || sample.m_nReflectionDelay == 0) // check if not delayed reflection
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
#ifdef ATTACH_RELEASING_SOUNDS_TO_ENTITIES
|
||||||
|
if (sample.m_nCounter <= 255 && !sample.m_bIs2D) { // check if not reflection and is a 3D sound
|
||||||
|
CEntity* entity = (CEntity*)GetEntityPointer(sample.m_nEntityIndex);
|
||||||
|
if (entity && m_asAudioEntities[sample.m_nEntityIndex].m_nType == AUDIOTYPE_PHYSICAL) {
|
||||||
|
sample.m_vecPos = entity->GetPosition();
|
||||||
|
float oldDistance = sample.m_fDistance;
|
||||||
|
sample.m_fDistance = Sqrt(GetDistanceSquared(sample.m_vecPos));
|
||||||
|
if (sample.m_nSampleIndex >= SAMPLEBANK_PED_START && sample.m_nSampleIndex <= SAMPLEBANK_PED_END) { // check if it's ped comment
|
||||||
|
uint8 vol;
|
||||||
|
if (CWorld::GetIsLineOfSightClear(TheCamera.GetPosition(), sample.m_vecPos, true, false, false, false, false, false))
|
||||||
|
vol = MAX_VOLUME;
|
||||||
|
else
|
||||||
|
vol = 31;
|
||||||
|
#ifdef EXTERNAL_3D_SOUND
|
||||||
|
sample.m_nEmittingVolume = vol;
|
||||||
|
#endif
|
||||||
|
sample.m_nVolume = ComputeVolume(vol, sample.m_MaxDistance, sample.m_fDistance);
|
||||||
|
} else {
|
||||||
|
// calculate new volume with changed distance
|
||||||
|
float volumeDiff = sq((sample.m_MaxDistance - sample.m_fDistance) / (sample.m_MaxDistance - oldDistance));
|
||||||
|
if (volumeDiff > 0.0f) {
|
||||||
|
uint8 newVolume = volumeDiff * sample.m_nVolume;
|
||||||
|
if (sample.m_nVolumeChange > 0)
|
||||||
|
sample.m_nVolumeChange = volumeDiff * sample.m_nVolumeChange;
|
||||||
|
#if defined(FIX_BUGS) && defined(EXTERNAL_3D_SOUND)
|
||||||
|
if (sample.m_nEmittingVolumeChange > 0)
|
||||||
|
sample.m_nEmittingVolumeChange = volumeDiff * sample.m_nEmittingVolumeChange;
|
||||||
|
#endif
|
||||||
|
sample.m_nVolume = Min(127, newVolume);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (sample.m_nVolume == 0)
|
||||||
|
sample.m_nFramesToPlay = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef FIX_BUGS
|
||||||
|
if (sample.m_nFramesToPlay <= 0)
|
||||||
|
continue;
|
||||||
|
if (sample.m_nLoopCount == 0) {
|
||||||
|
if (sample.m_nVolumeChange == -1) {
|
||||||
|
sample.m_nVolumeChange = sample.m_nVolume / sample.m_nFramesToPlay;
|
||||||
|
if (sample.m_nVolumeChange <= 0)
|
||||||
|
sample.m_nVolumeChange = 1;
|
||||||
|
#ifdef EXTERNAL_3D_SOUND
|
||||||
|
sample.m_nEmittingVolumeChange = sample.m_nEmittingVolume / sample.m_nFramesToPlay;
|
||||||
|
if (sample.m_nEmittingVolumeChange <= 0)
|
||||||
|
sample.m_nEmittingVolumeChange = 1;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
if (sample.m_nVolume <= sample.m_nVolumeChange * CTimer::GetTimeStepFix()) {
|
||||||
|
sample.m_nFramesToPlay = 0;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
sample.m_nVolume -= sample.m_nVolumeChange * CTimer::GetTimeStepFix();
|
||||||
|
#ifdef EXTERNAL_3D_SOUND
|
||||||
|
if (sample.m_nEmittingVolume <= sample.m_nEmittingVolumeChange * CTimer::GetTimeStepFix()) {
|
||||||
|
sample.m_nFramesToPlay = 0;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
sample.m_nEmittingVolume -= sample.m_nEmittingVolumeChange * CTimer::GetTimeStepFix();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
sample.m_nFramesToPlay -= CTimer::GetTimeStepFix();
|
||||||
|
if (sample.m_nFramesToPlay < 0)
|
||||||
|
sample.m_nFramesToPlay = 0;
|
||||||
|
#else
|
||||||
if (sample.m_nFramesToPlay == 0)
|
if (sample.m_nFramesToPlay == 0)
|
||||||
continue;
|
continue;
|
||||||
if (sample.m_nLoopCount == 0) {
|
if (sample.m_nLoopCount == 0) {
|
||||||
if (sample.m_nVolumeChange == -1) {
|
if (sample.m_nVolumeChange == -1) {
|
||||||
#if defined(FIX_BUGS) && defined(EXTERNAL_3D_SOUND)
|
|
||||||
sample.m_nVolumeChange = sample.m_nEmittingVolume / sample.m_nFramesToPlay;
|
|
||||||
#else
|
|
||||||
sample.m_nVolumeChange = sample.m_nVolume / sample.m_nFramesToPlay;
|
sample.m_nVolumeChange = sample.m_nVolume / sample.m_nFramesToPlay;
|
||||||
#endif
|
|
||||||
if (sample.m_nVolumeChange <= 0)
|
if (sample.m_nVolumeChange <= 0)
|
||||||
sample.m_nVolumeChange = 1;
|
sample.m_nVolumeChange = 1;
|
||||||
}
|
}
|
||||||
#if defined(FIX_BUGS) && defined(EXTERNAL_3D_SOUND)
|
|
||||||
if (sample.m_nEmittingVolume <= sample.m_nVolumeChange) {
|
|
||||||
#else
|
|
||||||
if (sample.m_nVolume <= sample.m_nVolumeChange) {
|
if (sample.m_nVolume <= sample.m_nVolumeChange) {
|
||||||
#endif
|
|
||||||
sample.m_nFramesToPlay = 0;
|
sample.m_nFramesToPlay = 0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#if defined(FIX_BUGS) && defined(EXTERNAL_3D_SOUND)
|
|
||||||
sample.m_nEmittingVolume -= sample.m_nVolumeChange;
|
|
||||||
#else
|
|
||||||
sample.m_nVolume -= sample.m_nVolumeChange;
|
sample.m_nVolume -= sample.m_nVolumeChange;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#ifdef FIX_BUGS
|
sample.m_nFramesToPlay--;
|
||||||
if(CTimer::GetLogicalFramesPassed() != 0)
|
|
||||||
#endif
|
#endif
|
||||||
--sample.m_nFramesToPlay;
|
|
||||||
if (m_bReduceReleasingPriority) {
|
if (m_bReduceReleasingPriority) {
|
||||||
if (sample.m_nPriority < 20)
|
if (sample.m_nPriority < 20)
|
||||||
++sample.m_nPriority;
|
sample.m_nPriority++;
|
||||||
}
|
}
|
||||||
sample.m_bStatic = FALSE;
|
sample.m_bStatic = FALSE;
|
||||||
}
|
}
|
||||||
@ -997,18 +1088,28 @@ cAudioManager::ProcessActiveQueues()
|
|||||||
bool8 isPhoneCall;
|
bool8 isPhoneCall;
|
||||||
uint8 channelOffset = 0;
|
uint8 channelOffset = 0;
|
||||||
|
|
||||||
for (int32 i = 0; i < m_nActiveSamples; i++) {
|
#ifdef EXTERNAL_3D_SOUND
|
||||||
m_asSamples[m_nActiveSampleQueue][i].m_bIsBeingPlayed = FALSE;
|
#define WORKING_VOLUME_FIELD m_nEmittingVolume
|
||||||
|
#else
|
||||||
|
#define WORKING_VOLUME_FIELD m_nVolume
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_TIME_SCALE_FOR_AUDIO
|
||||||
|
float timeScale = m_bIsPaused ? 1.0f : CTimer::GetTimeScale();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (uint8 i = 0; i < m_nActiveSamples; i++) {
|
||||||
|
m_aRequestedQueue[m_nActiveQueue][i].m_bIsBeingPlayed = FALSE;
|
||||||
m_asActiveSamples[i].m_bIsBeingPlayed = FALSE;
|
m_asActiveSamples[i].m_bIsBeingPlayed = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32 i = 0; i < m_SampleRequestQueuesStatus[m_nActiveSampleQueue]; i++) {
|
for (uint8 i = 0; i < m_nRequestedCount[m_nActiveQueue]; i++) {
|
||||||
tSound &sample = m_asSamples[m_nActiveSampleQueue][m_abSampleQueueIndexTable[m_nActiveSampleQueue][i]];
|
tSound &sample = m_aRequestedQueue[m_nActiveQueue][m_aRequestedOrderList[m_nActiveQueue][i]];
|
||||||
if (sample.m_nSampleIndex != NO_SAMPLE) {
|
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 &&
|
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) {
|
sample.m_nSampleIndex == m_asActiveSamples[j].m_nSampleIndex) {
|
||||||
if (sample.m_nLoopCount) {
|
if (sample.m_nLoopCount > 0) {
|
||||||
if (m_FrameCounter & 1)
|
if (m_FrameCounter & 1)
|
||||||
flag = !!(j & 1);
|
flag = !!(j & 1);
|
||||||
else
|
else
|
||||||
@ -1029,12 +1130,12 @@ cAudioManager::ProcessActiveQueues()
|
|||||||
sample.m_nVolumeChange = -1;
|
sample.m_nVolumeChange = -1;
|
||||||
if (!sample.m_bStatic) {
|
if (!sample.m_bStatic) {
|
||||||
if (sample.m_bIs2D) {
|
if (sample.m_bIs2D) {
|
||||||
#ifdef EXTERNAL_3D_SOUND
|
emittingVol = m_bDoubleVolume ? 2 * Min(63, sample.WORKING_VOLUME_FIELD) : sample.WORKING_VOLUME_FIELD;
|
||||||
emittingVol = m_bDoubleVolume ? 2 * Min(63, sample.m_nEmittingVolume) : sample.m_nEmittingVolume;
|
#ifdef USE_TIME_SCALE_FOR_AUDIO
|
||||||
|
SampleManager.SetChannelFrequency(j, sample.m_nFrequency * timeScale);
|
||||||
#else
|
#else
|
||||||
emittingVol = m_bDoubleVolume ? 2 * Min(63, sample.m_nVolume) : sample.m_nVolume;
|
|
||||||
#endif
|
|
||||||
SampleManager.SetChannelFrequency(j, sample.m_nFrequency);
|
SampleManager.SetChannelFrequency(j, sample.m_nFrequency);
|
||||||
|
#endif
|
||||||
#ifdef EXTERNAL_3D_SOUND
|
#ifdef EXTERNAL_3D_SOUND
|
||||||
SampleManager.SetChannelEmittingVolume(j, emittingVol);
|
SampleManager.SetChannelEmittingVolume(j, emittingVol);
|
||||||
#else
|
#else
|
||||||
@ -1049,7 +1150,11 @@ cAudioManager::ProcessActiveQueues()
|
|||||||
if (sample.m_nFrequency != m_asActiveSamples[j].m_nFrequency) {
|
if (sample.m_nFrequency != m_asActiveSamples[j].m_nFrequency) {
|
||||||
uint32 freq = Clamp2((int32)sample.m_nFrequency, (int32)m_asActiveSamples[j].m_nFrequency, 6000);
|
uint32 freq = Clamp2((int32)sample.m_nFrequency, (int32)m_asActiveSamples[j].m_nFrequency, 6000);
|
||||||
m_asActiveSamples[j].m_nFrequency = freq;
|
m_asActiveSamples[j].m_nFrequency = freq;
|
||||||
|
#ifdef USE_TIME_SCALE_FOR_AUDIO
|
||||||
|
SampleManager.SetChannelFrequency(j, freq * timeScale);
|
||||||
|
#else
|
||||||
SampleManager.SetChannelFrequency(j, freq);
|
SampleManager.SetChannelFrequency(j, freq);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#ifdef EXTERNAL_3D_SOUND
|
#ifdef EXTERNAL_3D_SOUND
|
||||||
if (sample.m_nEmittingVolume != m_asActiveSamples[j].m_nEmittingVolume) {
|
if (sample.m_nEmittingVolume != m_asActiveSamples[j].m_nEmittingVolume) {
|
||||||
@ -1103,15 +1208,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) {
|
if (m_asActiveSamples[i].m_nSampleIndex != NO_SAMPLE && !m_asActiveSamples[i].m_bIsBeingPlayed) {
|
||||||
SampleManager.StopChannel(i);
|
SampleManager.StopChannel(i);
|
||||||
m_asActiveSamples[i].m_nSampleIndex = NO_SAMPLE;
|
m_asActiveSamples[i].m_nSampleIndex = NO_SAMPLE;
|
||||||
m_asActiveSamples[i].m_nEntityIndex = AEHANDLE_NONE;
|
m_asActiveSamples[i].m_nEntityIndex = AEHANDLE_NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (uint8 i = 0; i < m_SampleRequestQueuesStatus[m_nActiveSampleQueue]; i++) {
|
for (uint8 i = 0; i < m_nRequestedCount[m_nActiveQueue]; i++) {
|
||||||
tSound &sample = m_asSamples[m_nActiveSampleQueue][m_abSampleQueueIndexTable[m_nActiveSampleQueue][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) {
|
if (!sample.m_bIsBeingPlayed && !sample.m_bIsPlayingFinished && m_asAudioEntities[sample.m_nEntityIndex].m_bIsUsed && sample.m_nSampleIndex < NO_SAMPLE) {
|
||||||
#ifdef AUDIO_REFLECTIONS
|
#ifdef AUDIO_REFLECTIONS
|
||||||
if (sample.m_nCounter > 255 && sample.m_nLoopCount > 0 && sample.m_nReflectionDelay > 0) { // check if reflection
|
if (sample.m_nCounter > 255 && sample.m_nLoopCount > 0 && sample.m_nReflectionDelay > 0) { // check if reflection
|
||||||
@ -1137,18 +1242,18 @@ cAudioManager::ProcessActiveQueues()
|
|||||||
m_asActiveSamples[j].m_nPan = ComputePan(m_asActiveSamples[j].m_fDistance, &position);
|
m_asActiveSamples[j].m_nPan = ComputePan(m_asActiveSamples[j].m_fDistance, &position);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#ifdef EXTERNAL_3D_SOUND
|
emittingVol = m_bDoubleVolume ? 2 * Min(63, m_asActiveSamples[j].WORKING_VOLUME_FIELD) : m_asActiveSamples[j].WORKING_VOLUME_FIELD;
|
||||||
emittingVol = m_bDoubleVolume ? 2 * Min(63, m_asActiveSamples[j].m_nEmittingVolume) : m_asActiveSamples[j].m_nEmittingVolume;
|
|
||||||
#else
|
|
||||||
emittingVol = m_bDoubleVolume ? 2 * Min(63, m_asActiveSamples[j].m_nVolume) : m_asActiveSamples[j].m_nVolume;
|
|
||||||
#endif
|
|
||||||
#ifdef GTA_PS2
|
#ifdef GTA_PS2
|
||||||
{
|
{
|
||||||
SampleManager.InitialiseChannel(k, m_asActiveSamples[k].m_nSampleIndex, m_asActiveSamples[k].m_nBankIndex);
|
SampleManager.InitialiseChannel(k, m_asActiveSamples[k].m_nSampleIndex, m_asActiveSamples[k].m_nBankIndex);
|
||||||
#else
|
#else
|
||||||
if (SampleManager.InitialiseChannel(k, m_asActiveSamples[k].m_nSampleIndex, m_asActiveSamples[k].m_nBankIndex)) {
|
if (SampleManager.InitialiseChannel(k, m_asActiveSamples[k].m_nSampleIndex, m_asActiveSamples[k].m_nBankIndex)) {
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef USE_TIME_SCALE_FOR_AUDIO
|
||||||
|
SampleManager.SetChannelFrequency(k, m_asActiveSamples[k].m_nFrequency * timeScale);
|
||||||
|
#else
|
||||||
SampleManager.SetChannelFrequency(k, m_asActiveSamples[k].m_nFrequency);
|
SampleManager.SetChannelFrequency(k, m_asActiveSamples[k].m_nFrequency);
|
||||||
|
#endif
|
||||||
isPhoneCall = FALSE;
|
isPhoneCall = FALSE;
|
||||||
for (int32 l = 0; l < MISSION_AUDIO_SLOTS; l++) {
|
for (int32 l = 0; l < MISSION_AUDIO_SLOTS; l++) {
|
||||||
if (m_bIsMissionAudioPhoneCall[l]) {
|
if (m_bIsMissionAudioPhoneCall[l]) {
|
||||||
@ -1171,8 +1276,8 @@ cAudioManager::ProcessActiveQueues()
|
|||||||
#endif
|
#endif
|
||||||
#ifndef GTA_PS2
|
#ifndef GTA_PS2
|
||||||
SampleManager.SetChannelLoopPoints(k, m_asActiveSamples[k].m_nLoopStart, m_asActiveSamples[k].m_nLoopEnd);
|
SampleManager.SetChannelLoopPoints(k, m_asActiveSamples[k].m_nLoopStart, m_asActiveSamples[k].m_nLoopEnd);
|
||||||
SampleManager.SetChannelLoopCount(k, m_asActiveSamples[k].m_nLoopCount);
|
|
||||||
#endif
|
#endif
|
||||||
|
SampleManager.SetChannelLoopCount(k, m_asActiveSamples[k].m_nLoopCount);
|
||||||
#if !defined(GTA_PS2) || defined(AUDIO_REVERB)
|
#if !defined(GTA_PS2) || defined(AUDIO_REVERB)
|
||||||
SampleManager.SetChannelReverbFlag(k, m_asActiveSamples[k].m_bReverb);
|
SampleManager.SetChannelReverbFlag(k, m_asActiveSamples[k].m_bReverb);
|
||||||
#endif
|
#endif
|
||||||
@ -1209,19 +1314,28 @@ cAudioManager::ProcessActiveQueues()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef GTA_PS2
|
#ifdef GTA_PS2
|
||||||
m_nChannelOffset += channelOffset;
|
m_nChannelOffset += channelOffset;
|
||||||
#endif
|
#endif
|
||||||
m_nChannelOffset %= m_nActiveSamples;
|
m_nChannelOffset %= m_nActiveSamples;
|
||||||
|
|
||||||
|
#ifdef USE_TIME_SCALE_FOR_AUDIO
|
||||||
|
for (uint8 i = 0; i < m_nActiveSamples; i++) {
|
||||||
|
if (m_asActiveSamples[i].m_nSampleIndex != NO_SAMPLE && m_asActiveSamples[i].m_bIsBeingPlayed)
|
||||||
|
SampleManager.SetChannelFrequency(i, m_asActiveSamples[i].m_nFrequency * timeScale);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#undef WORKING_VOLUME_FIELD
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cAudioManager::ClearRequestedQueue()
|
cAudioManager::ClearRequestedQueue()
|
||||||
{
|
{
|
||||||
for (int32 i = 0; i < m_nActiveSamples; i++) {
|
for (uint8 i = 0; i < m_nActiveSamples; i++)
|
||||||
m_abSampleQueueIndexTable[m_nActiveSampleQueue][i] = m_nActiveSamples;
|
m_aRequestedOrderList[m_nActiveQueue][i] = m_nActiveSamples;
|
||||||
}
|
m_nRequestedCount[m_nActiveQueue] = 0;
|
||||||
m_SampleRequestQueuesStatus[m_nActiveSampleQueue] = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -1275,17 +1389,16 @@ cAudioManager::LoadBankIfNecessary(uint8 bank)
|
|||||||
void
|
void
|
||||||
cAudioManager::GenerateIntegerRandomNumberTable()
|
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();
|
m_anRandomTable[i] = myrand();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef EXTERNAL_3D_SOUND
|
#ifdef EXTERNAL_3D_SOUND
|
||||||
void
|
void
|
||||||
cAudioManager::AdjustSamplesVolume()
|
cAudioManager::AdjustSamplesVolume()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < m_SampleRequestQueuesStatus[m_nActiveSampleQueue]; i++) {
|
for (uint8 i = 0; i < m_nRequestedCount[m_nActiveQueue]; i++) {
|
||||||
tSound *pSample = &m_asSamples[m_nActiveSampleQueue][m_abSampleQueueIndexTable[m_nActiveSampleQueue][i]];
|
tSound *pSample = &m_aRequestedQueue[m_nActiveQueue][m_aRequestedOrderList[m_nActiveQueue][i]];
|
||||||
|
|
||||||
if (!pSample->m_bIs2D)
|
if (!pSample->m_bIs2D)
|
||||||
pSample->m_nEmittingVolume = ComputeEmittingVolume(pSample->m_nEmittingVolume, pSample->m_MaxDistance, pSample->m_fDistance);
|
pSample->m_nEmittingVolume = ComputeEmittingVolume(pSample->m_nEmittingVolume, pSample->m_MaxDistance, pSample->m_fDistance);
|
||||||
|
@ -44,14 +44,21 @@ public:
|
|||||||
// 63 = L 100% R 100%
|
// 63 = L 100% R 100%
|
||||||
// 127 = L 0% R 100%
|
// 127 = L 0% R 100%
|
||||||
uint8 m_nFrontRearPan; // Used on PS2 for surround panning
|
uint8 m_nFrontRearPan; // Used on PS2 for surround panning
|
||||||
|
#ifndef FIX_BUGS
|
||||||
uint32 m_nFramesToPlay; // Number of frames the sound would be played (if it stops being queued).
|
uint32 m_nFramesToPlay; // Number of frames the sound would be played (if it stops being queued).
|
||||||
// This one is being set by queued sample for looping sounds, otherwise calculated inside AudioManager
|
// This one is being set by queued sample for looping sounds, otherwise calculated inside AudioManager
|
||||||
|
#else
|
||||||
|
float m_nFramesToPlay; // Made into float for high fps fix
|
||||||
|
#endif
|
||||||
|
|
||||||
// all fields below are internal to AudioManager calculations and aren't set by queued sample
|
// all fields below are internal to AudioManager calculations and aren't set by queued sample
|
||||||
bool8 m_bIsBeingPlayed; // Set to TRUE when the sound was added or changed on current frame to avoid it being overwritten
|
bool8 m_bIsBeingPlayed; // Set to TRUE when the sound was added or changed on current frame to avoid it being overwritten
|
||||||
bool8 m_bIsPlayingFinished; // Not sure about the name. Set to TRUE when sampman channel becomes free
|
bool8 m_bIsPlayingFinished; // Not sure about the name. Set to TRUE when sampman channel becomes free
|
||||||
uint32 m_nFinalPriority; // Actual value used to compare priority, calculated using volume and m_nPriority. Lesser value means higher priority
|
uint32 m_nFinalPriority; // Actual value used to compare priority, calculated using volume and m_nPriority. Lesser value means higher priority
|
||||||
int8 m_nVolumeChange; // How much m_nVolume should reduce per each frame.
|
int8 m_nVolumeChange; // How much m_nVolume should reduce per each frame.
|
||||||
|
#if defined(FIX_BUGS) && defined(EXTERNAL_3D_SOUND)
|
||||||
|
int8 m_nEmittingVolumeChange; // same as above but for m_nEmittingVolume
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
VALIDATE_SIZE(tSound, 96);
|
VALIDATE_SIZE(tSound, 96);
|
||||||
@ -229,16 +236,16 @@ public:
|
|||||||
uint8 m_nChannelOffset;
|
uint8 m_nChannelOffset;
|
||||||
float m_fSpeedOfSound;
|
float m_fSpeedOfSound;
|
||||||
bool8 m_bTimerJustReset;
|
bool8 m_bTimerJustReset;
|
||||||
int32 m_nTimer;
|
uint32 m_nTimer;
|
||||||
tSound m_sQueueSample;
|
tSound m_sQueueSample;
|
||||||
uint8 m_nActiveSampleQueue;
|
uint8 m_nActiveQueue;
|
||||||
tSound m_asSamples[NUM_SOUNDS_SAMPLES_BANKS][NUM_CHANNELS_GENERIC];
|
tSound m_aRequestedQueue[NUM_SOUND_QUEUES][NUM_CHANNELS_GENERIC];
|
||||||
uint8 m_abSampleQueueIndexTable[NUM_SOUNDS_SAMPLES_BANKS][NUM_CHANNELS_GENERIC];
|
uint8 m_aRequestedOrderList[NUM_SOUND_QUEUES][NUM_CHANNELS_GENERIC];
|
||||||
uint8 m_SampleRequestQueuesStatus[NUM_SOUNDS_SAMPLES_BANKS];
|
uint8 m_nRequestedCount[NUM_SOUND_QUEUES];
|
||||||
tSound m_asActiveSamples[NUM_CHANNELS_GENERIC];
|
tSound m_asActiveSamples[NUM_CHANNELS_GENERIC];
|
||||||
tAudioEntity m_asAudioEntities[NUM_AUDIOENTITIES];
|
tAudioEntity m_asAudioEntities[NUM_AUDIOENTITIES];
|
||||||
int32 m_anAudioEntityIndices[NUM_AUDIOENTITIES];
|
uint32 m_aAudioEntityOrderList[NUM_AUDIOENTITIES];
|
||||||
int32 m_nAudioEntitiesTotal;
|
uint32 m_nAudioEntitiesCount;
|
||||||
#ifdef AUDIO_REFLECTIONS
|
#ifdef AUDIO_REFLECTIONS
|
||||||
CVector m_avecReflectionsPos[MAX_REFLECTIONS];
|
CVector m_avecReflectionsPos[MAX_REFLECTIONS];
|
||||||
float m_afReflectionsDistances[MAX_REFLECTIONS];
|
float m_afReflectionsDistances[MAX_REFLECTIONS];
|
||||||
@ -278,15 +285,15 @@ public:
|
|||||||
uint8 m_nMissionAudioLoadingStatus[MISSION_AUDIO_SLOTS];
|
uint8 m_nMissionAudioLoadingStatus[MISSION_AUDIO_SLOTS];
|
||||||
uint8 m_nMissionAudioPlayStatus[MISSION_AUDIO_SLOTS];
|
uint8 m_nMissionAudioPlayStatus[MISSION_AUDIO_SLOTS];
|
||||||
bool8 m_bIsMissionAudioPlaying[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_bIsMissionAudioAllowedToPlay[MISSION_AUDIO_SLOTS];
|
||||||
bool8 m_bIsMissionAudioPhoneCall[MISSION_AUDIO_SLOTS];
|
bool8 m_bIsMissionAudioPhoneCall[MISSION_AUDIO_SLOTS];
|
||||||
uint8 m_nGlobalSfxVolumeMultiplier; // used to lower sfx volume during phone calls
|
uint8 m_nGlobalSfxVolumeMultiplier; // used to lower sfx volume during phone calls
|
||||||
|
|
||||||
int32 m_anRandomTable[5];
|
int32 m_anRandomTable[5];
|
||||||
uint8 m_nTimeSpent;
|
uint8 m_nTimeSpent;
|
||||||
bool8 m_nUserPause;
|
bool8 m_bIsPaused;
|
||||||
bool8 m_nPreviousUserPause;
|
bool8 m_bWasPaused;
|
||||||
uint32 m_FrameCounter;
|
uint32 m_FrameCounter;
|
||||||
|
|
||||||
uint32 field_5644_lcs;
|
uint32 field_5644_lcs;
|
||||||
|
@ -263,7 +263,7 @@ cMusicManager::GetRadioInCar(void)
|
|||||||
CVehicle* veh = AudioManager.FindVehicleOfPlayer();
|
CVehicle* veh = AudioManager.FindVehicleOfPlayer();
|
||||||
if (veh != nil) {
|
if (veh != nil) {
|
||||||
if (UsesPoliceRadio(veh) || UsesTaxiRadio(veh)) {
|
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 STREAMED_SOUND_RADIO_POLICE;
|
||||||
return m_nRadioInCar;
|
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 RADIO_OFF;
|
||||||
return m_nRadioInCar;
|
return m_nRadioInCar;
|
||||||
}
|
}
|
||||||
@ -353,7 +353,7 @@ cMusicManager::ChangeMusicMode(uint8 mode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cMusicManager::ResetTimers(int32 time)
|
cMusicManager::ResetTimers(uint32 time)
|
||||||
{
|
{
|
||||||
m_bResetTimers = TRUE;
|
m_bResetTimers = TRUE;
|
||||||
m_nResetTime = time;
|
m_nResetTime = time;
|
||||||
@ -374,7 +374,7 @@ cMusicManager::Service()
|
|||||||
if (!m_bMusicModeChangeStarted)
|
if (!m_bMusicModeChangeStarted)
|
||||||
m_nMusicModeToBeSet = m_nUpcomingMusicMode;
|
m_nMusicModeToBeSet = m_nUpcomingMusicMode;
|
||||||
if (m_nMusicModeToBeSet == m_nMusicMode) {
|
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)
|
switch (m_nMusicMode)
|
||||||
{
|
{
|
||||||
@ -387,7 +387,7 @@ cMusicManager::Service()
|
|||||||
m_nMusicMode = MUSICMODE_DISABLED;
|
m_nMusicMode = MUSICMODE_DISABLED;
|
||||||
} else {
|
} else {
|
||||||
m_bMusicModeChangeStarted = TRUE;
|
m_bMusicModeChangeStarted = TRUE;
|
||||||
if (!m_bUserResumedGame && !AudioManager.m_nUserPause && AudioManager.m_nPreviousUserPause)
|
if (!m_bUserResumedGame && !AudioManager.m_bIsPaused && AudioManager.m_bWasPaused)
|
||||||
m_bUserResumedGame = TRUE;
|
m_bUserResumedGame = TRUE;
|
||||||
if (AudioManager.m_FrameCounter % 4 == 0) {
|
if (AudioManager.m_FrameCounter % 4 == 0) {
|
||||||
gNumRetunePresses = 0;
|
gNumRetunePresses = 0;
|
||||||
@ -461,7 +461,7 @@ cMusicManager::ServiceFrontEndMode()
|
|||||||
} else {
|
} else {
|
||||||
if (m_nPlayingTrack == STREAMED_SOUND_RADIO_MP3_PLAYER)
|
if (m_nPlayingTrack == STREAMED_SOUND_RADIO_MP3_PLAYER)
|
||||||
SampleManager.StartStreamedFile(STREAMED_SOUND_RADIO_MP3_PLAYER, 0);
|
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);
|
ChangeMusicMode(MUSICMODE_GAME);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -76,7 +76,7 @@ public:
|
|||||||
void SetRadioInCar(uint32);
|
void SetRadioInCar(uint32);
|
||||||
void SetRadioChannelByScript(uint32, int32);
|
void SetRadioChannelByScript(uint32, int32);
|
||||||
|
|
||||||
void ResetTimers(int32);
|
void ResetTimers(uint32);
|
||||||
void Service();
|
void Service();
|
||||||
void ServiceFrontEndMode();
|
void ServiceFrontEndMode();
|
||||||
void ServiceGameMode();
|
void ServiceGameMode();
|
||||||
|
@ -125,7 +125,7 @@ cAudioManager::ServicePoliceRadio()
|
|||||||
|
|
||||||
if(!m_bIsInitialised) return;
|
if(!m_bIsInitialised) return;
|
||||||
|
|
||||||
if(!m_nUserPause) {
|
if(!m_bIsPaused) {
|
||||||
bool8 crimeReport = SetupCrimeReport();
|
bool8 crimeReport = SetupCrimeReport();
|
||||||
#ifdef FIX_BUGS // Crash at 0x5fe6ef
|
#ifdef FIX_BUGS // Crash at 0x5fe6ef
|
||||||
if(CReplay::IsPlayingBack() || !FindPlayerPed() || !FindPlayerPed()->m_pWanted)
|
if(CReplay::IsPlayingBack() || !FindPlayerPed() || !FindPlayerPed()->m_pWanted)
|
||||||
@ -168,14 +168,14 @@ cAudioManager::ServicePoliceRadioChannel(uint8 wantedLevel)
|
|||||||
|
|
||||||
if (!m_bIsInitialised) return;
|
if (!m_bIsInitialised) return;
|
||||||
|
|
||||||
if (m_nUserPause) {
|
if (m_bIsPaused) {
|
||||||
if (SampleManager.GetChannelUsedFlag(CHANNEL_POLICE_RADIO)) SampleManager.StopChannel(CHANNEL_POLICE_RADIO);
|
if (SampleManager.GetChannelUsedFlag(CHANNEL_POLICE_RADIO)) SampleManager.StopChannel(CHANNEL_POLICE_RADIO);
|
||||||
if (g_nMissionAudioSfx != NO_SAMPLE && bMissionAudioPhysicalPlayingStatus == PLAY_STATUS_PLAYING &&
|
if (g_nMissionAudioSfx != NO_SAMPLE && bMissionAudioPhysicalPlayingStatus == PLAY_STATUS_PLAYING &&
|
||||||
SampleManager.IsStreamPlaying(1)) {
|
SampleManager.IsStreamPlaying(1)) {
|
||||||
SampleManager.PauseStream(TRUE, 1);
|
SampleManager.PauseStream(TRUE, 1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (m_nPreviousUserPause && g_nMissionAudioSfx != NO_SAMPLE &&
|
if (m_bWasPaused && g_nMissionAudioSfx != NO_SAMPLE &&
|
||||||
bMissionAudioPhysicalPlayingStatus == PLAY_STATUS_PLAYING) {
|
bMissionAudioPhysicalPlayingStatus == PLAY_STATUS_PLAYING) {
|
||||||
SampleManager.PauseStream(FALSE, 1);
|
SampleManager.PauseStream(FALSE, 1);
|
||||||
}
|
}
|
||||||
@ -238,11 +238,15 @@ cAudioManager::ServicePoliceRadioChannel(uint8 wantedLevel)
|
|||||||
default: freq = SampleManager.GetSampleBaseFrequency(sample); break;
|
default: freq = SampleManager.GetSampleBaseFrequency(sample); break;
|
||||||
}
|
}
|
||||||
PoliceChannelFreq = freq;
|
PoliceChannelFreq = freq;
|
||||||
|
#ifdef USE_TIME_SCALE_FOR_AUDIO
|
||||||
|
SampleManager.SetChannelFrequency(CHANNEL_POLICE_RADIO, freq * CTimer::GetTimeScale());
|
||||||
|
#else
|
||||||
SampleManager.SetChannelFrequency(CHANNEL_POLICE_RADIO, freq);
|
SampleManager.SetChannelFrequency(CHANNEL_POLICE_RADIO, freq);
|
||||||
|
#endif
|
||||||
SampleManager.SetChannelVolume(CHANNEL_POLICE_RADIO, 100);
|
SampleManager.SetChannelVolume(CHANNEL_POLICE_RADIO, 100);
|
||||||
SampleManager.SetChannelPan(CHANNEL_POLICE_RADIO, 63);
|
SampleManager.SetChannelPan(CHANNEL_POLICE_RADIO, 63);
|
||||||
#ifndef GTA_PS2
|
|
||||||
SampleManager.SetChannelLoopCount(CHANNEL_POLICE_RADIO, 1);
|
SampleManager.SetChannelLoopCount(CHANNEL_POLICE_RADIO, 1);
|
||||||
|
#ifndef GTA_PS2
|
||||||
SampleManager.SetChannelLoopPoints(CHANNEL_POLICE_RADIO, 0, -1);
|
SampleManager.SetChannelLoopPoints(CHANNEL_POLICE_RADIO, 0, -1);
|
||||||
#endif
|
#endif
|
||||||
SampleManager.StartChannel(CHANNEL_POLICE_RADIO);
|
SampleManager.StartChannel(CHANNEL_POLICE_RADIO);
|
||||||
|
@ -727,7 +727,7 @@ CCam::LookRight(void)
|
|||||||
CVector TargetCoors, TargetFwd;
|
CVector TargetCoors, TargetFwd;
|
||||||
CColPoint colPoint;
|
CColPoint colPoint;
|
||||||
|
|
||||||
if((Mode == MODE_CAM_ON_A_STRING || Mode == MODE_BEHINDBOAT) && CamTargetEntity->IsVehicle()){
|
if((Mode == MODE_CAM_ON_A_STRING || Mode == MODE_BEHINDBOAT || Mode == MODE_BEHINDCAR) && CamTargetEntity->IsVehicle()){
|
||||||
LookingRight = true;
|
LookingRight = true;
|
||||||
TargetCoors = CamTargetEntity->GetPosition();
|
TargetCoors = CamTargetEntity->GetPosition();
|
||||||
Front = CamTargetEntity->GetPosition() - Source;
|
Front = CamTargetEntity->GetPosition() - Source;
|
||||||
|
@ -132,7 +132,7 @@ enum Config {
|
|||||||
NUM_PED_COMMENTS_BANKS = 2,
|
NUM_PED_COMMENTS_BANKS = 2,
|
||||||
NUM_PED_COMMENTS_SLOTS = 20,
|
NUM_PED_COMMENTS_SLOTS = 20,
|
||||||
|
|
||||||
NUM_SOUNDS_SAMPLES_BANKS = 2,
|
NUM_SOUND_QUEUES = 2,
|
||||||
NUM_AUDIOENTITIES = 250,
|
NUM_AUDIOENTITIES = 250,
|
||||||
|
|
||||||
NUM_SCRIPT_MAX_ENTITIES = 40,
|
NUM_SCRIPT_MAX_ENTITIES = 40,
|
||||||
@ -459,8 +459,10 @@ static_assert(false, "SUPPORT_XBOX_SCRIPT and SUPPORT_MOBILE_SCRIPT are mutually
|
|||||||
//#define PS2_AUDIO_PATHS // changes audio paths for cutscenes and radio to PS2 paths (needs vbdec on MSS builds)
|
//#define PS2_AUDIO_PATHS // changes audio paths for cutscenes and radio to PS2 paths (needs vbdec on MSS builds)
|
||||||
//#define AUDIO_OAL_USE_SNDFILE // use libsndfile to decode WAVs instead of our internal decoder
|
//#define AUDIO_OAL_USE_SNDFILE // use libsndfile to decode WAVs instead of our internal decoder
|
||||||
#define AUDIO_OAL_USE_MPG123 // use mpg123 to support mp3 files
|
#define AUDIO_OAL_USE_MPG123 // use mpg123 to support mp3 files
|
||||||
#define MULTITHREADED_AUDIO // for streams. requires C++11 or later
|
|
||||||
#define PAUSE_RADIO_IN_FRONTEND // pause radio when game is paused
|
#define PAUSE_RADIO_IN_FRONTEND // pause radio when game is paused
|
||||||
|
#define ATTACH_RELEASING_SOUNDS_TO_ENTITIES // sounds would follow ped and vehicles coordinates if not being queued otherwise
|
||||||
|
#define USE_TIME_SCALE_FOR_AUDIO // slow down/speed up sounds according to the speed of the game
|
||||||
|
#define MULTITHREADED_AUDIO // for streams. requires C++11 or later
|
||||||
|
|
||||||
#ifdef AUDIO_OPUS
|
#ifdef AUDIO_OPUS
|
||||||
#define AUDIO_OAL_USE_OPUS // enable support of opus files
|
#define AUDIO_OAL_USE_OPUS // enable support of opus files
|
||||||
|
@ -205,6 +205,8 @@ CPedIK::PointGunInDirection(float targetYaw, float targetPitch)
|
|||||||
else if (status == ANGLES_SET_EXACTLY)
|
else if (status == ANGLES_SET_EXACTLY)
|
||||||
m_flags |= GUN_POINTED_SUCCESSFULLY;
|
m_flags |= GUN_POINTED_SUCCESSFULLY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Game uses index 2 directly, which happens to be identical to BONE_spine
|
||||||
#ifdef FIX_BUGS
|
#ifdef FIX_BUGS
|
||||||
RwMatrix *m = GetBoneMatrix(m_ped, BONE_spine);
|
RwMatrix *m = GetBoneMatrix(m_ped, BONE_spine);
|
||||||
#else
|
#else
|
||||||
@ -213,7 +215,7 @@ CPedIK::PointGunInDirection(float targetYaw, float targetPitch)
|
|||||||
RwMatrix *m = &mats[2];
|
RwMatrix *m = &mats[2];
|
||||||
#endif
|
#endif
|
||||||
RwV3d axis = { 0.0f, 0.0f, 0.0f };
|
RwV3d axis = { 0.0f, 0.0f, 0.0f };
|
||||||
float axisangle = -CGeneral::LimitRadianAngle(Atan2(-m->up.y, -m->up.x) - m_ped->m_fRotationCur);
|
float axisangle = -CGeneral::LimitRadianAngle(Atan2(-m->at.y, -m->at.x) - m_ped->m_fRotationCur);
|
||||||
axis.y = -Sin(axisangle);
|
axis.y = -Sin(axisangle);
|
||||||
axis.z = Cos(axisangle);
|
axis.z = Cos(axisangle);
|
||||||
|
|
||||||
|
@ -729,10 +729,17 @@ CPlayerPed::ProcessWeaponSwitch(CPad *padUsed)
|
|||||||
|
|
||||||
for (m_nSelectedWepSlot = m_currentWeapon + 1; m_nSelectedWepSlot < TOTAL_WEAPON_SLOTS; ++m_nSelectedWepSlot) {
|
for (m_nSelectedWepSlot = m_currentWeapon + 1; m_nSelectedWepSlot < TOTAL_WEAPON_SLOTS; ++m_nSelectedWepSlot) {
|
||||||
if (HasWeaponSlot(m_nSelectedWepSlot) && GetWeapon(m_nSelectedWepSlot).HasWeaponAmmoToBeUsed()) {
|
if (HasWeaponSlot(m_nSelectedWepSlot) && GetWeapon(m_nSelectedWepSlot).HasWeaponAmmoToBeUsed()) {
|
||||||
|
#ifdef FIX_BUGS
|
||||||
|
goto switchDetectDone;
|
||||||
|
#else
|
||||||
goto spentAmmoCheck;
|
goto spentAmmoCheck;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_nSelectedWepSlot = 0;
|
m_nSelectedWepSlot = 0;
|
||||||
|
#ifdef FIX_BUGS
|
||||||
|
goto switchDetectDone;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
} else if (padUsed->CycleWeaponLeftJustDown()) {
|
} else if (padUsed->CycleWeaponLeftJustDown()) {
|
||||||
if (TheCamera.PlayerWeaponMode.Mode != CCam::MODE_M16_1STPERSON
|
if (TheCamera.PlayerWeaponMode.Mode != CCam::MODE_M16_1STPERSON
|
||||||
@ -754,6 +761,10 @@ CPlayerPed::ProcessWeaponSwitch(CPad *padUsed)
|
|||||||
|
|
||||||
--m_nSelectedWepSlot;
|
--m_nSelectedWepSlot;
|
||||||
} while (m_nSelectedWepSlot != WEAPONSLOT_UNARMED);
|
} while (m_nSelectedWepSlot != WEAPONSLOT_UNARMED);
|
||||||
|
#ifdef FIX_BUGS
|
||||||
|
goto switchDetectDone;
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1671,7 +1671,7 @@ CAutomobile::Teleport(CVector pos)
|
|||||||
|
|
||||||
float gHeadlightRange = 25.0f;
|
float gHeadlightRange = 25.0f;
|
||||||
float gTaxilightRange = 1.1f;
|
float gTaxilightRange = 1.1f;
|
||||||
CVector gHeadlightColour(0.86, 0.82f, 1.0f);
|
CVector gHeadlightColour(0.86f, 0.82f, 1.0f);
|
||||||
CVector gTaxilightColour(1.0, 1.0f, 0.5f);
|
CVector gTaxilightColour(1.0, 1.0f, 0.5f);
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user