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;