From 3425727ca6652f9a6210606760adbdd9284b51f0 Mon Sep 17 00:00:00 2001 From: JugadorXEI Date: Thu, 16 Oct 2025 02:19:41 +0000 Subject: [PATCH] Fix map vote dementia --- src/d_clisrv.c | 13 ++++++++ src/g_game.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 94 insertions(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 7d3fbfe60..9a8351646 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2729,6 +2729,19 @@ void CL_RemovePlayer(INT32 playernum, kickreason_t reason) K_CheckBumpers(); P_CheckRacers(); + + // Reset map headers' justPlayed and anger records + // when there are no players in a dedicated server. + // Otherwise maps get angry at newly-joined players + // that don't deserve it. + if (dedicated && D_NumPlayers() == 0) + { + for (INT32 i = 0; i < nummapheaders; i++) + { + mapheaderinfo[i]->justPlayed = 0; + mapheaderinfo[i]->anger = 0; + } + } } void CL_Reset(void) diff --git a/src/g_game.c b/src/g_game.c index fff406bdb..f86871a13 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -4064,12 +4064,91 @@ UINT16 G_RandMap(UINT32 tolflags, UINT16 pprevmap, boolean ignoreBuffers, boolea void G_AddMapToBuffer(UINT16 map) { +#if 0 + // DEBUG: make nearly everything but four race levels full justPlayed + // to look into what happens when a dedicated runs for seven million years. + INT32 justplayedvalue = TOLMaps(gametype) - VOTE_NUM_LEVELS; + UINT32 tolflag = G_TOLFlag(gametype); + + // Find all the maps that are ok + INT32 i; + for (i = 0; i < nummapheaders; i++) + { + if (mapheaderinfo[i] == NULL) + { + continue; + } + + if (mapheaderinfo[i]->lumpnum == LUMPERROR) + { + continue; + } + + if ((mapheaderinfo[i]->typeoflevel & tolflag) == 0) + { + continue; + } + + if (mapheaderinfo[i]->menuflags & LF2_HIDEINMENU) + { + // Don't include hidden + continue; + } + + // Only care about restrictions if the host is a listen server. + if (!dedicated) + { + 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; + } + + mapheaderinfo[i]->justPlayed = justplayedvalue; + justplayedvalue -= 1; + if (justplayedvalue <= 0) + break; + } +#else + if (dedicated && D_NumPlayers() == 0) + return; + + const size_t upperJustPlayedLimit = TOLMaps(gametype) - VOTE_NUM_LEVELS - 1; + if (mapheaderinfo[map]->justPlayed == 0) // Started playing a new map. { // Decrement every maps' justPlayed value. INT32 i; for (i = 0; i < nummapheaders; i++) { + // If the map's justPlayed value is higher + // than what it should be, clamp it. + // (Usually a result of SOC files + // manipulating which levels are hidden.) + if (mapheaderinfo[i]->justPlayed > upperJustPlayedLimit) + { + mapheaderinfo[i]->justPlayed = upperJustPlayedLimit; + } + if (mapheaderinfo[i]->justPlayed > 0) { mapheaderinfo[i]->justPlayed--; @@ -4078,8 +4157,9 @@ void G_AddMapToBuffer(UINT16 map) } // Set our map's justPlayed value. - mapheaderinfo[map]->justPlayed = TOLMaps(gametype) - VOTE_NUM_LEVELS; + mapheaderinfo[map]->justPlayed = upperJustPlayedLimit; mapheaderinfo[map]->anger = 0; // Reset voting anger now that we're playing it +#endif } //