diff --git a/src/doomstat.h b/src/doomstat.h index 300558131..06a38d724 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -42,8 +42,8 @@ extern "C" { // Selected by user. extern INT16 gamemap; +extern boolean g_reloadingMap; extern char mapmusname[7]; -extern UINT16 mapmusflags; extern UINT32 mapmusposition; extern UINT32 mapmusresume; extern UINT8 mapmusrng; diff --git a/src/f_finale.c b/src/f_finale.c index e751084bc..ce3e42ac2 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -1496,6 +1496,7 @@ void F_StartTitleScreen(void) gamestate_t prevwipegamestate = wipegamestate; titlemapinaction = true; gamemap = titleMapNum+1; + g_reloadingMap = false; G_DoLoadLevelEx(true, GS_TITLESCREEN); if (!titlemap) @@ -1536,6 +1537,7 @@ void F_StartTitleScreen(void) G_SetGamestate(GS_TITLESCREEN); titlemapinaction = false; gamemap = 1; // g_game.c + g_reloadingMap = false; CON_ClearHUD(); } diff --git a/src/g_game.c b/src/g_game.c index b5b7df905..19d513924 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -105,12 +105,12 @@ static void G_DoWorldDone(void); static void G_DoStartVote(void); char mapmusname[7]; // Music name -UINT16 mapmusflags; // Track and reset bit UINT32 mapmusposition; // Position to jump to UINT32 mapmusresume; UINT8 mapmusrng; // Random selection result -INT16 gamemap = 1; +INT16 gamemap = 0; +boolean g_reloadingMap; UINT32 maptol; preciptype_t globalweather = PRECIP_NONE; @@ -5926,11 +5926,9 @@ void G_InitNew(UINT8 pencoremode, INT32 map, boolean resetplayer, boolean skippr } } + g_reloadingMap = (map == gamemap); gamemap = map; - // Don't carry over custom music change to another map. - mapmusflags |= MUSIC_RELOADRESET; - automapactive = false; imcontinuing = false; diff --git a/src/k_podium.cpp b/src/k_podium.cpp index 6635071a3..072a4e075 100644 --- a/src/k_podium.cpp +++ b/src/k_podium.cpp @@ -940,6 +940,7 @@ boolean K_StartCeremony(void) && mapheaderinfo[podiumMapNum]->lumpnum != LUMPERROR) { gamemap = podiumMapNum+1; + g_reloadingMap = false; encoremode = grandprixinfo.encore; @@ -1034,8 +1035,6 @@ void K_ResetCeremony(void) { mapmusrng--; } - - mapmusflags |= MUSIC_RELOADRESET; } if (!grandprixinfo.cup) diff --git a/src/lua_script.c b/src/lua_script.c index bd54fac61..d47df24dc 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -299,9 +299,6 @@ int LUA_PushGlobals(lua_State *L, const char *word) } else if (fastcmp(word,"mapmusname")) { lua_pushstring(L, mapmusname); return 1; - } else if (fastcmp(word,"mapmusflags")) { - lua_pushinteger(L, mapmusflags); - return 1; } else if (fastcmp(word,"mapmusposition")) { lua_pushinteger(L, mapmusposition); return 1; @@ -424,8 +421,6 @@ int LUA_WriteGlobals(lua_State *L, const char *word) strncpy(mapmusname, str, strlength); } - else if (fastcmp(word, "mapmusflags")) - mapmusflags = (UINT16)luaL_checkinteger(L, 2); else if (fastcmp(word, "mapmusrng")) mapmusrng = (UINT8)luaL_checkinteger(L, 2); // SRB2Kart diff --git a/src/p_saveg.c b/src/p_saveg.c index 9d727cdcc..2f8a5d66b 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -6422,17 +6422,13 @@ static boolean P_NetUnArchiveMisc(savebuffer_t *save, boolean reloading) gametic = READUINT32(save->p); gamemap = READINT16(save->p); + g_reloadingMap = false; // gamemap changed; we assume that its map header is always valid, // so make it so if (!gamemap || gamemap > nummapheaders || !mapheaderinfo[gamemap-1]) I_Error("P_NetUnArchiveMisc: Internal map ID %d not found (nummapheaders = %d)", gamemap-1, nummapheaders); - // tell the sound code to reset the music since we're skipping what - // normally sets this flag - if (!reloading) - mapmusflags |= MUSIC_RELOADRESET; - G_SetGamestate(READINT16(save->p)); gametype = READINT16(save->p); diff --git a/src/p_setup.c b/src/p_setup.c index 1f1e371af..4b458037c 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -8069,7 +8069,7 @@ static void P_InitMinimapInfo(void) void P_ResetLevelMusic(void) { - mapmusrng = 0; + UINT8 idx = 0; if (mapheaderinfo[gamemap-1]->musname_size > 1) { @@ -8090,11 +8090,22 @@ void P_ResetLevelMusic(void) if (tempmapmus_size > 1) { - mapmusrng = P_RandomKey(PR_MUSICSELECT, tempmapmus_size); + if (g_reloadingMap) + { + // If restarting the map, simply cycle + // through available alt music. + idx = (mapmusrng + 1) % tempmapmus_size; + } + else + { + idx = P_RandomKey(PR_MUSICSELECT, tempmapmus_size); + } //CONS_Printf("Rolled position %u, maps to %u\n", mapmusrng, tempmapmus[mapmusrng]); - mapmusrng = tempmapmus[mapmusrng]; + idx = tempmapmus[idx]; } } + + mapmusrng = idx; } void P_LoadLevelMusic(void)