Remove previous commit's votebuffer, allow an external optional buffer to be passed into G_RandMap

I meant to fix the previous method, but I didn't even understand how it knew it was in a vote or not... so I just did it my own way :V

(Shouldn't FLUSHMAPBUFFEREARLY be on now...?)
This commit is contained in:
TehRealSalt 2018-11-26 04:27:31 -05:00
parent c6268253eb
commit 478f895ea0
6 changed files with 22 additions and 34 deletions

View file

@ -2076,6 +2076,7 @@ void D_SetupVote(void)
UINT8 *p = buf; UINT8 *p = buf;
INT32 i; INT32 i;
UINT8 secondgt = G_SometimesGetDifferentGametype(); UINT8 secondgt = G_SometimesGetDifferentGametype();
INT16 votebuffer[3] = {-1,-1,-1};
if (cv_kartencore.value && G_RaceGametype()) if (cv_kartencore.value && G_RaceGametype())
WRITEUINT8(p, (gametype|0x80)); WRITEUINT8(p, (gametype|0x80));
@ -2086,12 +2087,16 @@ void D_SetupVote(void)
for (i = 0; i < 5; i++) for (i = 0; i < 5; i++)
{ {
UINT16 m;
if (i == 2) // sometimes a different gametype if (i == 2) // sometimes a different gametype
WRITEUINT16(p, G_RandMap(G_TOLFlag(secondgt), prevmap, false, 0, true)); m = G_RandMap(G_TOLFlag(secondgt), prevmap, false, 0, true, votebuffer);
else if (i >= 3) // unknown-random and force-unknown MAP HELL else if (i >= 3) // unknown-random and force-unknown MAP HELL
WRITEUINT16(p, G_RandMap(G_TOLFlag(gametype), prevmap, false, (i-2), (i < 4))); m = G_RandMap(G_TOLFlag(gametype), prevmap, false, (i-2), (i < 4), votebuffer);
else else
WRITEUINT16(p, G_RandMap(G_TOLFlag(gametype), prevmap, false, 0, true)); m = G_RandMap(G_TOLFlag(gametype), prevmap, false, 0, true, votebuffer);
if (i < 3)
votebuffer[i] = m;
WRITEUINT16(p, m);
} }
SendNetXCmd(XD_SETUPVOTE, buf, p - buf); SendNetXCmd(XD_SETUPVOTE, buf, p - buf);

View file

@ -467,6 +467,7 @@ extern boolean comebackshowninfo;
extern tic_t curlap, bestlap; extern tic_t curlap, bestlap;
extern INT16 votelevels[5][2]; extern INT16 votelevels[5][2];
extern INT16 votebuffer[5];
extern SINT8 votes[MAXPLAYERS]; extern SINT8 votes[MAXPLAYERS];
extern SINT8 pickedvote; extern SINT8 pickedvote;

View file

@ -1068,7 +1068,7 @@ void F_TitleScreenTicker(boolean run)
return; return;
}*/ }*/
mapname = G_BuildMapName(G_RandMap(TOL_RACE, -2, false, 0, false)+1); mapname = G_BuildMapName(G_RandMap(TOL_RACE, -2, false, 0, false, NULL)+1);
numstaff = 1; numstaff = 1;
while (numstaff < 99 && (l = W_CheckNumForName(va("%sS%02u",mapname,numstaff+1))) != LUMPERROR) while (numstaff < 99 && (l = W_CheckNumForName(va("%sS%02u",mapname,numstaff+1))) != LUMPERROR)

View file

@ -779,7 +779,7 @@ const char *G_BuildMapName(INT32 map)
map = gamemap-1; map = gamemap-1;
else else
map = prevmap; map = prevmap;
map = G_RandMap(G_TOLFlag(cv_newgametype.value), map, false, 0, false)+1; map = G_RandMap(G_TOLFlag(cv_newgametype.value), map, false, 0, false, NULL)+1;
} }
if (map < 100) if (map < 100)
@ -3269,8 +3269,7 @@ static INT32 TOLMaps(INT16 tolflags)
* \author Graue <graue@oceanbase.org> * \author Graue <graue@oceanbase.org>
*/ */
static INT16 *okmaps = NULL; static INT16 *okmaps = NULL;
static INT16 votebuffer[3] = {-1, -1, -1}; INT16 G_RandMap(INT16 tolflags, INT16 pprevmap, boolean ignorebuffer, UINT8 maphell, boolean callagainsoon, INT16 *extbuffer)
INT16 G_RandMap(INT16 tolflags, INT16 pprevmap, boolean ignorebuffer, UINT8 maphell, boolean callagainsoon)
{ {
INT32 numokmaps = 0; INT32 numokmaps = 0;
INT16 ix, bufx; INT16 ix, bufx;
@ -3299,24 +3298,18 @@ tryagain:
if (!ignorebuffer) if (!ignorebuffer)
{ {
if (votebuffer[0] != -1) if (extbuffer != NULL)
{ {
if (ix == votebuffer[0]) for (bufx = 0; bufx < (INT16)(sizeof extbuffer); bufx++)
continue;
for (bufx = 1; bufx < 3; bufx++)
{ {
if (votebuffer[bufx] == -1) // Rest of buffer SHOULD be empty if (extbuffer[bufx] == -1) // Rest of buffer SHOULD be empty
break; break;
if (ix == votebuffer[bufx]) if (ix == extbuffer[bufx])
{ {
isokmap = false; isokmap = false;
break; break;
} }
} }
if (!isokmap)
continue;
} }
for (bufx = 0; bufx < (maphell ? 3 : NUMMAPS); bufx++) for (bufx = 0; bufx < (maphell ? 3 : NUMMAPS); bufx++)
@ -3351,18 +3344,18 @@ tryagain:
if (randmapbuffer[3] == -1) // Is the buffer basically empty? if (randmapbuffer[3] == -1) // Is the buffer basically empty?
{ {
ignorebuffer = true; // This will probably only help in situations where there's very few maps, but it's folly not to at least try it ignorebuffer = true; // This will probably only help in situations where there's very few maps, but it's folly not to at least try it
goto tryagain; //return G_RandMap(tolflags, pprevmap, true, maphell, callagainsoon); goto tryagain;
} }
for (bufx = 3; bufx < NUMMAPS; bufx++) // Let's clear all but the three most recent maps... for (bufx = 3; bufx < NUMMAPS; bufx++) // Let's clear all but the three most recent maps...
randmapbuffer[bufx] = -1; randmapbuffer[bufx] = -1;
goto tryagain; //return G_RandMap(tolflags, pprevmap, ignorebuffer, maphell, callagainsoon); goto tryagain;
} }
if (maphell) // Any wiggle room to loosen our restrictions here? if (maphell) // Any wiggle room to loosen our restrictions here?
{ {
maphell--; maphell--;
goto tryagain; //return G_RandMap(tolflags, pprevmap, true, maphell-1, callagainsoon); goto tryagain;
} }
ix = 0; // Sorry, none match. You get MAP01. ix = 0; // Sorry, none match. You get MAP01.
@ -3376,17 +3369,6 @@ tryagain:
{ {
Z_Free(okmaps); Z_Free(okmaps);
okmaps = NULL; 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; return ix;
@ -3548,7 +3530,7 @@ static void G_DoCompleted(void)
if (cv_advancemap.value == 0) // Stay on same map. if (cv_advancemap.value == 0) // Stay on same map.
nextmap = prevmap; nextmap = prevmap;
else if (cv_advancemap.value == 2) // Go to random map. else if (cv_advancemap.value == 2) // Go to random map.
nextmap = G_RandMap(G_TOLFlag(gametype), prevmap, false, 0, false); nextmap = G_RandMap(G_TOLFlag(gametype), prevmap, false, 0, false, NULL);
} }
// We are committed to this map now. // We are committed to this map now.

View file

@ -255,7 +255,7 @@ FUNCMATH INT32 G_TicsToMilliseconds(tic_t tics);
// Don't split up TOL handling // Don't split up TOL handling
INT16 G_TOLFlag(INT32 pgametype); INT16 G_TOLFlag(INT32 pgametype);
INT16 G_RandMap(INT16 tolflags, INT16 pprevmap, boolean ignorebuffer, UINT8 maphell, boolean callagainsoon); INT16 G_RandMap(INT16 tolflags, INT16 pprevmap, boolean ignorebuffer, UINT8 maphell, boolean callagainsoon, INT16 votebuffer[5]);
void G_AddMapToBuffer(INT16 map); void G_AddMapToBuffer(INT16 map);
#endif #endif

View file

@ -7454,7 +7454,7 @@ static void M_StartServer(INT32 choice)
G_StopMetalDemo(); G_StopMetalDemo();
if (!cv_nextmap.value) if (!cv_nextmap.value)
CV_SetValue(&cv_nextmap, G_RandMap(G_TOLFlag(cv_newgametype.value), -1, false, 0, false)+1); CV_SetValue(&cv_nextmap, G_RandMap(G_TOLFlag(cv_newgametype.value), -1, false, 0, false, NULL)+1);
if (cv_maxplayers.value < ssplayers+1) if (cv_maxplayers.value < ssplayers+1)
CV_SetValue(&cv_maxplayers, ssplayers+1); CV_SetValue(&cv_maxplayers, ssplayers+1);