Alt music: Don't destroy cache_muslock data when replacing the music in the mapheader

This commit is contained in:
toaster 2024-03-09 23:03:41 +00:00
parent f3af88200f
commit 7db5094577
2 changed files with 12 additions and 3 deletions

View file

@ -1234,8 +1234,6 @@ void readlevelheader(MYFILE *f, char * name)
break; break;
deh_strlcpy(mapheaderinfo[num]->musname[j], tmp, deh_strlcpy(mapheaderinfo[num]->musname[j], tmp,
sizeof(mapheaderinfo[num]->musname[j]), va("Level header %d: music", num)); sizeof(mapheaderinfo[num]->musname[j]), va("Level header %d: music", num));
if (j)
mapheaderinfo[num]->cache_muslock[j - 1] = MAXUNLOCKABLES;
j++; j++;
} while ((tmp = strtok(NULL,",")) != NULL); } while ((tmp = strtok(NULL,",")) != NULL);

View file

@ -433,6 +433,8 @@ static void P_ClearMapHeaderLighting(mapheader_lighting_t *lighting)
*/ */
static void P_ClearSingleMapHeaderInfo(INT16 num) static void P_ClearSingleMapHeaderInfo(INT16 num)
{ {
int i;
mapheaderinfo[num]->lvlttl[0] = '\0'; mapheaderinfo[num]->lvlttl[0] = '\0';
mapheaderinfo[num]->menuttl[0] = '\0'; mapheaderinfo[num]->menuttl[0] = '\0';
mapheaderinfo[num]->zonttl[0] = '\0'; mapheaderinfo[num]->zonttl[0] = '\0';
@ -441,13 +443,22 @@ static void P_ClearSingleMapHeaderInfo(INT16 num)
mapheaderinfo[num]->gravity = DEFAULT_GRAVITY; mapheaderinfo[num]->gravity = DEFAULT_GRAVITY;
mapheaderinfo[num]->keywords[0] = '\0'; mapheaderinfo[num]->keywords[0] = '\0';
mapheaderinfo[num]->relevantskin[0] = '\0'; mapheaderinfo[num]->relevantskin[0] = '\0';
mapheaderinfo[num]->musname[0][0] = 0; mapheaderinfo[num]->musname[0][0] = 0;
mapheaderinfo[num]->musname_size = 0; mapheaderinfo[num]->musname_size = 0;
for (i = 0; i < MAXMUSNAMES-1; i++)
{
mapheaderinfo[num]->cache_muslock[i] = MAXUNLOCKABLES;
}
mapheaderinfo[num]->positionmus[0] = '\0'; mapheaderinfo[num]->positionmus[0] = '\0';
mapheaderinfo[num]->associatedmus[0][0] = 0; mapheaderinfo[num]->associatedmus[0][0] = 0;
mapheaderinfo[num]->associatedmus_size = 0; mapheaderinfo[num]->associatedmus_size = 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;
snprintf(mapheaderinfo[num]->skytexture, 5, "SKY1"); snprintf(mapheaderinfo[num]->skytexture, 5, "SKY1");
mapheaderinfo[num]->skytexture[4] = 0; mapheaderinfo[num]->skytexture[4] = 0;
@ -494,7 +505,7 @@ static void P_ClearSingleMapHeaderInfo(INT16 num)
if (mapheaderinfo[num]->ghostBrief != NULL) if (mapheaderinfo[num]->ghostBrief != NULL)
{ {
for (int i = 0; i < mapheaderinfo[num]->ghostCount; i++) for (i = 0; i < mapheaderinfo[num]->ghostCount; i++)
{ {
Z_Free(mapheaderinfo[num]->ghostBrief[i]); Z_Free(mapheaderinfo[num]->ghostBrief[i]);
} }