mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-01-01 20:52:47 +00:00
ModifyClientVote sends a netxcmd for the player
It was implemented before SendNetXCmdForPlayer, so it used to just send it from the consoleplayer and just attach the player number separately. Now the packet will actually be guaranteed to come from the player that wants to change their vote. (Probably was fuckin possible to just change everyone else's votes with a hacked client before, right)
This commit is contained in:
parent
8432d7e552
commit
7641c6a276
4 changed files with 25 additions and 21 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue