Random map buffer only gets added to when

Needs another temporary buffer for the vote screen so that it doesn't roll dupes
This commit is contained in:
TehRealSalt 2018-11-20 00:13:08 -05:00
parent 9a4ebb916a
commit 5c67e22c22
5 changed files with 22 additions and 20 deletions

View File

@ -2066,6 +2066,7 @@ 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);
}
}
@ -2087,11 +2088,11 @@ void D_SetupVote(void)
for (i = 0; i < 5; i++)
{
if (i == 2) // sometimes a different gametype
WRITEUINT16(p, G_RandMap(G_TOLFlag(secondgt), prevmap, false, false, 0, true));
WRITEUINT16(p, G_RandMap(G_TOLFlag(secondgt), prevmap, false, 0, true));
else if (i >= 3) // unknown-random and force-unknown MAP HELL
WRITEUINT16(p, G_RandMap(G_TOLFlag(gametype), prevmap, true, false, (i-2), (i < 4)));
WRITEUINT16(p, G_RandMap(G_TOLFlag(gametype), prevmap, false, (i-2), (i < 4)));
else
WRITEUINT16(p, G_RandMap(G_TOLFlag(gametype), prevmap, false, false, 0, true));
WRITEUINT16(p, G_RandMap(G_TOLFlag(gametype), prevmap, false, 0, true));
}
SendNetXCmd(XD_SETUPVOTE, buf, p - buf);

View File

@ -1068,7 +1068,7 @@ void F_TitleScreenTicker(boolean run)
return;
}*/
mapname = G_BuildMapName(G_RandMap(TOL_RACE, -2, false, false, 0, false)+1);
mapname = G_BuildMapName(G_RandMap(TOL_RACE, -2, false, 0, false)+1);
numstaff = 1;
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;
else
map = prevmap;
map = G_RandMap(G_TOLFlag(cv_newgametype.value), map, false, false, 0, false)+1;
map = G_RandMap(G_TOLFlag(cv_newgametype.value), map, false, 0, false)+1;
}
if (map < 100)
@ -3268,7 +3268,7 @@ static INT32 TOLMaps(INT16 tolflags)
* \author Graue <graue@oceanbase.org>
*/
static INT16 *okmaps = NULL;
INT16 G_RandMap(INT16 tolflags, INT16 pprevmap, boolean dontadd, boolean ignorebuffer, UINT8 maphell, boolean callagainsoon)
INT16 G_RandMap(INT16 tolflags, INT16 pprevmap, boolean ignorebuffer, UINT8 maphell, boolean callagainsoon)
{
INT32 numokmaps = 0;
INT16 ix, bufx;
@ -3329,20 +3329,20 @@ tryagain:
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
goto tryagain; //return G_RandMap(tolflags, pprevmap, dontadd, true, maphell, callagainsoon);
goto tryagain; //return G_RandMap(tolflags, pprevmap, true, maphell, callagainsoon);
}
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, dontadd, ignorebuffer, maphell, callagainsoon);
goto tryagain; //return G_RandMap(tolflags, pprevmap, ignorebuffer, maphell, callagainsoon);
}
if (maphell) // Any wiggle room to loosen our restrictions here?
{
maphell--;
goto tryagain; //return G_RandMap(tolflags, pprevmap, dontadd, true, maphell-1, callagainsoon);
goto tryagain; //return G_RandMap(tolflags, pprevmap, true, maphell-1, callagainsoon);
}
ix = 0; // Sorry, none match. You get MAP01.
@ -3350,15 +3350,7 @@ tryagain:
randmapbuffer[bufx] = -1; // if we're having trouble finding a map we should probably clear it
}
else
{
ix = okmaps[M_RandomKey(numokmaps)];
if (!dontadd)
{
for (bufx = NUMMAPS-1; bufx > 0; bufx--)
randmapbuffer[bufx] = randmapbuffer[bufx-1];
randmapbuffer[0] = ix;
}
}
if (!callagainsoon)
{
@ -3369,6 +3361,14 @@ tryagain:
return ix;
}
void G_AddMapToBuffer(INT16 map)
{
INT16 bufx;
for (bufx = NUMMAPS-1; bufx > 0; bufx--)
randmapbuffer[bufx] = randmapbuffer[bufx-1];
randmapbuffer[0] = map;
}
//
// G_DoCompleted
//
@ -3519,7 +3519,7 @@ static void G_DoCompleted(void)
if (cv_advancemap.value == 0) // Stay on same map.
nextmap = prevmap;
else if (cv_advancemap.value == 2) // Go to random map.
nextmap = G_RandMap(G_TOLFlag(gametype), prevmap, false, false, 0, false);
nextmap = G_RandMap(G_TOLFlag(gametype), prevmap, false, 0, false);
}
// We are committed to this map now.

View File

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

View File

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