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!?
This commit is contained in:
toaster 2024-01-07 21:46:59 +00:00
parent 8f2c8b4a5d
commit cb133da7e2

View file

@ -3434,10 +3434,32 @@ static INT32 TOLMaps(UINT8 pgametype)
continue; continue;
} }
if (M_MapLocked(i + 1)) // Only care about restrictions if the host is a listen server.
if (!dedicated)
{ {
// Don't include locked if (!(mapheaderinfo[i]->menuflags & LF2_NOVISITNEEDED)
continue; && !(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++; num++;
@ -3519,10 +3541,32 @@ tryAgain:
continue; 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. if (!(mapheaderinfo[i]->menuflags & LF2_NOVISITNEEDED)
continue; && !(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) if (ignoreBuffers == false)
@ -3957,7 +4001,7 @@ void G_GetNextMap(void)
continue; continue;
} }
for (i = 0; i < cup->numlevels; i++) for (i = 0; i < CUPCACHE_PODIUM; i++)
{ {
cm = cup->cachedlevels[i]; cm = cup->cachedlevels[i];
@ -3965,9 +4009,35 @@ void G_GetNextMap(void)
if (cm >= nummapheaders if (cm >= nummapheaders
|| !mapheaderinfo[cm] || !mapheaderinfo[cm]
|| mapheaderinfo[cm]->lumpnum == LUMPERROR || mapheaderinfo[cm]->lumpnum == LUMPERROR
|| !(mapheaderinfo[cm]->typeoflevel & tolflag) || !(mapheaderinfo[cm]->typeoflevel & tolflag))
|| (!marathonmode && M_MapLocked(cm+1))) {
continue; 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 the map is in multiple cups, only consider the first one valid.
if (mapheaderinfo[cm]->cup != cup) if (mapheaderinfo[cm]->cup != cup)
@ -4012,24 +4082,50 @@ void G_GetNextMap(void)
else else
{ {
cm = prevmap; cm = prevmap;
if (++cm >= nummapheaders)
cm = 0;
while (cm != prevmap) do
{ {
if (++cm >= nummapheaders)
cm = 0;
if (!mapheaderinfo[cm] if (!mapheaderinfo[cm]
|| mapheaderinfo[cm]->lumpnum == LUMPERROR || mapheaderinfo[cm]->lumpnum == LUMPERROR
|| !(mapheaderinfo[cm]->typeoflevel & tolflag) || !(mapheaderinfo[cm]->typeoflevel & tolflag)
|| (mapheaderinfo[cm]->menuflags & LF2_HIDEINMENU) || (mapheaderinfo[cm]->menuflags & LF2_HIDEINMENU))
|| M_MapLocked(cm+1))
{ {
if (++cm >= nummapheaders)
cm = 0;
continue; 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; break;
} } while (cm != prevmap);
nextmap = cm; nextmap = cm;
} }