diff --git a/source/common/music/music.cpp b/source/common/music/music.cpp index 30d36cc5b..0347cb840 100644 --- a/source/common/music/music.cpp +++ b/source/common/music/music.cpp @@ -563,12 +563,6 @@ int Mus_Play(const char *mapname, const char *fn, bool loop) { return 0; } - // A restart was requested. Ignore the music name being passed and just try tp restart what got here last. - if (mapname && *mapname == '*') - { - mapname = lastMusicLevel.GetChars(); - fn = lastMusic.GetChars(); - } // Allow per level music substitution. // For most cases using $musicalias would be sufficient, but that method only works if a level actually has some music defined at all. diff --git a/source/common/statistics.cpp b/source/common/statistics.cpp index 868ff3e5c..58ebf0e1c 100644 --- a/source/common/statistics.cpp +++ b/source/common/statistics.cpp @@ -259,7 +259,8 @@ static void SaveStatistics(const char *fn, TArray &statlist) { fw->Printf("\t{\n"); - qsort(&ls[0], ls.Size(), sizeof(ls[0]), compare_level_names); + // Only makes sense if level names follow a strict format. This is noz the case here. + //qsort(&ls[0], ls.Size(), sizeof(ls[0]), compare_level_names); for(unsigned k=0;kx-pos->x, cam->y-pos->y, (cam->z-pos->z)); -#ifdef SPLITSCREEN_MOD_HACKS - if (g_fakeMultiMode==2) - { - // HACK for splitscreen mod: take the min of sound distances - // to 1st and 2nd player. - - if (PN(spriteNum) == APLAYER && P_Get(spriteNum) == 1) - { - sndist = sndang = 0; - goto sound_further_processing; - } - - { - const vec3_t *cam2 = &g_player[1].ps->pos; - int32_t sndist2 = FindDistance3D(cam2->x-pos->x, cam2->y-pos->y, (cam2->z-pos->z)); - - if (sndist2 < sndist) - { - cam = cam2; - sectNum = g_player[1].ps->cursectnum; - angle = g_player[1].ps->ang; - - sndist = sndist2; - sndang = S_GetAngle(angle, cam, pos); - } - } - } -#endif - if ((g_sounds[soundNum].m & (SF_GLOBAL|SF_DTAG)) != SF_GLOBAL && S_IsAmbientSFX(spriteNum) && (sector[SECT(spriteNum)].lotag&0xff) < 9) // ST_9_SLIDING_ST_DOOR sndist = divscale14(sndist, SHT(spriteNum)+1); @@ -464,13 +435,6 @@ int S_PlaySound3D(int num, int spriteNum, const vec3_t *pos) while (j < MAXSOUNDINSTANCES && snd.voices[j].id != voice) j++; -#ifdef DEBUGGINGAIDS - if (EDUKE32_PREDICT_FALSE(j >= MAXSOUNDINSTANCES)) - { - OSD_Printf(OSD_ERROR "%s %d: WTF?\n", __FILE__, __LINE__); - return -1; - } -#endif snd.voices[j].owner = spriteNum; @@ -482,14 +446,6 @@ int S_PlaySound3D(int num, int spriteNum, const vec3_t *pos) int pitch = S_GetPitch(sndNum); auto const pOther = g_player[screenpeek].ps; -#ifdef SPLITSCREEN_MOD_HACKS - if (g_fakeMultiMode==2) - { - // splitscreen HACK - if (g_player[1].ps->i == spriteNum) - pOther = g_player[1].ps; -} -#endif if (pOther->sound_pitch) pitch += pOther->sound_pitch; diff --git a/source/rr/src/savegame.cpp b/source/rr/src/savegame.cpp index f056ef7db..5ee8113ad 100644 --- a/source/rr/src/savegame.cpp +++ b/source/rr/src/savegame.cpp @@ -1613,9 +1613,7 @@ static void postloadplayer(int32_t savegamep) S_ClearSoundLocks(); G_CacheMapData(); MUS_ResumeSaved(); - - if (MusicEnabled()) - Mus_SetPaused(false); + Mus_SetPaused(false); g_player[myconnectindex].ps->gm = MODE_GAME; ud.recstat = 0; diff --git a/source/rr/src/sector.cpp b/source/rr/src/sector.cpp index da95f232e..a75f5f9e6 100644 --- a/source/rr/src/sector.cpp +++ b/source/rr/src/sector.cpp @@ -3654,7 +3654,7 @@ void P_HandleSharedKeys(int playerNum) } else { - if (MusicEnabled()) Mus_SetPaused(false); + Mus_SetPaused(false); S_PauseSounds(false); diff --git a/source/rr/src/sounds.cpp b/source/rr/src/sounds.cpp index 0f5424707..cb5097f3d 100644 --- a/source/rr/src/sounds.cpp +++ b/source/rr/src/sounds.cpp @@ -155,7 +155,7 @@ int S_TryPlaySpecialMusic(unsigned int m) void S_PlayRRMusic(int newTrack) { char fileName[16]; - if (!RR) + if (!RR || !mus_redbook) return; Mus_Stop(); g_cdTrack = newTrack != -1 ? newTrack : g_cdTrack+1; diff --git a/source/sw/CMakeLists.txt b/source/sw/CMakeLists.txt index 30277199e..6de3ea9b1 100644 --- a/source/sw/CMakeLists.txt +++ b/source/sw/CMakeLists.txt @@ -24,6 +24,7 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../common/textures ${CMAKE_CURRENT_SOURCE_DIR}/../common/fonts ${CMAKE_CURRENT_SOURCE_DIR}/../common/2d + ${CMAKE_CURRENT_SOURCE_DIR}/../common/music ${CMAKE_CURRENT_SOURCE_DIR}/../platform ) diff --git a/source/sw/src/demo.cpp b/source/sw/src/demo.cpp index 648671680..863214725 100644 --- a/source/sw/src/demo.cpp +++ b/source/sw/src/demo.cpp @@ -84,7 +84,6 @@ SWBOOL DemoInitOnce = FALSE; short DemoDebugBufferMax = 1; extern char LevelName[]; -extern char LevelSong[16]; extern uint8_t FakeMultiNumPlayers; extern SWBOOL QuitFlag; @@ -179,7 +178,7 @@ DemoWriteHeader(void) return; strcpy(dh.map_name, LevelName); - strcpy(dh.LevelSong, LevelSong); + strcpy(dh.LevelSong, ""); dh.Level = Level; if (FakeMultiNumPlayers) @@ -238,7 +237,6 @@ DemoReadHeader(void) DREAD(&dh, sizeof(dh), 1, DemoFileIn); strcpy(DemoLevelName, dh.map_name); - strcpy(LevelSong, dh.LevelSong); Level = dh.Level; if (dh.numplayers > 1) { @@ -389,13 +387,6 @@ DemoPlayBack(void) ControlInfo info; int Xdim, Ydim, ScreenSize; - if (SW_SHAREWARE) - { - // code here needs to be similar to RunLevel startup code - PlaySong(LevelSong, -1, TRUE, TRUE); - } - - // Initialize Game part of network code (When ready2send != 0) InitNetVars(); @@ -570,8 +561,7 @@ ScenePlayBack(void) if (SW_SHAREWARE) { // code here needs to be similar to RunLevel startup code - strcpy(LevelSong,"yokoha03.mid"); - PlaySong(LevelSong, -1, TRUE, TRUE); + PlaySong(nullptr, "yokoha03.mid", -1); } // IMPORTANT - MUST be right before game loop diff --git a/source/sw/src/game.cpp b/source/sw/src/game.cpp index 839f0bf3f..e0467609b 100644 --- a/source/sw/src/game.cpp +++ b/source/sw/src/game.cpp @@ -96,6 +96,7 @@ Things required to make savegames work: #include "m_argv.h" #include "debugbreak.h" #include "menu/menu.h" +#include "z_music.h" //#include "crc32.h" @@ -964,8 +965,6 @@ void InitGame() COVERsetbrightness(0, &palette_data[0][0]); InitFX(); // JBF: do it down here so we get a hold of the window handle - InitMusic(); - } @@ -986,7 +985,6 @@ TYTAIK16 MID YOKOHA03 MID */ -char LevelSong[16]; short SongLevelNum; //#ifndef SW_SHAREWARE LEVEL_INFO LevelInfo[MAX_LEVELS_REG+2] = @@ -1170,7 +1168,7 @@ InitLevel(void) // A few IMPORTANT GLOBAL RESETS InitLevelGlobals(); if (!DemoMode) - StopSong(); + Mus_Stop(); if (LoadGameOutsideMoveLoop) { @@ -1196,7 +1194,6 @@ InitLevel(void) FindLevelInfo(LevelName, &Level); if (Level > 0) { - strcpy(LevelSong, LevelInfo[Level].SongName); strcpy(LevelName, LevelInfo[Level].LevelName); UserMapName[0] = '\0'; } @@ -1235,7 +1232,6 @@ InitLevel(void) if (Level > 0) { // user map is part of game - treat it as such - strcpy(LevelSong, LevelInfo[Level].SongName); strcpy(LevelName, LevelInfo[Level].LevelName); UserMapName[0] = '\0'; } @@ -1243,7 +1239,6 @@ InitLevel(void) else { strcpy(LevelName, LevelInfo[Level].LevelName); - strcpy(LevelSong, LevelInfo[Level].SongName); } } @@ -1599,8 +1594,7 @@ void ResetKeyRange(uint8_t* kb, uint8_t* ke) void PlayTheme() { // start music at logo - strcpy(LevelSong,"theme.mid"); - PlaySong(LevelSong, RedBookSong[0], TRUE, TRUE); + PlaySong(nullptr, "theme.mid", RedBookSong[0]); DSPRINTF(ds,"After music stuff..."); MONO_PRINT(ds); @@ -1704,9 +1698,9 @@ void CreditsLevel(void) while (FX_SoundActive(handle)) ; // try 14 then 2 then quit - if (!PlaySong(NULL, 14, FALSE, TRUE)) + if (!PlaySong(nullptr, nullptr, 14, true)) { - if (!PlaySong(NULL, 2, FALSE, TRUE)) + if (!PlaySong(nullptr, nullptr, 2, true)) { handle = PlaySound(DIGI_NOLIKEMUSIC,&zero,&zero,&zero,v3df_none); if (handle > 0) @@ -1747,10 +1741,6 @@ void CreditsLevel(void) curpic = CREDITS1_PIC; } - - if (!SongIsPlaying()) - break; - if (inputState.GetKeyStatus(KEYSC_ESC)) break; } @@ -1759,7 +1749,7 @@ void CreditsLevel(void) videoClearViewableArea(0L); videoNextPage(); ResetKeys(); - StopSong(); + Mus_Stop(); } @@ -2247,10 +2237,7 @@ void BonusScreen(PLAYERp pp) totalclock = ototalclock = 0; limit = synctics; - if (MusicEnabled()) - { - PlaySong(voc[DIGI_ENDLEV].name, 3, TRUE, TRUE); - } + PlaySong(nullptr, voc[DIGI_ENDLEV].name, 3); // special case code because I don't care any more! if (FinishAnim) @@ -2565,10 +2552,7 @@ void StatScreen(PLAYERp mpp) inputState.ClearKeyStatus(KEYSC_SPACE); inputState.ClearKeyStatus(KEYSC_ENTER); - if (MusicEnabled()) - { - PlaySong(voc[DIGI_ENDLEV].name, 3, TRUE, TRUE); - } + PlaySong(nullptr, voc[DIGI_ENDLEV].name, 3); while (!inputState.GetKeyStatus(KEYSC_SPACE) && !inputState.GetKeyStatus(KEYSC_ENTER)) { @@ -2781,7 +2765,6 @@ void InitRunLevel(void) if (snd_ambience) StartAmbientSound(); SetCrosshair(); - PlaySong(LevelSong, -1, TRUE, TRUE); SetRedrawScreen(Player + myconnectindex); // crappy little hack to prevent play clock from being overwritten // for load games @@ -2803,7 +2786,7 @@ void InitRunLevel(void) waitforeverybody(); - StopSong(); + Mus_Stop(); if (Bstrcasecmp(CacheLastLevel, LevelName) != 0) DoTheCache(); @@ -2827,7 +2810,7 @@ void InitRunLevel(void) { track = RedBookSong[Level]; } - PlaySong(LevelSong, track, TRUE, TRUE); + PlaySong(LevelInfo[Level].LevelName, LevelInfo[Level].SongName, track); } InitPrediction(&Player[myconnectindex]); @@ -3270,12 +3253,12 @@ void PauseKey(PLAYERp pp) #define MSG_GAME_PAUSED "Game Paused" MNU_MeasureString(MSG_GAME_PAUSED, &w, &h); PutStringTimer(pp, TEXT_TEST_COL(w), 100, MSG_GAME_PAUSED, 999); - PauseSong(TRUE); + Mus_SetPaused(true); } else { pClearTextLine(pp, 100); - PauseSong(FALSE); + Mus_SetPaused(false); } } diff --git a/source/sw/src/menus.cpp b/source/sw/src/menus.cpp index b3a0ab579..eaa78bc41 100644 --- a/source/sw/src/menus.cpp +++ b/source/sw/src/menus.cpp @@ -2942,7 +2942,6 @@ void MNU_DoButton(MenuItem_p item, SWBOOL draw) SWBOOL state; int last_value; short shade = MENU_SHADE_DEFAULT; - extern char LevelSong[]; const char *extra_text = NULL; PLAYERp pp = &Player[myconnectindex]; int button_x,zero=0; @@ -3025,35 +3024,6 @@ void MNU_DoButton(MenuItem_p item, SWBOOL draw) } break; case btn_music: - last_value = mus_enabled; - mus_enabled = state = buttonsettings[item->button]; - if (mus_enabled != last_value) - { - SWBOOL bak; - - if (MusicEnabled()) - { - bak = DemoMode; - PlaySong(LevelSong, RedBookSong[Level], TRUE, TRUE); - DemoMode = bak; - } - else - { - bak = DemoMode; - StopSong(); - DemoMode = bak; - - if (SW_SHAREWARE) - { - handle = PlaySound(DIGI_NOLIKEMUSIC,&zero,&zero,&zero,v3df_none); - - if (handle > FX_Ok) - while (FX_SoundActive(handle)) - handleevents(); - } - } - } - break; case btn_talking: snd_speech = state = buttonsettings[item->button]; break; diff --git a/source/sw/src/save.cpp b/source/sw/src/save.cpp index 0c67aba1c..5b18cf121 100644 --- a/source/sw/src/save.cpp +++ b/source/sw/src/save.cpp @@ -57,6 +57,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "player.h" #include "i_specialpaths.h" #include "savegamehelp.h" +#include "z_music.h" //void TimerFunc(task * Task); BEGIN_SW_NS @@ -75,7 +76,6 @@ TO DO extern int lastUpdate; extern uint8_t RedBookSong[40]; extern char UserMapName[80]; -extern char LevelSong[16]; extern char SaveGameDescr[10][80]; extern int PlayClock; extern short TotalKillable; @@ -663,8 +663,6 @@ bool GameInterface::SaveGame(FSaveGameNode *sv) // game settings MWRITE(&gNet,sizeof(gNet),1,fil); - MWRITE(LevelSong,sizeof(LevelSong),1,fil); - MWRITE(palette,sizeof(palette),1,fil); MWRITE(palette_data,sizeof(palette_data),1,fil); MWRITE(&gs,sizeof(gs),1,fil); @@ -744,7 +742,7 @@ bool GameInterface::LoadGame(FSaveGameNode* sv) // Don't terminate until you've made sure conditions are valid for loading. if (InMenuLevel) - StopSong(); + Mus_Stop(); else TerminateLevel(); Terminate3DSounds(); @@ -1112,8 +1110,6 @@ bool GameInterface::LoadGame(FSaveGameNode* sv) // game settings MREAD(&gNet,sizeof(gNet),1,fil); - MREAD(LevelSong,sizeof(LevelSong),1,fil); - MREAD(palette,sizeof(palette),1,fil); MREAD(palette_data,sizeof(palette_data),1,fil); @@ -1225,7 +1221,7 @@ bool GameInterface::LoadGame(FSaveGameNode* sv) screenpeek = myconnectindex; PlayingLevel = Level; - PlaySong(LevelSong, RedBookSong[Level], TRUE, TRUE); + MUS_ResumeSaved(); if (snd_ambience) StartAmbientSound(); FX_SetVolume(snd_fxvolume); diff --git a/source/sw/src/serp.cpp b/source/sw/src/serp.cpp index 0e4debd0f..84f810f23 100644 --- a/source/sw/src/serp.cpp +++ b/source/sw/src/serp.cpp @@ -815,14 +815,13 @@ int DoDeathSpecial(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; USERp u = User[SpriteNum]; - static SWBOOL alreadydid = FALSE; DoMatchEverything(NULL, sp->lotag, ON); - if (!SW_SHAREWARE && MusicEnabled() && !alreadydid) + if (!SW_SHAREWARE) { - PlaySong(0, RedBookSong[Level], TRUE, TRUE); - alreadydid = TRUE; + // Resume the regular music - in a hack-free fashion. + PlaySong(LevelInfo[Level].LevelName, LevelInfo[Level].SongName, RedBookSong[Level]); } BossSpriteNum[0] = -2; diff --git a/source/sw/src/sounds.cpp b/source/sw/src/sounds.cpp index b668bd075..044e3d198 100644 --- a/source/sw/src/sounds.cpp +++ b/source/sw/src/sounds.cpp @@ -51,6 +51,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "menus.h" #include "config.h" #include "menu/menu.h" +#include "z_music.h" #ifdef _WIN32 #include "sdlayer.h" @@ -84,11 +85,9 @@ uint8_t RedBookSong[40] = SWBOOL Use_SoundSpriteNum = FALSE; int16_t SoundSpriteNum = -1; // Always set this back to -1 for proper validity checking! -SWBOOL MusicInitialized = FALSE; SWBOOL FxInitialized = FALSE; void SoundCallBack(unsigned int num); -SWBOOL LoadSong(const char *track); #define MUSIC_ID -65536 @@ -121,19 +120,6 @@ int voice; int loopflag; -typedef enum -{ - SongTypeNone, - SongTypeMIDI, - SongTypeWave, -} SongType_t; - -char *SongPtr = NULL; -int SongLength = 0; -char *SongName = NULL; -int SongTrack = 0; -SongType_t SongType = SongTypeNone; -int SongVoice = -1; extern SWBOOL DemoMode; // @@ -254,27 +240,6 @@ int PlayerYellVocs[] = DIGI_PLAYERYELL3 }; -#if 0 -// DEBUG -void CheckSndData(char *file, int line) -{ - short i; - - //return; - - for (i = 0; iname) - continue; -#endif - - if (!Bstrcasecmp(name, vp->name)) - { - // vp->priority = pri; - strcpy(vp->name, new_name); - vp->pitch_lo = pitch_lo; - vp->pitch_hi = pitch_hi; - } - } - } - - fclose(fin); -} - extern short Level; -SWBOOL -PlaySong(char *song_file_name, int cdaudio_track, SWBOOL loop, SWBOOL restart) +SWBOOL PlaySong(const char* mapname, const char* song_file_name, int cdaudio_track, bool isThemeTrack) //(nullptr, nullptr, -1, false) starts the normal level music. { - if (!MusicEnabled()) + if (mapname == nullptr && song_file_name == nullptr && cdaudio_track == -1) { - return FALSE; + // Get the music defined for the current level. + } - - if (DemoMode) - return FALSE; - - if (!restart) + // Play CD audio if enabled or if this is a theme track. + if (cdaudio_track >= 0 && (mus_redbook || isThemeTrack)) { - if (SongType == SongTypeWave) + FStringf trackname("track%02d.ogg", cdaudio_track); + if (!Mus_Play(nullptr, trackname, true)) { - if (SongTrack > 0 && SongTrack == cdaudio_track) - { - // ogg replacement for a CD track - return TRUE; - } - else if (SongName && song_file_name && !strcmp(SongName, song_file_name)) - { - return TRUE; - } - } - else if (SongType == SongTypeMIDI) - { - if (SongName && song_file_name && !strcmp(SongName, song_file_name)) - { - return TRUE; - } + buildprintf("Can't find CD track %i!\n", cdaudio_track); } } - - StopSong(); - - if (!SW_SHAREWARE) - { - if (cdaudio_track >= 0 && mus_redbook) - { - char waveformtrack[MAXWAVEFORMTRACKLENGTH]; - Bstrncpy(waveformtrack, gs.WaveformTrackName, MAXWAVEFORMTRACKLENGTH - 1); - - char *numPos = Bstrstr(waveformtrack, "??"); - - if (numPos && (numPos-waveformtrack) < MAXWAVEFORMTRACKLENGTH - 2) - { - static const char *tracktypes[] = { ".flac", ".ogg" }; - const size_t tracknamebaselen = Bstrlen(waveformtrack); - size_t i; - - numPos[0] = '0' + (cdaudio_track / 10) % 10; - numPos[1] = '0' + cdaudio_track % 10; - - for (i = 0; i < ARRAY_SIZE(tracktypes); ++i) - { - waveformtrack[tracknamebaselen] = '\0'; - Bstrncat(waveformtrack, tracktypes[i], MAXWAVEFORMTRACKLENGTH - 1); - - if (LoadSong(waveformtrack)) - { - SongVoice = FX_Play(SongPtr, SongLength, 0, 0, 0, - 255, 255, 255, FX_MUSIC_PRIORITY, 1.f, MUSIC_ID); - if (SongVoice > FX_Ok) - { - SongType = SongTypeWave; - SongTrack = cdaudio_track; - SongName = Bstrdup(waveformtrack); - return TRUE; - } - } - } - - buildprintf("Can't find CD track %i!\n", cdaudio_track); - } - else - { - buildprintf("Make sure to have \"??\" as a placeholder for the track number in your WaveformTrackName!\n"); - buildprintf(" e.g. WaveformTrackName = \"MUSIC/Track??\"\n"); - } - } - } - - if (!song_file_name || !LoadSong(song_file_name)) - { - return FALSE; - } - - if (!memcmp(SongPtr, "MThd", 4)) - { - MUSIC_PlaySong(SongPtr, SongLength, MUSIC_LoopSong); - SongType = SongTypeMIDI; - SongName = strdup(song_file_name); - return TRUE; - } - else - { - SongVoice = FX_Play(SongPtr, SongLength, 0, 0, 0, - 255, 255, 255, FX_MUSIC_PRIORITY, 1.f, MUSIC_ID); - if (SongVoice > FX_Ok) - { - SongType = SongTypeWave; - SongName = strdup(song_file_name); - return TRUE; - } - } - - return FALSE; + return Mus_Play(nullptr, song_file_name, true); } void @@ -522,57 +334,11 @@ StopFX(void) FX_StopAllSounds(); } -void -StopSong(void) -{ - if (DemoMode) - return; - - if (SongType == SongTypeWave && SongVoice > 0) - { - FX_StopSound(SongVoice); - SongVoice = 0; - } - else if (SongType == SongTypeMIDI) - { - MUSIC_StopSong(); - } - SongType = SongTypeNone; - - DO_FREE_AND_NULL(SongName); - SongTrack = 0; - - if (SongPtr) - { - FreeMem(SongPtr); - SongPtr = 0; - SongLength = 0; - } -} - -void -PauseSong(SWBOOL pauseon) -{ - if (!MusicEnabled()) return; - - if (SongType == SongTypeWave && SongVoice > 0) - { - FX_PauseVoice(SongVoice, pauseon); - } -} - - -SWBOOL -SongIsPlaying(void) -{ - return FALSE; -} - void StopSound(void) { StopFX(); - StopSong(); + Mus_Stop(); } // @@ -1082,34 +848,6 @@ ReadSound(FileReader &handle, VOC_INFOp vp, int length) return 0; } -SWBOOL -LoadSong(const char *filename) -{ - auto fr = fileSystem.OpenFileReader(filename, 0); - if (!fr.isOpen()) - { - return FALSE; - } - - auto size = fr.GetLength(); - - auto ptr = (char *) AllocMem(size); - if (ptr == NULL) - { - return FALSE; - } - - if (fr.Read(ptr, size) != size) - { - FreeMem(ptr); - return FALSE; - } - SongPtr = ptr; - SongLength = size; - - return TRUE; -} - void SoundStartup(void) { @@ -1159,52 +897,11 @@ SoundShutdown(void) } -/* -=================== -= -= MusicStartup -= -=================== -*/ - -void MusicStartup(void) -{ -#if 0 - auto fil = fileSystem.OpenFileReader("swtimbr.tmb", 0); - - if (fil.isOpen()) - { - auto tmb = fil.Read(); - if (tmb.Size()) - AL_RegisterTimbreBank(tmb.Data()); - } -#endif -} - void COVER_SetReverb(int amt) { FX_SetReverb(amt); } -/* -=================== -= -= MusicShutdown -= -=================== -*/ - -void MusicShutdown(void) -{ - StopSong(); - - int status = MUSIC_Shutdown(); - if (status != MUSIC_Ok) - { - buildprintf("Music error: %s\n", MUSIC_ErrorString(status)); - } -} - /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////// diff --git a/source/sw/src/sounds.h b/source/sw/src/sounds.h index 31a0b9dcf..e5b4af630 100644 --- a/source/sw/src/sounds.h +++ b/source/sw/src/sounds.h @@ -84,15 +84,11 @@ SWBOOL CacheSound(int num, int type); void COVER_SetReverb(int amt); void UnInitSound(void); void InitFX(void); -void InitMusic(void); void StopFX(void); -void StopSong(void); -void PauseSong(SWBOOL pauseon); void StopSound(void); void StartAmbientSound(void); void StopAmbientSound(void); -SWBOOL PlaySong(char *song_file_name, int cdaudio_track, SWBOOL loop, SWBOOL restart); -SWBOOL SongIsPlaying(void); +SWBOOL PlaySong(const char *mapname, const char *song_file_name, int cdaudio_track, bool isThemeTrack = false); //(nullptr, nullptr, -1, false) starts the normal level music. void PlaySoundRTS(int rts_num); // diff --git a/source/sw/src/sumo.cpp b/source/sw/src/sumo.cpp index c5a547105..b638f1de1 100644 --- a/source/sw/src/sumo.cpp +++ b/source/sw/src/sumo.cpp @@ -794,7 +794,6 @@ int DoSumoDeathMelt(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; USERp u = User[SpriteNum]; - static SWBOOL alreadydid = FALSE; PlaySound(DIGI_SUMOFART, &sp->x, &sp->y, &sp->z, v3df_follow); @@ -803,10 +802,10 @@ int DoSumoDeathMelt(short SpriteNum) u->ID = 0; DoMatchEverything(NULL, sp->lotag, ON); - if (!SW_SHAREWARE && MusicEnabled() && !alreadydid) + if (!SW_SHAREWARE) { - PlaySong(0, RedBookSong[Level], TRUE, TRUE); - alreadydid = TRUE; + // Resume the regular music - in a hack-free fashion. + PlaySong(LevelInfo[Level].LevelName, LevelInfo[Level].SongName, RedBookSong[Level]); } BossSpriteNum[1] = -2; // Sprite is gone, set it back to keep it valid! @@ -882,25 +881,25 @@ BossHealthMeter(void) if (i == 0 && !serpwasseen) { serpwasseen = TRUE; - if (!SW_SHAREWARE && MusicEnabled()) + if (!SW_SHAREWARE) { - PlaySong(0, ThemeTrack[2], TRUE, TRUE); + PlaySong(nullptr, nullptr, ThemeTrack[2], true); } } else if (i == 1 && !sumowasseen) { sumowasseen = TRUE; - if (!SW_SHAREWARE && MusicEnabled()) + if (!SW_SHAREWARE) { - PlaySong(0, ThemeTrack[3], TRUE, TRUE); + PlaySong(nullptr, nullptr, ThemeTrack[3], true); } } else if (i == 2 && !zillawasseen) { zillawasseen = TRUE; - if (!SW_SHAREWARE && MusicEnabled()) + if (!SW_SHAREWARE) { - PlaySong(0, ThemeTrack[4], TRUE, TRUE); + PlaySong(nullptr, nullptr, ThemeTrack[4], true); } } } @@ -919,13 +918,6 @@ BossHealthMeter(void) if (i == 2 && (!zillawasseen || BossSpriteNum[2] < 0)) continue; - // This is needed because of possible saved game situation - if (!SW_SHAREWARE && !triedplay) - { - PlaySong(0, ThemeTrack[i+2], TRUE, FALSE); - triedplay = TRUE; // Only try once, then give up - } - sp = &sprite[BossSpriteNum[i]]; u = User[BossSpriteNum[i]]; diff --git a/source/sw/src/zilla.cpp b/source/sw/src/zilla.cpp index 70a557c4b..fc1fb8dbc 100644 --- a/source/sw/src/zilla.cpp +++ b/source/sw/src/zilla.cpp @@ -769,7 +769,6 @@ int DoZillaDeathMelt(short SpriteNum) { SPRITEp sp = &sprite[SpriteNum]; USERp u = User[SpriteNum]; - static SWBOOL alreadydid = FALSE; if (RANDOM_RANGE(1000) > 800) SpawnGrenadeExp(SpriteNum); @@ -778,10 +777,10 @@ int DoZillaDeathMelt(short SpriteNum) RESET(u->Flags, SPR_JUMPING|SPR_FALLING|SPR_MOVED); //DoMatchEverything(NULL, sp->lotag, ON); - if (!SW_SHAREWARE && MusicEnabled() && !alreadydid) + if (!SW_SHAREWARE) { - PlaySong(0, RedBookSong[Level], TRUE, TRUE); - alreadydid = TRUE; + // Resume the regular music - in a hack-free fashion. + PlaySong(LevelInfo[Level].LevelName, LevelInfo[Level].SongName, RedBookSong[Level]); } //KeepActorOnFloor(SpriteNum); diff --git a/wadsrc/static/demolition/menudef.txt b/wadsrc/static/demolition/menudef.txt index 2243dd2a1..155eb7ee4 100644 --- a/wadsrc/static/demolition/menudef.txt +++ b/wadsrc/static/demolition/menudef.txt @@ -1286,7 +1286,7 @@ OptionMenu SoundOptions //protected //Option "$SNDMNU_RANDOMIZEPITCHES", "snd_pitched", "OnOff" Slider "$SNDMNU_CHANNELS", "snd_numchannels", 64, 128, 8, 0 staticText "" - ifgame (Blood, ShadowWarrior) + ifgame (Blood, ShadowWarrior, Redneck, RedneckRides) { Option "$SNDMNU_CDEMU", "mus_redbook", "OnOff" }