From 8bbb228c588909eb2804227a7442b8fb5e4efa84 Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 5 Nov 2019 19:22:54 -0800 Subject: [PATCH 1/2] Don't let players change their vote after the vote has ended --- src/y_inter.c | 97 +++++++++++++++++++++++++++------------------------ 1 file changed, 52 insertions(+), 45 deletions(-) diff --git a/src/y_inter.c b/src/y_inter.c index f5380d565..92607eec9 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -1555,63 +1555,70 @@ void Y_VoteTicker(void) if (votetic < 3*(NEWTICRATE/7)) // give it some time before letting you control it :V return; - for (i = 0; i <= splitscreen; i++) + /* + The vote ended, but it will take at least a tic for that to reach us from + the server. Don't let me change the vote now, it won't matter anyway! + */ + if (timer) { - UINT8 p; - boolean pressed = false; - - switch (i) + for (i = 0; i <= splitscreen; i++) { - case 1: - p = displayplayers[1]; - break; - case 2: - p = displayplayers[2]; - break; - case 3: - p = displayplayers[3]; - break; - default: - p = consoleplayer; - break; - } + UINT8 p; + boolean pressed = false; - if (voteclient.playerinfo[i].delay) - voteclient.playerinfo[i].delay--; - - if ((playeringame[p] && !players[p].spectator) - && !voteclient.playerinfo[i].delay - && pickedvote == -1 && votes[p] == -1) - { - if (InputDown(gc_aimforward, i+1) || JoyAxis(AXISAIM, i+1) < 0) + switch (i) { - voteclient.playerinfo[i].selection--; - pressed = true; + case 1: + p = displayplayers[1]; + break; + case 2: + p = displayplayers[2]; + break; + case 3: + p = displayplayers[3]; + break; + default: + p = consoleplayer; + break; } - if ((InputDown(gc_aimbackward, i+1) || JoyAxis(AXISAIM, i+1) > 0) && !pressed) + if (voteclient.playerinfo[i].delay) + voteclient.playerinfo[i].delay--; + + if ((playeringame[p] && !players[p].spectator) + && !voteclient.playerinfo[i].delay + && pickedvote == -1 && votes[p] == -1) { - voteclient.playerinfo[i].selection++; - pressed = true; + if (InputDown(gc_aimforward, i+1) || JoyAxis(AXISAIM, i+1) < 0) + { + voteclient.playerinfo[i].selection--; + pressed = true; + } + + if ((InputDown(gc_aimbackward, i+1) || JoyAxis(AXISAIM, i+1) > 0) && !pressed) + { + voteclient.playerinfo[i].selection++; + pressed = true; + } + + if (voteclient.playerinfo[i].selection < 0) + voteclient.playerinfo[i].selection = 3; + if (voteclient.playerinfo[i].selection > 3) + voteclient.playerinfo[i].selection = 0; + + if ((InputDown(gc_accelerate, i+1) || JoyAxis(AXISMOVE, i+1) > 0) && !pressed) + { + D_ModifyClientVote(voteclient.playerinfo[i].selection, i); + pressed = true; + } } - if (voteclient.playerinfo[i].selection < 0) - voteclient.playerinfo[i].selection = 3; - if (voteclient.playerinfo[i].selection > 3) - voteclient.playerinfo[i].selection = 0; - - if ((InputDown(gc_accelerate, i+1) || JoyAxis(AXISMOVE, i+1) > 0) && !pressed) + if (pressed) { - D_ModifyClientVote(voteclient.playerinfo[i].selection, i); - pressed = true; + S_StartSound(NULL, sfx_kc4a); + voteclient.playerinfo[i].delay = NEWTICRATE/7; } } - - if (pressed) - { - S_StartSound(NULL, sfx_kc4a); - voteclient.playerinfo[i].delay = NEWTICRATE/7; - } } if (server) From 8844e51afc6c2d9709aafab93972fa81b14ecd2e Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 5 Nov 2019 19:42:29 -0800 Subject: [PATCH 2/2] Don't pick the vote twice --- src/y_inter.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/y_inter.c b/src/y_inter.c index 92607eec9..dec02bc0d 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -155,6 +155,7 @@ static y_votelvlinfo levelinfo[5]; static y_voteclient voteclient; static INT32 votetic; static INT32 voteendtic = -1; +static boolean votenotyetpicked; static patch_t *cursor = NULL; static patch_t *cursor1 = NULL; static patch_t *cursor2 = NULL; @@ -1550,7 +1551,7 @@ void Y_VoteTicker(void) else voteclient.ranim = pickedvote; } - else + else if (votenotyetpicked) { if (votetic < 3*(NEWTICRATE/7)) // give it some time before letting you control it :V return; @@ -1642,7 +1643,10 @@ void Y_VoteTicker(void) timer = 0; if (voteendtic == -1) + { + votenotyetpicked = false;/* don't pick vote twice */ D_PickVote(); + } } } } @@ -1676,6 +1680,8 @@ void Y_StartVote(void) timer = cv_votetime.value*TICRATE; pickedvote = -1; + votenotyetpicked = true; + for (i = 0; i < 3; i++) { voteclient.playerinfo[i].selection = 0;