Fixes for Cups with incomplete map list

- Don't check alt-Podium maps as possible Cup stages
- Guarantee the cupcache is initialised to NEXTMAP_INVALID properly
This commit is contained in:
toaster 2023-11-21 22:13:11 +00:00
parent 382119b8fb
commit b46b61e7a1
3 changed files with 13 additions and 8 deletions

View file

@ -489,13 +489,18 @@ static void DEH_LoadDehackedFile(MYFILE *f, boolean mainfile)
if (!cup) if (!cup)
{ {
cup = Z_Calloc(sizeof (cupheader_t), PU_STATIC, NULL); cup = Z_Calloc(sizeof (cupheader_t), PU_STATIC, NULL);
cup->id = numkartcupheaders;
cup->monitor = 1;
cup->cache_cuplock = MAXUNLOCKABLES;
deh_strlcpy(cup->name, word2, deh_strlcpy(cup->name, word2,
sizeof(cup->name), va("Cup header %s: name", word2)); sizeof(cup->name), va("Cup header %s: name", word2));
cup->namehash = hash; cup->namehash = hash;
// Handle some variable init.
cup->monitor = 1;
cup->id = numkartcupheaders;
cup->cache_cuplock = MAXUNLOCKABLES;
for (i = 0; i < CUPCACHE_MAX; i++)
cup->cachedlevels[i] = NEXTMAP_INVALID;
char *start = strchr(word2, '_'); char *start = strchr(word2, '_');
if (start) if (start)
start++; start++;

View file

@ -60,7 +60,7 @@ static void M_StatisticsMaps(void)
if (M_CupLocked(cup)) if (M_CupLocked(cup))
continue; continue;
for (i = 0; i < CUPCACHE_MAX; i++) for (i = 0; i < CUPCACHE_PODIUM; i++)
{ {
if (cup->cachedlevels[i] >= nummapheaders) if (cup->cachedlevels[i] >= nummapheaders)
continue; continue;

View file

@ -114,7 +114,7 @@ UINT16 M_CountLevelsToShowInList(levelsearch_t *levelsearch)
if (levelsearch->checklocked && M_CupLocked(levelsearch->cup)) if (levelsearch->checklocked && M_CupLocked(levelsearch->cup))
return 0; return 0;
for (i = 0; i < CUPCACHE_MAX; i++) for (i = 0; i < CUPCACHE_PODIUM; i++)
{ {
if (!M_CanShowLevelInList(levelsearch->cup->cachedlevels[i], levelsearch)) if (!M_CanShowLevelInList(levelsearch->cup->cachedlevels[i], levelsearch))
continue; continue;
@ -158,13 +158,13 @@ UINT16 M_GetFirstLevelInList(UINT8 *i, levelsearch_t *levelsearch)
{ {
if (levelsearch->checklocked && M_CupLocked(levelsearch->cup)) if (levelsearch->checklocked && M_CupLocked(levelsearch->cup))
{ {
*i = CUPCACHE_MAX; *i = CUPCACHE_PODIUM;
return NEXTMAP_INVALID; return NEXTMAP_INVALID;
} }
*i = 0; *i = 0;
mapnum = NEXTMAP_INVALID; mapnum = NEXTMAP_INVALID;
for (; *i < CUPCACHE_MAX; (*i)++) for (; *i < CUPCACHE_PODIUM; (*i)++)
{ {
if (!M_CanShowLevelInList(levelsearch->cup->cachedlevels[*i], levelsearch)) if (!M_CanShowLevelInList(levelsearch->cup->cachedlevels[*i], levelsearch))
continue; continue;
@ -194,7 +194,7 @@ UINT16 M_GetNextLevelInList(UINT16 mapnum, UINT8 *i, levelsearch_t *levelsearch)
{ {
mapnum = NEXTMAP_INVALID; mapnum = NEXTMAP_INVALID;
(*i)++; (*i)++;
for (; *i < CUPCACHE_MAX; (*i)++) for (; *i < CUPCACHE_PODIUM; (*i)++)
{ {
if (!M_CanShowLevelInList(levelsearch->cup->cachedlevels[*i], levelsearch)) if (!M_CanShowLevelInList(levelsearch->cup->cachedlevels[*i], levelsearch))
continue; continue;