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)
{
cup = Z_Calloc(sizeof (cupheader_t), PU_STATIC, NULL);
cup->id = numkartcupheaders;
cup->monitor = 1;
cup->cache_cuplock = MAXUNLOCKABLES;
deh_strlcpy(cup->name, word2,
sizeof(cup->name), va("Cup header %s: name", word2));
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, '_');
if (start)
start++;

View file

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

View file

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