Invalidate all instances of the same map across multiple cups' cachedlevels, so that it DEFINITELY will be assigned to the first cup in the linked list in P_InitMapData.

This commit is contained in:
toaster 2022-12-18 14:37:15 +00:00
parent f9bdfd8a50
commit d25e59535c

View file

@ -3021,6 +3021,28 @@ void readwipes(MYFILE *f)
// SRB2KART
//
static void invalidateacrosscups(UINT16 map)
{
cupheader_t *cup = kartcupheaders;
UINT8 i;
if (map >= nummapheaders)
return;
while (cup)
{
for (i = 0; i < CUPCACHE_MAX; i++)
{
if (cup->cachedlevels[i] != map)
continue;
cup->cachedlevels[i] = NEXTMAP_INVALID;
}
cup = cup->next;
}
mapheaderinfo[map]->cup = NULL;
}
void readcupheader(MYFILE *f, cupheader_t *cup)
{
char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL);
@ -3077,8 +3099,7 @@ void readcupheader(MYFILE *f, cupheader_t *cup)
cup->levellist[cup->numlevels] = NULL;
if (cup->cachedlevels[cup->numlevels] == NEXTMAP_INVALID)
continue;
mapheaderinfo[cup->cachedlevels[cup->numlevels]]->cup = NULL;
cup->cachedlevels[cup->numlevels] = NEXTMAP_INVALID;
invalidateacrosscups(cup->cachedlevels[cup->numlevels]);
}
tmp = strtok(word2,",");
@ -3103,8 +3124,7 @@ void readcupheader(MYFILE *f, cupheader_t *cup)
cup->levellist[CUPCACHE_BONUS + cup->numbonus] = NULL;
if (cup->cachedlevels[CUPCACHE_BONUS + cup->numbonus] == NEXTMAP_INVALID)
continue;
mapheaderinfo[cup->cachedlevels[CUPCACHE_BONUS + cup->numbonus]]->cup = NULL;
cup->cachedlevels[CUPCACHE_BONUS + cup->numbonus] = NEXTMAP_INVALID;
invalidateacrosscups(cup->cachedlevels[CUPCACHE_BONUS + cup->numbonus]);
}
tmp = strtok(word2,",");
@ -3122,6 +3142,7 @@ void readcupheader(MYFILE *f, cupheader_t *cup)
}
else if (fastcmp(word, "SPECIALSTAGE"))
{
invalidateacrosscups(cup->cachedlevels[CUPCACHE_SPECIAL]);
Z_Free(cup->levellist[CUPCACHE_SPECIAL]);
cup->levellist[CUPCACHE_SPECIAL] = Z_StrDup(word2);
cup->cachedlevels[CUPCACHE_SPECIAL] = NEXTMAP_INVALID;