Everything

Been a while since I synced :V
This commit is contained in:
TehRealSalt 2018-02-03 23:47:47 -05:00
parent 58da420e30
commit b20e2d55eb
9 changed files with 368 additions and 168 deletions

View File

@ -63,6 +63,8 @@ static void Got_WeaponPref(UINT8 **cp, INT32 playernum);
static void Got_Mapcmd(UINT8 **cp, INT32 playernum); static void Got_Mapcmd(UINT8 **cp, INT32 playernum);
static void Got_ExitLevelcmd(UINT8 **cp, INT32 playernum); static void Got_ExitLevelcmd(UINT8 **cp, INT32 playernum);
static void Got_SetupVotecmd(UINT8 **cp, INT32 playernum); static void Got_SetupVotecmd(UINT8 **cp, INT32 playernum);
static void Got_ModifyVotecmd(UINT8 **cp, INT32 playernum);
static void Got_PickVotecmd(UINT8 **cp, INT32 playernum);
static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum); static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum);
#ifdef DELFILE #ifdef DELFILE
static void Got_Delfilecmd(UINT8 **cp, INT32 playernum); static void Got_Delfilecmd(UINT8 **cp, INT32 playernum);
@ -475,6 +477,8 @@ const char *netxcmdnames[MAXNETXCMD - 1] =
"SUICIDE", "SUICIDE",
"DEMOTED", "DEMOTED",
"SETUPVOTE", "SETUPVOTE",
"MODIFYVOTE",
"PICKVOTE",
#ifdef HAVE_BLUA #ifdef HAVE_BLUA
"LUACMD", "LUACMD",
"LUAVAR" "LUAVAR"
@ -504,11 +508,14 @@ void D_RegisterServerCommands(void)
RegisterNetXCmd(XD_PAUSE, Got_Pause); RegisterNetXCmd(XD_PAUSE, Got_Pause);
RegisterNetXCmd(XD_SUICIDE, Got_Suicide); RegisterNetXCmd(XD_SUICIDE, Got_Suicide);
RegisterNetXCmd(XD_RUNSOC, Got_RunSOCcmd); RegisterNetXCmd(XD_RUNSOC, Got_RunSOCcmd);
RegisterNetXCmd(XD_SETUPVOTE, Got_SetupVotecmd);
#ifdef HAVE_BLUA #ifdef HAVE_BLUA
RegisterNetXCmd(XD_LUACMD, Got_Luacmd); RegisterNetXCmd(XD_LUACMD, Got_Luacmd);
#endif #endif
RegisterNetXCmd(XD_SETUPVOTE, Got_SetupVotecmd);
RegisterNetXCmd(XD_MODIFYVOTE, Got_ModifyVotecmd);
RegisterNetXCmd(XD_PICKVOTE, Got_PickVotecmd);
// Remote Administration // Remote Administration
COM_AddCommand("password", Command_Changepassword_f); COM_AddCommand("password", Command_Changepassword_f);
RegisterNetXCmd(XD_LOGIN, Got_Login); RegisterNetXCmd(XD_LOGIN, Got_Login);
@ -1950,34 +1957,51 @@ void D_SetupVote(void)
{ {
XBOXSTATIC char buf[8]; XBOXSTATIC char buf[8];
char *p; char *p;
UINT16 maps[4];
INT32 i; INT32 i;
p = buf; p = buf;
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ WRITEUINT16(p, G_RandMap(G_TOLFlag(gametype), prevmap, false));
INT32 j;
maps[i] = RandMap(G_TOLFlag(gametype), prevmap);
for (j = 0; j < 4; j++) // Compare with others to make sure you don't roll duplicates
{
INT32 loops = 0;
if (j >= i)
continue;
while (maps[i] == maps[j] && loops < 4) // If this needs more than 4 loops, I think it's safe to assume it's not finding any suitable matches :V
{
maps[i] = RandMap(G_TOLFlag(gametype), prevmap);
loops++;
}
}
WRITEUINT16(p, maps[i]);
}
SendNetXCmd(XD_SETUPVOTE, buf, p - buf); SendNetXCmd(XD_SETUPVOTE, buf, p - buf);
} }
void D_ModifyClientVote(INT8 voted)
{
XBOXSTATIC UINT8 buf[1];
buf[0] = (UINT8)(voted+1);
SendNetXCmd(XD_MODIFYVOTE, &buf, 1);
}
void D_PickVote(void)
{
XBOXSTATIC UINT8 buf[2];
UINT8 temppicks[MAXPLAYERS];
UINT8 templevels[MAXPLAYERS];
UINT8 numvotes = 0, key = 0;
INT32 i;
for (i = 0; i < MAXPLAYERS; i++)
{
if (!playeringame[i] || players[i].spectator)
continue;
if (votes[i] != -1)
{
temppicks[numvotes] = (UINT8)i;
templevels[numvotes] = (UINT8)votes[i];
numvotes++;
}
}
key = P_RandomKey(numvotes);
buf[0] = temppicks[key];
buf[1] = templevels[key];
SendNetXCmd(XD_PICKVOTE, &buf, 2);
}
// Warp to map code. // Warp to map code.
// Called either from map <mapname> console command, or idclev cheat. // Called either from map <mapname> console command, or idclev cheat.
// //
@ -4557,12 +4581,44 @@ static void Got_SetupVotecmd(UINT8 **cp, INT32 playernum)
} }
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{
votelevels[i] = (INT16)READUINT16(*cp); votelevels[i] = (INT16)READUINT16(*cp);
if (!mapheaderinfo[votelevels[i]])
P_AllocMapHeader(votelevels[i]);
}
G_SetGamestate(GS_VOTING); G_SetGamestate(GS_VOTING);
Y_StartVote(); Y_StartVote();
} }
static void Got_ModifyVotecmd(UINT8 **cp, INT32 playernum)
{
INT8 voted = READUINT8(*cp);
votes[playernum] = (INT8)(voted-1);
}
static void Got_PickVotecmd(UINT8 **cp, INT32 playernum)
{
INT8 pick = READUINT8(*cp);
INT8 level = READUINT8(*cp);
if (playernum != serverplayer && !IsPlayerAdmin(playernum))
{
CONS_Alert(CONS_WARNING, M_GetText("Illegal vote setup received from %s\n"), player_names[playernum]);
if (server)
{
XBOXSTATIC UINT8 buf[2];
buf[0] = (UINT8)playernum;
buf[1] = KICK_MSG_CON_FAIL;
SendNetXCmd(XD_KICK, &buf, 2);
}
return;
}
Y_SetupVoteFinish((INT8)pick, (INT8)level);
}
/** Prints the number of the displayplayer. /** Prints the number of the displayplayer.
* *
* \todo Possibly remove this; it was useful for debugging at one point. * \todo Possibly remove this; it was useful for debugging at one point.

View File

@ -192,9 +192,11 @@ typedef enum
XD_SUICIDE, // 20 XD_SUICIDE, // 20
XD_DEMOTED, // 21 XD_DEMOTED, // 21
XD_SETUPVOTE, // 22 XD_SETUPVOTE, // 22
XD_MODIFYVOTE, // 23
XD_PICKVOTE, // 24
#ifdef HAVE_BLUA #ifdef HAVE_BLUA
XD_LUACMD, // 23 XD_LUACMD, // 25
XD_LUAVAR, // 24 XD_LUAVAR, // 26
#endif #endif
MAXNETXCMD MAXNETXCMD
} netxcmd_t; } netxcmd_t;
@ -250,6 +252,8 @@ void Command_Retry_f(void);
void D_GameTypeChanged(INT32 lastgametype); // not a real _OnChange function anymore void D_GameTypeChanged(INT32 lastgametype); // not a real _OnChange function anymore
void D_MapChange(INT32 pmapnum, INT32 pgametype, boolean pultmode, boolean presetplayers, INT32 pdelay, boolean pskipprecutscene, boolean pfromlevelselect); void D_MapChange(INT32 pmapnum, INT32 pgametype, boolean pultmode, boolean presetplayers, INT32 pdelay, boolean pskipprecutscene, boolean pfromlevelselect);
void D_SetupVote(void); void D_SetupVote(void);
void D_ModifyClientVote(INT8 voted);
void D_PickVote(void);
void ObjectPlace_OnChange(void); void ObjectPlace_OnChange(void);
boolean IsPlayerAdmin(INT32 playernum); boolean IsPlayerAdmin(INT32 playernum);
void SetAdminPlayer(INT32 playernum); void SetAdminPlayer(INT32 playernum);

View File

@ -7338,7 +7338,6 @@ static const char *const KARTSTUFF_LIST[] = {
"LAKITU", "LAKITU",
"THROWDIR", "THROWDIR",
"CAMSPIN",
"LAPANIMATION", "LAPANIMATION",
"CARDANIMATION", "CARDANIMATION",
"SOUNDS", "SOUNDS",

View File

@ -176,7 +176,6 @@ extern UINT32 totalrings; // Total # of rings in a level
// Fun extra stuff // Fun extra stuff
extern INT16 lastmap; // Last level you were at (returning from special stages). 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 mobj_t *redflag, *blueflag; // Pointers to physical flags
extern mapthing_t *rflagpoint, *bflagpoint; // Pointers to the flag spawn locations extern mapthing_t *rflagpoint, *bflagpoint; // Pointers to the flag spawn locations
#define GF_REDFLAG 1 #define GF_REDFLAG 1
@ -445,9 +444,14 @@ extern UINT8 gamespeed;
extern boolean franticitems; extern boolean franticitems;
extern boolean mirrormode; extern boolean mirrormode;
extern boolean comeback; extern boolean comeback;
extern tic_t curlap, bestlap; extern tic_t curlap, bestlap;
extern boolean legitimateexit; extern boolean legitimateexit;
extern INT16 votelevels[4];
extern INT8 votes[MAXPLAYERS];
extern INT8 pickedvote;
extern tic_t hidetime; extern tic_t hidetime;
extern UINT32 timesBeaten; // # of times the game has been beaten. extern UINT32 timesBeaten; // # of times the game has been beaten.

View File

@ -120,7 +120,6 @@ tic_t gametic;
tic_t levelstarttic; // gametic at level start tic_t levelstarttic; // gametic at level start
UINT32 totalrings; // for intermission UINT32 totalrings; // for intermission
INT16 lastmap; // last level you were at (returning from special stages) 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) tic_t timeinmap; // Ticker for time spent in level (used for levelcard display)
INT16 spstage_start; INT16 spstage_start;
@ -251,6 +250,13 @@ boolean legitimateexit; // Did this client actually finish the match? Calculated
tic_t curlap; // Current lap time, calculated locally tic_t curlap; // Current lap time, calculated locally
tic_t bestlap; // Best lap time, locally tic_t bestlap; // Best lap time, locally
INT16 randmapbuffer[3*NUMMAPS/4]; // Buffer for maps RandMap is allowed to roll
// Voting system
INT16 votelevels[4]; // Levels that were rolled by the host
INT8 votes[MAXPLAYERS]; // Each player's vote
INT8 pickedvote; // What vote the host rolls
tic_t hidetime; tic_t hidetime;
// Grading // Grading
@ -3081,6 +3087,24 @@ INT16 G_TOLFlag(INT32 pgametype)
return INT16_MAX; return INT16_MAX;
} }
static INT32 TOLMaps(INT16 tolflags)
{
INT32 num = 0;
INT16 i;
// Find all the maps that are ok and and put them in an array.
for (i = 0; i < NUMMAPS; i++)
{
if (!mapheaderinfo[i])
continue;
if ((mapheaderinfo[i]->typeoflevel & tolflags) == tolflags)
num++;
}
return num;
}
/** Select a random map with the given typeoflevel flags. /** Select a random map with the given typeoflevel flags.
* If no map has those flags, this arbitrarily gives you map 1. * If no map has those flags, this arbitrarily gives you map 1.
* \param tolflags The typeoflevel flags to insist on. Other bits may * \param tolflags The typeoflevel flags to insist on. Other bits may
@ -3089,24 +3113,59 @@ INT16 G_TOLFlag(INT32 pgametype)
* has those flags. * has those flags.
* \author Graue <graue@oceanbase.org> * \author Graue <graue@oceanbase.org>
*/ */
INT16 RandMap(INT16 tolflags, INT16 pprevmap) INT16 G_RandMap(INT16 tolflags, INT16 pprevmap, boolean ignorebuffer)
{ {
INT16 *okmaps = Z_Malloc(NUMMAPS * sizeof(INT16), PU_STATIC, NULL); INT16 *okmaps = Z_Malloc(NUMMAPS * sizeof(INT16), PU_STATIC, NULL);
INT32 numokmaps = 0; INT32 numokmaps = 0;
INT16 ix; INT16 ix, bufx;
// Find all the maps that are ok and and put them in an array. // Find all the maps that are ok and and put them in an array.
for (ix = 0; ix < NUMMAPS; ix++) for (ix = 0; ix < NUMMAPS; ix++)
if (mapheaderinfo[ix] && (mapheaderinfo[ix]->typeoflevel & tolflags) == tolflags {
&& ix != pprevmap // Don't pick the same map. boolean isokmap = true;
&& (dedicated || !M_MapLocked(ix+1)) // Don't pick locked maps.
) if (!mapheaderinfo[ix])
continue;
if ((mapheaderinfo[ix]->typeoflevel & tolflags) != tolflags
|| ix == pprevmap
|| (M_MapLocked(ix+1) && !dedicated))
isokmap = false;
if (!ignorebuffer)
{
for (bufx = 0; bufx < 3*NUMMAPS/4; bufx++)
{
if (randmapbuffer[bufx] == 0) // Rest of buffer SHOULD be empty
break;
if (ix == randmapbuffer[bufx])
{
isokmap = false;
break;
}
}
}
if (isokmap)
okmaps[numokmaps++] = ix; okmaps[numokmaps++] = ix;
}
if (numokmaps == 0) if (numokmaps == 0)
{
if (!ignorebuffer)
return G_RandMap(tolflags, pprevmap, true); // If there's no matches, (An incredibly silly function chain, buuut... :V)
ix = 0; // Sorry, none match. You get MAP01. ix = 0; // Sorry, none match. You get MAP01.
for (bufx = 0; bufx < 3*NUMMAPS/4; bufx++)
randmapbuffer[bufx] = -1; // if we're having trouble finding a map we should probably clear it
}
else else
{
ix = okmaps[P_RandomKey(numokmaps)]; ix = okmaps[P_RandomKey(numokmaps)];
for (bufx = 3*NUMMAPS/4; bufx > 0; bufx--)
randmapbuffer[bufx] = randmapbuffer[bufx-1];
randmapbuffer[0] = ix;
}
Z_Free(okmaps); Z_Free(okmaps);
@ -3233,12 +3292,18 @@ static void G_DoCompleted(void)
automapactive = false; automapactive = false;
if (randmapbuffer[(3*TOLMaps(G_TOLFlag(gametype))/4)]) // filled up, so lets clear it
{
for (i = 0; i < 3*NUMMAPS/4; i++)
randmapbuffer[i] = -1;
}
if (gametype != GT_COOP) if (gametype != GT_COOP)
{ {
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 = RandMap(G_TOLFlag(gametype), prevmap); nextmap = G_RandMap(G_TOLFlag(gametype), prevmap, false);
} }
// We are committed to this map now. // We are committed to this map now.
@ -3935,7 +4000,6 @@ void G_InitNew(UINT8 pultmode, const char *mapname, boolean resetplayer, boolean
// Clear a bunch of variables // Clear a bunch of variables
tokenlist = token = sstimer = redscore = bluescore = lastmap = 0; tokenlist = token = sstimer = redscore = bluescore = lastmap = 0;
countdown = countdown2 = 0; countdown = countdown2 = 0;
votelevels[0] = votelevels[1] = votelevels[2] = votelevels[3] = 0;
for (i = 0; i < MAXPLAYERS; i++) for (i = 0; i < MAXPLAYERS; i++)
{ {

View File

@ -219,6 +219,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 RandMap(INT16 tolflags, INT16 pprevmap);
INT16 G_RandMap(INT16 tolflags, INT16 pprevmap, boolean ignorebuffer);
#endif #endif

View File

@ -3205,6 +3205,11 @@ static void P_NetArchiveMisc(void)
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
WRITEINT16(save_p, votelevels[i]); WRITEINT16(save_p, votelevels[i]);
for (i = 0; i < MAXPLAYERS; i++)
WRITESINT8(save_p, votes[i]);
WRITESINT8(save_p, pickedvote);
WRITEUINT16(save_p, emeralds); WRITEUINT16(save_p, emeralds);
WRITEUINT8(save_p, stagefailed); WRITEUINT8(save_p, stagefailed);
@ -3291,6 +3296,11 @@ static inline boolean P_NetUnArchiveMisc(void)
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
votelevels[i] = READINT16(save_p); votelevels[i] = READINT16(save_p);
for (i = 0; i < MAXPLAYERS; i++)
votes[i] = READSINT8(save_p);
pickedvote = READSINT8(save_p);
emeralds = READUINT16(save_p); emeralds = READUINT16(save_p);
stagefailed = READUINT8(save_p); stagefailed = READUINT8(save_p);

View File

@ -36,7 +36,8 @@
#include "m_cond.h" // condition sets #include "m_cond.h" // condition sets
#include "m_random.h" // M_RandomKey #include "m_random.h" // P_RandomKey
#include "g_input.h" // PLAYER1INPUTDOWN
#ifdef HWRENDER #ifdef HWRENDER
#include "hardware/hw_main.h" #include "hardware/hw_main.h"
@ -172,34 +173,17 @@ typedef struct
{ {
char str[40]; char str[40];
patch_t *pic; patch_t *pic;
} y_votelvlinfo_t; } y_votelvlinfo;
typedef struct typedef struct
{ {
UINT8 *color;
INT32 *character;
UINT8 delay;
INT8 selection; INT8 selection;
boolean voted; UINT8 delay;
} y_voteplayers_t; } y_voteclient;
typedef struct static y_votelvlinfo levelinfo[4];
{ static y_voteclient voteclient;
UINT8 level; // 0 to 3; 3 is random static UINT8 randomanim = 0;
UINT8 playernum;
} y_vote_t;
typedef struct
{
y_votelvlinfo_t levels[4];
y_voteplayers_t playerinfo[MAXPLAYERS];
y_vote_t votes[MAXPLAYERS]; // votes have their own struct instead of being attached to the player so they can be listed in order
UINT8 numvotes;
INT32 timeleft;
INT8 pickedvote;
} y_votedata;
static y_votedata votedata;
static INT32 votetic; static INT32 votetic;
static INT32 voteendtic = -1; static INT32 voteendtic = -1;
static patch_t *cursor = NULL; static patch_t *cursor = NULL;
@ -2174,13 +2158,13 @@ void Y_VoteDrawer(void)
} }
else else
{ {
strcpy(str, votedata.levels[i].str); strcpy(str, levelinfo[i].str);
pic = votedata.levels[i].pic; pic = levelinfo[i].pic;
} }
if (i == votedata.playerinfo[consoleplayer].selection) if (i == voteclient.selection)
{ {
if (!votedata.playerinfo[consoleplayer].voted) if (votes[consoleplayer] == -1)
{ {
V_DrawScaledPatch(BASEVIDWIDTH-124, y+21, V_SNAPTORIGHT, cursor); V_DrawScaledPatch(BASEVIDWIDTH-124, y+21, V_SNAPTORIGHT, cursor);
if (votetic % 4 > 1) if (votetic % 4 > 1)
@ -2202,18 +2186,18 @@ void Y_VoteDrawer(void)
x = 20; x = 20;
y = 15; y = 15;
if (votedata.numvotes > 0) for (i = 0; i < MAXPLAYERS; i++)
{ {
for (i = 0; i < votedata.numvotes; i++) if (votes[i] != -1)
{ {
patch_t *pic; patch_t *pic;
if (votedata.votes[i].level == 3 && i != votedata.pickedvote) if ((votes[i] == 3 && i != pickedvote) || voteendtic-votetic > 3*TICRATE)
pic = randomlvl; pic = randomlvl;
else else
pic = votedata.levels[votedata.votes[i].level].pic; pic = levelinfo[votes[i]].pic;
if (i == votedata.pickedvote) if (!timer && i == randomanim)
{ {
V_DrawScaledPatch(x-18, y+9, V_SNAPTOLEFT, cursor); V_DrawScaledPatch(x-18, y+9, V_SNAPTOLEFT, cursor);
if (votetic % 4 > 1) if (votetic % 4 > 1)
@ -2224,27 +2208,42 @@ void Y_VoteDrawer(void)
V_DrawTinyScaledPatch(x, y, V_SNAPTOLEFT, pic); V_DrawTinyScaledPatch(x, y, V_SNAPTOLEFT, pic);
if (votedata.playerinfo[votedata.votes[i].playernum].color == 0) if (players[i].skincolor == 0)
V_DrawSmallScaledPatch(x+24, y+9, V_SNAPTOLEFT, faceprefix[*votedata.playerinfo[votedata.votes[i].playernum].character]); V_DrawSmallScaledPatch(x+24, y+9, V_SNAPTOLEFT, faceprefix[players[i].skin]);
else else
{ {
UINT8 *colormap = R_GetTranslationColormap(*votedata.playerinfo[votedata.votes[i].playernum].character, *votedata.playerinfo[votedata.votes[i].playernum].color, GTC_CACHE); UINT8 *colormap = R_GetTranslationColormap(players[i].skin, players[i].skincolor, GTC_CACHE);
V_DrawSmallMappedPatch(x+24, y+9, V_SNAPTOLEFT, faceprefix[*votedata.playerinfo[votedata.votes[i].playernum].character], colormap); V_DrawSmallMappedPatch(x+24, y+9, V_SNAPTOLEFT, faceprefix[players[i].skin], colormap);
} }
}
y += 30; if (splitscreen) // only 1p has a vote in splitscreen
break;
if (y > BASEVIDHEIGHT-38) y += 30;
{
x += 20; if (y > BASEVIDHEIGHT-38)
y = 15; {
} x += 100;
y = 15;
} }
} }
if (votedata.timeleft) //V_DrawScaledPatch(x, y, V_SNAPTOBOTTOM, pic);
V_DrawCenteredString(BASEVIDWIDTH/2, 188, V_YELLOWMAP|V_SNAPTOBOTTOM,
va("Vote ends in %d seconds", votedata.timeleft/TICRATE)); if (timer)
{
if (votes[consoleplayer] == -1)
{
V_DrawCenteredString(BASEVIDWIDTH/2, 188, V_YELLOWMAP|V_SNAPTOBOTTOM,
va("Vote ends in %d seconds", timer/TICRATE));
}
else
{
V_DrawCenteredString(BASEVIDWIDTH/2, 188, V_YELLOWMAP|V_SNAPTOBOTTOM,
va("Waiting for everyone to vote..."));
}
}
} }
// //
@ -2254,11 +2253,9 @@ void Y_VoteDrawer(void)
// //
void Y_VoteTicker(void) void Y_VoteTicker(void)
{ {
UINT8 numplayers; boolean pressed = false;
INT32 i; INT32 i;
numplayers = 0;
if (paused || P_AutoPause()) if (paused || P_AutoPause())
return; return;
@ -2271,85 +2268,123 @@ void Y_VoteTicker(void)
return; return;
} }
for (i = 0; i < MAXPLAYERS; i++) // Correct votes as early as possible, before they're processed by the game at all
{
if (!playeringame[i] || players[i].spectator)
votes[i] = -1;
else if (pickedvote != -1 && votes[i] == -1)
votes[i] = 3; // Slow people get random
}
if (server && votes[pickedvote] == -1) // Uh oh! The person who got picked left! Recalculate, quick!
D_PickVote();
if (!votetic) if (!votetic)
S_ChangeMusicInternal("racent", true); S_ChangeMusicInternal("racent", true);
if (votetic < TICRATE) // give it some time before letting you control it :V if (timer)
return; timer--;
if (votedata.timeleft > 0) if (voteclient.delay)
votedata.timeleft--; voteclient.delay--;
for (i = 0; i < MAXPLAYERS; i++) if (pickedvote != -1)
{ {
boolean pressed = false; timer = 0;
if (!playeringame[i] || players[i].spectator) if (voteendtic == -1)
continue; return;
numplayers++; if (voteendtic-votetic > 3*TICRATE)
if (votedata.playerinfo[i].voted)
continue;
/*if (votedata.timeleft <= 0 && !votedata.playerinfo[i].voted)
{ {
votedata.votes[votedata.numvotes].level = 3; // too slow? you pick random UINT8 tempvotes[MAXPLAYERS];
votedata.votes[votedata.numvotes].playernum = i; UINT8 numvotes = 0;
votedata.playerinfo[i].voted = true;
votedata.numvotes++;
continue;
}*/
if (votedata.playerinfo[i].delay > 0) if (votetic % (TICRATE/7) != 0)
{ return;
votedata.playerinfo[i].delay--;
continue; for (i = 0; i < MAXPLAYERS; i++)
{
if (votes[i] == -1)
continue;
tempvotes[numvotes] = i;
numvotes++;
}
randomanim = tempvotes[((pickedvote - ((voteendtic-votetic) / (TICRATE/7))) % numvotes)];
S_StartSound(NULL, sfx_menu1);
} }
else
if (players[i].cmd.buttons & BT_FORWARD && !pressed)
{ {
votedata.playerinfo[i].selection--; randomanim = pickedvote;
pressed = true; if (voteendtic-votetic == 3*TICRATE-1)
S_StartSound(NULL, sfx_ncitem);
} }
}
else
{
if (votetic < 3*(NEWTICRATE/7)) // give it some time before letting you control it :V
return;
if (players[i].cmd.buttons & BT_BACKWARD && !pressed) if ((!playeringame[consoleplayer] || players[consoleplayer].spectator) && votes[consoleplayer] != -1)
D_ModifyClientVote(-1);
else if (pickedvote == -1 && votes[consoleplayer] == -1 && !voteclient.delay)
{ {
votedata.playerinfo[i].selection++; if (PLAYER1INPUTDOWN(gc_aimforward))
pressed = true; {
} voteclient.selection--;
pressed = true;
if (votedata.playerinfo[i].selection < 0) }
votedata.playerinfo[i].selection = 3; if (PLAYER1INPUTDOWN(gc_aimbackward) && !pressed)
if (votedata.playerinfo[i].selection > 3) {
votedata.playerinfo[i].selection = 0; voteclient.selection++;
pressed = true;
if (players[i].cmd.buttons & BT_ACCELERATE && !pressed) }
{ if (voteclient.selection < 0)
votedata.votes[votedata.numvotes].level = votedata.playerinfo[i].selection; voteclient.selection = 3;
votedata.votes[votedata.numvotes].playernum = i; if (voteclient.selection > 3)
votedata.playerinfo[i].voted = true; voteclient.selection = 0;
pressed = true; if (PLAYER1INPUTDOWN(gc_accelerate) && !pressed)
votedata.numvotes++; {
D_ModifyClientVote(voteclient.selection);
pressed = true;
}
} }
if (pressed) if (pressed)
{ {
if (i == consoleplayer) S_StartSound(NULL, sfx_menu1);
S_StartSound(NULL, sfx_menu1); voteclient.delay = NEWTICRATE/7;
votedata.playerinfo[i].delay = 3;
} }
}
if (votedata.numvotes >= numplayers) if (server)
votedata.timeleft = 0; {
UINT8 numplayers = 0, numvotes = 0;
if (votedata.timeleft == 0 && voteendtic == -1) if (splitscreen)
{ {
votedata.pickedvote = P_RandomKey(votedata.numvotes); numplayers = 1;
nextmap = (votelevels[votedata.votes[votedata.pickedvote].level]); // oh my god if (votes[0] != -1)
S_StartSound(NULL, sfx_ncitem); numvotes = 1;
voteendtic = votetic+(3*TICRATE); }
else
{
for (i = 0; i < MAXPLAYERS; i++)
{
if (!playeringame[i] || players[i].spectator)
continue;
numplayers++;
if (votes[i] != -1)
numvotes++;
}
}
if (numvotes >= numplayers)
timer = 0;
if (timer == 0 && voteendtic == -1)
D_PickVote();
}
} }
} }
@ -2374,21 +2409,15 @@ void Y_StartVote(void)
cursor = W_CachePatchName("M_CURSOR", PU_STATIC); cursor = W_CachePatchName("M_CURSOR", PU_STATIC);
randomlvl = W_CachePatchName("RANDOMLV", PU_STATIC); randomlvl = W_CachePatchName("RANDOMLV", PU_STATIC);
votedata.timeleft = cv_votetime.value*TICRATE; timer = cv_votetime.value*TICRATE;
votedata.numvotes = 0; pickedvote = -1;
votedata.pickedvote = -1; randomanim = 0;
voteclient.selection = 0;
voteclient.delay = 0;
for (i = 0; i < MAXPLAYERS; i++) for (i = 0; i < MAXPLAYERS; i++)
{ votes[i] = -1;
votedata.playerinfo[i].color = &players[i].skincolor;
votedata.playerinfo[i].character = &players[i].skin;
votedata.playerinfo[i].delay = 0;
votedata.playerinfo[i].selection = 0;
votedata.playerinfo[i].voted = false;
votedata.votes[i].level = 0;
votedata.votes[i].playernum = 0;
}
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
@ -2398,37 +2427,37 @@ void Y_StartVote(void)
if (mapheaderinfo[votelevels[i]]->zonttl) if (mapheaderinfo[votelevels[i]]->zonttl)
{ {
if (mapheaderinfo[votelevels[i]]->actnum) if (mapheaderinfo[votelevels[i]]->actnum)
snprintf(votedata.levels[i].str, snprintf(levelinfo[i].str,
sizeof votedata.levels[i].str, sizeof levelinfo[i].str,
"%.32s %.32s %d", "%.32s %.32s %d",
mapheaderinfo[votelevels[i]]->lvlttl, mapheaderinfo[votelevels[i]]->zonttl, mapheaderinfo[votelevels[i]]->actnum); mapheaderinfo[votelevels[i]]->lvlttl, mapheaderinfo[votelevels[i]]->zonttl, mapheaderinfo[votelevels[i]]->actnum);
else else
snprintf(votedata.levels[i].str, snprintf(levelinfo[i].str,
sizeof votedata.levels[i].str, sizeof levelinfo[i].str,
"%.32s %.32s", "%.32s %.32s",
mapheaderinfo[votelevels[i]]->lvlttl, mapheaderinfo[votelevels[i]]->zonttl); mapheaderinfo[votelevels[i]]->lvlttl, mapheaderinfo[votelevels[i]]->zonttl);
} }
else else
{ {
if (mapheaderinfo[votelevels[i]]->actnum) if (mapheaderinfo[votelevels[i]]->actnum)
snprintf(votedata.levels[i].str, snprintf(levelinfo[i].str,
sizeof votedata.levels[i].str, sizeof levelinfo[i].str,
"%.32s %d", "%.32s %d",
mapheaderinfo[votelevels[i]]->lvlttl, mapheaderinfo[votelevels[i]]->actnum); mapheaderinfo[votelevels[i]]->lvlttl, mapheaderinfo[votelevels[i]]->actnum);
else else
snprintf(votedata.levels[i].str, snprintf(levelinfo[i].str,
sizeof votedata.levels[i].str, sizeof levelinfo[i].str,
"%.32s", "%.32s",
mapheaderinfo[votelevels[i]]->lvlttl); mapheaderinfo[votelevels[i]]->lvlttl);
} }
votedata.levels[i].str[sizeof votedata.levels[i].str - 1] = '\0'; levelinfo[i].str[sizeof levelinfo[i].str - 1] = '\0';
lumpnum = W_CheckNumForName(va("%sP", G_BuildMapName(votelevels[i]+1))); lumpnum = W_CheckNumForName(va("%sP", G_BuildMapName(votelevels[i]+1)));
if (lumpnum != LUMPERROR) if (lumpnum != LUMPERROR)
votedata.levels[i].pic = W_CachePatchName(va("%sP", G_BuildMapName(votelevels[i]+1)), PU_STATIC); levelinfo[i].pic = W_CachePatchName(va("%sP", G_BuildMapName(votelevels[i]+1)), PU_STATIC);
else else
votedata.levels[i].pic = W_CachePatchName("BLANKLVL", PU_STATIC); levelinfo[i].pic = W_CachePatchName("BLANKLVL", PU_STATIC);
} }
} }
@ -2454,8 +2483,40 @@ static void Y_UnloadVoteData(void)
UNLOAD(cursor); UNLOAD(cursor);
UNLOAD(randomlvl); UNLOAD(randomlvl);
UNLOAD(votedata.levels[3].pic); UNLOAD(levelinfo[3].pic);
UNLOAD(votedata.levels[2].pic); UNLOAD(levelinfo[2].pic);
UNLOAD(votedata.levels[1].pic); UNLOAD(levelinfo[1].pic);
UNLOAD(votedata.levels[0].pic); UNLOAD(levelinfo[0].pic);
} }
//
// Y_SetupVoteFinish
//
void Y_SetupVoteFinish(INT8 pick, INT8 level)
{
pickedvote = pick;
nextmap = votelevels[level];
timer = 0;
if (voteendtic == -1)
{
UINT8 numplayers = 0;
if (splitscreen)
numplayers = 1;
else
{
UINT8 i;
for (i = 0; i < MAXPLAYERS; i++)
{
if (playeringame[i] && !players[i].spectator)
numplayers++;
}
}
if (numplayers > 1)
voteendtic = votetic+(6*TICRATE);
else
voteendtic = votetic+(3*TICRATE);
}
}

View File

@ -21,6 +21,7 @@ void Y_VoteDrawer(void);
void Y_VoteTicker(void); void Y_VoteTicker(void);
void Y_StartVote(void); void Y_StartVote(void);
void Y_EndVote(void); void Y_EndVote(void);
void Y_SetupVoteFinish(INT8 pick, INT8 level);
typedef enum typedef enum
{ {