Basic alt music

mapheaderinfo's musname field is now a 2 dimensional array, it can take up to 3 tracks and will randomly select between them on level load.
This commit is contained in:
wolfy852 2023-02-08 22:11:37 -06:00
parent c9ab4105da
commit 276cba4641
5 changed files with 21 additions and 8 deletions

View file

@ -1165,11 +1165,16 @@ void readlevelheader(MYFILE *f, char * name)
else if (fastcmp(word, "MUSIC")) else if (fastcmp(word, "MUSIC"))
{ {
if (fastcmp(word2, "NONE")) if (fastcmp(word2, "NONE"))
mapheaderinfo[num]->musname[0] = 0; // becomes empty string mapheaderinfo[num]->musname[0][0] = 0; // becomes empty string
else else
{ {
deh_strlcpy(mapheaderinfo[num]->musname, word2, UINT8 i = 0;
sizeof(mapheaderinfo[num]->musname), va("Level header %d: music", num)); tmp = strtok(word2, ",");
do {
deh_strlcpy(mapheaderinfo[num]->musname[i], tmp,
sizeof(mapheaderinfo[num]->musname[i]), va("Level header %d: music", num));
i += 1;
} while ((tmp = strtok(NULL,",")) != NULL);
} }
} }
else if (fastcmp(word, "MUSICSLOT")) else if (fastcmp(word, "MUSICSLOT"))

View file

@ -410,7 +410,7 @@ struct mapheader_t
fixed_t gravity; ///< Map-wide gravity. fixed_t gravity; ///< Map-wide gravity.
// Music information // Music information
char musname[7]; ///< Music track to play. "" for no music. char musname[3][7]; ///< Music tracks to play. First dimension is the track number, second is the music string. "" for no music.
UINT16 mustrack; ///< Subsong to play. Only really relevant for music modules and specific formats supported by GME. 0 to ignore. UINT16 mustrack; ///< Subsong to play. Only really relevant for music modules and specific formats supported by GME. 0 to ignore.
UINT32 muspos; ///< Music position to jump to. UINT32 muspos; ///< Music position to jump to.

View file

@ -67,6 +67,8 @@ typedef enum
PR_SPARKLE, // Endsign and/or Emerald PR_SPARKLE, // Endsign and/or Emerald
PR_MOVINGTARGET, // Randomised moving targets PR_MOVINGTARGET, // Randomised moving targets
PR_MUSICSELECT, // Randomized music selection
PRNUMCLASS PRNUMCLASS
} pr_class_t; } pr_class_t;

View file

@ -378,6 +378,8 @@ void P_DeleteFlickies(INT16 i)
*/ */
static void P_ClearSingleMapHeaderInfo(INT16 num) static void P_ClearSingleMapHeaderInfo(INT16 num)
{ {
UINT8 i = 0;
mapheaderinfo[num]->lvlttl[0] = '\0'; mapheaderinfo[num]->lvlttl[0] = '\0';
mapheaderinfo[num]->subttl[0] = '\0'; mapheaderinfo[num]->subttl[0] = '\0';
mapheaderinfo[num]->zonttl[0] = '\0'; mapheaderinfo[num]->zonttl[0] = '\0';
@ -385,8 +387,11 @@ static void P_ClearSingleMapHeaderInfo(INT16 num)
mapheaderinfo[num]->typeoflevel = 0; mapheaderinfo[num]->typeoflevel = 0;
mapheaderinfo[num]->gravity = DEFAULT_GRAVITY; mapheaderinfo[num]->gravity = DEFAULT_GRAVITY;
mapheaderinfo[num]->keywords[0] = '\0'; mapheaderinfo[num]->keywords[0] = '\0';
sprintf(mapheaderinfo[num]->musname, "%.5sM", G_BuildMapName(num+1)); for (i = 0; i < 3; i++)
mapheaderinfo[num]->musname[6] = 0; {
sprintf(mapheaderinfo[num]->musname[i], "%.5sM", G_BuildMapName(num+1));
mapheaderinfo[num]->musname[i][6] = 0;
}
mapheaderinfo[num]->mustrack = 0; mapheaderinfo[num]->mustrack = 0;
mapheaderinfo[num]->muspos = 0; mapheaderinfo[num]->muspos = 0;
mapheaderinfo[num]->weather = PRECIP_NONE; mapheaderinfo[num]->weather = PRECIP_NONE;

View file

@ -2431,7 +2431,8 @@ void S_StartEx(boolean reset)
if (mapmusflags & MUSIC_RELOADRESET) if (mapmusflags & MUSIC_RELOADRESET)
{ {
strncpy(mapmusname, mapheaderinfo[gamemap-1]->musname, 7); UINT32 i = P_RandomKey(PR_MUSICSELECT, 2);
strncpy(mapmusname, mapheaderinfo[gamemap-1]->musname[i], 7);
mapmusname[6] = 0; mapmusname[6] = 0;
mapmusflags = (mapheaderinfo[gamemap-1]->mustrack & MUSIC_TRACKMASK); mapmusflags = (mapheaderinfo[gamemap-1]->mustrack & MUSIC_TRACKMASK);
mapmusposition = mapheaderinfo[gamemap-1]->muspos; mapmusposition = mapheaderinfo[gamemap-1]->muspos;
@ -2514,7 +2515,7 @@ static void Command_Tunes_f(void)
} }
else if (!strcasecmp(tunearg, "-default")) else if (!strcasecmp(tunearg, "-default"))
{ {
tunearg = mapheaderinfo[gamemap-1]->musname; tunearg = mapheaderinfo[gamemap-1]->musname[0];
track = mapheaderinfo[gamemap-1]->mustrack; track = mapheaderinfo[gamemap-1]->mustrack;
} }