1
0
Fork 0
mirror of https://github.com/halpz/re3.git synced 2024-12-22 17:35:29 +00:00

Merge branch 'miami' into lcs

# Conflicts:
#	src/audio/AudioLogic.cpp
#	src/audio/sampman.h
#	src/audio/sampman_miles.cpp
#	src/audio/sampman_oal.cpp
This commit is contained in:
Sergeanur 2021-09-02 21:00:15 +03:00
commit 33abd1b4e7
6 changed files with 81 additions and 58 deletions

View file

@ -5441,7 +5441,7 @@ cAudioManager::SetupPedComments(cPedParams &params, uint16 sound)
else
Vol = PED_COMMENT_VOLUME_BEHIND_WALL;
m_sQueueSample.m_nVolume = ComputeVolume(Vol, maxDist, m_sQueueSample.m_fDistance);
pedComment.m_nProcess = 10;
pedComment.m_nLoadingTimeout = 10;
if (m_sQueueSample.m_nVolume > 0) {
pedComment.m_nEntityIndex = m_sQueueSample.m_nEntityIndex;
pedComment.m_vecPos = m_sQueueSample.m_vecPos;
@ -8229,7 +8229,7 @@ cAudioManager::DebugPlayPedComment(int32 sound)
tPedComment pedComment;
pedComment.m_nSampleIndex = sound;
pedComment.m_nProcess = 10;
pedComment.m_nLoadingTimeout = 10;
pedComment.m_nEntityIndex = 0;
pedComment.m_fDistance = 0.0f;
pedComment.m_nVolume = 99;
@ -8302,11 +8302,11 @@ cPedComments::Process()
for(int i = 0; i < ARRAY_SIZE(prevSamples); i++) {
if(m_aPedCommentQueue[m_nActiveQueue][m_aPedCommentOrderList[m_nActiveQueue][0]].m_nSampleIndex ==
prevSamples[(counter + 1 + i) % ARRAY_SIZE(prevSamples)]) {
m_aPedCommentQueue[m_nActiveQueue][m_aPedCommentOrderList[m_nActiveQueue][0]].m_nProcess = -1;
m_aPedCommentQueue[m_nActiveQueue][m_aPedCommentOrderList[m_nActiveQueue][0]].m_nLoadingTimeout = -1;
goto PedCommentAlreadyAdded;
}
}
bool8 IsLoadedResult;
uint8 IsLoadedResult;
sampleIndex = m_aPedCommentQueue[m_nActiveQueue][m_aPedCommentOrderList[m_nActiveQueue][0]].m_nSampleIndex;
if (sampleIndex >= PLAYER_COMMENTS_START && sampleIndex <= PLAYER_COMMENTS_END) {
IsLoadedResult = SampleManager.IsMissionAudioLoaded(MISSION_AUDIO_PLAYER_COMMENT, sampleIndex);
@ -8315,8 +8315,8 @@ cPedComments::Process()
IsLoadedResult = SampleManager.IsPedCommentLoaded(sampleIndex);
bIsPlayerComment = FALSE;
}
switch(IsLoadedResult) { // yes, this was a switch
case FALSE:
switch(IsLoadedResult) {
case LOADING_STATUS_NOT_LOADED:
#if defined(GTA_PC) && !defined(FIX_BUGS)
if(!m_bDelay)
#endif
@ -8325,7 +8325,7 @@ cPedComments::Process()
else
SampleManager.LoadPedComment(sampleIndex);
break;
case TRUE:
case LOADING_STATUS_LOADED:
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;
@ -8376,7 +8376,7 @@ cPedComments::Process()
if (CTimer::GetIsSlowMotionActive())
AudioManager.m_sQueueSample.m_nFrequency >>= 1;
#endif
m_aPedCommentQueue[m_nActiveQueue][m_aPedCommentOrderList[m_nActiveQueue][0]].m_nProcess = -1;
m_aPedCommentQueue[m_nActiveQueue][m_aPedCommentOrderList[m_nActiveQueue][0]].m_nLoadingTimeout = -1;
prevSamples[counter++] = sampleIndex;
if(counter == 10) counter = 0;
AudioManager.AddSampleToRequestedQueue();
@ -8385,8 +8385,8 @@ cPedComments::Process()
m_bDelay = TRUE;
#endif
break;
default:
break;
case LOADING_STATUS_LOADING: break;
default: break;
}
}
@ -8400,8 +8400,8 @@ PedCommentAlreadyAdded:
m_nActiveQueue = 0;
}
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--;
if (m_aPedCommentQueue[queue][m_aPedCommentOrderList[queue][i]].m_nLoadingTimeout > 0) {
m_aPedCommentQueue[queue][m_aPedCommentOrderList[queue][i]].m_nLoadingTimeout--;
Add(&m_aPedCommentQueue[queue][m_aPedCommentOrderList[queue][i]]);
}
}
@ -11862,7 +11862,7 @@ cAudioManager::ProcessMissionAudioSlot(uint8 slot)
m_nMissionAudioLoadingStatus[slot] = LOADING_STATUS_LOADED;
nFramesUntilFailedLoad[slot] = 0;
break;
case LOADING_STATUS_FAILED:
case LOADING_STATUS_LOADING:
if (++nFramesUntilFailedLoad[slot] >= 120) {
nFramesForPretendPlaying[slot] = 0;
g_bMissionAudioLoadFailed[slot] = TRUE;

View file

@ -89,7 +89,7 @@ public:
CVector m_vecPos;
float m_fDistance;
uint8 m_nVolume;
int8 m_nProcess;
int8 m_nLoadingTimeout; // how many iterations we gonna wait until dropping the sample if it's still not loaded (only useful on PS2)
#if defined(EXTERNAL_3D_SOUND) && defined(FIX_BUGS)
uint8 m_nEmittingVolume;
#endif
@ -113,7 +113,7 @@ public:
{
for (int i = 0; i < NUM_PED_COMMENTS_SLOTS; i++)
for (int j = 0; j < NUM_SOUND_QUEUES; j++) {
m_aPedCommentQueue[j][i].m_nProcess = -1;
m_aPedCommentQueue[j][i].m_nLoadingTimeout = -1;
m_aPedCommentOrderList[j][i] = NUM_PED_COMMENTS_SLOTS;
}
@ -223,7 +223,7 @@ enum {
#endif
enum PLAY_STATUS { PLAY_STATUS_STOPPED = 0, PLAY_STATUS_PLAYING, PLAY_STATUS_FINISHED };
enum LOADING_STATUS { LOADING_STATUS_NOT_LOADED = 0, LOADING_STATUS_LOADED, LOADING_STATUS_FAILED };
enum LOADING_STATUS { LOADING_STATUS_NOT_LOADED = 0, LOADING_STATUS_LOADED, LOADING_STATUS_LOADING };
class cAudioManager
{

View file

@ -206,12 +206,12 @@ public:
bool8 LoadSampleBank (uint8 nBank);
void UnloadSampleBank (uint8 nBank);
bool8 IsSampleBankLoaded(uint8 nBank);
int8 IsSampleBankLoaded(uint8 nBank);
bool8 IsMissionAudioLoaded(uint8 nSlot, uint32 nSample);
uint8 IsMissionAudioLoaded(uint8 nSlot, uint32 nSample);
bool8 LoadMissionAudio (uint8 nSlot, uint32 nSample);
bool8 IsPedCommentLoaded(uint32 nComment);
uint8 IsPedCommentLoaded(uint32 nComment);
bool8 LoadPedComment (uint32 nComment);
int32 GetBankContainingSound(uint32 offset);

View file

@ -29,7 +29,7 @@ char SampleBankDataFilename[] = "AUDIO\\SFX.RAW";
FILE *fpSampleDescHandle;
FILE *fpSampleDataHandle;
bool8 bSampleBankLoaded [MAX_SFX_BANKS];
int8 gBankLoaded [MAX_SFX_BANKS];
int32 nSampleBankDiscStartOffset [MAX_SFX_BANKS];
int32 nSampleBankSize [MAX_SFX_BANKS];
int32 nSampleBankMemoryStartAddress[MAX_SFX_BANKS];
@ -1039,7 +1039,7 @@ cSampleManager::Initialise(void)
for ( int32 i = 0; i < MAX_SFX_BANKS; i++ )
{
bSampleBankLoaded[i] = FALSE;
gBankLoaded[i] = LOADING_STATUS_NOT_LOADED;
nSampleBankDiscStartOffset[i] = 0;
nSampleBankSize[i] = 0;
nSampleBankMemoryStartAddress[i] = 0;
@ -1659,7 +1659,7 @@ cSampleManager::LoadSampleBank(uint8 nBank)
if ( fread((void *)nSampleBankMemoryStartAddress[nBank], 1, nSampleBankSize[nBank],fpSampleDataHandle) != nSampleBankSize[nBank] )
return FALSE;
bSampleBankLoaded[nBank] = TRUE;
gBankLoaded[nBank] = LOADING_STATUS_LOADED;
return TRUE;
}
@ -1667,16 +1667,16 @@ cSampleManager::LoadSampleBank(uint8 nBank)
void
cSampleManager::UnloadSampleBank(uint8 nBank)
{
bSampleBankLoaded[nBank] = FALSE;
gBankLoaded[nBank] = LOADING_STATUS_NOT_LOADED;
}
bool8
int8
cSampleManager::IsSampleBankLoaded(uint8 nBank)
{
return bSampleBankLoaded[nBank];
return gBankLoaded[nBank];
}
bool8
uint8
cSampleManager::IsMissionAudioLoaded(uint8 nSlot, uint32 nSample)
{
ASSERT(nSlot != MISSION_AUDIO_POLRADIO_CRIME_OR_COLOR && nSlot != MISSION_AUDIO_POLRADIO_AREA_OR_CAR); // these are not used in LCS
@ -1685,9 +1685,9 @@ cSampleManager::IsMissionAudioLoaded(uint8 nSlot, uint32 nSample)
{
case MISSION_AUDIO_SLOT_1:
case MISSION_AUDIO_SLOT_2:
return nMissionSlotSfx[nSlot] == nSample;
return nMissionSlotSfx[nSlot] == nSample ? LOADING_STATUS_LOADED : LOADING_STATUS_NOT_LOADED;
case MISSION_AUDIO_PLAYER_COMMENT:
return nSample == gPlayerTalkSfx;
return nSample == gPlayerTalkSfx ? LOADING_STATUS_LOADED : LOADING_STATUS_NOT_LOADED;
}
return FALSE;
}
@ -1721,7 +1721,7 @@ cSampleManager::LoadMissionAudio(uint8 nSlot, uint32 nSample)
return TRUE;
}
bool8
uint8
cSampleManager::IsPedCommentLoaded(uint32 nComment)
{
int8 slot;
@ -1734,10 +1734,10 @@ cSampleManager::IsPedCommentLoaded(uint32 nComment)
slot += ARRAY_SIZE(nPedSlotSfx);
#endif
if ( nComment == nPedSlotSfx[slot] )
return TRUE;
return LOADING_STATUS_LOADED;
}
return FALSE;
return LOADING_STATUS_NOT_LOADED;
}
int32
@ -1964,12 +1964,23 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank)
}
}
if ( !IsPedCommentLoaded(nSfx) )
return FALSE;
int32 slot = _GetPedCommentSlot(nSfx);
int32 i;
for ( i = 0; i < _TODOCONST(3); i++ )
{
int32 slot = nCurrentPedSlot - i - 1;
#ifdef FIX_BUGS
if (slot < 0)
slot += ARRAY_SIZE(nPedSlotSfx);
#endif
if ( nSfx == nPedSlotSfx[slot] )
{
addr = nPedSlotSfxAddr[slot];
break;
}
}
if (i == _TODOCONST(3))
return FALSE;
}
MissionAudioFound:

View file

@ -148,20 +148,20 @@ cSampleManager::UnloadSampleBank(uint8 nBank)
ASSERT( nBank < MAX_SFX_BANKS );
}
bool8
int8
cSampleManager::IsSampleBankLoaded(uint8 nBank)
{
ASSERT( nBank < MAX_SFX_BANKS );
return FALSE;
return LOADING_STATUS_NOT_LOADED;
}
bool8
uint8
cSampleManager::IsMissionAudioLoaded(uint8 nSlot, uint32 nSample)
{
ASSERT(nSlot < MISSION_AUDIO_COUNT);
return FALSE;
return LOADING_STATUS_NOT_LOADED;
}
bool8
@ -172,12 +172,12 @@ cSampleManager::LoadMissionAudio(uint8 nSlot, uint32 nSample)
return FALSE;
}
bool8
uint8
cSampleManager::IsPedCommentLoaded(uint32 nComment)
{
ASSERT( nComment < TOTAL_AUDIO_SAMPLES );
return FALSE;
return LOADING_STATUS_NOT_LOADED;
}

View file

@ -92,7 +92,7 @@ OggOpusFile *fpSampleDataHandle;
#else
FILE *fpSampleDataHandle;
#endif
bool8 bSampleBankLoaded [MAX_SFX_BANKS];
int8 gBankLoaded [MAX_SFX_BANKS];
int32 nSampleBankDiscStartOffset [MAX_SFX_BANKS];
int32 nSampleBankSize [MAX_SFX_BANKS];
uintptr nSampleBankMemoryStartAddress[MAX_SFX_BANKS];
@ -887,7 +887,7 @@ cSampleManager::Initialise(void)
for ( int32 i = 0; i < MAX_SFX_BANKS; i++ )
{
bSampleBankLoaded[i] = FALSE;
gBankLoaded[i] = LOADING_STATUS_NOT_LOADED;
nSampleBankDiscStartOffset[i] = 0;
nSampleBankSize[i] = 0;
nSampleBankMemoryStartAddress[i] = 0;
@ -1343,7 +1343,7 @@ cSampleManager::LoadSampleBank(uint8 nBank)
if ( fread((void *)nSampleBankMemoryStartAddress[nBank], 1, nSampleBankSize[nBank], fpSampleDataHandle) != nSampleBankSize[nBank] )
return FALSE;
#endif
bSampleBankLoaded[nBank] = TRUE;
gBankLoaded[nBank] = LOADING_STATUS_LOADED;
return TRUE;
}
@ -1353,18 +1353,18 @@ cSampleManager::UnloadSampleBank(uint8 nBank)
{
ASSERT( nBank < MAX_SFX_BANKS);
bSampleBankLoaded[nBank] = FALSE;
gBankLoaded[nBank] = LOADING_STATUS_NOT_LOADED;
}
bool8
int8
cSampleManager::IsSampleBankLoaded(uint8 nBank)
{
ASSERT( nBank < MAX_SFX_BANKS);
return bSampleBankLoaded[nBank];
return gBankLoaded[nBank];
}
bool8
uint8
cSampleManager::IsMissionAudioLoaded(uint8 nSlot, uint32 nSample)
{
ASSERT(nSlot != MISSION_AUDIO_POLRADIO_CRIME_OR_COLOR && nSlot != MISSION_AUDIO_POLRADIO_AREA_OR_CAR); // these are not used in LCS
@ -1373,9 +1373,9 @@ cSampleManager::IsMissionAudioLoaded(uint8 nSlot, uint32 nSample)
{
case MISSION_AUDIO_SLOT_1:
case MISSION_AUDIO_SLOT_2:
return nMissionSlotSfx[nSlot] == nSample;
return nMissionSlotSfx[nSlot] == nSample ? LOADING_STATUS_LOADED : LOADING_STATUS_NOT_LOADED;
case MISSION_AUDIO_PLAYER_COMMENT:
return nSample == gPlayerTalkSfx;
return nSample == gPlayerTalkSfx ? LOADING_STATUS_LOADED : LOADING_STATUS_NOT_LOADED;
}
return FALSE;
}
@ -1409,7 +1409,7 @@ cSampleManager::LoadMissionAudio(uint8 nSlot, uint32 nSample)
return TRUE;
}
bool8
uint8
cSampleManager::IsPedCommentLoaded(uint32 nComment)
{
ASSERT( nComment < TOTAL_AUDIO_SAMPLES );
@ -1424,10 +1424,10 @@ cSampleManager::IsPedCommentLoaded(uint32 nComment)
uint8 slot = nCurrentPedSlot - i - 1;
#endif
if ( nComment == nPedSlotSfx[slot] )
return TRUE;
return LOADING_STATUS_LOADED;
}
return FALSE;
return LOADING_STATUS_NOT_LOADED;
}
@ -1659,11 +1659,23 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank)
}
}
if ( !IsPedCommentLoaded(nSfx) )
return FALSE;
int32 slot = _GetPedCommentSlot(nSfx);
int32 i;
for ( i = 0; i < _TODOCONST(3); i++ )
{
int32 slot = nCurrentPedSlot - i - 1;
#ifdef FIX_BUGS
if (slot < 0)
slot += ARRAY_SIZE(nPedSlotSfx);
#endif
if ( nSfx == nPedSlotSfx[slot] )
{
addr = (nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BLOCKSIZE * slot);
break;
}
}
if (i == _TODOCONST(3))
return FALSE;
}
MissionAudioFound: