mirror of
https://github.com/GTAmodding/re3.git
synced 2025-02-18 04:45:30 +00:00
Audio: add separate buffer for player comments like on PS2 to fix overflow, add ped comments debug to debug menu
This commit is contained in:
parent
4b747e567a
commit
669c8c8988
7 changed files with 197 additions and 8 deletions
|
@ -43,6 +43,7 @@
|
|||
#include "Fluff.h"
|
||||
#include "Script.h"
|
||||
#include "Wanted.h"
|
||||
#include "debugmenu.h"
|
||||
|
||||
#ifndef GTA_PS2
|
||||
#define CHANNEL_PLAYER_VEHICLE_ENGINE m_nActiveSamples
|
||||
|
@ -7922,6 +7923,20 @@ cAudioManager::DebugPlayPedComment(int32 sound)
|
|||
m_sPedComments.Add(&pedComment);
|
||||
}
|
||||
|
||||
#ifdef DEBUGMENU
|
||||
uint32 nDebugPlayPedComment = SAMPLEBANK_PED_START;
|
||||
|
||||
void DebugMenuPlayPedComment()
|
||||
{
|
||||
AudioManager.DebugPlayPedComment(nDebugPlayPedComment);
|
||||
}
|
||||
|
||||
SETTWEAKPATH("Audio");
|
||||
TWEAKUINT32N(nDebugPlayPedComment, SAMPLEBANK_PED_START, SAMPLEBANK_PED_END, 1, "Ped Comment ID");
|
||||
TWEAKFUNCN(DebugMenuPlayPedComment, "Play Ped Comment");
|
||||
|
||||
#endif
|
||||
|
||||
void
|
||||
cPedComments::Add(tPedComment *com)
|
||||
{
|
||||
|
@ -7958,6 +7973,7 @@ cPedComments::Process()
|
|||
{
|
||||
uint32 sampleIndex;
|
||||
uint8 queue;
|
||||
bool8 bIsPlayerComment;
|
||||
static uint8 counter = 0;
|
||||
static uint32 prevSamples[10] = { NO_SAMPLE, NO_SAMPLE, NO_SAMPLE, NO_SAMPLE, NO_SAMPLE, NO_SAMPLE, NO_SAMPLE, NO_SAMPLE, NO_SAMPLE, NO_SAMPLE };
|
||||
|
||||
|
@ -7971,13 +7987,30 @@ cPedComments::Process()
|
|||
goto PedCommentAlreadyAdded;
|
||||
}
|
||||
}
|
||||
#if defined(GTA_PS2) || defined(FIX_BUGS)
|
||||
bool8 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);
|
||||
bIsPlayerComment = TRUE;
|
||||
} else {
|
||||
IsLoadedResult = SampleManager.IsPedCommentLoaded(sampleIndex);
|
||||
bIsPlayerComment = FALSE;
|
||||
}
|
||||
switch(IsLoadedResult) { // yes, this was a switch
|
||||
#else
|
||||
switch(SampleManager.IsPedCommentLoaded(sampleIndex)) { // yes, this was a switch
|
||||
#endif
|
||||
case FALSE:
|
||||
#if defined(GTA_PC) && !defined(FIX_BUGS)
|
||||
if(!m_bDelay)
|
||||
#endif
|
||||
SampleManager.LoadPedComment(sampleIndex);
|
||||
#if defined(GTA_PS2) || defined(FIX_BUGS)
|
||||
if (bIsPlayerComment)
|
||||
SampleManager.LoadMissionAudio(MISSION_AUDIO_PLAYER_COMMENT, sampleIndex);
|
||||
else
|
||||
#endif
|
||||
SampleManager.LoadPedComment(sampleIndex);
|
||||
break;
|
||||
case TRUE:
|
||||
AudioManager.m_sQueueSample.m_nEntityIndex = m_aPedCommentQueue[m_nActiveQueue][m_aPedCommentOrderList[m_nActiveQueue][0]].m_nEntityIndex;
|
||||
|
@ -8021,7 +8054,7 @@ cPedComments::Process()
|
|||
(sampleIndex >= SFX_POLICE_HELI_1 && sampleIndex <= SFX_POLICE_HELI_20))
|
||||
AudioManager.m_sQueueSample.m_MaxDistance = PED_COMMENT_POLICE_HELI_MAX_DIST;
|
||||
#ifndef ATTACH_RELEASING_SOUNDS_TO_ENTITIES
|
||||
else if (sampleIndex >= SFX_PLAYER_ANGRY_BUSTED_1 && sampleIndex <= SFX_PLAYER_ON_FIRE_16) { // check if player sfx
|
||||
else if (sampleIndex >= PLAYER_COMMENTS_START && sampleIndex <= PLAYER_COMMENTS_END) { // check if player sfx
|
||||
AudioManager.m_sQueueSample.m_bIs2D = TRUE;
|
||||
AudioManager.m_sQueueSample.m_nPan = 63;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
#include "common.h"
|
||||
|
||||
#define FIRST_PLAYER_COMMENT(e) PLAYER_COMMENTS_START, e = PLAYER_COMMENTS_START
|
||||
#define LAST_PLAYER_COMMENT(e) e, PLAYER_COMMENTS_END = e
|
||||
|
||||
enum eSfxSample
|
||||
{
|
||||
SFX_CAR_HORN_JEEP = 0,
|
||||
|
@ -8864,7 +8867,7 @@ enum eSfxSample
|
|||
SFX_COP_VOICE_5_COP_TARGETING_3,
|
||||
SFX_COP_VOICE_5_COP_TARGETING_4,
|
||||
|
||||
SFX_PLAYER_ANGRY_BUSTED_1,
|
||||
FIRST_PLAYER_COMMENT(SFX_PLAYER_ANGRY_BUSTED_1),
|
||||
SFX_PLAYER_ANGRY_BUSTED_2,
|
||||
SFX_PLAYER_ANGRY_BUSTED_3,
|
||||
SFX_PLAYER_ANGRY_BUSTED_4,
|
||||
|
@ -10113,7 +10116,7 @@ enum eSfxSample
|
|||
SFX_PLAYER_ON_FIRE_13,
|
||||
SFX_PLAYER_ON_FIRE_14,
|
||||
SFX_PLAYER_ON_FIRE_15,
|
||||
SFX_PLAYER_ON_FIRE_16,
|
||||
LAST_PLAYER_COMMENT(SFX_PLAYER_ON_FIRE_16),
|
||||
TOTAL_AUDIO_SAMPLES,
|
||||
NO_SAMPLE,
|
||||
|
||||
|
@ -10122,6 +10125,6 @@ enum eSfxSample
|
|||
SAMPLEBANK_END = SFX_FOOTSTEP_SAND_4,
|
||||
SAMPLEBANK_MAX = SFX_FOOTSTEP_SAND_4 + 1,
|
||||
SAMPLEBANK_PED_START = SFX_FOOTSTEP_SAND_4 + 1,
|
||||
SAMPLEBANK_PED_END = 9940,
|
||||
SAMPLEBANK_PED_END = SFX_PLAYER_ON_FIRE_16,
|
||||
SAMPLEBANK_PED_MAX = SAMPLEBANK_PED_END + 1,
|
||||
};
|
||||
|
|
|
@ -1324,3 +1324,13 @@ enum
|
|||
NUM_CHANNELS
|
||||
};
|
||||
#endif
|
||||
|
||||
enum
|
||||
{
|
||||
MISSION_AUDIO_SLOT_1,
|
||||
MISSION_AUDIO_SLOT_2,
|
||||
MISSION_AUDIO_POLRADIO_CRIME_OR_COLOR,
|
||||
MISSION_AUDIO_POLRADIO_AREA_OR_CAR,
|
||||
MISSION_AUDIO_PLAYER_COMMENT,
|
||||
MISSION_AUDIO_COUNT
|
||||
};
|
||||
|
|
|
@ -204,6 +204,11 @@ public:
|
|||
bool8 LoadSampleBank (uint8 nBank);
|
||||
void UnloadSampleBank (uint8 nBank);
|
||||
bool8 IsSampleBankLoaded(uint8 nBank);
|
||||
|
||||
#if defined (GTA_PS2) || defined (FIX_BUGS)
|
||||
bool8 IsMissionAudioLoaded(uint8 nSlot, uint32 nSample);
|
||||
bool8 LoadMissionAudio (uint8 nSlot, uint32 nSample);
|
||||
#endif
|
||||
|
||||
bool8 IsPedCommentLoaded(uint32 nComment);
|
||||
bool8 LoadPedComment (uint32 nComment);
|
||||
|
|
|
@ -39,6 +39,11 @@ int32 nPedSlotSfx [MAX_PEDSFX];
|
|||
int32 nPedSlotSfxAddr[MAX_PEDSFX];
|
||||
uint8 nCurrentPedSlot;
|
||||
|
||||
#ifdef FIX_BUGS
|
||||
uint32 gPlayerTalkSfx = UINT32_MAX;
|
||||
void *gPlayerTalkData = 0;
|
||||
#endif
|
||||
|
||||
uint8 nChannelVolume[MAXCHANNELS+MAX2DCHANNELS];
|
||||
|
||||
uint32 nStreamLength[TOTAL_STREAMED_SOUNDS];
|
||||
|
@ -1266,6 +1271,20 @@ cSampleManager::Initialise(void)
|
|||
|
||||
nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = (int32)AIL_mem_alloc_lock(PED_BLOCKSIZE*MAX_PEDSFX);
|
||||
|
||||
#ifdef FIX_BUGS
|
||||
// Find biggest player comment
|
||||
uint32 nMaxPedSize = 0;
|
||||
for (uint32 i = PLAYER_COMMENTS_START; i <= PLAYER_COMMENTS_END; i++)
|
||||
nMaxPedSize = Max(nMaxPedSize, m_aSamples[i].nSize);
|
||||
|
||||
gPlayerTalkData = AIL_mem_alloc_lock(nMaxPedSize);
|
||||
if ( !gPlayerTalkData )
|
||||
{
|
||||
Terminate();
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
LoadSampleBank(SFX_BANK_0);
|
||||
|
||||
TRACE("stream");
|
||||
|
@ -1419,6 +1438,14 @@ cSampleManager::Terminate(void)
|
|||
AIL_mem_free_lock((void *)nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS]);
|
||||
nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = 0;
|
||||
}
|
||||
|
||||
#ifdef FIX_BUGS
|
||||
if ( gPlayerTalkData != 0)
|
||||
{
|
||||
AIL_mem_free_lock(gPlayerTalkData);
|
||||
gPlayerTalkData = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if ( DIG )
|
||||
{
|
||||
|
@ -1585,6 +1612,33 @@ cSampleManager::IsSampleBankLoaded(uint8 nBank)
|
|||
return bSampleBankLoaded[nBank];
|
||||
}
|
||||
|
||||
#ifdef FIX_BUGS
|
||||
bool8
|
||||
cSampleManager::IsMissionAudioLoaded(uint8 nSlot, uint32 nSample)
|
||||
{
|
||||
ASSERT(nSlot == MISSION_AUDIO_PLAYER_COMMENT); // only MISSION_AUDIO_PLAYER_COMMENT is supported on PC
|
||||
|
||||
return nSample == gPlayerTalkSfx;
|
||||
}
|
||||
|
||||
bool8
|
||||
cSampleManager::LoadMissionAudio(uint8 nSlot, uint32 nSample)
|
||||
{
|
||||
ASSERT(nSlot == MISSION_AUDIO_PLAYER_COMMENT); // only MISSION_AUDIO_PLAYER_COMMENT is supported on PC
|
||||
ASSERT(nSample < TOTAL_AUDIO_SAMPLES);
|
||||
|
||||
if (fseek(fpSampleDataHandle, m_aSamples[nSample].nOffset, SEEK_SET) != 0)
|
||||
return FALSE;
|
||||
|
||||
if (fread(gPlayerTalkData, 1, m_aSamples[nSample].nSize, fpSampleDataHandle) != m_aSamples[nSample].nSize)
|
||||
return FALSE;
|
||||
|
||||
gPlayerTalkSfx = nSample;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool8
|
||||
cSampleManager::IsPedCommentLoaded(uint32 nComment)
|
||||
{
|
||||
|
@ -1808,6 +1862,15 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank)
|
|||
|
||||
addr = nSampleBankMemoryStartAddress[nBank] + m_aSamples[nSfx].nOffset - m_aSamples[BankStartOffset[nBank]].nOffset;
|
||||
}
|
||||
#ifdef FIX_BUGS
|
||||
else if ( nSfx >= PLAYER_COMMENTS_START && nSfx <= PLAYER_COMMENTS_END )
|
||||
{
|
||||
if ( !IsMissionAudioLoaded(MISSION_AUDIO_PLAYER_COMMENT, nSfx) )
|
||||
return FALSE;
|
||||
|
||||
addr = (uintptr)gPlayerTalkData;
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
if ( !IsPedCommentLoaded(nSfx) )
|
||||
|
@ -2496,7 +2559,7 @@ cSampleManager::InitialiseSampleBanks(void)
|
|||
fclose(fpSampleDescHandle);
|
||||
fpSampleDescHandle = NULL;
|
||||
|
||||
for ( int32 i = 0; i < TOTAL_AUDIO_SAMPLES; i++ )
|
||||
for ( uint32 i = 0; i < TOTAL_AUDIO_SAMPLES; i++ )
|
||||
{
|
||||
#ifdef FIX_BUGS
|
||||
if (nBank >= MAX_SFX_BANKS) break;
|
||||
|
|
|
@ -156,6 +156,22 @@ cSampleManager::IsSampleBankLoaded(uint8 nBank)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
bool8
|
||||
cSampleManager::IsMissionAudioLoaded(uint8 nSlot, uint32 nSample)
|
||||
{
|
||||
ASSERT(nSlot < MISSION_AUDIO_COUNT);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8
|
||||
cSampleManager::LoadMissionAudio(uint8 nSlot, uint32 nSample)
|
||||
{
|
||||
ASSERT(nSlot < MISSION_AUDIO_COUNT);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8
|
||||
cSampleManager::IsPedCommentLoaded(uint32 nComment)
|
||||
{
|
||||
|
|
|
@ -102,6 +102,11 @@ int32 nPedSlotSfx [MAX_PEDSFX];
|
|||
int32 nPedSlotSfxAddr[MAX_PEDSFX];
|
||||
uint8 nCurrentPedSlot;
|
||||
|
||||
#ifdef FIX_BUGS
|
||||
uint32 gPlayerTalkSfx = UINT32_MAX;
|
||||
void *gPlayerTalkData = 0;
|
||||
#endif
|
||||
|
||||
CChannel aChannel[NUM_CHANNELS];
|
||||
uint8 nChannelVolume[NUM_CHANNELS];
|
||||
|
||||
|
@ -963,7 +968,17 @@ cSampleManager::Initialise(void)
|
|||
|
||||
nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = (uintptr)malloc(PED_BLOCKSIZE*MAX_PEDSFX);
|
||||
ASSERT(nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] != 0);
|
||||
|
||||
|
||||
#ifdef FIX_BUGS
|
||||
// Find biggest player comment
|
||||
uint32 nMaxPedSize = 0;
|
||||
for (uint32 i = PLAYER_COMMENTS_START; i <= PLAYER_COMMENTS_END; i++)
|
||||
nMaxPedSize = Max(nMaxPedSize, m_aSamples[i].nSize);
|
||||
|
||||
gPlayerTalkData = malloc(nMaxPedSize);
|
||||
ASSERT(gPlayerTalkData != 0);
|
||||
#endif
|
||||
|
||||
LoadSampleBank(SFX_BANK_0);
|
||||
}
|
||||
|
||||
|
@ -1123,6 +1138,14 @@ cSampleManager::Terminate(void)
|
|||
free((void *)nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS]);
|
||||
nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = 0;
|
||||
}
|
||||
|
||||
#ifdef FIX_BUGS
|
||||
if ( gPlayerTalkData != 0 )
|
||||
{
|
||||
free(gPlayerTalkData);
|
||||
gPlayerTalkData = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
_bSampmanInitialised = FALSE;
|
||||
}
|
||||
|
@ -1248,6 +1271,33 @@ cSampleManager::IsSampleBankLoaded(uint8 nBank)
|
|||
return bSampleBankLoaded[nBank];
|
||||
}
|
||||
|
||||
#ifdef FIX_BUGS
|
||||
bool8
|
||||
cSampleManager::IsMissionAudioLoaded(uint8 nSlot, uint32 nSample)
|
||||
{
|
||||
ASSERT(nSlot == MISSION_AUDIO_PLAYER_COMMENT); // only MISSION_AUDIO_PLAYER_COMMENT is supported on PC
|
||||
|
||||
return nSample == gPlayerTalkSfx;
|
||||
}
|
||||
|
||||
bool8
|
||||
cSampleManager::LoadMissionAudio(uint8 nSlot, uint32 nSample)
|
||||
{
|
||||
ASSERT(nSlot == MISSION_AUDIO_PLAYER_COMMENT); // only MISSION_AUDIO_PLAYER_COMMENT is supported on PC
|
||||
ASSERT(nSample < TOTAL_AUDIO_SAMPLES);
|
||||
|
||||
if (fseek(fpSampleDataHandle, m_aSamples[nSample].nOffset, SEEK_SET) != 0)
|
||||
return FALSE;
|
||||
|
||||
if (fread(gPlayerTalkData, 1, m_aSamples[nSample].nSize, fpSampleDataHandle) != m_aSamples[nSample].nSize)
|
||||
return FALSE;
|
||||
|
||||
gPlayerTalkSfx = nSample;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool8
|
||||
cSampleManager::IsPedCommentLoaded(uint32 nComment)
|
||||
{
|
||||
|
@ -1482,6 +1532,15 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank)
|
|||
|
||||
addr = nSampleBankMemoryStartAddress[nBank] + m_aSamples[nSfx].nOffset - m_aSamples[BankStartOffset[nBank]].nOffset;
|
||||
}
|
||||
#ifdef FIX_BUGS
|
||||
else if ( nSfx >= PLAYER_COMMENTS_START && nSfx <= PLAYER_COMMENTS_END )
|
||||
{
|
||||
if ( !IsMissionAudioLoaded(MISSION_AUDIO_PLAYER_COMMENT, nSfx) )
|
||||
return FALSE;
|
||||
|
||||
addr = (uintptr)gPlayerTalkData;
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
if ( !IsPedCommentLoaded(nSfx) )
|
||||
|
@ -1984,7 +2043,7 @@ cSampleManager::InitialiseSampleBanks(void)
|
|||
fclose(fpSampleDescHandle);
|
||||
fpSampleDescHandle = NULL;
|
||||
|
||||
for ( int32 i = 0; i < TOTAL_AUDIO_SAMPLES; i++ )
|
||||
for ( uint32 i = 0; i < TOTAL_AUDIO_SAMPLES; i++ )
|
||||
{
|
||||
#ifdef FIX_BUGS
|
||||
if (nBank >= MAX_SFX_BANKS) break;
|
||||
|
|
Loading…
Add table
Reference in a new issue