From e21cf463eadd5e8be0109e734225ba89488cb9d0 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Tue, 3 Sep 2024 20:56:36 -0400 Subject: [PATCH] Duel vote: More conveyance - Show X over selection, to make it more obvious when it's rip snortin' time - "Waiting for [player]..." when it's not your turn - Halve vote timer in Duels (maybe make a separate cvar?) - Fix bots sometimes striking stages out realllllly slowly --- src/d_netcmd.c | 8 ++- src/k_vote.c | 138 ++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 111 insertions(+), 35 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index d743ed3a2..939fa84c1 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -5833,23 +5833,21 @@ static void Got_ModifyVotecmd(const UINT8 **cp, INT32 playernum) if (targetID >= MAXPLAYERS) { // only the server is allowed to send these - if (playernum != serverplayer) + if (playernum != serverplayer) { goto fail; } } else if (playeringame[targetID] == true && players[targetID].bot == true) { - if (targetID >= MAXPLAYERS - || playernum != serverplayer) + if (playernum != serverplayer) { goto fail; } } else { - if (targetID >= MAXPLAYERS - || playernode[targetID] != playernode[playernum]) + if (playernode[targetID] != playernode[playernum]) { goto fail; } diff --git a/src/k_vote.c b/src/k_vote.c index 39d0fc36f..8c17cfedb 100644 --- a/src/k_vote.c +++ b/src/k_vote.c @@ -242,6 +242,32 @@ typedef struct static y_vote_data vote = {0}; static y_vote_draw vote_draw = {0}; +static void Y_SetVoteTimer(void) +{ + vote.timer = cv_votetime.value * TICRATE; + + if (vote.stage_striking == true) + { + vote.timer /= 2; + } +} + +static UINT8 Y_CountStriked(void) +{ + INT32 i; + + UINT8 num_striked = 0; + for (i = 0; i < VOTE_NUM_LEVELS; i++) + { + if (g_votes_striked[i] == true) + { + num_striked++; + } + } + + return num_striked; +} + static boolean Y_VoteIDIsSpecial(const UINT8 playerId) { switch (playerId) @@ -486,18 +512,9 @@ void Y_SetPlayersVote(const UINT8 inputPlayerId, SINT8 newVote) if (vote.stage_striking == true) { - UINT8 num_striked = 0; - for (i = 0; i < VOTE_NUM_LEVELS; i++) - { - if (g_votes_striked[i] == true) - { - num_striked++; - } - } - if (newVote != VOTE_NOT_PICKED - && num_striked < VOTE_NUM_LEVELS-1 - && g_votes_striked[newVote] == false) + && g_votes_striked[newVote] == false + && Y_CountStriked() < VOTE_NUM_LEVELS-1) { // Strike a stage, instead of voting. g_votes_striked[newVote] = true; @@ -506,7 +523,7 @@ void Y_SetPlayersVote(const UINT8 inputPlayerId, SINT8 newVote) vote.strike_turn = !vote.strike_turn; // Reset variables. - vote.timer = cv_votetime.value * TICRATE; + Y_SetVoteTimer(); for (i = 0; i <= splitscreen; i++) { vote.players[i].sentTimeOutVote = false; @@ -544,12 +561,12 @@ void Y_SetPlayersVote(const UINT8 inputPlayerId, SINT8 newVote) if (vote.timer == -1) { // Someone has voted, so start the timer now. - vote.timer = cv_votetime.value * TICRATE; + Y_SetVoteTimer(); } #endif } -static void Y_DrawVoteThumbnail(fixed_t center_x, fixed_t center_y, fixed_t width, INT32 flags, SINT8 v, boolean dim, SINT8 playerID) +static void Y_DrawVoteThumbnail(fixed_t center_x, fixed_t center_y, fixed_t width, INT32 flags, SINT8 v, boolean dim, SINT8 playerID, boolean from_selection) { const boolean encore = vote_draw.levels[v].encore; const fixed_t height = (width * BASEVIDHEIGHT) / BASEVIDWIDTH; @@ -597,7 +614,7 @@ static void Y_DrawVoteThumbnail(fixed_t center_x, fixed_t center_y, fixed_t widt V_AdjustXYWithSnap(&fx, &fy, flags, dupx, dupy); boolean striked = false; - if (playerID < 0) + if (from_selection == true) { striked = g_votes_striked[v]; } @@ -637,6 +654,22 @@ static void Y_DrawVoteThumbnail(fixed_t center_x, fixed_t center_y, fixed_t widt NULL ); } + + if (vote.stage_striking == true + && from_selection == true + && dim == false) + { + if (Y_CountStriked() < VOTE_NUM_LEVELS-1) + { + const fixed_t strikeScale = width / 32; + V_DrawFixedPatch( + center_x - (strikeScale * 25 / 2), center_y - (strikeScale * 22 / 2), + strikeScale, flags /*| V_TRANSLUCENT*/, + vote_draw.strike_icon, + NULL + ); + } + } } if (dim == true) @@ -765,7 +798,7 @@ static void Y_DrawCatcher(y_vote_catcher *catcher) baseX, catcher->y, ((catcher->small == true) ? PILE_WIDTH : SELECTION_WIDTH), 0, catcher->level, false, - catcher->player + catcher->player, false ); } @@ -1028,12 +1061,41 @@ static void Y_DrawVoteSelection(fixed_t offset) x, y - vote_draw.levels[i].hop, SELECTION_WIDTH, 0, i, (selected == false), - -1 + -1, true ); x += SELECTION_SPACING_W; } + if (vote.stage_striking == true && Y_CountStriked() < VOTE_NUM_LEVELS-1) + { + UINT8 current_strike_player = ( + (vote.strike_turn == true) + ? (vote.strike_winner - players) + : (vote.strike_loser - players) + ); + + for (i = 0; i <= splitscreen; i++) + { + if (g_localplayers[i] == current_strike_player) + { + break; + } + } + + if (i > splitscreen) + { + const char *wait_str = va("Waiting for %s...", player_names[current_strike_player]); + + V_DrawThinString( + BASEVIDWIDTH / 2 - (V_ThinStringWidth(wait_str, 0) / 2), + 180, + 0, + wait_str + ); + } + } + // // Draw our catchers // @@ -1091,7 +1153,7 @@ static void Y_DrawVotePile(void) PILE_WIDTH, 0, g_votes[i], (i != vote.roulette.anim || g_pickedVote == VOTE_NOT_PICKED), - i + i, false ); } @@ -1594,18 +1656,19 @@ static void Y_ExitStageStrike(void) { INT32 i; + vote.stage_striking = false; + for (i = 0; i < VOTE_NUM_LEVELS; i++) { g_votes_striked[i] = false; } - vote.stage_striking = false; - vote.timer = cv_votetime.value * TICRATE; - vote.strike_loser = NULL; vote.strike_winner = NULL; vote.strike_turn = false; vote.strike_time_out = false; + + Y_SetVoteTimer(); } static boolean Y_CheckStageStrikeStatus(void) @@ -1880,12 +1943,27 @@ static void Y_TickVoteSelection(void) continue; } - if (players[i].bot == true && Y_PlayerIDCanVoteRightNow(i) == true && g_votes[i] == VOTE_NOT_PICKED) + if (server && players[i].bot == true && Y_PlayerIDCanVoteRightNow(i) == true && g_votes[i] == VOTE_NOT_PICKED) { - if (server && ( M_RandomFixed() % 100 ) == 0) + if (( M_RandomFixed() % 100 ) == 0) { // bots vote randomly - D_ModifyClientVote(i, M_RandomKey(VOTE_NUM_LEVELS)); + INT32 rng = M_RandomKey(VOTE_NUM_LEVELS); + for (i = 0; i < VOTE_NUM_LEVELS; i++) + { + if (g_votes_striked[i] == false) + { + break; + } + + rng++; + if (rng >= VOTE_NUM_LEVELS) + { + rng = 0; + } + } + + D_ModifyClientVote(i, rng); } } @@ -2220,12 +2298,6 @@ void Y_StartVote(void) vote.tic = vote.endtic = -1; -#ifdef VOTE_TIME_WAIT_FOR_VOTE - vote.timer = -1; // Timer is not set until the first vote is added -#else - vote.timer = cv_votetime.value * TICRATE; -#endif - g_pickedVote = VOTE_NOT_PICKED; vote.notYetPicked = true; @@ -2260,6 +2332,12 @@ void Y_StartVote(void) Y_DetermineStageStrike(); +#ifdef VOTE_TIME_WAIT_FOR_VOTE + vote.timer = -1; // Timer is not set until the first vote is added +#else + Y_SetVoteTimer(); +#endif + Y_InitVoteDrawing(); vote.loaded = true;