mirror of
https://git.rip/DMCA_FUCKER/re3.git
synced 2024-11-13 00:49:15 +00:00
Mission audio slots
This commit is contained in:
parent
0afb1d9e24
commit
36a6d124aa
|
@ -154,13 +154,25 @@ cAudioManager::PostInitialiseGameSpecificSetup()
|
|||
if (m_nBridgeEntity >= 0)
|
||||
SetEntityStatus(m_nBridgeEntity, 1);
|
||||
|
||||
m_sMissionAudio.m_nSampleIndex = NO_SAMPLE;
|
||||
m_sMissionAudio.m_nLoadingStatus = LOADING_STATUS_NOT_LOADED;
|
||||
m_sMissionAudio.m_nPlayStatus = PLAY_STATUS_STOPPED;
|
||||
m_sMissionAudio.field_22 = 0;
|
||||
m_sMissionAudio.m_bIsPlayed = false;
|
||||
m_sMissionAudio.m_bPredefinedProperties = true;
|
||||
m_sMissionAudio.m_nMissionAudioCounter = 0;
|
||||
m_sMissionAudio.m_nSampleIndex[0] = NO_SAMPLE;
|
||||
m_sMissionAudio.m_nLoadingStatus[0] = LOADING_STATUS_NOT_LOADED;
|
||||
m_sMissionAudio.m_nPlayStatus[0] = PLAY_STATUS_STOPPED;
|
||||
m_sMissionAudio.field_22[0] = 0;
|
||||
m_sMissionAudio.m_bIsPlayed[0] = false;
|
||||
m_sMissionAudio.m_bPredefinedProperties[0] = true;
|
||||
m_sMissionAudio.m_nMissionAudioCounter[0] = 0;
|
||||
m_sMissionAudio.m_bIsMobile[0] = false;
|
||||
field_5538 = 127;
|
||||
m_sMissionAudio.m_nSampleIndex[1] = NO_SAMPLE;
|
||||
m_sMissionAudio.m_nLoadingStatus[1] = LOADING_STATUS_NOT_LOADED;
|
||||
m_sMissionAudio.m_nPlayStatus[1] = PLAY_STATUS_STOPPED;
|
||||
m_sMissionAudio.field_22[1] = 0;
|
||||
m_sMissionAudio.m_bIsPlayed[1] = false;
|
||||
m_sMissionAudio.m_bPredefinedProperties[1] = true;
|
||||
m_sMissionAudio.m_nMissionAudioCounter[1] = 0;
|
||||
m_sMissionAudio.m_bIsMobile[1] = false;
|
||||
field_5538 = 127;
|
||||
|
||||
ResetAudioLogicTimers(CTimer::GetTimeInMilliseconds());
|
||||
}
|
||||
void
|
||||
|
@ -223,7 +235,8 @@ cAudioManager::ResetAudioLogicTimers(uint32 timer)
|
|||
}
|
||||
}
|
||||
}
|
||||
ClearMissionAudio();
|
||||
ClearMissionAudio(0);
|
||||
ClearMissionAudio(1);
|
||||
SampleManager.StopChannel(policeChannel);
|
||||
}
|
||||
|
||||
|
@ -5203,7 +5216,7 @@ cAudioManager::ProcessBridgeOneShots()
|
|||
#endif
|
||||
|
||||
#pragma region MISSION_AUDIO
|
||||
bool g_bMissionAudioLoadFailed;
|
||||
bool g_bMissionAudioLoadFailed[MISSION_AUDIO_SLOTS];
|
||||
|
||||
struct MissionAudioData {
|
||||
const char *m_pName;
|
||||
|
@ -5605,77 +5618,104 @@ cAudioManager::MissionScriptAudioUsesPoliceChannel(int32 soundMission) const
|
|||
}
|
||||
|
||||
void
|
||||
cAudioManager::PreloadMissionAudio(const char *name)
|
||||
cAudioManager::PreloadMissionAudio(uint8 slot, Const char *name)
|
||||
{
|
||||
if (m_bIsInitialised) {
|
||||
if (m_bIsInitialised && slot < MISSION_AUDIO_SLOTS) {
|
||||
int32 missionAudioSfx = FindMissionAudioSfx(name);
|
||||
if (missionAudioSfx != NO_SAMPLE) {
|
||||
m_sMissionAudio.m_nSampleIndex = missionAudioSfx;
|
||||
m_sMissionAudio.m_nLoadingStatus = LOADING_STATUS_NOT_LOADED;
|
||||
m_sMissionAudio.m_nPlayStatus = PLAY_STATUS_STOPPED;
|
||||
m_sMissionAudio.field_22 = 0;
|
||||
m_sMissionAudio.m_nMissionAudioCounter = m_nTimeSpent * SampleManager.GetStreamedFileLength(missionAudioSfx) / 1000;
|
||||
m_sMissionAudio.m_nMissionAudioCounter *= 4;
|
||||
m_sMissionAudio.m_bIsPlayed = false;
|
||||
m_sMissionAudio.m_bPredefinedProperties = 1;
|
||||
g_bMissionAudioLoadFailed = false;
|
||||
m_sMissionAudio.m_nSampleIndex[slot] = missionAudioSfx;
|
||||
m_sMissionAudio.m_nLoadingStatus[slot] = LOADING_STATUS_NOT_LOADED;
|
||||
m_sMissionAudio.m_nPlayStatus[slot] = PLAY_STATUS_STOPPED;
|
||||
m_sMissionAudio.field_22[slot] = 0;
|
||||
m_sMissionAudio.m_nMissionAudioCounter[slot] = m_nTimeSpent * SampleManager.GetStreamedFileLength(missionAudioSfx) / 1000;
|
||||
m_sMissionAudio.m_nMissionAudioCounter[slot] *= 4;
|
||||
m_sMissionAudio.m_bIsPlayed[slot] = false;
|
||||
m_sMissionAudio.m_bPredefinedProperties[slot] = true;
|
||||
g_bMissionAudioLoadFailed[slot] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint8
|
||||
cAudioManager::GetMissionAudioLoadingStatus() const
|
||||
cAudioManager::GetMissionAudioLoadingStatus(uint8 slot) const
|
||||
{
|
||||
if (m_bIsInitialised)
|
||||
return m_sMissionAudio.m_nLoadingStatus;
|
||||
if (m_bIsInitialised && slot < MISSION_AUDIO_SLOTS)
|
||||
return m_sMissionAudio.m_nLoadingStatus[slot];
|
||||
|
||||
return LOADING_STATUS_LOADED;
|
||||
}
|
||||
|
||||
void
|
||||
cAudioManager::SetMissionAudioLocation(float x, float y, float z)
|
||||
cAudioManager::SetMissionAudioLocation(uint8 slot, float x, float y, float z)
|
||||
{
|
||||
if (m_bIsInitialised) {
|
||||
m_sMissionAudio.m_bPredefinedProperties = false;
|
||||
m_sMissionAudio.m_vecPos = CVector(x, y, z);
|
||||
if (m_bIsInitialised && slot < MISSION_AUDIO_SLOTS) {
|
||||
m_sMissionAudio.m_bPredefinedProperties[slot] = false;
|
||||
m_sMissionAudio.m_vecPos[slot] = CVector(x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
cAudioManager::PlayLoadedMissionAudio()
|
||||
cAudioManager::PlayLoadedMissionAudio(uint8 slot)
|
||||
{
|
||||
if (m_bIsInitialised && m_sMissionAudio.m_nSampleIndex != NO_SAMPLE && m_sMissionAudio.m_nLoadingStatus == LOADING_STATUS_LOADED &&
|
||||
m_sMissionAudio.m_nPlayStatus == PLAY_STATUS_STOPPED)
|
||||
m_sMissionAudio.m_bIsPlayed = true;
|
||||
if (m_bIsInitialised && slot < MISSION_AUDIO_SLOTS && m_sMissionAudio.m_nSampleIndex[slot] != NO_SAMPLE && m_sMissionAudio.m_nLoadingStatus[slot] == LOADING_STATUS_LOADED &&
|
||||
m_sMissionAudio.m_nPlayStatus[slot] == PLAY_STATUS_STOPPED)
|
||||
m_sMissionAudio.m_bIsPlayed[slot] = true;
|
||||
}
|
||||
|
||||
bool
|
||||
cAudioManager::IsMissionAudioSampleFinished()
|
||||
cAudioManager::ShouldDuckMissionAudio(uint8 slot) const
|
||||
{
|
||||
if (m_bIsInitialised)
|
||||
return m_sMissionAudio.m_nPlayStatus == PLAY_STATUS_FINISHED;
|
||||
if (IsMissionAudioSamplePlaying(slot))
|
||||
return m_sMissionAudio.m_nSampleIndex[slot] != STREAMED_SOUND_MISSION_ROK2_01;
|
||||
return false;
|
||||
}
|
||||
|
||||
static int32 cPretendFrame = 1;
|
||||
bool
|
||||
cAudioManager::IsMissionAudioSamplePlaying(uint8 slot) const
|
||||
{
|
||||
if (m_bIsInitialised) {
|
||||
if (slot < MISSION_AUDIO_SLOTS)
|
||||
return m_sMissionAudio.m_nPlayStatus[slot] == PLAY_STATUS_PLAYING;
|
||||
else
|
||||
return true;
|
||||
} else {
|
||||
static int32 cPretendFrame[MISSION_AUDIO_SLOTS] = { 1, 1 };
|
||||
|
||||
return (cPretendFrame++ & 63) == 0;
|
||||
return (cPretendFrame[MISSION_AUDIO_SLOTS]++ % 64) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
cAudioManager::IsMissionAudioSampleFinished(uint8 slot)
|
||||
{
|
||||
if (m_bIsInitialised) {
|
||||
if (slot < MISSION_AUDIO_SLOTS)
|
||||
return m_sMissionAudio.m_nPlayStatus[slot] == PLAY_STATUS_FINISHED;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
static int32 cPretendFrame[MISSION_AUDIO_SLOTS] = { 1, 1 };
|
||||
|
||||
return (cPretendFrame[MISSION_AUDIO_SLOTS]++ % 64) == 0;
|
||||
}
|
||||
|
||||
void
|
||||
cAudioManager::ClearMissionAudio()
|
||||
cAudioManager::ClearMissionAudio(uint8 slot)
|
||||
{
|
||||
if (m_bIsInitialised) {
|
||||
m_sMissionAudio.m_nSampleIndex = NO_SAMPLE;
|
||||
m_sMissionAudio.m_nLoadingStatus = LOADING_STATUS_NOT_LOADED;
|
||||
m_sMissionAudio.m_nPlayStatus = PLAY_STATUS_STOPPED;
|
||||
m_sMissionAudio.field_22 = 0;
|
||||
m_sMissionAudio.m_bIsPlayed = false;
|
||||
m_sMissionAudio.m_bPredefinedProperties = true;
|
||||
m_sMissionAudio.m_nMissionAudioCounter = 0;
|
||||
if (m_bIsInitialised && slot < MISSION_AUDIO_SLOTS) {
|
||||
m_sMissionAudio.m_nSampleIndex[slot] = NO_SAMPLE;
|
||||
m_sMissionAudio.m_nLoadingStatus[slot] = LOADING_STATUS_NOT_LOADED;
|
||||
m_sMissionAudio.m_nPlayStatus[slot] = PLAY_STATUS_STOPPED;
|
||||
m_sMissionAudio.field_22[slot] = 0;
|
||||
m_sMissionAudio.m_bIsPlayed[slot] = false;
|
||||
m_sMissionAudio.m_bPredefinedProperties[slot] = true;
|
||||
m_sMissionAudio.m_nMissionAudioCounter[slot] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
cAudioManager::ProcessMissionAudio()
|
||||
cAudioManager::ProcessMissionAudioSlot(uint8 slot)
|
||||
{
|
||||
float dist;
|
||||
uint8 emittingVol;
|
||||
|
@ -5683,104 +5723,135 @@ cAudioManager::ProcessMissionAudio()
|
|||
float distSquared;
|
||||
CVector vec;
|
||||
|
||||
static uint8 nCheckPlayingDelay = 0;
|
||||
static uint8 nFramesUntilFailedLoad = 0;
|
||||
static uint8 nFramesForPretendPlaying = 0;
|
||||
static uint8 nCheckPlayingDelay[MISSION_AUDIO_SLOTS] = { 0, 0 };
|
||||
static uint8 nFramesUntilFailedLoad[MISSION_AUDIO_SLOTS] = { 0, 0 };
|
||||
static uint8 nFramesForPretendPlaying[MISSION_AUDIO_SLOTS] = { 0, 0 };
|
||||
|
||||
if (!m_bIsInitialised) return;
|
||||
if (m_sMissionAudio.m_nSampleIndex == NO_SAMPLE) return;
|
||||
if (m_sMissionAudio.m_nSampleIndex[slot] == NO_SAMPLE) return;
|
||||
|
||||
switch (m_sMissionAudio.m_nLoadingStatus) {
|
||||
switch (m_sMissionAudio.m_nLoadingStatus[slot]) {
|
||||
case LOADING_STATUS_NOT_LOADED:
|
||||
SampleManager.PreloadStreamedFile(m_sMissionAudio.m_nSampleIndex, 1);
|
||||
m_sMissionAudio.m_nLoadingStatus = LOADING_STATUS_LOADED;
|
||||
nFramesUntilFailedLoad = 0;
|
||||
SampleManager.PreloadStreamedFile(m_sMissionAudio.m_nSampleIndex[slot], slot + 1);
|
||||
m_sMissionAudio.m_nLoadingStatus[slot] = LOADING_STATUS_LOADED;
|
||||
nFramesUntilFailedLoad[slot] = 0;
|
||||
break;
|
||||
case LOADING_STATUS_LOADED:
|
||||
if (!m_sMissionAudio.m_bIsPlayed)
|
||||
if (!m_sMissionAudio.m_bIsPlayed[slot])
|
||||
return;
|
||||
if (g_bMissionAudioLoadFailed) {
|
||||
if (g_bMissionAudioLoadFailed[slot]) {
|
||||
if (m_bTimerJustReset) {
|
||||
ClearMissionAudio();
|
||||
SampleManager.StopStreamedFile(1);
|
||||
nFramesForPretendPlaying = 0;
|
||||
nCheckPlayingDelay = 0;
|
||||
nFramesUntilFailedLoad = 0;
|
||||
ClearMissionAudio(slot);
|
||||
SampleManager.StopStreamedFile(slot + 1);
|
||||
nFramesForPretendPlaying[slot] = 0;
|
||||
nCheckPlayingDelay[slot] = 0;
|
||||
nFramesUntilFailedLoad[slot] = 0;
|
||||
} else if (!m_nUserPause) {
|
||||
if (++nFramesForPretendPlaying < 120) {
|
||||
m_sMissionAudio.m_nPlayStatus = PLAY_STATUS_PLAYING;
|
||||
if (++nFramesForPretendPlaying[slot] < 120) {
|
||||
m_sMissionAudio.m_nPlayStatus[slot] = PLAY_STATUS_PLAYING;
|
||||
} else {
|
||||
m_sMissionAudio.m_nPlayStatus = PLAY_STATUS_FINISHED;
|
||||
m_sMissionAudio.m_nSampleIndex = NO_SAMPLE;
|
||||
m_sMissionAudio.m_nPlayStatus[slot] = PLAY_STATUS_FINISHED;
|
||||
m_sMissionAudio.m_nSampleIndex[slot] = NO_SAMPLE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
switch (m_sMissionAudio.m_nPlayStatus) {
|
||||
switch (m_sMissionAudio.m_nPlayStatus[slot]) {
|
||||
case PLAY_STATUS_STOPPED:
|
||||
if (MissionScriptAudioUsesPoliceChannel(m_sMissionAudio.m_nSampleIndex)) {
|
||||
SetMissionScriptPoliceAudio(m_sMissionAudio.m_nSampleIndex);
|
||||
if (MissionScriptAudioUsesPoliceChannel(m_sMissionAudio.m_nSampleIndex[slot])) {
|
||||
SetMissionScriptPoliceAudio(m_sMissionAudio.m_nSampleIndex[slot]);
|
||||
} else {
|
||||
if (m_nUserPause)
|
||||
SampleManager.PauseStream(1, 1);
|
||||
SampleManager.PauseStream(1, slot + 1);
|
||||
if (m_sMissionAudio.m_bPredefinedProperties) {
|
||||
SampleManager.SetStreamedVolumeAndPan(80, 63, 1, 1);
|
||||
if (m_sMissionAudio.m_nSampleIndex[slot] == STREAMED_SOUND_MISSION_CAMERAL)
|
||||
SampleManager.SetStreamedVolumeAndPan(80, 0, 1, slot + 1);
|
||||
else if (m_sMissionAudio.m_nSampleIndex[slot] == STREAMED_SOUND_MISSION_CAMERAR)
|
||||
SampleManager.SetStreamedVolumeAndPan(80, 127, 1, slot + 1);
|
||||
else
|
||||
SampleManager.SetStreamedVolumeAndPan(80, 63, 1, slot + 1);
|
||||
} else {
|
||||
distSquared = GetDistanceSquared(m_sMissionAudio.m_vecPos);
|
||||
if (distSquared >= SQR(50.0f)) {
|
||||
distSquared = GetDistanceSquared(m_sMissionAudio.m_vecPos[slot]);
|
||||
if (distSquared >= SQR(80.0f)) {
|
||||
emittingVol = 0;
|
||||
pan = 63;
|
||||
} else {
|
||||
dist = Sqrt(distSquared);
|
||||
emittingVol = ComputeVolume(80, 50.0f, dist);
|
||||
TranslateEntity(&m_sMissionAudio.m_vecPos, &vec);
|
||||
pan = ComputePan(50.f, &vec);
|
||||
emittingVol = 80;
|
||||
if (distSquared > 0.0f) {
|
||||
dist = Sqrt(distSquared);
|
||||
emittingVol = ComputeVolume(80, 80.0f, dist);
|
||||
}
|
||||
TranslateEntity(&m_sMissionAudio.m_vecPos[slot], &vec);
|
||||
pan = ComputePan(80.f, &vec);
|
||||
}
|
||||
SampleManager.SetStreamedVolumeAndPan(emittingVol, pan, 1, 1);
|
||||
SampleManager.SetStreamedVolumeAndPan(emittingVol, pan, 1, slot + 1);
|
||||
}
|
||||
SampleManager.StartPreloadedStreamedFile(1);
|
||||
SampleManager.StartPreloadedStreamedFile(slot + 1);
|
||||
}
|
||||
m_sMissionAudio.m_nPlayStatus = PLAY_STATUS_PLAYING;
|
||||
nCheckPlayingDelay = 30;
|
||||
m_sMissionAudio.m_nPlayStatus[slot] = PLAY_STATUS_PLAYING;
|
||||
nCheckPlayingDelay[slot] = 30;
|
||||
if (m_sMissionAudio.m_nSampleIndex[slot] >= STREAMED_SOUND_MISSION_MOB_01A && m_sMissionAudio.m_nSampleIndex[slot] <= STREAMED_SOUND_MISSION_MOB_99A)
|
||||
m_sMissionAudio.m_bIsMobile[slot] = true;
|
||||
break;
|
||||
case PLAY_STATUS_PLAYING:
|
||||
if (m_bTimerJustReset) {
|
||||
ClearMissionAudio();
|
||||
SampleManager.StopStreamedFile(1);
|
||||
ClearMissionAudio(slot);
|
||||
SampleManager.StopStreamedFile(slot + 1);
|
||||
break;
|
||||
}
|
||||
if (MissionScriptAudioUsesPoliceChannel(m_sMissionAudio.m_nSampleIndex)) {
|
||||
if (MissionScriptAudioUsesPoliceChannel(m_sMissionAudio.m_nSampleIndex[slot])) {
|
||||
if (!m_nUserPause) {
|
||||
if (nCheckPlayingDelay) {
|
||||
--nCheckPlayingDelay;
|
||||
} else if (GetMissionScriptPoliceAudioPlayingStatus() == PLAY_STATUS_FINISHED || m_sMissionAudio.m_nMissionAudioCounter-- == 0) {
|
||||
m_sMissionAudio.m_nPlayStatus = PLAY_STATUS_FINISHED;
|
||||
m_sMissionAudio.m_nSampleIndex = NO_SAMPLE;
|
||||
SampleManager.StopStreamedFile(1);
|
||||
m_sMissionAudio.m_nMissionAudioCounter = 0;
|
||||
if (nCheckPlayingDelay[slot]) {
|
||||
--nCheckPlayingDelay[slot];
|
||||
} else if (GetMissionScriptPoliceAudioPlayingStatus() == PLAY_STATUS_FINISHED || m_sMissionAudio.m_nMissionAudioCounter[slot]-- == 0) {
|
||||
m_sMissionAudio.m_nPlayStatus[slot] = PLAY_STATUS_FINISHED;
|
||||
m_sMissionAudio.m_nSampleIndex[slot] = NO_SAMPLE;
|
||||
SampleManager.StopStreamedFile(slot + 1);
|
||||
m_sMissionAudio.m_nMissionAudioCounter[slot] = 0;
|
||||
}
|
||||
}
|
||||
} else if (m_sMissionAudio.field_22) {
|
||||
if (SampleManager.IsStreamPlaying(1) || m_nUserPause || m_nPreviousUserPause) {
|
||||
} else if (m_sMissionAudio.field_22[slot]) {
|
||||
if (SampleManager.IsStreamPlaying(slot + 1) || m_nUserPause || m_nPreviousUserPause) {
|
||||
if (m_nUserPause)
|
||||
SampleManager.PauseStream(1, 1);
|
||||
SampleManager.PauseStream(1, slot + 1);
|
||||
else
|
||||
SampleManager.PauseStream(0, 1);
|
||||
{
|
||||
SampleManager.PauseStream(0, slot + 1);
|
||||
if (!m_sMissionAudio.m_bPredefinedProperties) {
|
||||
distSquared = GetDistanceSquared(m_sMissionAudio.m_vecPos[slot]);
|
||||
if (distSquared >= SQR(80.0f)) {
|
||||
emittingVol = 0;
|
||||
pan = 63;
|
||||
} else {
|
||||
emittingVol = 127;
|
||||
if (distSquared > 0.0f) {
|
||||
dist = Sqrt(distSquared);
|
||||
emittingVol = ComputeVolume(127, 80.0f, dist);
|
||||
}
|
||||
TranslateEntity(&m_sMissionAudio.m_vecPos[slot], &vec);
|
||||
pan = ComputePan(80.f, &vec);
|
||||
}
|
||||
SampleManager.SetStreamedVolumeAndPan(emittingVol, pan, 1, slot + 1);
|
||||
}
|
||||
}
|
||||
} else if (m_sMissionAudio.m_nSampleIndex[slot] == STREAMED_SOUND_MISSION_ROK2_01) {
|
||||
m_sMissionAudio.m_nPlayStatus[slot] = PLAY_STATUS_STOPPED;
|
||||
} else {
|
||||
m_sMissionAudio.m_nPlayStatus = PLAY_STATUS_FINISHED;
|
||||
m_sMissionAudio.m_nSampleIndex = NO_SAMPLE;
|
||||
SampleManager.StopStreamedFile(1);
|
||||
m_sMissionAudio.m_nMissionAudioCounter = 0;
|
||||
m_sMissionAudio.m_nPlayStatus[slot] = PLAY_STATUS_FINISHED;
|
||||
if (m_sMissionAudio.m_nSampleIndex[slot] >= STREAMED_SOUND_MISSION_MOB_01A && m_sMissionAudio.m_nSampleIndex[slot] <= STREAMED_SOUND_MISSION_MOB_99A)
|
||||
m_sMissionAudio.m_bIsMobile[slot] = false;
|
||||
m_sMissionAudio.m_nSampleIndex[slot] = NO_SAMPLE;
|
||||
SampleManager.StopStreamedFile(slot + 1);
|
||||
m_sMissionAudio.m_nMissionAudioCounter[slot] = 0;
|
||||
}
|
||||
} else {
|
||||
if (m_nUserPause)
|
||||
break;
|
||||
if (nCheckPlayingDelay--) {
|
||||
if (!SampleManager.IsStreamPlaying(1))
|
||||
if (nCheckPlayingDelay[slot]--) {
|
||||
if (!SampleManager.IsStreamPlaying(slot + 1))
|
||||
break;
|
||||
nCheckPlayingDelay = 0;
|
||||
nCheckPlayingDelay[slot] = 0;
|
||||
}
|
||||
m_sMissionAudio.field_22 = 1;
|
||||
m_sMissionAudio.field_22[slot] = 1;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -5788,15 +5859,32 @@ cAudioManager::ProcessMissionAudio()
|
|||
}
|
||||
break;
|
||||
case LOADING_STATUS_FAILED:
|
||||
if (++nFramesUntilFailedLoad >= 90) {
|
||||
nFramesForPretendPlaying = 0;
|
||||
g_bMissionAudioLoadFailed = true;
|
||||
nFramesUntilFailedLoad = 0;
|
||||
m_sMissionAudio.m_nLoadingStatus = LOADING_STATUS_LOADED;
|
||||
if (++nFramesUntilFailedLoad[slot] >= 90) {
|
||||
nFramesForPretendPlaying[slot] = 0;
|
||||
g_bMissionAudioLoadFailed[slot] = true;
|
||||
nFramesUntilFailedLoad[slot] = 0;
|
||||
m_sMissionAudio.m_nLoadingStatus[slot] = LOADING_STATUS_LOADED;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
cAudioManager::ProcessMissionAudio()
|
||||
{
|
||||
if (!m_bIsInitialised) return;
|
||||
|
||||
for (int i = 0; i < MISSION_AUDIO_SLOTS; i++)
|
||||
ProcessMissionAudioSlot(i);
|
||||
|
||||
if (m_sMissionAudio.m_bIsMobile[0] || m_sMissionAudio.m_bIsMobile[1])
|
||||
field_5538 = 64;
|
||||
else if (field_5538 < 127) {
|
||||
field_5538 += 5;
|
||||
if (field_5538 > 127)
|
||||
field_5538 = 127;
|
||||
}
|
||||
}
|
||||
#pragma endregion All the mission audio stuff
|
|
@ -257,7 +257,8 @@ cAudioManager::ResetTimers(uint32 time)
|
|||
m_nActiveSampleQueue = 0;
|
||||
}
|
||||
ClearActiveSamples();
|
||||
ClearMissionAudio();
|
||||
ClearMissionAudio(0);
|
||||
ClearMissionAudio(1);
|
||||
SampleManager.StopChannel(policeChannel);
|
||||
SampleManager.SetEffectsFadeVolume(0);
|
||||
SampleManager.SetMusicFadeVolume(0);
|
||||
|
|
|
@ -95,19 +95,24 @@ VALIDATE_SIZE(cPedComments, 1164);
|
|||
|
||||
class CEntity;
|
||||
|
||||
#define MISSION_AUDIO_SLOTS (2)
|
||||
|
||||
// So instead of doing cMissionAudio [2] they've added [2] to every field of the struct...
|
||||
// Only someone with a VERY EXTRAORDINARY mind could have come up with that
|
||||
class cMissionAudio
|
||||
{
|
||||
public:
|
||||
CVector m_vecPos;
|
||||
bool m_bPredefinedProperties;
|
||||
int32 m_nSampleIndex;
|
||||
uint8 m_nLoadingStatus;
|
||||
uint8 m_nPlayStatus;
|
||||
uint8 field_22; // todo find a name
|
||||
int32 m_nMissionAudioCounter;
|
||||
bool m_bIsPlayed;
|
||||
CVector m_vecPos[MISSION_AUDIO_SLOTS];
|
||||
bool m_bPredefinedProperties[MISSION_AUDIO_SLOTS];
|
||||
int32 m_nSampleIndex[MISSION_AUDIO_SLOTS];
|
||||
uint8 m_nLoadingStatus[MISSION_AUDIO_SLOTS];
|
||||
uint8 m_nPlayStatus[MISSION_AUDIO_SLOTS];
|
||||
uint8 field_22[MISSION_AUDIO_SLOTS]; // todo find a name
|
||||
int32 m_nMissionAudioCounter[MISSION_AUDIO_SLOTS];
|
||||
bool m_bIsPlayed[MISSION_AUDIO_SLOTS];
|
||||
bool m_bIsMobile[MISSION_AUDIO_SLOTS];
|
||||
};
|
||||
VALIDATE_SIZE(cMissionAudio, 32);
|
||||
VALIDATE_SIZE(cMissionAudio, 0x38);
|
||||
|
||||
// name made up
|
||||
class cAudioScriptObjectManager
|
||||
|
@ -199,6 +204,7 @@ public:
|
|||
int32 m_nProjectileEntity;
|
||||
int32 m_nBridgeEntity;
|
||||
cMissionAudio m_sMissionAudio;
|
||||
uint8 field_5538; // something related to phone dialogues
|
||||
int32 m_anRandomTable[5];
|
||||
uint8 m_nTimeSpent;
|
||||
uint8 m_nUserPause;
|
||||
|
@ -213,7 +219,8 @@ public:
|
|||
float GetReflectionsDistance(int32 idx) const { return m_afReflectionsDistances[idx]; }
|
||||
int32 GetRandomNumber(int32 idx) const { return m_anRandomTable[idx]; }
|
||||
int32 GetRandomNumberInRange(int32 idx, int32 low, int32 high) const { return (m_anRandomTable[idx] % (high - low + 1)) + low; }
|
||||
bool IsMissionAudioPlaying() const { return m_sMissionAudio.m_nPlayStatus == 1; }
|
||||
bool IsMissionAudioSamplePlaying(uint8 slot) const;// { return m_sMissionAudio.m_nPlayStatus == 1; }
|
||||
bool ShouldDuckMissionAudio(uint8 slot) const;
|
||||
|
||||
// "Should" be in alphabetic order, except "getXTalkSfx"
|
||||
void AddDetailsToRequestedOrderList(uint8 sample);
|
||||
|
@ -227,7 +234,7 @@ public:
|
|||
void CalculateDistance(bool &condition, float dist);
|
||||
bool CheckForAnAudioFileOnCD() const;
|
||||
void ClearActiveSamples();
|
||||
void ClearMissionAudio();
|
||||
void ClearMissionAudio(uint8 slot);
|
||||
void ClearRequestedQueue();
|
||||
int32 ComputeDopplerEffectedFrequency(uint32 oldFreq, float position1, float position2,
|
||||
float speedMultiplier) const;
|
||||
|
@ -253,7 +260,7 @@ public:
|
|||
float GetCollisionRatio(float a, float b, float c, float d) const;
|
||||
float GetDistanceSquared(const CVector &v) const;
|
||||
int32 GetJumboTaxiFreq() const;
|
||||
uint8 GetMissionAudioLoadingStatus() const;
|
||||
uint8 GetMissionAudioLoadingStatus(uint8 slot) const;
|
||||
int8 GetMissionScriptPoliceAudioPlayingStatus() const;
|
||||
uint8 GetNum3DProvidersAvailable() const;
|
||||
int32 GetPedCommentSfx(CPed *ped, int32 sound);
|
||||
|
@ -270,12 +277,12 @@ public:
|
|||
void InitialisePoliceRadioZones();
|
||||
void InterrogateAudioEntities();
|
||||
bool IsAudioInitialised() const;
|
||||
bool IsMissionAudioSampleFinished();
|
||||
bool IsMissionAudioSampleFinished(uint8 slot);
|
||||
bool IsMP3RadioChannelAvailable() const;
|
||||
|
||||
bool MissionScriptAudioUsesPoliceChannel(int32 soundMission) const;
|
||||
|
||||
void PlayLoadedMissionAudio();
|
||||
void PlayLoadedMissionAudio(uint8 slot);
|
||||
void PlayOneShot(int32 index, int16 sound, float vol);
|
||||
void PlaySuspectLastSeen(float x, float y, float z);
|
||||
void PlayerJustGotInCar() const;
|
||||
|
@ -283,7 +290,7 @@ public:
|
|||
void PostInitialiseGameSpecificSetup();
|
||||
void PostTerminateGameSpecificShutdown();
|
||||
void PreInitialiseGameSpecificSetup() const;
|
||||
void PreloadMissionAudio(const char *name);
|
||||
void PreloadMissionAudio(uint8 slot, Const char *name);
|
||||
void PreTerminateGameSpecificShutdown();
|
||||
/// processX - main logic of adding new sounds
|
||||
void ProcessActiveQueues();
|
||||
|
@ -316,6 +323,7 @@ public:
|
|||
void ProcessJumboTaxi();
|
||||
void ProcessLoopingScriptObject(uint8 sound);
|
||||
void ProcessMissionAudio();
|
||||
void ProcessMissionAudioSlot(uint8 slot);
|
||||
void ProcessModelCarEngine(cVehicleParams *params);
|
||||
void ProcessOneShotScriptObject(uint8 sound);
|
||||
void ProcessPed(CPhysical *ped);
|
||||
|
@ -366,7 +374,7 @@ public:
|
|||
void SetEffectsMasterVolume(uint8 volume) const;
|
||||
void SetEntityStatus(int32 id, uint8 status);
|
||||
uint32 SetLoopingCollisionRequestedSfxFreqAndGetVol(const cAudioCollision &audioCollision);
|
||||
void SetMissionAudioLocation(float x, float y, float z);
|
||||
void SetMissionAudioLocation(uint8 slot, float x, float y, float z);
|
||||
void SetMissionScriptPoliceAudio(int32 sfx) const;
|
||||
void SetMonoMode(uint8); // todo (mobile)
|
||||
void SetMusicFadeVol(uint8 volume) const;
|
||||
|
@ -400,7 +408,7 @@ public:
|
|||
};
|
||||
|
||||
#ifdef AUDIO_MSS
|
||||
static_assert(sizeof(cAudioManager) == 19220, "cAudioManager: error");
|
||||
//static_assert(sizeof(cAudioManager) == 19220, "cAudioManager: error");
|
||||
#endif
|
||||
|
||||
extern cAudioManager AudioManager;
|
||||
|
|
|
@ -290,39 +290,39 @@ cDMAudio::StopCutSceneMusic(void)
|
|||
}
|
||||
|
||||
void
|
||||
cDMAudio::PreloadMissionAudio(char *missionAudio)
|
||||
cDMAudio::PreloadMissionAudio(uint8 slot, Const char *missionAudio)
|
||||
{
|
||||
AudioManager.PreloadMissionAudio(missionAudio);
|
||||
AudioManager.PreloadMissionAudio(slot, missionAudio);
|
||||
}
|
||||
|
||||
uint8
|
||||
cDMAudio::GetMissionAudioLoadingStatus(void)
|
||||
cDMAudio::GetMissionAudioLoadingStatus(uint8 slot)
|
||||
{
|
||||
return AudioManager.GetMissionAudioLoadingStatus();
|
||||
return AudioManager.GetMissionAudioLoadingStatus(slot);
|
||||
}
|
||||
|
||||
void
|
||||
cDMAudio::SetMissionAudioLocation(float x, float y, float z)
|
||||
cDMAudio::SetMissionAudioLocation(uint8 slot, float x, float y, float z)
|
||||
{
|
||||
AudioManager.SetMissionAudioLocation(x, y, z);
|
||||
AudioManager.SetMissionAudioLocation(slot, x, y, z);
|
||||
}
|
||||
|
||||
void
|
||||
cDMAudio::PlayLoadedMissionAudio(void)
|
||||
cDMAudio::PlayLoadedMissionAudio(uint8 slot)
|
||||
{
|
||||
AudioManager.PlayLoadedMissionAudio();
|
||||
AudioManager.PlayLoadedMissionAudio(slot);
|
||||
}
|
||||
|
||||
bool
|
||||
cDMAudio::IsMissionAudioSampleFinished(void)
|
||||
cDMAudio::IsMissionAudioSampleFinished(uint8 slot)
|
||||
{
|
||||
return AudioManager.IsMissionAudioSampleFinished();
|
||||
return AudioManager.IsMissionAudioSampleFinished(slot);
|
||||
}
|
||||
|
||||
void
|
||||
cDMAudio::ClearMissionAudio(void)
|
||||
cDMAudio::ClearMissionAudio(uint8 slot)
|
||||
{
|
||||
AudioManager.ClearMissionAudio();
|
||||
AudioManager.ClearMissionAudio(slot);
|
||||
}
|
||||
|
||||
uint8
|
||||
|
|
|
@ -76,12 +76,12 @@ public:
|
|||
void PlayPreloadedCutSceneMusic(void);
|
||||
void StopCutSceneMusic(void);
|
||||
|
||||
void PreloadMissionAudio(char *missionAudio);
|
||||
uint8 GetMissionAudioLoadingStatus(void);
|
||||
void SetMissionAudioLocation(float x, float y, float z);
|
||||
void PlayLoadedMissionAudio(void);
|
||||
bool IsMissionAudioSampleFinished(void);
|
||||
void ClearMissionAudio(void);
|
||||
void PreloadMissionAudio(uint8 slot, Const char *missionAudio);
|
||||
uint8 GetMissionAudioLoadingStatus(uint8 slot);
|
||||
void SetMissionAudioLocation(uint8 slot, float x, float y, float z);
|
||||
void PlayLoadedMissionAudio(uint8 slot);
|
||||
bool IsMissionAudioSampleFinished(uint8 slot);
|
||||
void ClearMissionAudio(uint8 slot);
|
||||
|
||||
uint8 GetRadioInCar(void);
|
||||
void SetRadioInCar(uint32 radio);
|
||||
|
|
|
@ -524,7 +524,7 @@ cMusicManager::ServiceGameMode()
|
|||
} else if (dist >= 100.0f) {
|
||||
int8 volume = ((45.0f - (Sqrt(dist) - 10.0f)) / 45.0f * 100.0f);
|
||||
int8 pan;
|
||||
if (AudioManager.IsMissionAudioPlaying())
|
||||
if (AudioManager.ShouldDuckMissionAudio(0) || AudioManager.ShouldDuckMissionAudio(1))
|
||||
volume /= 4;
|
||||
if (volume != 0) {
|
||||
CVector trVec;
|
||||
|
@ -536,7 +536,7 @@ cMusicManager::ServiceGameMode()
|
|||
if (gRetuneCounter)
|
||||
volume /= 4;
|
||||
SampleManager.SetStreamedVolumeAndPan(volume, pan, 0, 0);
|
||||
} else if (AudioManager.IsMissionAudioPlaying()) {
|
||||
} else if (AudioManager.ShouldDuckMissionAudio(0) || AudioManager.ShouldDuckMissionAudio(1)) {
|
||||
SampleManager.SetStreamedVolumeAndPan(25, 63, 0, 0);
|
||||
} else if (gRetuneCounter) {
|
||||
SampleManager.SetStreamedVolumeAndPan(25, 63, 0, 0);
|
||||
|
@ -544,7 +544,7 @@ cMusicManager::ServiceGameMode()
|
|||
SampleManager.SetStreamedVolumeAndPan(100, 63, 0, 0);
|
||||
}
|
||||
}
|
||||
} else if (AudioManager.IsMissionAudioPlaying()) {
|
||||
} else if (AudioManager.ShouldDuckMissionAudio(0) || AudioManager.ShouldDuckMissionAudio(1)) {
|
||||
SampleManager.SetStreamedVolumeAndPan(25, 63, 0, 0);
|
||||
nFramesSinceCutsceneEnded = 0;
|
||||
} else {
|
||||
|
@ -830,7 +830,7 @@ cMusicManager::ServiceAnnouncement()
|
|||
|
||||
SampleManager.SetStreamedVolumeAndPan(0, 63, 0, 0);
|
||||
if (SampleManager.StartStreamedFile(m_nAnnouncement, 0, 0)) {
|
||||
SampleManager.SetStreamedVolumeAndPan(AudioManager.IsMissionAudioPlaying() ? 25 : 100, 63, 0, 0);
|
||||
SampleManager.SetStreamedVolumeAndPan((AudioManager.IsMissionAudioSamplePlaying(0) || AudioManager.IsMissionAudioSamplePlaying(1)) ? 25 : 100, 63, 0, 0);
|
||||
m_bAnnouncementInProgress = true;
|
||||
m_nPreviousStreamedSound = m_nCurrentStreamedSound;
|
||||
m_nCurrentStreamedSound = m_nAnnouncement;
|
||||
|
@ -903,7 +903,7 @@ cMusicManager::ChangeRadioChannel()
|
|||
return false;
|
||||
if (!SampleManager.StartStreamedFile(m_nCurrentStreamedSound, GetTrackStartPos(m_nCurrentStreamedSound), 0))
|
||||
return false;
|
||||
SampleManager.SetStreamedVolumeAndPan(AudioManager.IsMissionAudioPlaying() ? 25 : 100, 63, 0, 0);
|
||||
SampleManager.SetStreamedVolumeAndPan((AudioManager.IsMissionAudioSamplePlaying(0) || AudioManager.IsMissionAudioSamplePlaying(1)) ? 25 : 100, 63, 0, 0);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -105,7 +105,7 @@ enum
|
|||
#define MAX2DCHANNELS 1
|
||||
#define CHANNEL2D MAXCHANNELS
|
||||
|
||||
#define MAX_STREAMS 2
|
||||
#define MAX_STREAMS 3
|
||||
|
||||
#define DIGITALRATE 32000
|
||||
#define DIGITALBITS 16
|
||||
|
|
|
@ -193,15 +193,15 @@ CGameLogic::Update()
|
|||
pPlayerInfo.m_nBustedAudioStatus = BUSTEDAUDIO_LOADING;
|
||||
char name[12];
|
||||
sprintf(name, pPlayerInfo.m_nCurrentBustedAudio >= 10 ? "bust_%d" : "bust_0%d", pPlayerInfo.m_nCurrentBustedAudio);
|
||||
DMAudio.ClearMissionAudio(); // TODO(MIAMI): argument is 0
|
||||
DMAudio.PreloadMissionAudio(name); // TODO(MIAMI): argument is 0
|
||||
DMAudio.ClearMissionAudio(0); // TODO(MIAMI): argument is 0
|
||||
DMAudio.PreloadMissionAudio(0, name); // TODO(MIAMI): argument is 0
|
||||
pPlayerInfo.m_nCurrentBustedAudio = pPlayerInfo.m_nCurrentBustedAudio % 28 + 1; // enum? const? TODO
|
||||
}
|
||||
}
|
||||
if (CTimer::GetTimeInMilliseconds() - pPlayerInfo.m_nWBTime > 4000 &&
|
||||
pPlayerInfo.m_nBustedAudioStatus == BUSTEDAUDIO_LOADING &&
|
||||
DMAudio.GetMissionAudioLoadingStatus() == 1) { // TODO: argument is 0
|
||||
DMAudio.PlayLoadedMissionAudio(); // TODO: argument is 0
|
||||
DMAudio.GetMissionAudioLoadingStatus(0) == 1) { // TODO: argument is 0
|
||||
DMAudio.PlayLoadedMissionAudio(0); // TODO: argument is 0
|
||||
pPlayerInfo.m_nBustedAudioStatus = BUSTEDAUDIO_DONE;
|
||||
}
|
||||
|
||||
|
|
|
@ -318,8 +318,8 @@ void CMissionCleanup::Process()
|
|||
//CSpecialFX::bLiftCam = false;
|
||||
//CSpecialFX::bVideoCam = false;
|
||||
//CTimeCycle::StopExtraColour(0);
|
||||
// TODO(MIAMI): change this to loop when it supports parameters
|
||||
DMAudio.ClearMissionAudio();
|
||||
for (int i = 0; i < MISSION_AUDIO_SLOTS; i++)
|
||||
DMAudio.ClearMissionAudio(i);
|
||||
CWeather::ReleaseWeather();
|
||||
for (int i = 0; i < NUM_OF_SPECIAL_CHARS; i++)
|
||||
CStreaming::SetMissionDoesntRequireSpecialChar(i);
|
||||
|
@ -8664,40 +8664,23 @@ int8 CRunningScript::ProcessCommands900To999(int32 command)
|
|||
str[i] = tolower(str[i]);
|
||||
static bool bShowed = false;
|
||||
m_nIp += KEY_LENGTH_IN_SCRIPT;
|
||||
if (!bShowed) {
|
||||
debug("LOAD_MISSION_AUDIO not implemented\n");
|
||||
bShowed = true;
|
||||
}
|
||||
//DMAudio.PreloadMissionAudio(str);
|
||||
DMAudio.PreloadMissionAudio(ScriptParams[0] - 1, str);
|
||||
return 0;
|
||||
}
|
||||
case COMMAND_HAS_MISSION_AUDIO_LOADED:
|
||||
{
|
||||
CollectParameters(&m_nIp, 1);
|
||||
static bool bShowed = false;
|
||||
if (!bShowed) {
|
||||
debug("HAS_MISSION_AUDIO_LOADED not implemented, default to TRUE\n");
|
||||
bShowed = true;
|
||||
}
|
||||
UpdateCompareFlag(true);
|
||||
//UpdateCompareFlag(DMAudio.GetMissionAudioLoadingStatus() == 1);
|
||||
UpdateCompareFlag(DMAudio.GetMissionAudioLoadingStatus(ScriptParams[0] - 1) == 1);
|
||||
return 0;
|
||||
}
|
||||
case COMMAND_PLAY_MISSION_AUDIO:
|
||||
CollectParameters(&m_nIp, 1);
|
||||
debug("PLAY_MISSION_AUDIO doesn't support parameter yet, skipping\n");
|
||||
//DMAudio.PlayLoadedMissionAudio();
|
||||
DMAudio.PlayLoadedMissionAudio(ScriptParams[0] - 1);
|
||||
return 0;
|
||||
case COMMAND_HAS_MISSION_AUDIO_FINISHED:
|
||||
{
|
||||
CollectParameters(&m_nIp, 1);
|
||||
static bool bShowed = false;
|
||||
if (!bShowed) {
|
||||
debug("HAS_MISSION_AUDIO_FINISHED not implemented, default to TRUE\n");
|
||||
bShowed = true;
|
||||
}
|
||||
UpdateCompareFlag(true);
|
||||
//UpdateCompareFlag(DMAudio.IsMissionAudioSampleFinished());
|
||||
UpdateCompareFlag(DMAudio.IsMissionAudioSampleFinished(ScriptParams[0] - 1));
|
||||
return 0;
|
||||
}
|
||||
case COMMAND_GET_CLOSEST_CAR_NODE_WITH_HEADING:
|
||||
|
@ -8735,12 +8718,7 @@ int8 CRunningScript::ProcessCommands900To999(int32 command)
|
|||
{
|
||||
CollectParameters(&m_nIp, 4);
|
||||
CVector pos = *(CVector*)&ScriptParams[1];
|
||||
static bool bShowed = false;
|
||||
if (!bShowed) {
|
||||
debug("SET_MISSION_AUDIO_POSITION not implemented\n");
|
||||
bShowed = true;
|
||||
}
|
||||
//DMAudio.SetMissionAudioLocation(pos.x, pos.y, pos.z);
|
||||
DMAudio.SetMissionAudioLocation(ScriptParams[0] - 1, pos.x, pos.y, pos.z);
|
||||
return 0;
|
||||
}
|
||||
case COMMAND_ACTIVATE_SAVE_MENU:
|
||||
|
|
Loading…
Reference in a new issue