From c6268253eb8d414cbadad8a7a2992ebbc42c3566 Mon Sep 17 00:00:00 2001 From: toaster Date: Thu, 22 Nov 2018 17:10:36 +0000 Subject: [PATCH] The oft-promised buffer fixes. Also, making it so the gametype switch for "Sometimes" is every 10 maps, not a full buffer round (now that it doesn't add to the buffer when you first see it). Unfortunately, the code didn't turn out nearly as nice as I'd desired, but things don't always work out. In addition: For some reason, I rolled Tinkerer's Arena twice within three hits of the Dice voting option, so something's wrong and this branch needs proper, rigorous investigative testing but I don't know what and I'm way too tired (both physically and metaphysically) to investigate any further. --- src/d_netcmd.c | 1 - src/g_game.c | 49 +++++++++++++++++++++++++++++++++++++++---------- src/p_setup.c | 2 ++ 3 files changed, 41 insertions(+), 11 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 47f47451..4a08a1af 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2066,7 +2066,6 @@ void D_MapChange(INT32 mapnum, INT32 newgametype, boolean pencoremode, boolean r chmappending++; if (netgame) WRITEUINT32(buf_p, M_RandomizedSeed()); // random seed - G_AddMapToBuffer(mapnum-1); SendNetXCmd(XD_MAP, buf, buf_p - buf); } } diff --git a/src/g_game.c b/src/g_game.c index ba6bf5a3..f9f156a8 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3137,8 +3137,7 @@ INT16 G_SometimesGetDifferentGametype(void) if (randmapbuffer[NUMMAPS] > 0 && (encorepossible || cv_kartvoterulechanges.value != 3)) { - if (cv_kartvoterulechanges.value != 1) - randmapbuffer[NUMMAPS]--; + randmapbuffer[NUMMAPS]--; if (encorepossible) { switch (cv_kartvoterulechanges.value) @@ -3166,6 +3165,8 @@ INT16 G_SometimesGetDifferentGametype(void) randmapbuffer[NUMMAPS] = 1; // every other vote (or always if !encorepossible) break; case 1: // sometimes + randmapbuffer[NUMMAPS] = 10; // ...every two cups? + break; default: // fallthrough - happens when clearing buffer, but needs a reasonable countdown if cvar is modified case 2: // frequent @@ -3268,6 +3269,7 @@ static INT32 TOLMaps(INT16 tolflags) * \author Graue */ static INT16 *okmaps = NULL; +static INT16 votebuffer[3] = {-1, -1, -1}; INT16 G_RandMap(INT16 tolflags, INT16 pprevmap, boolean ignorebuffer, UINT8 maphell, boolean callagainsoon) { INT32 numokmaps = 0; @@ -3297,6 +3299,26 @@ tryagain: if (!ignorebuffer) { + if (votebuffer[0] != -1) + { + if (ix == votebuffer[0]) + continue; + + for (bufx = 1; bufx < 3; bufx++) + { + if (votebuffer[bufx] == -1) // Rest of buffer SHOULD be empty + break; + if (ix == votebuffer[bufx]) + { + isokmap = false; + break; + } + } + + if (!isokmap) + continue; + } + for (bufx = 0; bufx < (maphell ? 3 : NUMMAPS); bufx++) { if (randmapbuffer[bufx] == -1) // Rest of buffer SHOULD be empty @@ -3307,12 +3329,12 @@ tryagain: break; } } + + if (!isokmap) + continue; } - if (!isokmap) - continue; - - if (pprevmap == -2) // title demos + if (pprevmap == -2) // title demo hack { lumpnum_t l; if ((l = W_CheckNumForName(va("%sS01",G_BuildMapName(ix+1)))) == LUMPERROR) @@ -3334,8 +3356,6 @@ tryagain: for (bufx = 3; bufx < NUMMAPS; bufx++) // Let's clear all but the three most recent maps... randmapbuffer[bufx] = -1; - if (cv_kartvoterulechanges.value == 1) // sometimes - randmapbuffer[NUMMAPS] = 0; goto tryagain; //return G_RandMap(tolflags, pprevmap, ignorebuffer, maphell, callagainsoon); } @@ -3356,6 +3376,17 @@ tryagain: { Z_Free(okmaps); okmaps = NULL; + for (bufx = 0; bufx < 3; bufx++) + votebuffer[bufx] = -1; + } + else if (votebuffer[2] == -1) + { + for (bufx = 0; bufx < 3; bufx++) + if (votebuffer[bufx] == -1) + { + votebuffer[bufx] = ix; + break; + } } return ix; @@ -3509,8 +3540,6 @@ static void G_DoCompleted(void) { for (i = 3; i < NUMMAPS; i++) // Let's clear all but the three most recent maps... randmapbuffer[i] = -1; - if (cv_kartvoterulechanges.value == 1) // sometimes - randmapbuffer[NUMMAPS] = 0; } #endif diff --git a/src/p_setup.c b/src/p_setup.c index 68cdc797..533bba14 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3113,6 +3113,8 @@ boolean P_SetupLevel(boolean skipprecip) #endif } + G_AddMapToBuffer(gamemap-1); + return true; }