From 116ef8065f90eef80337634aef51e3c04a3c7d82 Mon Sep 17 00:00:00 2001 From: TehRealSalt Date: Mon, 29 Jan 2018 21:39:13 -0500 Subject: [PATCH] welp --- src/doomstat.h | 1 + src/g_game.c | 28 ++++++++++++++++++++++++++-- src/g_game.h | 1 - src/p_saveg.c | 6 ++++++ src/y_inter.c | 43 ++++++++++++------------------------------- 5 files changed, 45 insertions(+), 34 deletions(-) diff --git a/src/doomstat.h b/src/doomstat.h index a74e470b..ddd381b0 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -176,6 +176,7 @@ extern UINT32 totalrings; // Total # of rings in a level // Fun extra stuff extern INT16 lastmap; // Last level you were at (returning from special stages). +extern INT16 votelevels[4]; // srb2kart extern mobj_t *redflag, *blueflag; // Pointers to physical flags extern mapthing_t *rflagpoint, *bflagpoint; // Pointers to the flag spawn locations #define GF_REDFLAG 1 diff --git a/src/g_game.c b/src/g_game.c index 0698a7f2..2efe2293 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -120,6 +120,7 @@ tic_t gametic; tic_t levelstarttic; // gametic at level start UINT32 totalrings; // for intermission INT16 lastmap; // last level you were at (returning from special stages) +INT16 votelevels[4]; // srb2kart tic_t timeinmap; // Ticker for time spent in level (used for levelcard display) INT16 spstage_start; @@ -3088,7 +3089,7 @@ INT16 G_TOLFlag(INT32 pgametype) * has those flags. * \author Graue */ -INT16 RandMap(INT16 tolflags, INT16 pprevmap) +static INT16 RandMap(INT16 tolflags, INT16 pprevmap) { INT16 *okmaps = Z_Malloc(NUMMAPS * sizeof(INT16), PU_STATIC, NULL); INT32 numokmaps = 0; @@ -3105,7 +3106,7 @@ INT16 RandMap(INT16 tolflags, INT16 pprevmap) if (numokmaps == 0) ix = 0; // Sorry, none match. You get MAP01. else - ix = okmaps[M_RandomKey(numokmaps)]; + ix = okmaps[P_RandomKey(numokmaps)]; Z_Free(okmaps); @@ -3238,6 +3239,28 @@ static void G_DoCompleted(void) nextmap = prevmap; else if (cv_advancemap.value == 2) // Go to random map. nextmap = RandMap(G_TOLFlag(gametype), prevmap); + else if (cv_advancemap.value == 3) + { + INT32 j; + for (j = 0; j < 4; j++) + { + INT32 k; + votelevels[j] = RandMap(G_TOLFlag(gametype), prevmap); + for (k = 0; k < 4; k++) // Compare with others to make sure you don't roll multiple :V + { + INT32 loopcount = 0; + if (j == k) + continue; + while (votelevels[j] == votelevels[k] && loopcount < 4) // If this needs more than 4 loops, I think it's safe to assume it's not finding anything :VVV + { + votelevels[j] = RandMap(G_TOLFlag(gametype), prevmap); + loopcount++; + } + } + if (votelevels[j] < NUMMAPS && !mapheaderinfo[votelevels[j]]) + P_AllocMapHeader(votelevels[j]); + } + } } // We are committed to this map now. @@ -3937,6 +3960,7 @@ void G_InitNew(UINT8 pultmode, const char *mapname, boolean resetplayer, boolean // Clear a bunch of variables tokenlist = token = sstimer = redscore = bluescore = lastmap = 0; countdown = countdown2 = 0; + votelevels[0] = votelevels[1] = votelevels[2] = votelevels[3] = 0; for (i = 0; i < MAXPLAYERS; i++) { diff --git a/src/g_game.h b/src/g_game.h index f6e62ea7..832a8e0c 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -219,6 +219,5 @@ FUNCMATH INT32 G_TicsToMilliseconds(tic_t tics); // Don't split up TOL handling INT16 G_TOLFlag(INT32 pgametype); -INT16 RandMap(INT16 tolflags, INT16 pprevmap); #endif diff --git a/src/p_saveg.c b/src/p_saveg.c index 012f2888..438ed1da 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -3202,6 +3202,9 @@ static void P_NetArchiveMisc(void) WRITEUINT32(save_p, totalrings); WRITEINT16(save_p, lastmap); + for (i = 0; i < 4; i++) + WRITEINT16(save_p, votelevels[i]); + WRITEUINT16(save_p, emeralds); WRITEUINT8(save_p, stagefailed); @@ -3285,6 +3288,9 @@ static inline boolean P_NetUnArchiveMisc(void) totalrings = READUINT32(save_p); lastmap = READINT16(save_p); + for (i = 0; i < 4; i++) + votelevels[i] = READINT16(save_p); + emeralds = READUINT16(save_p); stagefailed = READUINT8(save_p); diff --git a/src/y_inter.c b/src/y_inter.c index 258c1e96..785047d2 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -172,7 +172,6 @@ typedef struct { char str[40]; patch_t *pic; - UINT16 num; } y_votelvlinfo_t; typedef struct @@ -2293,14 +2292,14 @@ void Y_VoteTicker(void) if (votedata.playerinfo[i].voted) continue; - if (votedata.timeleft <= 0 && !votedata.playerinfo[i].voted) + /*if (votedata.timeleft <= 0 && !votedata.playerinfo[i].voted) { votedata.votes[votedata.numvotes].level = 3; // too slow? you pick random votedata.votes[votedata.numvotes].playernum = i; votedata.playerinfo[i].voted = true; votedata.numvotes++; continue; - } + }*/ if (votedata.playerinfo[i].delay > 0) { @@ -2348,7 +2347,7 @@ void Y_VoteTicker(void) if (votedata.timeleft == 0 && voteendtic == -1) { votedata.pickedvote = P_RandomKey(votedata.numvotes); - nextmap = (votedata.levels[votedata.votes[votedata.pickedvote].level].num); // oh my god + nextmap = (votelevels[votedata.votes[votedata.pickedvote].level]); // oh my god S_StartSound(NULL, sfx_ncitem); voteendtic = votetic+(3*TICRATE); } @@ -2393,59 +2392,41 @@ void Y_StartVote(void) for (i = 0; i < 4; i++) { - INT32 j; lumpnum_t lumpnum; - votedata.levels[i].num = RandMap(G_TOLFlag(gametype), prevmap); - - for (j = 0; j < 4; j++) - { - INT32 loopcount = 0; - if (i == j) - continue; - while (votedata.levels[i].num == votedata.levels[j].num && loopcount < 5) - { - votedata.levels[i].num = RandMap(G_TOLFlag(gametype), prevmap); - loopcount++; - } - } - - if (!mapheaderinfo[votedata.levels[i].num]) - P_AllocMapHeader(votedata.levels[i].num); - // set up the str - if (mapheaderinfo[votedata.levels[i].num]->zonttl) + if (mapheaderinfo[votelevels[i]]->zonttl) { - if (mapheaderinfo[votedata.levels[i].num]->actnum) + if (mapheaderinfo[votelevels[i]]->actnum) snprintf(votedata.levels[i].str, sizeof votedata.levels[i].str, "%.32s %.32s %d", - mapheaderinfo[votedata.levels[i].num]->lvlttl, mapheaderinfo[votedata.levels[i].num]->zonttl, mapheaderinfo[votedata.levels[i].num]->actnum); + mapheaderinfo[votelevels[i]]->lvlttl, mapheaderinfo[votelevels[i]]->zonttl, mapheaderinfo[votelevels[i]]->actnum); else snprintf(votedata.levels[i].str, sizeof votedata.levels[i].str, "%.32s %.32s", - mapheaderinfo[votedata.levels[i].num]->lvlttl, mapheaderinfo[votedata.levels[i].num]->zonttl); + mapheaderinfo[votelevels[i]]->lvlttl, mapheaderinfo[votelevels[i]]->zonttl); } else { - if (mapheaderinfo[votedata.levels[i].num]->actnum) + if (mapheaderinfo[votelevels[i]]->actnum) snprintf(votedata.levels[i].str, sizeof votedata.levels[i].str, "%.32s %d", - mapheaderinfo[votedata.levels[i].num]->lvlttl, mapheaderinfo[votedata.levels[i].num]->actnum); + mapheaderinfo[votelevels[i]]->lvlttl, mapheaderinfo[votelevels[i]]->actnum); else snprintf(votedata.levels[i].str, sizeof votedata.levels[i].str, "%.32s", - mapheaderinfo[votedata.levels[i].num]->lvlttl); + mapheaderinfo[votelevels[i]]->lvlttl); } votedata.levels[i].str[sizeof votedata.levels[i].str - 1] = '\0'; - lumpnum = W_CheckNumForName(va("%sP", G_BuildMapName(votedata.levels[i].num+1))); + lumpnum = W_CheckNumForName(va("%sP", G_BuildMapName(votelevels[i]+1))); if (lumpnum != LUMPERROR) - votedata.levels[i].pic = W_CachePatchName(va("%sP", G_BuildMapName(votedata.levels[i].num+1)), PU_STATIC); + votedata.levels[i].pic = W_CachePatchName(va("%sP", G_BuildMapName(votelevels[i]+1)), PU_STATIC); else votedata.levels[i].pic = W_CachePatchName("BLANKLVL", PU_STATIC); }