From b08969602175b6517d54aa7e71919048e2a22e00 Mon Sep 17 00:00:00 2001 From: wolfy852 Date: Fri, 10 Feb 2023 12:59:53 -0600 Subject: [PATCH] Add MAXMUSNAMES constant --- src/deh_soc.c | 4 +++- src/doomstat.h | 2 ++ src/p_setup.c | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/deh_soc.c b/src/deh_soc.c index e2674bcd5..b54fe9bcb 100644 --- a/src/deh_soc.c +++ b/src/deh_soc.c @@ -50,6 +50,7 @@ // SRB2Kart #include "filesrch.h" // refreshdirmenu #include "k_follower.h" +#include "doomstat.h" // MAXMUSNAMES // Loops through every constant and operation in word and performs its calculations, returning the final value. fixed_t get_number(const char *word) @@ -1173,7 +1174,8 @@ void readlevelheader(MYFILE *f, char * name) do { deh_strlcpy(mapheaderinfo[num]->musname[j], tmp, sizeof(mapheaderinfo[num]->musname[j]), va("Level header %d: music", num)); - j += 1; + if (j < MAXMUSNAMES) + j++; } while ((tmp = strtok(NULL,",")) != NULL); mapheaderinfo[num]->musname_size = j; } diff --git a/src/doomstat.h b/src/doomstat.h index 8ba85e51b..316e4a1a9 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -369,6 +369,8 @@ struct staffbrief_t tic_t lap; }; +#define MAXMUSNAMES 3 // maximum definable music tracks per level + /** Map header information. */ struct mapheader_t diff --git a/src/p_setup.c b/src/p_setup.c index af57b7a32..068a23033 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -100,6 +100,7 @@ #include "k_director.h" // K_InitDirector #include "k_specialstage.h" #include "acs/interface.h" +#include "doomstat.h" // MAXMUSNAMES // Replay names have time #if !defined (UNDER_CE) @@ -387,7 +388,7 @@ static void P_ClearSingleMapHeaderInfo(INT16 num) mapheaderinfo[num]->typeoflevel = 0; mapheaderinfo[num]->gravity = DEFAULT_GRAVITY; mapheaderinfo[num]->keywords[0] = '\0'; - for (i = 0; i < 3; i++) + for (i = 0; i < MAXMUSNAMES; i++) { sprintf(mapheaderinfo[num]->musname[i], "%.5sM", G_BuildMapName(num+1)); mapheaderinfo[num]->musname[i][6] = 0;