diff --git a/src/dehacked.c b/src/dehacked.c index 5189af4bb..3e64e1ed1 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -9227,8 +9227,8 @@ int LUA_EnumLib(lua_State *L) PUSHGETTER(globalweather, u8); PUSHGETTER(levelskynum, i32); PUSHGETTER(globallevelskynum, i32); - PUSHGETTER(mapmusflags, u16); - PUSHGETTER(mapmusposition, u32); + PUSHGETTER(mapmusic.flags, u16); + PUSHGETTER(mapmusic.position, u32); PUSHGETTER(gravity, fxp); PUSHGETTER(gamespeed, u8); PUSHGETTER(encoremode, bool); @@ -9245,7 +9245,7 @@ int LUA_EnumLib(lua_State *L) lua_pushcfunction(L, lua_glib_new_getter); lua_pushliteral(L, "mapmusname"); - lua_glib_push_str_getter(L, mapmusname); + lua_glib_push_str_getter(L, mapmusic.name); lua_call(L, 2, 0); lua_pushcfunction(L, lua_glib_new_getter); diff --git a/src/doomstat.h b/src/doomstat.h index b3290b884..b0be7113d 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -30,16 +30,22 @@ // ============================= // Selected by user. -extern INT16 gamemap; -extern char mapmusname[7]; -extern UINT16 mapmusflags; -extern UINT32 mapmusposition; -extern UINT32 mapmusresume; + +typedef struct +{ + char name[7]; // Music name + UINT16 flags; // Track and reset bit + UINT32 position; // Position to jump to + UINT32 resume; // Saved Position when music was stopped +} mapmusic_t; +extern mapmusic_t mapmusic; + #define MUSIC_TRACKMASK 0x0FFF // ----************ #define MUSIC_RELOADRESET 0x8000 // *--------------- #define MUSIC_FORCERESET 0x4000 // -*-------------- // Use other bits if necessary. +extern INT16 gamemap; extern INT16 maptol; extern UINT8 globalweather; extern INT32 curWeather; diff --git a/src/g_game.c b/src/g_game.c index 5e9bc1077..6144a500d 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -85,10 +85,7 @@ static void G_DoStartVote(void); static void G_ResetDemoPlayback(char *pdemoname); -char mapmusname[7]; // Music name -UINT16 mapmusflags; // Track and reset bit -UINT32 mapmusposition; // Position to jump to -UINT32 mapmusresume; +mapmusic_t mapmusic; INT16 gamemap = 1; INT16 maptol; @@ -2302,7 +2299,7 @@ void G_PlayerReborn(INT32 player) if (p-players == consoleplayer) { - if (mapmusflags & MUSIC_RELOADRESET) + if (mapmusic.flags & MUSIC_RELOADRESET) { S_HandleReloadResetMusic(); songcredit = true; @@ -4059,7 +4056,7 @@ void G_InitNew(UINT8 pencoremode, const char *mapname, boolean resetplayer, bool globalweather = mapheaderinfo[gamemap-1]->weather; // Don't carry over custom music change to another map. - mapmusflags |= MUSIC_RELOADRESET; + mapmusic.flags |= MUSIC_RELOADRESET; automapactive = false; imcontinuing = false; diff --git a/src/p_saveg.c b/src/p_saveg.c index 4f52bf900..d7e592431 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -3351,7 +3351,7 @@ FUNCINLINE static ATTRINLINE boolean P_NetUnArchiveMisc(savebuffer_t *save, bool // tell the sound code to reset the music since we're skipping what // normally sets this flag if (!reloading) - mapmusflags |= MUSIC_RELOADRESET; + mapmusic.flags |= MUSIC_RELOADRESET; G_SetGamestate(READINT16(save->p)); diff --git a/src/p_spec.c b/src/p_spec.c index 61c0a010a..d64ca35fe 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2080,7 +2080,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; case 413: // Change music - if (keepmusic && (leveltime <= MUSICSTARTTIME)) // why check for starttime? cause encore music Zzz... + if (keepmapmusic && (leveltime <= MUSICSTARTTIME)) // why check for starttime? cause encore music Zzz... return; //if (cv_ignoremusicchanges.value && (leveltime >= MUSICSTARTTIME) && !fromlapexec) // keep lap music intanct tho @@ -2128,19 +2128,19 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) // Change the music and apply position/fade operations else { - strncpy(mapmusname, sides[line->sidenum[0]].text, 7); - mapmusname[6] = 0; + strncpy(mapmusic.name, sides[line->sidenum[0]].text, 7); + mapmusic.name[6] = 0; - mapmusflags = tracknum & MUSIC_TRACKMASK; + mapmusic.flags = tracknum & MUSIC_TRACKMASK; if (!(line->flags & ML_BLOCKMONSTERS)) - mapmusflags |= MUSIC_RELOADRESET; + mapmusic.flags |= MUSIC_RELOADRESET; if (line->flags & ML_BOUNCY) - mapmusflags |= MUSIC_FORCERESET; + mapmusic.flags |= MUSIC_FORCERESET; - mapmusposition = position; - mapmusresume = 0; + mapmusic.position = position; + mapmusic.resume = 0; - S_ChangeMusicEx(mapmusname, mapmusflags, !(line->flags & ML_EFFECT4), position, + S_ChangeMusicEx(mapmusic.name, mapmusic.flags, !(line->flags & ML_EFFECT4), position, !(line->flags & ML_EFFECT2) ? prefadems : 0, !(line->flags & ML_EFFECT2) ? postfadems : 0); @@ -2167,7 +2167,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) INT32 sfxnum; //dont play any funky sound intros that may interfere with the music - if ((skipintromus || keepmusic) && (leveltime < MUSICSTARTTIME)) + if ((skipintromus || keepmapmusic) && (leveltime < MUSICSTARTTIME)) return; sfxnum = sides[line->sidenum[0]].toptexture; //P_AproxDistance(line->dx, line->dy)>>FRACBITS; diff --git a/src/p_user.c b/src/p_user.c index addbefbe4..852d2b6be 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -788,14 +788,14 @@ void P_RestoreMusic(player_t *player) if (G_RaceGametype() && player->laps >= (UINT8)(cv_numlaps.value - 1)) S_SpeedMusic(1.2f); #endif - if (mapmusresume && cv_resume.value) // mapmusresume will be 0 anyways when birdmusic stuff is disabled - position = mapmusresume; + if (mapmusic.resume && cv_resume.value) // mapmusresume will be 0 anyways when birdmusic stuff is disabled + position = mapmusic.resume; else - position = mapmusposition; + position = mapmusic.position; - S_ChangeMusicEx(mapmusname, mapmusflags, true, position, 0, S_GetRestoreMusicFadeIn()); + S_ChangeMusicEx(mapmusic.name, mapmusic.flags, true, position, 0, S_GetRestoreMusicFadeIn()); S_ClearRestoreMusicFadeInCvar(); - mapmusresume = 0; + mapmusic.resume = 0; } } } diff --git a/src/s_sound.c b/src/s_sound.c index 569ba5af9..42efd4a01 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -117,13 +117,10 @@ consvar_t cv_keepmusic = {"keepmusic", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, N consvar_t cv_skipintromusic = {"skipintromusic", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; //consvar_t cv_ignoremusicchanges = {"ignoremusicchanges", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; -boolean keepmusic = false; // keep the current music on map restart +boolean keepmapmusic = false; // keep the current music on map restart boolean skipintromus = false; // skip the intro fanfare static boolean keepmusicresume = false; -static char keepmusname[7]; -static UINT32 keepmusresume = 0; -static UINT16 keepmusflags = 0; -static UINT32 keepmusposition = 0; +mapmusic_t keepmusic; static void S_SetKeepMusResume(void); static void S_SetKeepMusicStuff(void); @@ -1827,7 +1824,7 @@ void S_StopMusic(void) || demo.title) // SRB2Kart: Demos don't interrupt title screen music return; - mapmusresume = (cv_birdmusic.value && (strcasecmp(music_name, mapmusname) == 0)) ? I_GetSongPosition() : 0; + mapmusic.resume = (cv_birdmusic.value && (strcasecmp(music_name, mapmusic.name) == 0)) ? I_GetSongPosition() : 0; S_SetKeepMusResume(); @@ -1956,6 +1953,9 @@ static const char *musicexception_list[] = { // check if the current music is smth we dont want to keep (vote music, etc) static boolean S_CheckMusicException(void) { + if (stricmp(music_name, mapmusic.name)) + return true; + for (size_t i = 0; i < sizeof(musicexception_list)/sizeof(musicexception_list[0]); i++) { if (!stricmp(music_name, musicexception_list[i]) || !stricmp(checkmusic, musicexception_list[i])) @@ -1969,14 +1969,14 @@ static boolean S_CheckMusicException(void) void S_ResetKeepAndSpecialMus(void) { - keepmusic = skipintromus = false; + keepmapmusic = skipintromus = false; } static void S_SetKeepMusResume(void) { - if (strcasecmp(music_name, mapmusname) == 0) + if (strcasecmp(music_name, mapmusic.name) == 0) { - keepmusresume = I_GetSongPosition(); + keepmusic.resume = I_GetSongPosition(); } } @@ -1988,17 +1988,17 @@ static void S_SetKeepMusicStuff(void) return; } - strncpy(keepmusname, mapmusname, 7); - keepmusflags = mapmusflags; - keepmusposition = mapmusposition; + strncpy(keepmusic.name, mapmusic.name, 7); + keepmusic.flags = mapmusic.flags; + keepmusic.position = mapmusic.position; } static void S_ClearKeepMusicPosition(void) { - memset(keepmusname, 0, sizeof(keepmusname)); - keepmusresume = 0; - keepmusflags = 0; - keepmusposition = 0; + memset(keepmusic.name, 0, sizeof(keepmusic.name)); + keepmusic.resume = 0; + keepmusic.flags = 0; + keepmusic.position = 0; } void S_CopyKeepMusicStuff(void) @@ -2008,9 +2008,9 @@ void S_CopyKeepMusicStuff(void) return; } - strncpy(mapmusname, keepmusname, 7); - mapmusflags = keepmusflags; - mapmusposition = keepmusposition; + strncpy(mapmusic.name, keepmusic.name, 7); + mapmusic.flags = keepmusic.flags; + mapmusic.position = keepmusic.position; } // determine if we should keep the music on a map restart @@ -2024,16 +2024,16 @@ void S_KeepMusic(void) if (!cv_keepmusic.value) { - keepmusic = keepmusicresume = false; + keepmapmusic = keepmusicresume = false; } else if (oldmap == gamemap && oldencore == encoremode) { - keepmusicresume = (musicchanged && keepmusresume); - keepmusic = (!musicchanged || keepmusicresume); + keepmusicresume = (musicchanged && keepmusic.resume); + keepmapmusic = (!musicchanged || keepmusicresume); } else { - keepmusic = keepmusicresume = false; + keepmapmusic = keepmusicresume = false; S_ClearKeepMusicPosition(); } @@ -2043,23 +2043,23 @@ void S_KeepMusic(void) void S_HandleReloadResetMusic(void) { - if (!(mapmusflags & MUSIC_RELOADRESET)) + if (!(mapmusic.flags & MUSIC_RELOADRESET)) return; - if (keepmusic) + if (keepmapmusic) { // this is horrible, this copies over everything about the mapmusic into temporary variables to reuse S_CopyKeepMusicStuff(); } else { - strncpy(mapmusname, mapheaderinfo[gamemap-1]->musname, 7); - mapmusname[6] = 0; - mapmusflags = (mapheaderinfo[gamemap-1]->mustrack & MUSIC_TRACKMASK); - mapmusposition = mapheaderinfo[gamemap-1]->muspos; + strncpy(mapmusic.name, mapheaderinfo[gamemap-1]->musname, 7); + mapmusic.name[6] = 0; + mapmusic.flags = (mapheaderinfo[gamemap-1]->mustrack & MUSIC_TRACKMASK); + mapmusic.position = mapheaderinfo[gamemap-1]->muspos; } - mapmusresume = 0; + mapmusic.resume = 0; } // @@ -2071,11 +2071,11 @@ void S_InitMapMusic(void) { S_HandleReloadResetMusic(); - if (keepmusic) + if (keepmapmusic) { // this is kinda silly, but we can use it to fade back into the map song at the saved point, should the current music be different from the map music if (keepmusicresume) - S_ChangeMusicEx(mapmusname, mapmusflags, true, keepmusresume, 0, 500); + S_ChangeMusicEx(mapmusic.name, mapmusic.flags, true, keepmusic.resume, 0, 500); return; } @@ -2100,7 +2100,7 @@ void S_InitMapMusic(void) if (leveltime < MUSICSTARTTIME) // SRB2Kart S_ChangeMusicInternal((encoremode ? "estart" : "kstart"), false); //S_StopMusic(); - //S_ChangeMusicEx((encoremode ? "estart" : "kstart"), 0, false, mapmusposition, 0, 0); + //S_ChangeMusicEx((encoremode ? "estart" : "kstart"), 0, false, mapmusic.position, 0, 0); } void S_StartMapMusic(void) @@ -2109,13 +2109,13 @@ void S_StartMapMusic(void) if (leveltime > MUSICSTARTTIME) return; - if (keepmusic) + if (keepmapmusic) return; if (skipintromus) { if (leveltime < starttime) - S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, 0); + S_ChangeMusicEx(mapmusic.name, mapmusic.flags, true, mapmusic.position, 0, 0); if (leveltime == MUSICSTARTTIME) S_ShowMusicCredit(); return; @@ -2127,7 +2127,7 @@ void S_StartMapMusic(void) S_StopMusic(); else if (leveltime == MUSICSTARTTIME) // Plays the music after the starting countdown. { - S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, 0); + S_ChangeMusicEx(mapmusic.name, mapmusic.flags, true, mapmusic.position, 0, 0); S_ShowMusicCredit(); } } @@ -2177,7 +2177,7 @@ static void Command_Tunes_f(void) if (!strcasecmp(tunearg, "-show")) { CONS_Printf(M_GetText("The current tune is: %s [track %d]\n"), - mapmusname, (mapmusflags & MUSIC_TRACKMASK)); + mapmusic.name, (mapmusic.flags & MUSIC_TRACKMASK)); return; } if (!strcasecmp(tunearg, "-none")) @@ -2205,19 +2205,19 @@ static void Command_Tunes_f(void) track = (UINT16)atoi(COM_Argv(2))-1; if (tunenum) - snprintf(mapmusname, 7, "%sM", G_BuildMapName(tunenum)); + snprintf(mapmusic.name, 7, "%sM", G_BuildMapName(tunenum)); else - strncpy(mapmusname, tunearg, 7); + strncpy(mapmusic.name, tunearg, 7); if (argc > 4) position = (UINT32)atoi(COM_Argv(4)); - mapmusname[6] = 0; - mapmusflags = (track & MUSIC_TRACKMASK); - mapmusposition = position; - mapmusresume = 0; + mapmusic.name[6] = 0; + mapmusic.flags = (track & MUSIC_TRACKMASK); + mapmusic.position = position; + mapmusic.resume = 0; - S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, 0); + S_ChangeMusicEx(mapmusic.name, mapmusic.flags, true, mapmusic.position, 0, 0); if (argc > 3) { diff --git a/src/s_sound.h b/src/s_sound.h index 089008174..4ed52d7bb 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -71,7 +71,7 @@ extern consvar_t cv_birdmusic; extern consvar_t cv_keepmusic; extern consvar_t cv_skipintromusic; //extern consvar_t cv_ignoremusicchanges; -extern boolean keepmusic; +extern boolean keepmapmusic; extern boolean skipintromus; #define MUSICSTARTTIME (starttime + (TICRATE/2))