Merge branch 'alt-music-reroll' into 'master'

Restart the level to cycle through alt music (no RNG)

See merge request KartKrew/Kart!1664
This commit is contained in:
Oni 2023-11-29 22:38:23 +00:00
commit fcc773f660
7 changed files with 22 additions and 21 deletions

View file

@ -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;

View file

@ -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();
}

View file

@ -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;

View file

@ -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)

View file

@ -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

View file

@ -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);

View file

@ -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)