diff --git a/src/g_game.c b/src/g_game.c index 8616d55dc..2d2fe7bb6 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -4380,6 +4380,7 @@ void G_InitNew(UINT8 pencoremode, const char *mapname, boolean resetplayer, bool else { LUAh_MapChange(gamemap); + S_CheckMap(); G_DoLoadLevel(resetplayer); } diff --git a/src/k_kart.c b/src/k_kart.c index a96a6bbda..8c6356fdf 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -5359,12 +5359,9 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) // Handle invincibility sfx K_UpdateInvincibilitySounds(player); // Also thanks, VAda! - // Plays the music after the starting countdown. - if (P_IsLocalPlayer(player) && leveltime == (starttime + (TICRATE/2))) - { - S_ChangeMusic(mapmusname, mapmusflags, true); - S_ShowMusicCredit(); - } + // Plays the music during and after the starting countdown. + if (P_IsLocalPlayer(player)) + S_StartMapMusic(); } void K_KartPlayerAfterThink(player_t *player) @@ -6552,10 +6549,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) if ((leveltime == starttime-(3*TICRATE)) || (leveltime == starttime-(2*TICRATE)) || (leveltime == starttime-TICRATE)) S_StartSound(NULL, sfx_s3ka7); if (leveltime == starttime) - { S_StartSound(NULL, sfx_s3kad); - S_StopMusic(); // The GO! sound stops the level start ambience - } } // Start charging once you're given the opportunity. diff --git a/src/m_menu.c b/src/m_menu.c index bc7e9d85b..101afbd8d 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1658,21 +1658,25 @@ static const char* OP_SoundTooltips[] = static menuitem_t OP_SoundAdvancedMenu[] = { #ifdef HAVE_OPENMPT - {IT_HEADER, NULL, "Tracker Module Options", NULL, 10}, + {IT_HEADER, NULL, "Tracker Module Options", NULL, 0}, - {IT_STRING | IT_CVAR, NULL, "Instrument Filter", &cv_modfilter, 22}, - {IT_STRING | IT_CVAR, NULL, "Amiga Resampler", &cv_amigafilter, 42}, + {IT_STRING | IT_CVAR, NULL, "Instrument Filter", &cv_modfilter, 20}, + {IT_STRING | IT_CVAR, NULL, "Amiga Resampler", &cv_amigafilter, 30}, #if OPENMPT_API_VERSION_MAJOR < 1 && OPENMPT_API_VERSION_MINOR > 4 - {IT_STRING | IT_CVAR, NULL, "Amiga Type", &cv_amigatype, 62}, + {IT_STRING | IT_CVAR, NULL, "Amiga Type", &cv_amigatype, 40}, #endif - {IT_STRING | IT_CVAR, NULL, "Stereo Seperation", &cv_stereosep, 82}, + {IT_STRING | IT_CVAR, NULL, "Stereo Seperation", &cv_stereosep, 50}, #endif - {IT_HEADER, NULL, "Misc", NULL, 105}, - {IT_STRING | IT_CVAR, NULL, "Grow Music", &cv_growmusic, 117}, - {IT_STRING | IT_CVAR, NULL, "Invulnerability Music", &cv_supermusic, 127}, + {IT_HEADER, NULL, "Misc", NULL, 70}, - {IT_STRING | IT_CVAR, NULL, "Audio Buffer Size", &cv_audbuffersize, 147}, + {IT_STRING | IT_CVAR, NULL, "Grow Music", &cv_growmusic, 90}, + {IT_STRING | IT_CVAR, NULL, "Invulnerability Music", &cv_supermusic, 100}, + + {IT_STRING | IT_CVAR, NULL, "Keep Map Music", &cv_keepmusic, 120}, + {IT_STRING | IT_CVAR, NULL, "Skip Intro Music", &cv_skipintromusic, 130}, + + {IT_STRING | IT_CVAR, NULL, "Audio Buffer Size", &cv_audbuffersize, 150}, }; static const char* OP_SoundAdvancedTooltips[] = @@ -1690,6 +1694,8 @@ static const char* OP_SoundAdvancedTooltips[] = NULL, "Should the Grow music be on or off?", "Should the Invulnerability music be on or off?", + "Should music be kept when restarting the map?", + "Should the Intro fanfare be skipped\nand map music be played on map start?", "Size of the Audio Buffer\nreducing it will result in less sound latency\nbut may cause issues such as crackling or distorted Sound.", }; diff --git a/src/p_setup.c b/src/p_setup.c index 17d050dc4..672b1b347 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2683,7 +2683,7 @@ boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate) // As oddly named as this is, this handles music only. // We should be fine starting it here. if (!reloadinggamestate) - S_Start(); + S_InitMapMusic(); levelfadecol = (encoremode && !ranspecialwipe ? 122 : 120); diff --git a/src/p_spec.c b/src/p_spec.c index 81d5ad8b4..997cc437c 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -99,6 +99,8 @@ typedef struct thinker_t **thinkers; } thinkerlist_t; +//static boolean fromlapexec = false; + static void P_SearchForDisableLinedefs(void); static void P_SpawnScrollers(void); static void P_SpawnFriction(void); @@ -1340,6 +1342,7 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller fixed_t dist = P_AproxDistance(triggerline->dx, triggerline->dy)>>FRACBITS; size_t i, linecnt, sectori; INT16 specialtype = triggerline->special; + //fromlapexec = false; ///////////////////////////////////////////////// // Distance-checking/sector trigger conditions // @@ -1461,6 +1464,8 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller if (lap != (sides[triggerline->sidenum[0]].textureoffset >> FRACBITS)) return false; } + + //fromlapexec = true; } // If we were not triggered by a sector type especially for the purpose, // a Linedef Executor linedef trigger is not handling sector triggers properly, return. @@ -2113,12 +2118,12 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) return; if (bot) - P_Teleport(bot, dest->x, dest->y, dest->z, (line->flags & ML_NOCLIMB) ? mo->angle : dest->angle, (line->flags & ML_BLOCKMONSTERS) == 0, (line->flags & ML_EFFECT4) == ML_EFFECT4); + P_Teleport(bot, dest->x, dest->y, dest->z, (line->flags & ML_NOCLIMB) ? mo->angle : dest->angle, (line->flags & ML_BLOCKMONSTERS) == 0, (line->flags & ML_EFFECT4) == ML_EFFECT4); if (line->flags & ML_BLOCKMONSTERS) - P_Teleport(mo, dest->x, dest->y, dest->z, (line->flags & ML_NOCLIMB) ? mo->angle : dest->angle, false, (line->flags & ML_EFFECT4) == ML_EFFECT4); + P_Teleport(mo, dest->x, dest->y, dest->z, (line->flags & ML_NOCLIMB) ? mo->angle : dest->angle, false, (line->flags & ML_EFFECT4) == ML_EFFECT4); else { - P_Teleport(mo, dest->x, dest->y, dest->z, (line->flags & ML_NOCLIMB) ? mo->angle : dest->angle, true, (line->flags & ML_EFFECT4) == ML_EFFECT4); + P_Teleport(mo, dest->x, dest->y, dest->z, (line->flags & ML_NOCLIMB) ? mo->angle : dest->angle, true, (line->flags & ML_EFFECT4) == ML_EFFECT4); // Play the 'bowrwoosh!' sound S_StartSound(dest, sfx_mixup); } @@ -2127,6 +2132,12 @@ 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... + return; + + //if (cv_ignoremusicchanges.value && (leveltime >= MUSICSTARTTIME) && !fromlapexec) // keep lap music intanct tho + //return; + // console player only unless NOCLIMB is set if ((line->flags & ML_NOCLIMB) || (mo && mo->player && P_IsLocalPlayer(mo->player))) { @@ -2207,6 +2218,10 @@ 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 && (leveltime < MUSICSTARTTIME)) + return; + sfxnum = sides[line->sidenum[0]].toptexture; //P_AproxDistance(line->dx, line->dy)>>FRACBITS; if (sfxnum == sfx_None) diff --git a/src/p_user.c b/src/p_user.c index 4cdbd2ae5..643e03e9b 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -742,9 +742,8 @@ void P_RestoreMusic(player_t *player) if (P_EndingMusic(player)) return; - // Event - Level Start - if (leveltime < (starttime + (TICRATE/2))) - S_ChangeMusicInternal((encoremode ? "estart" : "kstart"), false); //S_StopMusic(); + if (leveltime < MUSICSTARTTIME) + S_StartMapMusic(); else // see also where time overs are handled - search for "lives = 2" in this file { INT32 wantedmus = 0; // 0 is level music, 1 is invincibility, 2 is grow diff --git a/src/s_sound.c b/src/s_sound.c index f8db2b296..5e171b6d4 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -11,6 +11,7 @@ /// \file s_sound.c /// \brief System-independent sound and music routines +#include "d_netcmd.h" #include "doomdef.h" #include "doomstat.h" #include "command.h" @@ -118,6 +119,14 @@ consvar_t cv_resume = {"resume", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0 consvar_t cv_fading = {"fading", "Off", CV_SAVE|CV_CALL, CV_OnOff, Bird_menu_Onchange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_birdmusic = {"birdmusicstuff", "No", CV_SAVE|CV_CALL, CV_YesNo, Bird_menu_Onchange, 0, NULL, NULL, 0, 0, NULL}; + +consvar_t cv_keepmusic = {"keepmusic", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; +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; +static void S_CheckEventMus(const char *newmus); + #ifdef HAVE_OPENMPT openmpt_module *openmpt_mhandle = NULL; @@ -297,6 +306,10 @@ void S_RegisterSoundStuff(void) CV_RegisterVar(&cv_birdmusic); // bird music stuff end + CV_RegisterVar(&cv_keepmusic); + CV_RegisterVar(&cv_skipintromusic); + //CV_RegisterVar(&cv_ignoremusicchanges); + COM_AddCommand("tunes", Command_Tunes_f); COM_AddCommand("restartaudio", Command_RestartAudio_f); COM_AddCommand("restartmusic", Command_RestartMusic_f); @@ -1960,6 +1973,8 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 strncpy(newmusic, mmusic, 6); + S_CheckEventMus(newmusic); + if (LUAh_MusicChange(music_name, newmusic, &mflags, &looping, &position, &prefadems, &fadeinms)) return; @@ -2151,13 +2166,92 @@ boolean S_FadeOutStopMusic(UINT32 ms) /// Init & Others /// ------------------------ +/*static boolean S_KeepMusic(void) +{ + //if (!cv_keepmusic.value) + //return false; + + // should i compare songs or maps? + static char oldmusname[7] = ""; + + if (strcmp(music_name, mapmusname) != 0) + return false; + + if (strcmp(oldmusname, mapmusname) == 0) + return true; + + strncpy(oldmusname, mapmusname, 7); + oldmusname[6] = '\0'; + + return false; +}*/ + +static INT16 oldmap = 0; +static boolean oldencore = false; +static boolean skipmusic = false; +boolean skipintromus = false; + +static const char *musicexception_list[16] = { + "vote", "voteea", "voteeb", "racent", "krwin", + "krok", "krlose", "krfail", "kbwin", "kbok", + "kblose", "kstart", "estart", "wait2j", "CHRSHP", + "CHRSHF" +}; + +//checks for any kind of event music like intermission, vote etc. +//always runs when musicchange gets invoked +static void S_CheckEventMus(const char *newmus) +{ + skipmusic = false; + + if (!cv_keepmusic.value) + return; + + for (int i = 0; i < 16; i++) + if (stricmp(music_name, musicexception_list[i]) == 0 || stricmp(newmus, musicexception_list[i]) == 0) // weird? sure! but were lucky enough newmus reflects whats being replaced + { + skipmusic = true; + break; + } + + //CONS_Printf("musname = %s\n", music_name); + //CONS_Printf("newmus = %s\n", newmus); + //CONS_Printf("newmus = %d\n", skipmusic); +} + +//this one compares map and encoremode instead of the music itself +//makes tunes work and stuff +void S_CheckMap(void) +{ + if (!cv_keepmusic.value) + { + keepmusic = false; + return; + } + + keepmusic = (!skipmusic && gamestate == GS_LEVEL && oldmap == gamemap && oldencore == encoremode); + + oldencore = encoremode; + oldmap = gamemap; +} + // // Per level startup code. // Kills playing sounds at start of level, // determines music if any, changes music. // -void S_Start(void) +void S_InitMapMusic(void) { + if (!cv_skipintromusic.value) + skipintromus = false; + else + { + char *maptitle = G_BuildMapTitle(gamemap); + skipintromus = cv_skipintromusic.value && stricmp(maptitle, "Wandering Falls") != 0; // thanks diggle! + if (maptitle) + Z_Free(maptitle); + } + if (mapmusflags & MUSIC_RELOADRESET) { strncpy(mapmusname, mapheaderinfo[gamemap-1]->musname, 7); @@ -2167,13 +2261,48 @@ void S_Start(void) mapmusresume = 0; } - //if (cv_resetmusic.value) // Starting ambience should always be restarted - S_StopMusic(); + if (keepmusic) + return; - if (leveltime < (starttime + (TICRATE/2))) // SRB2Kart - S_ChangeMusicEx((encoremode ? "estart" : "kstart"), 0, false, mapmusposition, 0, 0); - else + // Starting ambience should always be restarted + // lug: but not when we keep the map music lol + S_StopMusic(); + + if (skipintromus) + return; + + if (leveltime < MUSICSTARTTIME) // SRB2Kart + S_ChangeMusicInternal((encoremode ? "estart" : "kstart"), false); //S_StopMusic(); + //S_ChangeMusicEx((encoremode ? "estart" : "kstart"), 0, false, mapmusposition, 0, 0); +} + +void S_StartMapMusic(void) +{ + //no need to constantly run this after race has started + if (leveltime > MUSICSTARTTIME) + return; + + if (keepmusic) + return; + + if (skipintromus) + { + if (leveltime < starttime) // dumb but i dont need this to be spammed honestly + S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, 0); + if (leveltime == MUSICSTARTTIME) + S_ShowMusicCredit(); + return; + } + + if (leveltime < starttime) // SRB2Kart + S_ChangeMusicInternal((encoremode ? "estart" : "kstart"), false); // yes this will be spammed otherwise encore and some stuff WILL overwrite it + else if (leveltime == starttime) // The GO! sound stops the level start ambience + S_StopMusic(); + else if (leveltime == MUSICSTARTTIME) // Plays the music after the starting countdown. + { S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, 0); + S_ShowMusicCredit(); + } } void S_RestartMusic(void) diff --git a/src/s_sound.h b/src/s_sound.h index 899d0e043..a22763449 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -68,6 +68,13 @@ extern consvar_t cv_resume; extern consvar_t cv_fading; 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 skipintromus; +#define MUSICSTARTTIME (starttime + (TICRATE/2)) + extern consvar_t precachesound; typedef enum @@ -101,7 +108,11 @@ void S_InitSfxChannels(INT32 sfxVolume); // void S_StopSounds(void); void S_ClearSfx(void); -void S_Start(void); + +void S_InitMapMusic(void); +void S_StartMapMusic(void); + +void S_CheckMap(void); // Stops music and restarts it from same position. Used for instant applying changes to amiga filters. void S_RestartMusic(void);