From 1b2301709e9985ad35f9a6dca6465a528980dde0 Mon Sep 17 00:00:00 2001 From: terencehill Date: Sun, 28 May 2023 00:33:41 +0200 Subject: [PATCH 1/1] Add a cvar to make it easy to debug votes --- commands.cfg | 1 + qcsrc/server/command/vote.qc | 5 +++-- qcsrc/server/command/vote.qh | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/commands.cfg b/commands.cfg index d5b03ee3e..5d4a7271e 100644 --- a/commands.cfg +++ b/commands.cfg @@ -369,6 +369,7 @@ set sv_vote_stop 15 "a player can not call a vote again for this many seconds wh set sv_vote_majority_factor 0.5 "What percentage of the PLAYERS constitute a majority? (Must be at least 0.5, recommended: 0.5)" set sv_vote_majority_factor_of_voted 0.5 "What percentage of the VOTERS constitute a majority too? (Must be at least 0.5, recommended: 0.5)" set sv_vote_gamestart 0 "Allow voting during map change" +set sv_vote_debug 0 "count votes by bots too for debugging purposes (to get a bot to vote exec this command: bot_cmd 1 cc vote yes) // when disabled, don't allow game type changes "note: set these two equal to JUST support simple majorities" set sv_vote_override_mostrecent 0 diff --git a/qcsrc/server/command/vote.qc b/qcsrc/server/command/vote.qc index 5ee0ebfb3..02cb8e1ce 100644 --- a/qcsrc/server/command/vote.qc +++ b/qcsrc/server/command/vote.qc @@ -215,7 +215,6 @@ void VoteSpam(float notvoters, float mincount, string result) void VoteCount(float first_count) { - // declarations vote_accept_count = vote_reject_count = vote_abstain_count = 0; float vote_player_count = 0, notvoters = 0; @@ -227,7 +226,7 @@ void VoteCount(float first_count) Nagger_VoteCountChanged(); // add up all the votes from each connected client - FOREACH_CLIENT(IS_REAL_CLIENT(it), { + FOREACH_CLIENT(IS_REAL_CLIENT(it) || autocvar_sv_vote_debug, { ++vote_player_count; if (IS_PLAYER(it) || INGAME(it)) ++vote_real_player_count; switch (it.vote_selection) @@ -978,6 +977,8 @@ void VoteCommand_call(int request, entity caller, int argc, string vote_command) FOREACH_CLIENT(IS_REAL_CLIENT(it), { ++tmp_playercount; }); bprint("\{1}^2* ^3", OriginalCallerName(), "^2 calls a vote for ", vote_called_display, "\n"); + if (autocvar_sv_vote_debug) + bprint("\{1}^2* ^3", "^6DEBUG MODE ACTIVE: bots can vote too\n"); // so servers don't forget it on if (autocvar_sv_eventlog) GameLogEcho(strcat(":vote:vcall:", ftos(vote_caller.playerid), ":", vote_called_display)); Nagger_VoteChanged(); diff --git a/qcsrc/server/command/vote.qh b/qcsrc/server/command/vote.qh index 3f555ed8d..509d4d233 100644 --- a/qcsrc/server/command/vote.qh +++ b/qcsrc/server/command/vote.qh @@ -3,6 +3,8 @@ bool autocvar_sv_vote_call; bool autocvar_sv_vote_change; string autocvar_sv_vote_commands; +bool autocvar_sv_vote_debug; +bool autocvar_sv_vote_gamestart; int autocvar_sv_vote_limit; float autocvar_sv_vote_majority_factor; float autocvar_sv_vote_majority_factor_of_voted; @@ -19,7 +21,6 @@ bool autocvar_sv_vote_singlecount; float autocvar_sv_vote_stop; float autocvar_sv_vote_timeout; float autocvar_sv_vote_wait; -bool autocvar_sv_vote_gamestart; // definitions for command selection between progs const float VC_ASGNMNT_BOTH = 1; -- 2.39.2