diff --git a/src/deh_soc.c b/src/deh_soc.c index f23c71970..5b007d4f9 100644 --- a/src/deh_soc.c +++ b/src/deh_soc.c @@ -3078,6 +3078,7 @@ void readcupheader(MYFILE *f, cupheader_t *cup) if (cup->cachedlevels[cup->numlevels] == NEXTMAP_INVALID) continue; mapheaderinfo[cup->cachedlevels[cup->numlevels]]->cup = NULL; + cup->cachedlevels[cup->numlevels] = NEXTMAP_INVALID; } tmp = strtok(word2,","); @@ -3100,6 +3101,10 @@ void readcupheader(MYFILE *f, cupheader_t *cup) cup->numbonus--; Z_Free(cup->levellist[CUPCACHE_BONUS + cup->numbonus]); 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; } tmp = strtok(word2,","); diff --git a/src/g_game.c b/src/g_game.c index ab4b6bc9c..1bcbd5555 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3891,6 +3891,12 @@ static void G_GetNextMap(void) || (!marathonmode && M_MapLocked(cm+1))) continue; + // If the map is in multiple cups, only consider the first one valid. + if (mapheaderinfo[cm]->cup != cup) + { + continue; + } + // Grab the first valid after the map you're on if (gettingresult) { diff --git a/src/p_setup.c b/src/p_setup.c index 6a1c5c049..0130acc86 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -7794,13 +7794,9 @@ UINT8 P_InitMapData(boolean existingmapheaders) if (strcasecmp(cup->levellist[j], name) != 0) continue; - // Only panic about back-reference for non-bonus material. - if (j < MAXLEVELLIST) - { - if (mapheaderinfo[i]->cup) - I_Error("P_InitMapData: Map %s cannot appear in cups multiple times! (First in %s, now in %s)", name, mapheaderinfo[i]->cup->name, cup->name); + // Have a map recognise the first cup it's a part of. + if (!mapheaderinfo[i]->cup) mapheaderinfo[i]->cup = cup; - } cup->cachedlevels[j] = i; }