readcupheader: Permit emptying out BonusGame and SpecialStage for an existing cup

Provide a single / and it'll be empty
This commit is contained in:
toaster 2023-06-18 23:17:21 +01:00
parent 2c09f39796
commit 8689e0735e

View file

@ -3438,6 +3438,15 @@ static void invalidateacrosscups(UINT16 map)
mapheaderinfo[map]->cup = NULL;
}
static char *MapNameOrRemoval(char *name)
{
if (name[0] == '\0'
|| (name[0] == '/' && name[1] == '\0'))
return NULL;
return Z_StrDup(name);
}
void readcupheader(MYFILE *f, cupheader_t *cup)
{
char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL);
@ -3539,8 +3548,12 @@ void readcupheader(MYFILE *f, cupheader_t *cup)
break;
}
cup->levellist[CUPCACHE_BONUS + cup->numbonus] = Z_StrDup(tmp);
cup->levellist[CUPCACHE_BONUS + cup->numbonus] = MapNameOrRemoval(tmp);
cup->cachedlevels[CUPCACHE_BONUS + cup->numbonus] = NEXTMAP_INVALID;
if (cup->levellist[CUPCACHE_BONUS + cup->numbonus] == NULL)
break;
cup->numbonus++;
} while((tmp = strtok(NULL,",")) != NULL);
}
@ -3548,7 +3561,7 @@ void readcupheader(MYFILE *f, cupheader_t *cup)
{
invalidateacrosscups(cup->cachedlevels[CUPCACHE_SPECIAL]);
Z_Free(cup->levellist[CUPCACHE_SPECIAL]);
cup->levellist[CUPCACHE_SPECIAL] = Z_StrDup(word2);
cup->levellist[CUPCACHE_SPECIAL] = MapNameOrRemoval(word2);
cup->cachedlevels[CUPCACHE_SPECIAL] = NEXTMAP_INVALID;
}
else if (fastcmp(word, "EMERALDNUM"))