From cb133da7e2979a33bb3f276bbd2a8f9cc0a4af8d Mon Sep 17 00:00:00 2001 From: toaster Date: Sun, 7 Jan 2024 21:46:59 +0000 Subject: [PATCH] g_game.c: Outside of dedicated, don't visit Courses that aren't menu-selectable Applies to the following - G_RandMap - Voting - Title Demos - Challenge Board - `advancemap random` - G_GetNextMap - `advancemap next` - This was previously completely broken for gametypes other than Race!? --- src/g_game.c | 130 ++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 113 insertions(+), 17 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index e33973316..755f62234 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3434,10 +3434,32 @@ static INT32 TOLMaps(UINT8 pgametype) continue; } - if (M_MapLocked(i + 1)) + // Only care about restrictions if the host is a listen server. + if (!dedicated) { - // Don't include locked - continue; + if (!(mapheaderinfo[i]->menuflags & LF2_NOVISITNEEDED) + && !(mapheaderinfo[i]->records.mapvisited & MV_VISITED) + && !( + mapheaderinfo[i]->cup + && mapheaderinfo[i]->cup->cachedlevels[0] == i + )) + { + // Not visited OR head of cup + continue; + } + + if ((mapheaderinfo[i]->menuflags & LF2_FINISHNEEDED) + && !(mapheaderinfo[i]->records.mapvisited & MV_BEATEN)) + { + // Not completed + continue; + } + + if (M_MapLocked(i + 1) == true) + { + // We haven't earned this one. + continue; + } } num++; @@ -3519,10 +3541,32 @@ tryAgain: continue; } - if (M_MapLocked(i + 1) == true) + // Only care about restrictions if the host is a listen server. + if (!dedicated) { - // We haven't earned this one. - continue; + if (!(mapheaderinfo[i]->menuflags & LF2_NOVISITNEEDED) + && !(mapheaderinfo[i]->records.mapvisited & MV_VISITED) + && !( + mapheaderinfo[i]->cup + && mapheaderinfo[i]->cup->cachedlevels[0] == i + )) + { + // Not visited OR head of cup + continue; + } + + if ((mapheaderinfo[i]->menuflags & LF2_FINISHNEEDED) + && !(mapheaderinfo[i]->records.mapvisited & MV_BEATEN)) + { + // Not completed + continue; + } + + if (M_MapLocked(i + 1) == true) + { + // We haven't earned this one. + continue; + } } if (ignoreBuffers == false) @@ -3957,7 +4001,7 @@ void G_GetNextMap(void) continue; } - for (i = 0; i < cup->numlevels; i++) + for (i = 0; i < CUPCACHE_PODIUM; i++) { cm = cup->cachedlevels[i]; @@ -3965,9 +4009,35 @@ void G_GetNextMap(void) if (cm >= nummapheaders || !mapheaderinfo[cm] || mapheaderinfo[cm]->lumpnum == LUMPERROR - || !(mapheaderinfo[cm]->typeoflevel & tolflag) - || (!marathonmode && M_MapLocked(cm+1))) + || !(mapheaderinfo[cm]->typeoflevel & tolflag)) + { continue; + } + + // Only care about restrictions if the host is a listen server. + if (!dedicated && !marathonmode) + { + if (!(mapheaderinfo[cm]->menuflags & LF2_NOVISITNEEDED) + && !(mapheaderinfo[cm]->records.mapvisited & MV_VISITED) + && i != 0) + { + // Not visited OR head of cup + continue; + } + + if ((mapheaderinfo[cm]->menuflags & LF2_FINISHNEEDED) + && !(mapheaderinfo[cm]->records.mapvisited & MV_BEATEN)) + { + // Not completed + continue; + } + + if (M_MapLocked(cm + 1) == true) + { + // We haven't earned this one. + continue; + } + } // If the map is in multiple cups, only consider the first one valid. if (mapheaderinfo[cm]->cup != cup) @@ -4012,24 +4082,50 @@ void G_GetNextMap(void) else { cm = prevmap; - if (++cm >= nummapheaders) - cm = 0; - while (cm != prevmap) + do { + if (++cm >= nummapheaders) + cm = 0; + if (!mapheaderinfo[cm] || mapheaderinfo[cm]->lumpnum == LUMPERROR || !(mapheaderinfo[cm]->typeoflevel & tolflag) - || (mapheaderinfo[cm]->menuflags & LF2_HIDEINMENU) - || M_MapLocked(cm+1)) + || (mapheaderinfo[cm]->menuflags & LF2_HIDEINMENU)) { - if (++cm >= nummapheaders) - cm = 0; continue; } + // Only care about restrictions if the host is a listen server. + if (!dedicated && !marathonmode) + { + if (!(mapheaderinfo[cm]->menuflags & LF2_NOVISITNEEDED) + && !(mapheaderinfo[cm]->records.mapvisited & MV_VISITED) + && !( + mapheaderinfo[cm]->cup + && mapheaderinfo[cm]->cup->cachedlevels[0] == cm + )) + { + // Not visited OR head of cup + continue; + } + + if ((mapheaderinfo[cm]->menuflags & LF2_FINISHNEEDED) + && !(mapheaderinfo[cm]->records.mapvisited & MV_BEATEN)) + { + // Not completed + continue; + } + + if (M_MapLocked(cm + 1) == true) + { + // We haven't earned this one. + continue; + } + } + break; - } + } while (cm != prevmap); nextmap = cm; }