diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 2e845fa8f..9337e98c6 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2633,17 +2633,18 @@ void D_SetupVote(void) SendNetXCmd(XD_SETUPVOTE, buf, p - buf); } -void D_ModifyClientVote(UINT8 player, SINT8 voted, UINT8 splitplayer) +void D_ModifyClientVote(UINT8 player, SINT8 voted) { - char buf[2]; + char buf[1]; char *p = buf; - if (splitplayer > 0) - player = g_localplayers[splitplayer]; + if (player >= MAXSPLITSCREENPLAYERS) + { + return; + } WRITESINT8(p, voted); - WRITEUINT8(p, player); - SendNetXCmd(XD_MODIFYVOTE, &buf, 2); + SendNetXCmdForPlayer(player, XD_MODIFYVOTE, &buf, 2); } void D_PickVote(void) @@ -2652,21 +2653,27 @@ void D_PickVote(void) char* p = buf; SINT8 temppicks[MAXPLAYERS]; SINT8 templevels[MAXPLAYERS]; - SINT8 votecompare = -1; + SINT8 votecompare = VOTE_NOT_PICKED; UINT8 numvotes = 0, key = 0; INT32 i; for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].spectator) + if (Y_PlayerIDCanVote(i) == false) + { continue; - if (g_votes[i] != -1) + } + + if (g_votes[i] != VOTE_NOT_PICKED) { temppicks[numvotes] = i; templevels[numvotes] = g_votes[i]; numvotes++; - if (votecompare == -1) + + if (votecompare == VOTE_NOT_PICKED) + { votecompare = g_votes[i]; + } } } @@ -2679,7 +2686,7 @@ void D_PickVote(void) } else { - WRITESINT8(p, -1); + WRITESINT8(p, VOTE_NOT_PICKED); WRITESINT8(p, 0); } @@ -5415,11 +5422,7 @@ static void Got_SetupVotecmd(UINT8 **cp, INT32 playernum) static void Got_ModifyVotecmd(UINT8 **cp, INT32 playernum) { - SINT8 voted = READSINT8(*cp); - UINT8 p = READUINT8(*cp); - - (void)playernum; - g_votes[p] = voted; + g_votes[playernum] = READSINT8(*cp); } static void Got_PickVotecmd(UINT8 **cp, INT32 playernum) diff --git a/src/d_netcmd.h b/src/d_netcmd.h index c7e75b83c..d4c7d82a4 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -240,7 +240,7 @@ void Command_Retry_f(void); void D_GameTypeChanged(INT32 lastgametype); // not a real _OnChange function anymore void D_MapChange(INT32 pmapnum, INT32 pgametype, boolean pencoremode, boolean presetplayers, INT32 pdelay, boolean pskipprecutscene, boolean pfromlevelselect); void D_SetupVote(void); -void D_ModifyClientVote(UINT8 player, SINT8 voted, UINT8 splitplayer); +void D_ModifyClientVote(UINT8 player, SINT8 voted); void D_PickVote(void); void ObjectPlace_OnChange(void); boolean IsPlayerAdmin(INT32 playernum); diff --git a/src/k_vote.c b/src/k_vote.c index 58cab978a..542bd5566 100644 --- a/src/k_vote.c +++ b/src/k_vote.c @@ -123,7 +123,7 @@ typedef struct static y_vote_data vote = {0}; static y_vote_draw vote_draw = {0}; -static boolean Y_PlayerIDCanVote(const UINT8 id) +boolean Y_PlayerIDCanVote(const UINT8 id) { if (id >= MAXPLAYERS) { @@ -386,7 +386,7 @@ void Y_VoteDrawer(void) if (dedicated && i == 0) // While leaving blank spots for non-existent players is largely intentional, the first spot *always* being blank looks a tad silly :V continue; - if ((playeringame[i] && !players[i].spectator) && g_votes[i] != VOTE_NOT_PICKED) + if (Y_PlayerIDCanVote(i) == true && g_votes[i] != VOTE_NOT_PICKED) { if (!timer && i == voteclient.ranim) { @@ -502,7 +502,7 @@ void Y_VoteTicker(void) for (i = 0; i < MAXPLAYERS; i++) // Correct votes as early as possible, before they're processed by the game at all { - if (playeringame[i] == false || players[i].spectator == true) + if (Y_PlayerIDCanVote(i) == false) { g_votes[i] = VOTE_NOT_PICKED; // Spectators are the lower class, and have effectively no voice in the government. Democracy sucks. } @@ -657,7 +657,7 @@ void Y_VoteTicker(void) if (G_PlayerInputDown(i, gc_a, 0) && moved == false) { - D_ModifyClientVote(consoleplayer, vote.players[i].selection, i); + D_ModifyClientVote(i, vote.players[i].selection); moved = true; } } diff --git a/src/k_vote.h b/src/k_vote.h index 3f3d12b44..6705c994a 100644 --- a/src/k_vote.h +++ b/src/k_vote.h @@ -24,6 +24,7 @@ extern "C" { #define VOTE_MOD_ENCORE (0x01) +boolean Y_PlayerIDCanVote(const UINT8 id); void Y_VoteDrawer(void); void Y_VoteTicker(void); void Y_StartVote(void);