summaryrefslogtreecommitdiff
path: root/src/audio/AudioLogic.cpp
diff options
context:
space:
mode:
authorSergeanur <s.anureev@yandex.ua>2021-08-29 08:58:54 +0300
committerSergeanur <s.anureev@yandex.ua>2021-08-29 08:58:54 +0300
commit2be8fcfa64a9925206ed2356c2934c7559873a6a (patch)
tree9937e069805afb805c13c81877714465ad34b5fd /src/audio/AudioLogic.cpp
parent2a69f34f93b1188c479fe385780b0ca768f65d35 (diff)
parent8ef1e29a5ca389f56e942b25e7ad8062beb56cac (diff)
Merge remote-tracking branch 'origin/miami' into lcs
# Conflicts: # src/audio/AudioManager.cpp # src/core/Radar.cpp
Diffstat (limited to 'src/audio/AudioLogic.cpp')
-rw-r--r--src/audio/AudioLogic.cpp78
1 files changed, 42 insertions, 36 deletions
diff --git a/src/audio/AudioLogic.cpp b/src/audio/AudioLogic.cpp
index aa69a949..33f22fb2 100644
--- a/src/audio/AudioLogic.cpp
+++ b/src/audio/AudioLogic.cpp
@@ -2031,7 +2031,11 @@ cAudioManager::ProcessPlayersVehicleEngine(cVehicleParams& params, CVehicle* veh
CurrentPretendGear = 1;
bHandbrakeOnLastFrame = FALSE;
}
+#ifdef FIX_BUGS
+ if (CReplay::IsPlayingBack() || FindPlayerPed()->GetPedState() == PED_EXIT_CAR) {
+#else
if (CReplay::IsPlayingBack()) {
+#endif
accelerateState = (255.0f * Clamp(params.m_pVehicle->m_fGasPedal, 0.0f, 1.0f));
brakeState = (255.0f * Clamp(params.m_pVehicle->m_fBrakePedal, 0.0f, 1.0f));
} else {
@@ -8030,49 +8034,51 @@ cPedComments::Add(tPedComment *com)
{
uint8 index;
- if (m_nCommentsInBank[m_nActiveBank] >= NUM_PED_COMMENTS_SLOTS) {
- index = m_nIndexMap[m_nActiveBank][NUM_PED_COMMENTS_SLOTS - 1];
- if (m_asPedComments[m_nActiveBank][index].m_nVolume > com->m_nVolume)
+ // copypasted priority check from cAudioManager::AddSampleToRequestedQueue
+
+ if (m_nPedCommentCount[m_nActiveQueue] >= NUM_PED_COMMENTS_SLOTS) {
+ index = m_aPedCommentOrderList[m_nActiveQueue][NUM_PED_COMMENTS_SLOTS - 1];
+ if (m_aPedCommentQueue[m_nActiveQueue][index].m_nVolume > com->m_nVolume)
return;
} else
- index = m_nCommentsInBank[m_nActiveBank]++;
+ index = m_nPedCommentCount[m_nActiveQueue]++;
- m_asPedComments[m_nActiveBank][index] = *com;
+ m_aPedCommentQueue[m_nActiveQueue][index] = *com;
+ // this bit is basically copypasted cAudioManager::AddDetailsToRequestedOrderList
uint8 i = 0;
if (index != 0) {
for (i = 0; i < index; i++) {
- if (m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][i]].m_nVolume < m_asPedComments[m_nActiveBank][index].m_nVolume)
+ if (m_aPedCommentQueue[m_nActiveQueue][m_aPedCommentOrderList[m_nActiveQueue][i]].m_nVolume < m_aPedCommentQueue[m_nActiveQueue][index].m_nVolume)
break;
}
if (i < index)
- memmove(&m_nIndexMap[m_nActiveBank][i + 1], &m_nIndexMap[m_nActiveBank][i], NUM_PED_COMMENTS_SLOTS - 1 - i);
+ memmove(&m_aPedCommentOrderList[m_nActiveQueue][i + 1], &m_aPedCommentOrderList[m_nActiveQueue][i], NUM_PED_COMMENTS_SLOTS - 1 - i);
}
- m_nIndexMap[m_nActiveBank][i] = index;
+ m_aPedCommentOrderList[m_nActiveQueue][i] = index;
}
void
cPedComments::Process()
{
uint32 sampleIndex;
- uint8 actualUsedBank;
- tPedComment *comment;
+ uint8 queue;
static uint8 counter = 0;
- static int32 prevSamples[10] = { NO_SAMPLE, NO_SAMPLE, NO_SAMPLE, NO_SAMPLE, NO_SAMPLE, NO_SAMPLE, NO_SAMPLE, NO_SAMPLE, NO_SAMPLE, NO_SAMPLE };
+ static uint32 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_bIsPaused) return;
- if(m_nCommentsInBank[m_nActiveBank]) {
+ if(m_nPedCommentCount[m_nActiveQueue]) {
for(int i = 0; i < ARRAY_SIZE(prevSamples); i++) {
- if(m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nSampleIndex ==
+ if(m_aPedCommentQueue[m_nActiveQueue][m_aPedCommentOrderList[m_nActiveQueue][0]].m_nSampleIndex ==
prevSamples[(counter + 1 + i) % ARRAY_SIZE(prevSamples)]) {
- m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nProcess = -1;
+ m_aPedCommentQueue[m_nActiveQueue][m_aPedCommentOrderList[m_nActiveQueue][0]].m_nProcess = -1;
goto PedCommentAlreadyAdded;
}
}
- sampleIndex = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nSampleIndex;
+ sampleIndex = m_aPedCommentQueue[m_nActiveQueue][m_aPedCommentOrderList[m_nActiveQueue][0]].m_nSampleIndex;
switch(SampleManager.IsPedCommentLoaded(sampleIndex)) { // yes, this was a switch
case FALSE:
#if defined(GTA_PC) && !defined(FIX_BUGS)
@@ -8081,13 +8087,13 @@ cPedComments::Process()
SampleManager.LoadPedComment(sampleIndex);
break;
case TRUE:
- AudioManager.m_sQueueSample.m_nEntityIndex = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nEntityIndex;
+ AudioManager.m_sQueueSample.m_nEntityIndex = m_aPedCommentQueue[m_nActiveQueue][m_aPedCommentOrderList[m_nActiveQueue][0]].m_nEntityIndex;
AudioManager.m_sQueueSample.m_nCounter = 0;
AudioManager.m_sQueueSample.m_nSampleIndex = sampleIndex;
AudioManager.m_sQueueSample.m_nBankIndex = SFX_BANK_PED_COMMENTS;
AudioManager.m_sQueueSample.m_nPriority = 3;
- AudioManager.m_sQueueSample.m_nVolume = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nVolume;
- AudioManager.m_sQueueSample.m_fDistance = m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_fDistance;
+ AudioManager.m_sQueueSample.m_nVolume = m_aPedCommentQueue[m_nActiveQueue][m_aPedCommentOrderList[m_nActiveQueue][0]].m_nVolume;
+ AudioManager.m_sQueueSample.m_fDistance = m_aPedCommentQueue[m_nActiveQueue][m_aPedCommentOrderList[m_nActiveQueue][0]].m_fDistance;
AudioManager.m_sQueueSample.m_nLoopCount = 1;
#ifndef GTA_PS2
AudioManager.m_sQueueSample.m_nLoopStart = 0;
@@ -8095,7 +8101,7 @@ cPedComments::Process()
#endif
#ifdef EXTERNAL_3D_SOUND
#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_aPedCommentQueue[m_nActiveQueue][m_aPedCommentOrderList[m_nActiveQueue][0]].m_nEmittingVolume;
#else
AudioManager.m_sQueueSample.m_nEmittingVolume = MAX_VOLUME;
#endif // FIX_BUGS
@@ -8109,7 +8115,7 @@ cPedComments::Process()
#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;
+ AudioManager.m_sQueueSample.m_vecPos = m_aPedCommentQueue[m_nActiveQueue][m_aPedCommentOrderList[m_nActiveQueue][0]].m_vecPos;
#ifdef AUDIO_REVERB
AudioManager.m_sQueueSample.m_bReverb = TRUE;
#endif // AUDIO_REVERB
@@ -8131,7 +8137,7 @@ cPedComments::Process()
if (CTimer::GetIsSlowMotionActive())
AudioManager.m_sQueueSample.m_nFrequency >>= 1;
#endif
- m_asPedComments[m_nActiveBank][m_nIndexMap[m_nActiveBank][0]].m_nProcess = -1;
+ m_aPedCommentQueue[m_nActiveQueue][m_aPedCommentOrderList[m_nActiveQueue][0]].m_nProcess = -1;
prevSamples[counter++] = sampleIndex;
if(counter == 10) counter = 0;
AudioManager.AddSampleToRequestedQueue();
@@ -8144,27 +8150,27 @@ cPedComments::Process()
break;
}
}
+
PedCommentAlreadyAdded:
- // Switch bank
- if (m_nActiveBank == 0) {
- actualUsedBank = 0;
- m_nActiveBank = 1;
+ // Switch queue
+ if (m_nActiveQueue == 0) {
+ queue = 0;
+ m_nActiveQueue = 1;
} else {
- actualUsedBank = 1;
- m_nActiveBank = 0;
+ queue = 1;
+ m_nActiveQueue = 0;
}
- comment = m_asPedComments[actualUsedBank];
- for (uint32 i = 0; i < m_nCommentsInBank[actualUsedBank]; i++) {
- if (m_asPedComments[actualUsedBank][m_nIndexMap[actualUsedBank][i]].m_nProcess > 0) {
- m_asPedComments[actualUsedBank][m_nIndexMap[actualUsedBank][i]].m_nProcess--;
- Add(&comment[m_nIndexMap[actualUsedBank][i]]);
+ for (uint8 i = 0; i < m_nPedCommentCount[queue]; i++) {
+ if (m_aPedCommentQueue[queue][m_aPedCommentOrderList[queue][i]].m_nProcess > 0) {
+ m_aPedCommentQueue[queue][m_aPedCommentOrderList[queue][i]].m_nProcess--;
+ Add(&m_aPedCommentQueue[queue][m_aPedCommentOrderList[queue][i]]);
}
}
- for (uint32 i = 0; i < NUM_PED_COMMENTS_SLOTS; i++) {
- m_nIndexMap[actualUsedBank][i] = NUM_PED_COMMENTS_SLOTS;
- }
- m_nCommentsInBank[actualUsedBank] = 0;
+ // clear queue
+ for (uint8 i = 0; i < NUM_PED_COMMENTS_SLOTS; i++)
+ m_aPedCommentOrderList[queue][i] = NUM_PED_COMMENTS_SLOTS;
+ m_nPedCommentCount[queue] = 0;
#if defined(GTA_PC) && !defined(FIX_BUGS)
if(m_bDelay)
if(CTimer::GetTimeInMilliseconds() - m_nDelayTimer > 6000) m_bDelay = FALSE;