1
0
Fork 0
mirror of https://git.rip/DMCA_FUCKER/re3.git synced 2024-12-23 07:50:01 +00:00

Overhaul MusicManager - fix radio bugs, scroll to prev station, radio off text

This commit is contained in:
erorcun 2021-01-30 14:52:48 +03:00
parent 990637bf52
commit 902e539c0d
15 changed files with 393 additions and 264 deletions

View file

@ -8846,7 +8846,7 @@ cAudioManager::ProcessFrontEnd()
break; break;
case SOUND_PICKUP_BONUS: case SOUND_PICKUP_BONUS:
case SOUND_FRONTEND_MENU_STARTING: case SOUND_FRONTEND_MENU_STARTING:
case SOUND_HUD_SOUND: case SOUND_HUD:
stereo = true; stereo = true;
m_sQueueSample.m_nSampleIndex = SFX_INFO_LEFT; m_sQueueSample.m_nSampleIndex = SFX_INFO_LEFT;
center = true; center = true;
@ -8882,11 +8882,11 @@ cAudioManager::ProcessFrontEnd()
case SOUND_CLOCK_TICK: case SOUND_CLOCK_TICK:
m_sQueueSample.m_nSampleIndex = SFX_TIMER; m_sQueueSample.m_nSampleIndex = SFX_TIMER;
break; break;
case SOUND_FRONTEND_NO_RADIO: case SOUND_FRONTEND_RADIO_TURN_OFF:
case SOUND_FRONTEND_RADIO_CHANGE: case SOUND_FRONTEND_RADIO_TURN_ON:
m_sQueueSample.m_nSampleIndex = SFX_RADIO_CLICK; m_sQueueSample.m_nSampleIndex = SFX_RADIO_CLICK;
break; break;
case SOUND_FRONTEND_RADIO_CHANGE_2: case SOUND_FRONTEND_HURRICANE:
m_sQueueSample.m_nSampleIndex = SFX_HURRICANE_MA; m_sQueueSample.m_nSampleIndex = SFX_HURRICANE_MA;
break; break;
case SOUND_BULLETTRACE_1: case SOUND_BULLETTRACE_1:
@ -8937,9 +8937,9 @@ cAudioManager::ProcessFrontEnd()
sample = m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_awAudioEvent[i]; sample = m_asAudioEntities[m_sQueueSample.m_nEntityIndex].m_awAudioEvent[i];
if (sample == SOUND_FRONTEND_NO_RADIO) if (sample == SOUND_FRONTEND_RADIO_TURN_OFF)
m_sQueueSample.m_nFrequency = 28509; m_sQueueSample.m_nFrequency = 28509;
else if (sample == SOUND_FRONTEND_RADIO_CHANGE) else if (sample == SOUND_FRONTEND_RADIO_TURN_ON)
m_sQueueSample.m_nFrequency = 32000; m_sQueueSample.m_nFrequency = 32000;
else if (sample == SOUND_BULLETTRACE_1 || sample == SOUND_BULLETTRACE_2) { else if (sample == SOUND_BULLETTRACE_1 || sample == SOUND_BULLETTRACE_2) {
m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nFrequency = SampleManager.GetSampleBaseFrequency(m_sQueueSample.m_nSampleIndex);

View file

@ -21,6 +21,10 @@
#include "DMAudio.h" #include "DMAudio.h"
#include "GenericGameStorage.h" #include "GenericGameStorage.h"
#if !defined FIX_BUGS && (defined RADIO_SCROLL_TO_PREV_STATION || defined RADIO_OFF_TEXT)
static_assert(false, "R*'s radio implementation is quite buggy, RADIO_SCROLL_TO_PREV_STATION and RADIO_OFF_TEXT won't work without FIX_BUGS");
#endif
cMusicManager MusicManager; cMusicManager MusicManager;
int32 gNumRetunePresses; int32 gNumRetunePresses;
int32 gRetuneCounter; int32 gRetuneCounter;
@ -52,7 +56,7 @@ cMusicManager::cMusicManager()
m_nPlayingTrack = NO_TRACK; m_nPlayingTrack = NO_TRACK;
m_nUpcomingMusicMode = MUSICMODE_DISABLED; m_nUpcomingMusicMode = MUSICMODE_DISABLED;
m_nMusicMode = MUSICMODE_DISABLED; m_nMusicMode = MUSICMODE_DISABLED;
field_2 = false; m_bSetNextStation = false;
for (int i = 0; i < NUM_RADIOS; i++) for (int i = 0; i < NUM_RADIOS; i++)
aListenTimeArray[i] = 0.0f; aListenTimeArray[i] = 0.0f;
@ -71,27 +75,27 @@ cMusicManager::ResetMusicAfterReload()
float afRadioTime[NUM_RADIOS]; float afRadioTime[NUM_RADIOS];
m_bRadioSetByScript = false; m_bRadioSetByScript = false;
m_nRadioStation = WILDSTYLE; m_nRadioStationScript = WILDSTYLE;
m_nRadioPosition = -1; m_nRadioPosition = -1;
m_nAnnouncement = NO_TRACK; m_nAnnouncement = NO_TRACK;
m_bAnnouncementInProgress = false; m_bAnnouncementInProgress = false;
field_2 = false; m_bSetNextStation = false;
RadioStaticTimer = 0; RadioStaticTimer = 0;
gNumRetunePresses = 0; gNumRetunePresses = 0;
gRetuneCounter = 0; gRetuneCounter = 0;
m_nFrontendTrack = NO_TRACK; m_nFrontendTrack = NO_TRACK;
m_nPlayingTrack = NO_TRACK; m_nPlayingTrack = NO_TRACK;
field_398E = false; m_FrontendLoopFlag = false;
field_398F = false; m_bTrackChangeStarted = false;
m_nStreamedTrack = NO_TRACK; m_nNextTrack = NO_TRACK;
field_3994 = false; m_nNextLoopFlag = false;
field_3995 = false; m_bVerifyNextTrackStartedToPlay = false;
field_3996 = false; m_bGameplayAllowsRadio = false;
field_3997 = false; m_bRadioStreamReady = false;
nFramesSinceCutsceneEnded = -1; nFramesSinceCutsceneEnded = -1;
field_3999 = false; m_bUserResumedGame = false;
field_399A = false; m_bMusicModeChangeStarted = false;
field_399C = false; m_bEarlyFrontendTrack = false;
m_nVolumeLatency = 0; m_nVolumeLatency = 0;
m_nCurrentVolume = 0; m_nCurrentVolume = 0;
m_nMaxVolume = 0; m_nMaxVolume = 0;
@ -108,7 +112,7 @@ cMusicManager::ResetMusicAfterReload()
for (int i = 0; i < NUM_RADIOS; i++) { for (int i = 0; i < NUM_RADIOS; i++) {
aListenTimeArray[i] = afRadioTime[i]; aListenTimeArray[i] = afRadioTime[i];
uint32 trackPos = GetSavedRadioStationPosition(i); int32 trackPos = GetSavedRadioStationPosition(i);
if (trackPos != -1) { if (trackPos != -1) {
if (trackPos > m_aTracks[i].m_nLength) { if (trackPos > m_aTracks[i].m_nLength) {
debug("Radio Track %d saved position is %d, Length is only %d\n", i, trackPos, m_aTracks[i].m_nLength); debug("Radio Track %d saved position is %d, Length is only %d\n", i, trackPos, m_aTracks[i].m_nLength);
@ -179,7 +183,7 @@ cMusicManager::Initialise()
m_bResetTimers = false; m_bResetTimers = false;
m_nResetTime = 0; m_nResetTime = 0;
m_bRadioSetByScript = false; m_bRadioSetByScript = false;
m_nRadioStation = WILDSTYLE; m_nRadioStationScript = WILDSTYLE;
m_nRadioPosition = -1; m_nRadioPosition = -1;
m_nRadioInCar = NO_TRACK; m_nRadioInCar = NO_TRACK;
gRetuneCounter = 0; gRetuneCounter = 0;
@ -188,18 +192,18 @@ cMusicManager::Initialise()
m_nPlayingTrack = NO_TRACK; m_nPlayingTrack = NO_TRACK;
m_nUpcomingMusicMode = MUSICMODE_DISABLED; m_nUpcomingMusicMode = MUSICMODE_DISABLED;
m_nMusicMode = MUSICMODE_DISABLED; m_nMusicMode = MUSICMODE_DISABLED;
field_398E = false; m_FrontendLoopFlag = false;
field_398F = false; m_bTrackChangeStarted = false;
m_nStreamedTrack = NO_TRACK; m_nNextTrack = NO_TRACK;
field_3994 = false; m_nNextLoopFlag = false;
field_3995 = false; m_bVerifyNextTrackStartedToPlay = false;
field_3996 = false; m_bGameplayAllowsRadio = false;
field_3997 = false; m_bRadioStreamReady = false;
nFramesSinceCutsceneEnded = -1; nFramesSinceCutsceneEnded = -1;
field_3999 = false; m_bUserResumedGame = false;
field_399A = false; m_bMusicModeChangeStarted = false;
m_nMusicModeToBeSet = MUSICMODE_DISABLED; m_nMusicModeToBeSet = MUSICMODE_DISABLED;
field_399C = false; m_bEarlyFrontendTrack = false;
m_nVolumeLatency = 0; m_nVolumeLatency = 0;
m_nCurrentVolume = 0; m_nCurrentVolume = 0;
m_nMaxVolume = 0; m_nMaxVolume = 0;
@ -227,7 +231,7 @@ cMusicManager::SetRadioChannelByScript(uint32 station, int32 pos)
station = STREAMED_SOUND_CITY_AMBIENT; station = STREAMED_SOUND_CITY_AMBIENT;
if (station <= STREAMED_SOUND_RADIO_POLICE) { if (station <= STREAMED_SOUND_RADIO_POLICE) {
m_bRadioSetByScript = true; m_bRadioSetByScript = true;
m_nRadioStation = station; m_nRadioStationScript = station;
m_nRadioPosition = pos == -1 ? -1 : pos % m_aTracks[station].m_nLength; m_nRadioPosition = pos == -1 ? -1 : pos % m_aTracks[station].m_nLength;
} }
} }
@ -292,7 +296,7 @@ cMusicManager::SetRadioInCar(uint32 station)
void void
cMusicManager::RecordRadioStats() cMusicManager::RecordRadioStats()
{ {
if (m_nPlayingTrack < STREAMED_SOUND_CITY_AMBIENT) { if (m_nPlayingTrack < NUM_RADIOS) {
double time /*Rusty*/ = CTimer::GetTimeInMillisecondsPauseMode(); double time /*Rusty*/ = CTimer::GetTimeInMillisecondsPauseMode();
if (time > m_nLastTrackServiceTime) if (time > m_nLastTrackServiceTime)
aListenTimeArray[m_nPlayingTrack] += time - m_nLastTrackServiceTime; aListenTimeArray[m_nPlayingTrack] += time - m_nLastTrackServiceTime;
@ -321,11 +325,11 @@ cMusicManager::ChangeMusicMode(uint8 mode)
while (SampleManager.IsStreamPlaying(0)) while (SampleManager.IsStreamPlaying(0))
SampleManager.StopStreamedFile(0); SampleManager.StopStreamedFile(0);
m_nMusicMode = m_nUpcomingMusicMode; m_nMusicMode = m_nUpcomingMusicMode;
field_399A = false; m_bMusicModeChangeStarted = false;
field_398F = false; m_bTrackChangeStarted = false;
m_nStreamedTrack = NO_TRACK; m_nNextTrack = NO_TRACK;
field_3994 = false; m_nNextLoopFlag = false;
field_3995 = false; m_bVerifyNextTrackStartedToPlay = false;
m_nPlayingTrack = NO_TRACK; m_nPlayingTrack = NO_TRACK;
m_nFrontendTrack = NO_TRACK; m_nFrontendTrack = NO_TRACK;
m_bAnnouncementInProgress = false; m_bAnnouncementInProgress = false;
@ -356,7 +360,7 @@ cMusicManager::Service()
if (!m_bIsInitialised || m_bDisabled) return; if (!m_bIsInitialised || m_bDisabled) return;
if (!field_399A) 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_nUserPause || AudioManager.m_nPreviousUserPause || m_nMusicMode != MUSICMODE_FRONTEND)
@ -371,13 +375,13 @@ cMusicManager::Service()
else else
m_nMusicMode = MUSICMODE_DISABLED; m_nMusicMode = MUSICMODE_DISABLED;
} else { } else {
field_399A = true; m_bMusicModeChangeStarted = true;
if (!field_3999 && !AudioManager.m_nUserPause && AudioManager.m_nPreviousUserPause) if (!m_bUserResumedGame && !AudioManager.m_nUserPause && AudioManager.m_nPreviousUserPause)
field_3999 = true; m_bUserResumedGame = true;
if (AudioManager.m_FrameCounter % 4 == 0) { if (AudioManager.m_FrameCounter % 4 == 0) {
gNumRetunePresses = 0; gNumRetunePresses = 0;
gRetuneCounter = 0; gRetuneCounter = 0;
field_2 = false; m_bSetNextStation = false;
if (SampleManager.IsStreamPlaying(0)) { if (SampleManager.IsStreamPlaying(0)) {
if (m_nPlayingTrack != NO_TRACK && !bRadioStatsRecorded) if (m_nPlayingTrack != NO_TRACK && !bRadioStatsRecorded)
{ {
@ -390,14 +394,14 @@ cMusicManager::Service()
} else { } else {
bRadioStatsRecorded = false; bRadioStatsRecorded = false;
m_nMusicMode = m_nMusicModeToBeSet; m_nMusicMode = m_nMusicModeToBeSet;
field_399A = false; m_bMusicModeChangeStarted = false;
field_398F = false; m_bTrackChangeStarted = false;
m_nStreamedTrack = NO_TRACK; m_nNextTrack = NO_TRACK;
field_3994 = false; m_nNextLoopFlag = false;
field_3995 = false; m_bVerifyNextTrackStartedToPlay = false;
m_nPlayingTrack = NO_TRACK; m_nPlayingTrack = NO_TRACK;
if (field_399C) if (m_bEarlyFrontendTrack)
field_399C = false; m_bEarlyFrontendTrack = false;
else else
m_nFrontendTrack = NO_TRACK; m_nFrontendTrack = NO_TRACK;
} }
@ -417,19 +421,19 @@ cMusicManager::ServiceFrontEndMode()
g_bAnnouncementReadPosAlready = false; g_bAnnouncementReadPosAlready = false;
m_nAnnouncement = NO_TRACK; m_nAnnouncement = NO_TRACK;
m_bAnnouncementInProgress = false; m_bAnnouncementInProgress = false;
m_nStreamedTrack = NO_TRACK; m_nNextTrack = NO_TRACK;
m_nFrontendTrack = NO_TRACK; m_nFrontendTrack = NO_TRACK;
m_nPlayingTrack = NO_TRACK; m_nPlayingTrack = NO_TRACK;
} }
if (AudioManager.m_FrameCounter % 4 != 0) return; if (AudioManager.m_FrameCounter % 4 != 0) return;
if (!field_398F && !field_3995) { if (!m_bTrackChangeStarted && !m_bVerifyNextTrackStartedToPlay) {
m_nStreamedTrack = m_nFrontendTrack; m_nNextTrack = m_nFrontendTrack;
field_3994 = field_398E; m_nNextLoopFlag = m_FrontendLoopFlag;
} }
if (m_nStreamedTrack == m_nPlayingTrack) { if (m_nNextTrack == m_nPlayingTrack) {
if (SampleManager.IsStreamPlaying(0)) { if (SampleManager.IsStreamPlaying(0)) {
if (m_nVolumeLatency > 0) m_nVolumeLatency--; if (m_nVolumeLatency > 0) m_nVolumeLatency--;
else { else {
@ -444,25 +448,25 @@ cMusicManager::ServiceFrontEndMode()
ChangeMusicMode(MUSICMODE_GAME); ChangeMusicMode(MUSICMODE_GAME);
} }
} else { } else {
field_398F = true; m_bTrackChangeStarted = true;
if (field_3995 || !SampleManager.IsStreamPlaying(0)) { if (m_bVerifyNextTrackStartedToPlay || !SampleManager.IsStreamPlaying(0)) {
bRadioStatsRecorded = false; bRadioStatsRecorded = false;
if (SampleManager.IsStreamPlaying(0) || m_nStreamedTrack == NO_TRACK) { if (SampleManager.IsStreamPlaying(0) || m_nNextTrack == NO_TRACK) {
m_nPlayingTrack = m_nStreamedTrack; m_nPlayingTrack = m_nNextTrack;
field_3995 = false; m_bVerifyNextTrackStartedToPlay = false;
field_398F = false; m_bTrackChangeStarted = false;
} else { } else {
uint32 trackStartPos = (m_nStreamedTrack > STREAMED_SOUND_RADIO_POLICE) ? 0 : GetTrackStartPos(m_nStreamedTrack); uint32 trackStartPos = (m_nNextTrack > STREAMED_SOUND_RADIO_POLICE) ? 0 : GetTrackStartPos(m_nNextTrack);
if (m_nStreamedTrack != NO_TRACK) { if (m_nNextTrack != NO_TRACK) {
SampleManager.SetStreamedFileLoopFlag(field_3994, 0); SampleManager.SetStreamedFileLoopFlag(m_nNextLoopFlag, 0);
SampleManager.StartStreamedFile(m_nStreamedTrack, trackStartPos, 0); SampleManager.StartStreamedFile(m_nNextTrack, trackStartPos, 0);
m_nVolumeLatency = 3; m_nVolumeLatency = 3;
m_nCurrentVolume = 0; m_nCurrentVolume = 0;
m_nMaxVolume = 100; m_nMaxVolume = 100;
SampleManager.SetStreamedVolumeAndPan(m_nCurrentVolume, 63, 0, 0); SampleManager.SetStreamedVolumeAndPan(m_nCurrentVolume, 63, 0, 0);
if (m_nStreamedTrack < STREAMED_SOUND_CITY_AMBIENT) if (m_nNextTrack < STREAMED_SOUND_CITY_AMBIENT)
m_nLastTrackServiceTime = CTimer::GetTimeInMillisecondsPauseMode(); m_nLastTrackServiceTime = CTimer::GetTimeInMillisecondsPauseMode();
field_3995 = true; m_bVerifyNextTrackStartedToPlay = true;
} }
} }
} else { } else {
@ -483,8 +487,8 @@ cMusicManager::ServiceGameMode()
{ {
CPed *ped = FindPlayerPed(); CPed *ped = FindPlayerPed();
CVehicle *vehicle = AudioManager.FindVehicleOfPlayer(); CVehicle *vehicle = AudioManager.FindVehicleOfPlayer();
field_3997 = field_3996; m_bRadioStreamReady = m_bGameplayAllowsRadio;
field_3996 = false; m_bGameplayAllowsRadio = false;
switch (CGame::currArea) switch (CGame::currArea)
{ {
@ -495,29 +499,28 @@ cMusicManager::ServiceGameMode()
case AREA_BLOOD: case AREA_BLOOD:
case AREA_OVALRING: case AREA_OVALRING:
case AREA_MALIBU_CLUB: case AREA_MALIBU_CLUB:
field_3996 = false; m_bGameplayAllowsRadio = false;
break; break;
default: default:
if (SampleManager.GetMusicVolume()) { if (SampleManager.GetMusicVolume()) {
if (PlayerInCar()) if (PlayerInCar())
field_3996 = true; m_bGameplayAllowsRadio = true;
} else } else
field_3996 = false; m_bGameplayAllowsRadio = false;
break; break;
} }
if (!field_3996) { if (!m_bGameplayAllowsRadio) {
nFramesSinceCutsceneEnded = -1; nFramesSinceCutsceneEnded = -1;
gNumRetunePresses = 0; gNumRetunePresses = 0;
gRetuneCounter = 0; gRetuneCounter = 0;
field_2 = false; m_bSetNextStation = false;
} else if (ped) { } else if (ped) {
if(!ped->DyingOrDead()) { if(!ped->DyingOrDead() && vehicle) {
#ifdef GTA_PC #ifdef GTA_PC
if (SampleManager.IsMP3RadioChannelAvailable() if (SampleManager.IsMP3RadioChannelAvailable()
&& vehicle->m_nRadioStation < USERTRACK && vehicle->m_nRadioStation < USERTRACK
&& ControlsManager.GetIsKeyboardKeyJustDown(rsF9) && ControlsManager.GetIsKeyboardKeyJustDown(rsF9))
&& vehicle)
{ {
if (!UsesPoliceRadio(vehicle) && !UsesTaxiRadio(vehicle)) { if (!UsesPoliceRadio(vehicle) && !UsesTaxiRadio(vehicle)) {
gNumRetunePresses = 0; gNumRetunePresses = 0;
@ -532,7 +535,7 @@ cMusicManager::ServiceGameMode()
} }
} }
#endif #endif
if (CPad::GetPad(0)->ChangeStationJustDown() && vehicle) if (CPad::GetPad(0)->ChangeStationJustDown())
{ {
if (!UsesPoliceRadio(vehicle) && !UsesTaxiRadio(vehicle)) { if (!UsesPoliceRadio(vehicle) && !UsesTaxiRadio(vehicle)) {
gNumRetunePresses++; gNumRetunePresses++;
@ -540,34 +543,77 @@ cMusicManager::ServiceGameMode()
RadioStaticCounter = 0; RadioStaticCounter = 0;
} }
} }
#ifdef RADIO_SCROLL_TO_PREV_STATION
else if(CPad::GetPad(0)->GetMouseWheelDownJustDown() || CPad::GetPad(0)->GetMouseWheelUpJustDown()) {
if(!UsesPoliceRadio(vehicle) && !UsesTaxiRadio(vehicle)) {
int scrollNext = ControlsManager.GetControllerKeyAssociatedWithAction(VEHICLE_CHANGE_RADIO_STATION, MOUSE);
int scrollPrev = scrollNext == rsMOUSEWHEELUPBUTTON ? rsMOUSEWHEELDOWNBUTTON
: scrollNext == rsMOUSEWHEELDOWNBUTTON ? rsMOUSEWHEELUPBUTTON : -1;
if(scrollPrev != -1 && !ControlsManager.IsAnyVehicleActionAssignedToMouseKey(scrollPrev)) {
gNumRetunePresses--;
gRetuneCounter = 20;
RadioStaticCounter = 0;
int track = gNumRetunePresses + vehicle->m_nRadioStation;
while(track < 0) track += NUM_RADIOS + 1;
while(track >= NUM_RADIOS + 1) track -= NUM_RADIOS + 1;
if(!DMAudio.IsMP3RadioChannelAvailable() && track == USERTRACK) gNumRetunePresses--;
}
}
}
#endif
} }
} }
if (field_3999) if (m_bUserResumedGame)
{ {
field_3997 = false; m_bRadioStreamReady = false;
field_3999 = false; m_bUserResumedGame = false;
} }
if (m_nPlayingTrack == NO_TRACK && m_nFrontendTrack == NO_TRACK) if (m_nPlayingTrack == NO_TRACK && m_nFrontendTrack == NO_TRACK)
field_3997 = false; m_bRadioStreamReady = false;
if (field_3996) if (m_bGameplayAllowsRadio)
{ {
if (field_3997) if (!m_bRadioStreamReady)
{ {
if(vehicle == nil) {
m_nFrontendTrack = STREAMED_SOUND_RADIO_WAVE; // huh?
return;
}
if(m_bRadioSetByScript) {
if(UsesPoliceRadio(vehicle))
m_nFrontendTrack = STREAMED_SOUND_RADIO_POLICE;
else if(UsesTaxiRadio(vehicle))
m_nFrontendTrack = STREAMED_SOUND_RADIO_TAXI;
else {
m_nFrontendTrack = m_nRadioStationScript;
vehicle->m_nRadioStation = m_nRadioStationScript;
}
if(m_nRadioPosition != -1) {
m_aTracks[m_nFrontendTrack].m_nPosition = m_nRadioPosition;
m_aTracks[m_nFrontendTrack].m_nLastPosCheckTimer = CTimer::GetTimeInMillisecondsPauseMode();
}
m_bRadioSetByScript = false;
return;
}
// This starts the radio when you enter the car.
m_nFrontendTrack = GetCarTuning();
return;
}
if (m_nAnnouncement < NO_TRACK) { if (m_nAnnouncement < NO_TRACK) {
if ((m_bAnnouncementInProgress || m_nFrontendTrack == m_nPlayingTrack) && ServiceAnnouncement()) { if ((m_bAnnouncementInProgress || m_nFrontendTrack == m_nPlayingTrack) && ServiceAnnouncement()) {
if (m_bAnnouncementInProgress) { if (m_bAnnouncementInProgress) {
field_2 = false; m_bSetNextStation = false;
gNumRetunePresses = 0; gNumRetunePresses = 0;
gRetuneCounter = 0; gRetuneCounter = 0;
return; return;
} }
if(m_nAnnouncement == NO_TRACK) { if(m_nAnnouncement == NO_TRACK) {
m_nStreamedTrack = NO_TRACK; m_nNextTrack = NO_TRACK;
m_nFrontendTrack = GetCarTuning(); m_nFrontendTrack = GetCarTuning();
field_2 = false; m_bSetNextStation = false;
gRetuneCounter = 0; gRetuneCounter = 0;
gNumRetunePresses = 0; gNumRetunePresses = 0;
} }
@ -583,36 +629,56 @@ cMusicManager::ServiceGameMode()
if (!m_bRadioSetByScript) if (!m_bRadioSetByScript)
{ {
// Because when you switch radio back and forth, gNumRetunePresses will be 0 but gRetuneCounter won't.
#ifdef RADIO_SCROLL_TO_PREV_STATION
if(gRetuneCounter != 0) {
if(gRetuneCounter > 1)
gRetuneCounter--;
else if(gRetuneCounter == 1) {
m_bSetNextStation = true;
gRetuneCounter = 0;
}
}
#else
if (gNumRetunePresses != 0) if (gNumRetunePresses != 0)
{ {
if (--gRetuneCounter == 0) if (--gRetuneCounter == 0)
{ {
field_2 = true; m_bSetNextStation = true;
gRetuneCounter = 0; gRetuneCounter = 0;
} }
} }
#endif
if (gRetuneCounter) if (gRetuneCounter)
{ {
int32 station = gNumRetunePresses + vehicle->m_nRadioStation; int32 station = gNumRetunePresses + vehicle->m_nRadioStation;
while (station >= RADIO_OFF) station -= RADIO_OFF; #ifdef RADIO_SCROLL_TO_PREV_STATION
while (station < 0) station += NUM_RADIOS + 1;
#endif
while (station >= NUM_RADIOS + 1) station -= NUM_RADIOS + 1;
// Scrolling back won't hit here, so increasing isn't problem
if (!DMAudio.IsMP3RadioChannelAvailable() && station == USERTRACK) if (!DMAudio.IsMP3RadioChannelAvailable() && station == USERTRACK)
{ {
++gNumRetunePresses; ++gNumRetunePresses;
station = NUM_RADIOS; station = RADIO_OFF;
} }
if (station == NUM_RADIOS) if (station == RADIO_OFF)
{ {
if (gRetuneCounter == NUM_RADIOS + 9) if (gRetuneCounter == 19) // One less then what switching radio sets, so runs right after turning off radio
{ {
AudioManager.PlayOneShot(AudioManager.m_nFrontEndEntity, SOUND_FRONTEND_NO_RADIO, 0.0f); AudioManager.PlayOneShot(AudioManager.m_nFrontEndEntity, SOUND_FRONTEND_RADIO_TURN_OFF, 0.0f);
RadioStaticCounter = 5; RadioStaticCounter = 5;
} }
} }
else else
{ {
if (station == WILDSTYLE && gRetuneCounter == NUM_RADIOS + 9) #ifdef RADIO_SCROLL_TO_PREV_STATION
AudioManager.PlayOneShot(AudioManager.m_nFrontEndEntity, SOUND_FRONTEND_RADIO_CHANGE, 0.0f); if (vehicle->m_nRadioStation == RADIO_OFF && gRetuneCounter == 19) // Right after turning on the radio
#else
if (station == 0 && gRetuneCounter == 19) // Right after turning on the radio
#endif
AudioManager.PlayOneShot(AudioManager.m_nFrontEndEntity, SOUND_FRONTEND_RADIO_TURN_ON, 0.0f);
AudioManager.DoPoliceRadioCrackle(); AudioManager.DoPoliceRadioCrackle();
} }
} }
@ -622,13 +688,13 @@ cMusicManager::ServiceGameMode()
RadioStaticCounter++; RadioStaticCounter++;
RadioStaticTimer = CTimer::GetTimeInMilliseconds(); RadioStaticTimer = CTimer::GetTimeInMilliseconds();
} }
if (field_2) if (m_bSetNextStation)
m_nFrontendTrack = GetNextCarTuning(); m_nFrontendTrack = GetNextCarTuning();
if (m_nFrontendTrack >= STREAMED_SOUND_CITY_AMBIENT && m_nFrontendTrack <= STREAMED_SOUND_AMBSIL_AMBIENT) if (m_nFrontendTrack >= STREAMED_SOUND_CITY_AMBIENT && m_nFrontendTrack <= STREAMED_SOUND_AMBSIL_AMBIENT)
SetUpCorrectAmbienceTrack(); SetUpCorrectAmbienceTrack();
ServiceTrack(vehicle, ped); ServiceTrack(vehicle, ped);
if (field_2) if (m_bSetNextStation)
field_2 = false; m_bSetNextStation = false;
return; return;
} }
if (UsesPoliceRadio(vehicle)) if (UsesPoliceRadio(vehicle))
@ -636,8 +702,8 @@ cMusicManager::ServiceGameMode()
else if (UsesTaxiRadio(vehicle)) else if (UsesTaxiRadio(vehicle))
m_nFrontendTrack = STREAMED_SOUND_RADIO_TAXI; m_nFrontendTrack = STREAMED_SOUND_RADIO_TAXI;
else { else {
m_nFrontendTrack = m_nRadioStation; m_nFrontendTrack = m_nRadioStationScript;
vehicle->m_nRadioStation = m_nRadioStation; vehicle->m_nRadioStation = m_nRadioStationScript;
} }
if (m_nRadioPosition != -1) { if (m_nRadioPosition != -1) {
@ -647,40 +713,13 @@ cMusicManager::ServiceGameMode()
gRetuneCounter = 0; gRetuneCounter = 0;
gNumRetunePresses = 0; gNumRetunePresses = 0;
field_2 = false; m_bSetNextStation = false;
m_bRadioSetByScript = false; m_bRadioSetByScript = false;
if (m_nFrontendTrack >= STREAMED_SOUND_CITY_AMBIENT && m_nFrontendTrack <= STREAMED_SOUND_AMBSIL_AMBIENT) if (m_nFrontendTrack >= STREAMED_SOUND_CITY_AMBIENT && m_nFrontendTrack <= STREAMED_SOUND_AMBSIL_AMBIENT)
SetUpCorrectAmbienceTrack(); SetUpCorrectAmbienceTrack();
ServiceTrack(vehicle, ped); ServiceTrack(vehicle, ped);
if (field_2) if (m_bSetNextStation)
field_2 = false; m_bSetNextStation = false;
return;
}
if (vehicle == nil)
{
m_nFrontendTrack = STREAMED_SOUND_RADIO_WAVE; // huh?
return;
}
if (m_bRadioSetByScript)
{
if (UsesPoliceRadio(vehicle))
m_nFrontendTrack = STREAMED_SOUND_RADIO_POLICE;
else if (UsesTaxiRadio(vehicle))
m_nFrontendTrack = STREAMED_SOUND_RADIO_TAXI;
else {
m_nFrontendTrack = m_nRadioStation;
vehicle->m_nRadioStation = m_nRadioStation;
}
if (m_nRadioPosition != -1)
{
m_aTracks[m_nFrontendTrack].m_nPosition = m_nRadioPosition;
m_aTracks[m_nFrontendTrack].m_nLastPosCheckTimer = CTimer::GetTimeInMillisecondsPauseMode();
}
m_bRadioSetByScript = false;
return;
}
m_nFrontendTrack = GetCarTuning();
return; return;
} }
@ -692,7 +731,7 @@ cMusicManager::ServiceGameMode()
g_bAnnouncementReadPosAlready = false; g_bAnnouncementReadPosAlready = false;
m_nAnnouncement = NO_TRACK; m_nAnnouncement = NO_TRACK;
m_bAnnouncementInProgress = false; m_bAnnouncementInProgress = false;
m_nStreamedTrack = NO_TRACK; m_nNextTrack = NO_TRACK;
m_nFrontendTrack = NO_TRACK; m_nFrontendTrack = NO_TRACK;
m_nPlayingTrack = NO_TRACK; m_nPlayingTrack = NO_TRACK;
} }
@ -834,7 +873,7 @@ cMusicManager::ServiceAnnouncement()
{ {
if (m_bAnnouncementInProgress) { if (m_bAnnouncementInProgress) {
if (SampleManager.IsStreamPlaying(0)) if (SampleManager.IsStreamPlaying(0))
m_nPlayingTrack = m_nStreamedTrack; m_nPlayingTrack = m_nNextTrack;
else if (m_nPlayingTrack != NO_TRACK) { else if (m_nPlayingTrack != NO_TRACK) {
m_nAnnouncement = NO_TRACK; m_nAnnouncement = NO_TRACK;
m_bAnnouncementInProgress = false; m_bAnnouncementInProgress = false;
@ -852,9 +891,9 @@ cMusicManager::ServiceAnnouncement()
} else { } else {
g_bAnnouncementReadPosAlready = false; g_bAnnouncementReadPosAlready = false;
m_nPlayingTrack = NO_TRACK; m_nPlayingTrack = NO_TRACK;
m_nStreamedTrack = m_nAnnouncement; m_nNextTrack = m_nAnnouncement;
SampleManager.SetStreamedFileLoopFlag(0, false); SampleManager.SetStreamedFileLoopFlag(0, 0);
SampleManager.StartStreamedFile(m_nStreamedTrack, 0, 0); SampleManager.StartStreamedFile(m_nNextTrack, 0, 0);
SampleManager.SetStreamedVolumeAndPan(MAX_VOLUME, 63, 0, 0); SampleManager.SetStreamedVolumeAndPan(MAX_VOLUME, 63, 0, 0);
m_bAnnouncementInProgress = true; m_bAnnouncementInProgress = true;
} }
@ -868,9 +907,9 @@ cMusicManager::ServiceTrack(CVehicle *veh, CPed *ped)
static bool bRadioStatsRecorded = false; static bool bRadioStatsRecorded = false;
static bool bRadioStatsRecorded2 = false; static bool bRadioStatsRecorded2 = false;
uint8 volume; uint8 volume;
if (!field_398F) if (!m_bTrackChangeStarted)
m_nStreamedTrack = m_nFrontendTrack; m_nNextTrack = m_nFrontendTrack;
if (gRetuneCounter != 0 || field_2) { if (gRetuneCounter != 0 || m_bSetNextStation) {
if (SampleManager.IsStreamPlaying(0)) { if (SampleManager.IsStreamPlaying(0)) {
if (m_nPlayingTrack != NO_TRACK && !bRadioStatsRecorded) { if (m_nPlayingTrack != NO_TRACK && !bRadioStatsRecorded) {
m_aTracks[m_nPlayingTrack].m_nPosition = SampleManager.GetStreamedFilePosition(0); m_aTracks[m_nPlayingTrack].m_nPosition = SampleManager.GetStreamedFilePosition(0);
@ -889,28 +928,35 @@ cMusicManager::ServiceTrack(CVehicle *veh, CPed *ped)
m_nPlayingTrack = NO_TRACK; m_nPlayingTrack = NO_TRACK;
} }
if (m_nStreamedTrack != m_nPlayingTrack) if (m_nNextTrack != m_nPlayingTrack)
{ {
field_398F = true; m_bTrackChangeStarted = true;
SampleManager.SetStreamedVolumeAndPan(0, 63, 0, 0); SampleManager.SetStreamedVolumeAndPan(0, 63, 0, 0);
if (!(AudioManager.m_FrameCounter & 1)) { if (!(AudioManager.m_FrameCounter & 1)) {
if (field_3995 || !SampleManager.IsStreamPlaying(0)) { if (m_bVerifyNextTrackStartedToPlay || !SampleManager.IsStreamPlaying(0)) {
bRadioStatsRecorded2 = false; bRadioStatsRecorded2 = false;
if (SampleManager.IsStreamPlaying(0)) { if (SampleManager.IsStreamPlaying(0)) {
m_nPlayingTrack = m_nStreamedTrack; m_nPlayingTrack = m_nNextTrack;
field_3995 = false; m_bVerifyNextTrackStartedToPlay = false;
field_398F = false; m_bTrackChangeStarted = false;
if (veh) { if (veh) {
if (veh->m_nRadioStation < STREAMED_SOUND_CITY_AMBIENT || veh->m_nRadioStation > STREAMED_SOUND_AMBSIL_AMBIENT) #ifdef FIX_BUGS
if (m_nPlayingTrack >= STREAMED_SOUND_CITY_AMBIENT && m_nPlayingTrack <= STREAMED_SOUND_AMBSIL_AMBIENT)
veh->m_nRadioStation = RADIO_OFF;
else if (m_nPlayingTrack < STREAMED_SOUND_CITY_AMBIENT)
veh->m_nRadioStation = m_nPlayingTrack; veh->m_nRadioStation = m_nPlayingTrack;
#else
if (veh->m_nRadioStation >= STREAMED_SOUND_CITY_AMBIENT && veh->m_nRadioStation <= STREAMED_SOUND_AMBSIL_AMBIENT)
veh->m_nRadioStation = RADIO_OFF;
else else
veh->m_nRadioStation = STREAMED_SOUND_CITY_AMBIENT; veh->m_nRadioStation = m_nPlayingTrack;
#endif
} }
} else { } else {
uint32 pos = GetTrackStartPos(m_nStreamedTrack); uint32 pos = GetTrackStartPos(m_nNextTrack);
if (m_nStreamedTrack != NO_TRACK) { if (m_nNextTrack != NO_TRACK) {
SampleManager.SetStreamedFileLoopFlag(1, 0); SampleManager.SetStreamedFileLoopFlag(1, 0);
SampleManager.StartStreamedFile(m_nStreamedTrack, pos, 0); SampleManager.StartStreamedFile(m_nNextTrack, pos, 0);
if (m_nFrontendTrack < STREAMED_SOUND_CITY_AMBIENT || m_nFrontendTrack > STREAMED_SOUND_AMBSIL_AMBIENT) if (m_nFrontendTrack < STREAMED_SOUND_CITY_AMBIENT || m_nFrontendTrack > STREAMED_SOUND_AMBSIL_AMBIENT)
{ {
m_nVolumeLatency = 10; m_nVolumeLatency = 10;
@ -923,9 +969,9 @@ cMusicManager::ServiceTrack(CVehicle *veh, CPed *ped)
ComputeAmbienceVol(true, volume); ComputeAmbienceVol(true, volume);
SampleManager.SetStreamedVolumeAndPan(volume, 63, 1, 0); SampleManager.SetStreamedVolumeAndPan(volume, 63, 1, 0);
} }
if (m_nStreamedTrack < STREAMED_SOUND_CITY_AMBIENT) if (m_nNextTrack < STREAMED_SOUND_CITY_AMBIENT)
m_nLastTrackServiceTime = CTimer::GetTimeInMillisecondsPauseMode(); m_nLastTrackServiceTime = CTimer::GetTimeInMillisecondsPauseMode();
field_3995 = true; m_bVerifyNextTrackStartedToPlay = true;
} }
} }
} else { } else {
@ -939,8 +985,8 @@ cMusicManager::ServiceTrack(CVehicle *veh, CPed *ped)
RecordRadioStats(); RecordRadioStats();
if (m_nPlayingTrack >= STREAMED_SOUND_HAVANA_CITY_AMBIENT && m_nPlayingTrack <= STREAMED_SOUND_HAVANA_BEACH_AMBIENT) if (m_nPlayingTrack >= STREAMED_SOUND_HAVANA_CITY_AMBIENT && m_nPlayingTrack <= STREAMED_SOUND_HAVANA_BEACH_AMBIENT)
{ {
if (m_nStreamedTrack >= STREAMED_SOUND_HAVANA_CITY_AMBIENT && m_nStreamedTrack <= STREAMED_SOUND_HAVANA_BEACH_AMBIENT) if (m_nNextTrack >= STREAMED_SOUND_HAVANA_CITY_AMBIENT && m_nNextTrack <= STREAMED_SOUND_HAVANA_BEACH_AMBIENT)
AudioManager.PlayOneShot(AudioManager.m_nFrontEndEntity, SOUND_FRONTEND_RADIO_CHANGE_2, 0.0); AudioManager.PlayOneShot(AudioManager.m_nFrontEndEntity, SOUND_FRONTEND_HURRICANE, 0.0);
} }
} }
SampleManager.SetStreamedVolumeAndPan(0, 63, 0, 0); SampleManager.SetStreamedVolumeAndPan(0, 63, 0, 0);
@ -1050,14 +1096,14 @@ cMusicManager::StopCutSceneMusic(void)
} }
void void
cMusicManager::PlayFrontEndTrack(uint32 track, uint8 bPlayInFrontend) cMusicManager::PlayFrontEndTrack(uint32 track, uint8 loopFlag)
{ {
if (IsInitialised() && !m_bDisabled && track < TOTAL_STREAMED_SOUNDS && (m_nUpcomingMusicMode == MUSICMODE_FRONTEND || m_nMusicMode == MUSICMODE_FRONTEND)) if (IsInitialised() && !m_bDisabled && track < TOTAL_STREAMED_SOUNDS && (m_nUpcomingMusicMode == MUSICMODE_FRONTEND || m_nMusicMode == MUSICMODE_FRONTEND))
{ {
m_nFrontendTrack = track; m_nFrontendTrack = track;
field_398E = bPlayInFrontend; m_FrontendLoopFlag = loopFlag;
if (m_nMusicMode != MUSICMODE_FRONTEND) if (m_nMusicMode != MUSICMODE_FRONTEND)
field_399C = true; m_bEarlyFrontendTrack = true;
} }
} }
@ -1083,10 +1129,18 @@ cMusicManager::GetNextCarTuning()
if (UsesPoliceRadio(veh)) return STREAMED_SOUND_RADIO_POLICE; if (UsesPoliceRadio(veh)) return STREAMED_SOUND_RADIO_POLICE;
if (UsesTaxiRadio(veh)) return STREAMED_SOUND_RADIO_TAXI; if (UsesTaxiRadio(veh)) return STREAMED_SOUND_RADIO_TAXI;
if (gNumRetunePresses != 0) { if (gNumRetunePresses != 0) {
#ifdef RADIO_SCROLL_TO_PREV_STATION
// m_nRadioStation is unsigned, so...
int station = veh->m_nRadioStation + gNumRetunePresses;
while(station < 0) station += NUM_RADIOS + 1;
while(station >= NUM_RADIOS + 1) station -= NUM_RADIOS + 1;
veh->m_nRadioStation = station;
#else
veh->m_nRadioStation += gNumRetunePresses; veh->m_nRadioStation += gNumRetunePresses;
while (veh->m_nRadioStation >= RADIO_OFF) while(veh->m_nRadioStation >= NUM_RADIOS + 1)
veh->m_nRadioStation -= RADIO_OFF; veh->m_nRadioStation -= NUM_RADIOS + 1;
DMAudio.IsMP3RadioChannelAvailable(); // woof, just call and do nothing =P #endif
DMAudio.IsMP3RadioChannelAvailable(); // woof, just call and do nothing =P they manipulate gNumRetunePresses on DisplayRadioStationName in this case
gNumRetunePresses = 0; gNumRetunePresses = 0;
} }
return veh->m_nRadioStation; return veh->m_nRadioStation;
@ -1129,7 +1183,7 @@ cMusicManager::GetTrackStartPos(uint32 track)
uint32 uint32
cMusicManager::GetRadioPosition(uint32 station) cMusicManager::GetRadioPosition(uint32 station)
{ {
if (station < STREAMED_SOUND_CITY_AMBIENT) if (station < NUM_RADIOS)
return GetTrackStartPos(station); return GetTrackStartPos(station);
return 0; return 0;
} }
@ -1158,7 +1212,7 @@ cMusicManager::SetMalibuClubTrackPos(uint8 scriptObject)
{ {
if (!IsInitialised()) if (!IsInitialised())
m_aTracks[STREAMED_SOUND_MALIBU_AMBIENT].m_nPosition = 8640; m_aTracks[STREAMED_SOUND_MALIBU_AMBIENT].m_nPosition = 8640;
if (m_nStreamedTrack != STREAMED_SOUND_MALIBU_AMBIENT && m_nPlayingTrack != STREAMED_SOUND_MALIBU_AMBIENT) { if (m_nNextTrack != STREAMED_SOUND_MALIBU_AMBIENT && m_nPlayingTrack != STREAMED_SOUND_MALIBU_AMBIENT) {
switch (scriptObject) switch (scriptObject)
{ {
case SCRIPT_SOUND_NEW_BUILDING_MALIBU_1: case SCRIPT_SOUND_NEW_BUILDING_MALIBU_1:
@ -1180,7 +1234,7 @@ cMusicManager::SetStripClubTrackPos(uint8 scriptObject)
{ {
if (!IsInitialised()) if (!IsInitialised())
m_aTracks[STREAMED_SOUND_STRIPCLUB_AMBIENT].m_nPosition = 0; m_aTracks[STREAMED_SOUND_STRIPCLUB_AMBIENT].m_nPosition = 0;
if (m_nStreamedTrack != STREAMED_SOUND_STRIPCLUB_AMBIENT && m_nPlayingTrack != STREAMED_SOUND_STRIPCLUB_AMBIENT) if (m_nNextTrack != STREAMED_SOUND_STRIPCLUB_AMBIENT && m_nPlayingTrack != STREAMED_SOUND_STRIPCLUB_AMBIENT)
{ {
switch (scriptObject) switch (scriptObject)
{ {
@ -1201,7 +1255,7 @@ cMusicManager::SetStripClubTrackPos(uint8 scriptObject)
void void
cMusicManager::DisplayRadioStationName() cMusicManager::DisplayRadioStationName()
{ {
int8 gStreamedSound; uint8 gStreamedSound;
static wchar *pCurrentStation = nil; static wchar *pCurrentStation = nil;
static uint8 cDisplay = 0; static uint8 cDisplay = 0;
@ -1211,20 +1265,25 @@ cMusicManager::DisplayRadioStationName()
if (vehicle) if (vehicle)
{ {
uint8 track; int8 track;
gStreamedSound = vehicle->m_nRadioStation; gStreamedSound = vehicle->m_nRadioStation;
if (gStreamedSound >= STREAMED_SOUND_CITY_AMBIENT && gStreamedSound <= STREAMED_SOUND_AMBSIL_AMBIENT) if (gStreamedSound >= STREAMED_SOUND_CITY_AMBIENT && gStreamedSound <= STREAMED_SOUND_AMBSIL_AMBIENT)
gStreamedSound = STREAMED_SOUND_CITY_AMBIENT; gStreamedSound = RADIO_OFF;
if (gNumRetunePresses != 0) if (gNumRetunePresses != 0)
{ {
track = gNumRetunePresses + gStreamedSound; track = gNumRetunePresses + gStreamedSound;
while (track >= RADIO_OFF) track -= RADIO_OFF; #ifdef RADIO_SCROLL_TO_PREV_STATION
while (track < 0) track += NUM_RADIOS + 1;
#endif
while (track >= NUM_RADIOS + 1) track -= NUM_RADIOS + 1;
// We already handle this condition while scrolling back, on key press. No need to change this.
if (!DMAudio.IsMP3RadioChannelAvailable() && track == USERTRACK) if (!DMAudio.IsMP3RadioChannelAvailable() && track == USERTRACK)
gNumRetunePresses++; gNumRetunePresses++;
} }
else else
#ifdef FIX_BUGS #ifdef FIX_BUGS
track = m_nFrontendTrack == NO_TRACK ? POLICE_RADIO : m_nFrontendTrack; track = GetCarTuning(); // gStreamedSound or veh->m_nRadioStation would also work, but these don't cover police/taxi radios
#else #else
track = m_nFrontendTrack; track = m_nFrontendTrack;
#endif #endif
@ -1244,6 +1303,18 @@ cMusicManager::DisplayRadioStationName()
if (!SampleManager.IsMP3RadioChannelAvailable()) if (!SampleManager.IsMP3RadioChannelAvailable())
return; return;
string = TheText.Get("FEA_MP3"); break; string = TheText.Get("FEA_MP3"); break;
#ifdef RADIO_OFF_TEXT
case RADIO_OFF: {
extern wchar WideErrorString[];
string = TheText.Get("FEA_FMN");
if (string == WideErrorString) {
pCurrentStation = nil;
return;
}
break;
}
#endif
default: return; default: return;
}; };
@ -1275,6 +1346,11 @@ cMusicManager::DisplayRadioStationName()
CFont::DrawFonts(); CFont::DrawFonts();
} }
} }
// Always show station text after entering car. Same behaviour as III and SA.
#ifdef FIX_BUGS
else
pCurrentStation = nil;
#endif
} }
bool bool

View file

@ -18,7 +18,7 @@ class cMusicManager
public: public:
bool m_bIsInitialised; bool m_bIsInitialised;
bool m_bDisabled; bool m_bDisabled;
bool field_2; bool m_bSetNextStation;
uint8 m_nVolumeLatency; uint8 m_nVolumeLatency;
uint8 m_nCurrentVolume; uint8 m_nCurrentVolume;
uint8 m_nMaxVolume; uint8 m_nMaxVolume;
@ -28,25 +28,25 @@ public:
bool m_bResetTimers; bool m_bResetTimers;
uint32 m_nResetTime; uint32 m_nResetTime;
bool m_bRadioSetByScript; bool m_bRadioSetByScript;
uint8 m_nRadioStation; uint8 m_nRadioStationScript;
int32 m_nRadioPosition; int32 m_nRadioPosition;
uint32 m_nRadioInCar; uint32 m_nRadioInCar;
uint32 m_nFrontendTrack; uint32 m_nFrontendTrack;
uint32 m_nPlayingTrack; uint32 m_nPlayingTrack;
uint8 m_nUpcomingMusicMode; uint8 m_nUpcomingMusicMode;
uint8 m_nMusicMode; uint8 m_nMusicMode;
bool field_398E; bool m_FrontendLoopFlag;
bool field_398F; bool m_bTrackChangeStarted;
uint32 m_nStreamedTrack; uint32 m_nNextTrack;
bool field_3994; bool m_nNextLoopFlag;
bool field_3995; bool m_bVerifyNextTrackStartedToPlay;
bool field_3996; bool m_bGameplayAllowsRadio;
bool field_3997; bool m_bRadioStreamReady;
int8 nFramesSinceCutsceneEnded; int8 nFramesSinceCutsceneEnded;
bool field_3999; bool m_bUserResumedGame;
bool field_399A; bool m_bMusicModeChangeStarted;
uint8 m_nMusicModeToBeSet; uint8 m_nMusicModeToBeSet;
bool field_399C; bool m_bEarlyFrontendTrack;
float aListenTimeArray[NUM_RADIOS]; float aListenTimeArray[NUM_RADIOS];
float m_nLastTrackServiceTime; float m_nLastTrackServiceTime;

View file

@ -14,8 +14,8 @@ enum eRadioStation
USERTRACK, USERTRACK,
NUM_RADIOS = 10, NUM_RADIOS = 10,
POLICE_RADIO = 10, POLICE_RADIO = 10,
RADIO_OFF = 10,
//TAXI_RADIO, //TAXI_RADIO,
RADIO_OFF,
}; };
enum eMusicMode enum eMusicMode

View file

@ -171,22 +171,22 @@ enum eSound
SOUND_CAR_PED_COLLISION, SOUND_CAR_PED_COLLISION,
SOUND_CLOCK_TICK, SOUND_CLOCK_TICK,
SOUND_PART_MISSION_COMPLETE, SOUND_PART_MISSION_COMPLETE,
SOUND_FRONTEND_MENU_STARTING, // same with SOUND_HUD_SOUND SOUND_FRONTEND_MENU_STARTING, // same sound as SOUND_HUD
// TODO(Miami): What are 170-175?? // TODO(Miami): What are 170-175??
SOUND_FRONTEND_NO_RADIO = 176, // those 3 are all same sound SOUND_FRONTEND_RADIO_TURN_OFF = 176, // those 2 are same sound
SOUND_FRONTEND_RADIO_CHANGE, SOUND_FRONTEND_RADIO_TURN_ON,
SOUND_FRONTEND_RADIO_CHANGE_2, SOUND_FRONTEND_HURRICANE, // yes, frontend
SOUND_HUD_SOUND, SOUND_HUD,
SOUND_180, SOUND_180,
SOUND_181, SOUND_181,
SOUND_182, SOUND_182,
SOUND_LIGHTNING, SOUND_LIGHTNING,
SOUND_BULLETTRACE_1, SOUND_BULLETTRACE_1,
SOUND_BULLETTRACE_2, SOUND_BULLETTRACE_2,
SOUND_186, // makes same sound with 40 SOUND_186, // makes same sound as 40
SOUND_187, // makes same sound with 46 SOUND_187, // makes same sound as 46
SOUND_MELEE_ATTACK_START, SOUND_MELEE_ATTACK_START,
SOUND_SKATING, SOUND_SKATING,
SOUND_WEAPON_MINIGUN_ATTACK, SOUND_WEAPON_MINIGUN_ATTACK,

View file

@ -1768,7 +1768,7 @@ CCamera::CamControl(void)
(m_bLookingAtPlayer || WhoIsInControlOfTheCamera == CAMCONTROL_OBBE) && (m_bLookingAtPlayer || WhoIsInControlOfTheCamera == CAMCONTROL_OBBE) &&
!m_WideScreenOn && !m_WideScreenOn &&
(WhoIsInControlOfTheCamera != CAMCONTROL_OBBE || bSwitchedToObbeCam)) (WhoIsInControlOfTheCamera != CAMCONTROL_OBBE || bSwitchedToObbeCam))
DMAudio.PlayFrontEndSound(SOUND_HUD_SOUND, 0); DMAudio.PlayFrontEndSound(SOUND_HUD, 0);
} }
// What a mess! // What a mess!

View file

@ -1765,6 +1765,51 @@ void CControllerConfigManager::DeleteMatching1rstPersonControls(e_ControllerActi
#undef CLEAR_ACTION_IF_NEEDED #undef CLEAR_ACTION_IF_NEEDED
#ifdef RADIO_SCROLL_TO_PREV_STATION
#define CHECK_ACTION(action) \
if (key == GetControllerKeyAssociatedWithAction(action, type))\
return true;
bool CControllerConfigManager::IsAnyVehicleActionAssignedToMouseKey(int32 key)
{
const eControllerType type = MOUSE;
if (!GetIsKeyBlank(key, type))
{
#ifdef BIND_VEHICLE_FIREWEAPON
CHECK_ACTION(VEHICLE_FIREWEAPON);
#endif
CHECK_ACTION(VEHICLE_LOOKBEHIND);
CHECK_ACTION(VEHICLE_LOOKLEFT);
CHECK_ACTION(VEHICLE_LOOKRIGHT);
CHECK_ACTION(VEHICLE_HORN);
CHECK_ACTION(VEHICLE_HANDBRAKE);
CHECK_ACTION(VEHICLE_ACCELERATE);
CHECK_ACTION(VEHICLE_BRAKE);
CHECK_ACTION(VEHICLE_CHANGE_RADIO_STATION);
CHECK_ACTION(TOGGLE_SUBMISSIONS);
CHECK_ACTION(VEHICLE_TURRETLEFT);
CHECK_ACTION(VEHICLE_TURRETRIGHT);
CHECK_ACTION(VEHICLE_TURRETUP);
CHECK_ACTION(VEHICLE_TURRETDOWN);
CHECK_ACTION(VEHICLE_ENTER_EXIT);
CHECK_ACTION(CAMERA_CHANGE_VIEW_ALL_SITUATIONS);
#ifndef BIND_VEHICLE_FIREWEAPON
CHECK_ACTION(PED_FIREWEAPON);
#endif
CHECK_ACTION(GO_LEFT);
CHECK_ACTION(GO_RIGHT);
CHECK_ACTION(NETWORK_TALK);
CHECK_ACTION(SWITCH_DEBUG_CAM_ON);
CHECK_ACTION(TOGGLE_DPAD);
CHECK_ACTION(TAKE_SCREEN_SHOT);
CHECK_ACTION(SHOW_MOUSE_POINTER_TOGGLE);
}
return false;
}
#undef CHECK_ACTION
#endif
void CControllerConfigManager::DeleteMatchingActionInitiators(e_ControllerAction action, int32 key, eControllerType type) void CControllerConfigManager::DeleteMatchingActionInitiators(e_ControllerAction action, int32 key, eControllerType type)
{ {
if (!GetIsKeyBlank(key, type)) if (!GetIsKeyBlank(key, type))

View file

@ -195,6 +195,10 @@ public:
void DeleteMatching1rstPersonControls (e_ControllerAction action, int32 key, eControllerType type); void DeleteMatching1rstPersonControls (e_ControllerAction action, int32 key, eControllerType type);
void DeleteMatchingActionInitiators (e_ControllerAction action, int32 key, eControllerType type); void DeleteMatchingActionInitiators (e_ControllerAction action, int32 key, eControllerType type);
#ifdef RADIO_SCROLL_TO_PREV_STATION
bool IsAnyVehicleActionAssignedToMouseKey(int32 key);
#endif
bool GetIsKeyBlank(int32 key, eControllerType type); bool GetIsKeyBlank(int32 key, eControllerType type);
e_ControllerActionType GetActionType(e_ControllerAction action); e_ControllerActionType GetActionType(e_ControllerAction action);

View file

@ -306,8 +306,8 @@ enum Config {
// Hud, frontend and radar // Hud, frontend and radar
#define PC_MENU #define PC_MENU
#define FIX_RADAR // use radar size from early version before R* broke it #define FIX_RADAR // use radar size from early version before R* broke it
#define RADIO_OFF_TEXT // Won't work without FIX_BUGS
#ifndef PC_MENU #ifndef PC_MENU
# define PS2_MENU # define PS2_MENU
@ -376,6 +376,7 @@ static_assert(false, "SUPPORT_XBOX_SCRIPT and SUPPORT_MOBILE_SCRIPT are mutually
#define FREE_CAM // Rotating cam #define FREE_CAM // Rotating cam
// Audio // Audio
#define RADIO_SCROLL_TO_PREV_STATION // Won't work without FIX_BUGS
#define AUDIO_CACHE // cache sound lengths to speed up the cold boot #define AUDIO_CACHE // cache sound lengths to speed up the cold boot
//#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
@ -462,6 +463,7 @@ static_assert(false, "SUPPORT_XBOX_SCRIPT and SUPPORT_MOBILE_SCRIPT are mutually
#undef BUTTON_ICONS #undef BUTTON_ICONS
#undef FIX_RADAR #undef FIX_RADAR
#undef RADIO_OFF_TEXT
#undef MAP_ENHANCEMENTS #undef MAP_ENHANCEMENTS
#undef MUCH_SHORTER_OUTRO_SCREEN #undef MUCH_SHORTER_OUTRO_SCREEN
@ -490,4 +492,6 @@ static_assert(false, "SUPPORT_XBOX_SCRIPT and SUPPORT_MOBILE_SCRIPT are mutually
#undef IMPROVED_CAMERA #undef IMPROVED_CAMERA
#undef FREE_CAM #undef FREE_CAM
#undef BIG_IMG #undef BIG_IMG
#undef RADIO_SCROLL_TO_PREV_STATION
#endif #endif

View file

@ -1225,7 +1225,7 @@ void CHud::Draw()
m_HelpMessageDisplayTime = CMessages::GetWideStringLength(m_HelpMessage) * 0.05f + 3.0f; m_HelpMessageDisplayTime = CMessages::GetWideStringLength(m_HelpMessage) * 0.05f + 3.0f;
if (TheCamera.m_ScreenReductionPercentage == 0.0f) if (TheCamera.m_ScreenReductionPercentage == 0.0f)
DMAudio.PlayFrontEndSound(SOUND_HUD_SOUND, 0); DMAudio.PlayFrontEndSound(SOUND_HUD, 0);
break; break;
case 1: case 1:
case 2: case 2:

View file

@ -67,16 +67,16 @@ bool StillToFadeOut;
uint32 TimeStartedCountingForFade; uint32 TimeStartedCountingForFade;
uint32 TimeToStayFadedBeforeFadeOut = 1750; uint32 TimeToStayFadedBeforeFadeOut = 1750;
uint32 RadioStationPosition[NUM_RADIOS]; int32 RadioStationPosition[NUM_RADIOS];
void void
InitRadioStationPositionList() InitRadioStationPositionList()
{ {
for (int i = 0; i < NUM_RADIOS; i++) for (int i = 0; i < NUM_RADIOS; i++)
RadioStationPosition[i] = 0; RadioStationPosition[i] = -1;
} }
uint32 int32
GetSavedRadioStationPosition(int32 station) GetSavedRadioStationPosition(int32 station)
{ {
return RadioStationPosition[station]; return RadioStationPosition[station];

View file

@ -6,7 +6,7 @@
#define SLOT_COUNT (8) #define SLOT_COUNT (8)
void InitRadioStationPositionList(); void InitRadioStationPositionList();
uint32 GetSavedRadioStationPosition(int32 station); int32 GetSavedRadioStationPosition(int32 station);
void PopulateRadioStationPositionList(); void PopulateRadioStationPositionList();
bool GenericSave(int file); bool GenericSave(int file);
bool GenericLoad(); bool GenericLoad();

View file

@ -9,7 +9,7 @@
#include "Text.h" #include "Text.h"
#include "Timer.h" #include "Timer.h"
static wchar WideErrorString[25]; wchar WideErrorString[25];
CText TheText; CText TheText;

View file

@ -152,7 +152,7 @@ CVehicle::CVehicle(uint8 CreatedBy)
m_audioEntityId = DMAudio.CreateEntity(AUDIOTYPE_PHYSICAL, this); m_audioEntityId = DMAudio.CreateEntity(AUDIOTYPE_PHYSICAL, this);
if(m_audioEntityId >= 0) if(m_audioEntityId >= 0)
DMAudio.SetEntityStatus(m_audioEntityId, true); DMAudio.SetEntityStatus(m_audioEntityId, true);
//m_nRadioStation = CGeneral::GetRandomNumber() % USERTRACK; //m_nRadioStation = CGeneral::GetRandomNumber() % NUM_RADIOS;
switch(GetModelIndex()){ switch(GetModelIndex()){
case MI_HUNTER: case MI_HUNTER:
case MI_ANGEL: case MI_ANGEL:
@ -169,7 +169,7 @@ CVehicle::CVehicle(uint8 CreatedBy)
m_nRadioStation = RADIO_OFF; m_nRadioStation = RADIO_OFF;
break; break;
default: default:
m_nRadioStation = CGeneral::GetRandomNumber() % USERTRACK; m_nRadioStation = CGeneral::GetRandomNumber() % NUM_RADIOS;
break; break;
} }
m_pCurGroundEntity = nil; m_pCurGroundEntity = nil;

View file

@ -266,7 +266,7 @@ public:
eCarLock m_nDoorLock; eCarLock m_nDoorLock;
int8 m_nLastWeaponDamage; // see eWeaponType, -1 if no damage int8 m_nLastWeaponDamage; // see eWeaponType, -1 if no damage
CEntity *m_pLastDamageEntity; CEntity *m_pLastDamageEntity;
int8 m_nRadioStation; uint8 m_nRadioStation;
uint8 m_bRainAudioCounter; uint8 m_bRainAudioCounter;
uint8 m_bRainSamplesCounter; uint8 m_bRainSamplesCounter;
uint32 m_nCarHornTimer; uint32 m_nCarHornTimer;