From 7499964cce8a349bc190fb3438b273b8e163f571 Mon Sep 17 00:00:00 2001 From: maikmerten Date: Sat, 1 Oct 2005 17:32:13 +0000 Subject: [PATCH] better documented voting system git-svn-id: svn://svn.icculus.org/nexuiz/trunk@535 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- qcsrc/default.cfg | 22 ++++++++++++------ qcsrc/gamec/clientcommands.c | 43 +++++++++++++++++++++++++++++++----- 2 files changed, 52 insertions(+), 13 deletions(-) diff --git a/qcsrc/default.cfg b/qcsrc/default.cfg index d5f23fb8a..070e01068 100755 --- a/qcsrc/default.cfg +++ b/qcsrc/default.cfg @@ -15,7 +15,7 @@ alias "-scores" "-showscores" alias "bsp" "ls maps/*.bsp" alias "mapcfg" "ls maps/*.mapcfg" -alias "chmap" "exec maps/$1.mapcfg" +alias "chmap" "exec $exit_cfg; exec game_reset.cfg; exec maps/$1.mapcfg" alias "dem" "ls demos/*.dem" alias "rec" "record demos/$1" @@ -365,13 +365,21 @@ bind PAUSE pause bind F10 quit bind F12 screenshot -set sv_vote_allowed "chmap timelimit fraglimit g_grappling_hook" // those commands can be voted -//set sv_vote_change "1" // allow to change you mind -//set sv_vote_singlecount "1" // count votes after timeout (or with every vote) +// these commands can be voted +set sv_vote_allowed "restart timelimit fraglimit chmap g_grappling_hook" +// set to 1 to allow to change you vote/mind +set sv_vote_change "0" +// set to 1 to count votes once after timeout or to 0 to count with every vote +set sv_vote_singlecount "0" +// a vote will timeout after this many seconds +set sv_vote_singlecount "60" +// a player can not call a vote again for this many seconds +set sv_vote_singlecount "120" +alias vhelp "cmd vote help" +alias vstatus "cmd vote status" alias vcall "cmd vote call $*" alias vstop "cmd vote stop" -alias vstatus "cmd vote status" -alias vyes "echo voted YES;cmd vote call $*" -alias vno "echo voted NO;cmd vote call $*" +alias vyes "echo voted YES;cmd vote yes" +alias vno "echo voted NO;cmd vote no" bind F1 vyes bind F2 vno diff --git a/qcsrc/gamec/clientcommands.c b/qcsrc/gamec/clientcommands.c index 0d689afe4..33ffe934b 100644 --- a/qcsrc/gamec/clientcommands.c +++ b/qcsrc/gamec/clientcommands.c @@ -36,9 +36,17 @@ void SV_ParseClientCommand(string s) { } } else if(argv(0) == "vote") { if(argv(1) == "help") { - sprint(self, "^1You can use vote with \"^2help^1\" \"^2status^1\" \"^2call^1\" \"^2stop^1\" \"^2yes^1\" \"^2no^1\".\n"); + sprint(self, "^1You can use voting with \"^2cmd vote help^1\" \"^2cmd vote status^1\" \"^2cmd vote call ^3COMMAND ARGUMENTS^1\" \"^2cmd vote stop^1\" \"^2cmd vote yes^1\" \"^2cmd vote no^1\".\n"); + sprint(self, "^1Or if your version is up to date you can use these aliases \"^2vhelp^1\" \"^2vstatus^1\" \"^2vcall ^3COMMAND ARGUMENTS^1\" \"^2vstop^1\" \"^2vyes^1\" \"^2vno^1\".\n"); + sprint(self, "^1\"^2help^1\" shows this info.\n"); + sprint(self, "^1\"^2status^1\" shows if there is a vote called and who called it.\n"); + sprint(self, "^1\"^2call^1\" is used to call a vote. See the list of allowed commands.\n"); + sprint(self, "^1If more then 50% of the players vote yes the vote is executed.\n"); + sprint(self, "^1If more then 50% of the players vote no the vote fails.\n"); + sprint(self, "^1\"^2stop^1\" can be used by the vote caller to stop a vote and maybe correct it.\n"); + sprint(self, "^1\"^2yes^1\" and \"^2no^1\" to make your vote.\n"); sprint(self, "^1You can call a vote with these commands:\n"); - sprint(self, strcat("^2", cvar_string("sv_vote_allowed"), "\n")); + sprint(self, strcat("^1\"^2vcall^1\" ^3", cvar_string("sv_vote_allowed"), "^1 and further ^3arguments^1\n")); } else if(argv(1) == "status") { if(votecalled == "") { sprint(self, "^1No vote called.\n"); @@ -56,6 +64,29 @@ void SV_ParseClientCommand(string s) { index++; } + // necessary for some of the string operations + vote = strzone(vote); + + // now we remove some things that could be misused + index = 0; + local float found; + found = FALSE; + local float votelength; + votelength = strlen(vote); + while(!found && index < votelength) + { + local string badchar; + badchar = substring(vote, index, 1); + if(badchar == ";" + || badchar == "\n") + { + found = TRUE; + } else { + index++; + } + } + vote = substring(vote, 0, index); + if(vote == "") { sprint(self, "^1You have to vote for something.\n"); } else if(time < self.vote_next) { @@ -64,8 +95,8 @@ void SV_ParseClientCommand(string s) { votecalled = strzone(vote); votecaller = self; // remember who called the vote self.vote_vote = 1; // of course you vote yes - self.vote_finished = time + 60; // vote may run this long - self.vote_next = time + 300; // no more votes from that player for this long + self.vote_finished = time + cvar("sv_vote_timeout"); + self.vote_next = time + cvar("sv_vote_wait"); bprint(strcat("^3Vote for \"^1", votecalled, "^3\" called by \"", self.netname, "^3\".\n")); VoteCount(); // needed if you are the only one } else { @@ -93,7 +124,7 @@ void SV_ParseClientCommand(string s) { } else if(self.vote_vote == 0 || cvar("sv_vote_change")) { self.vote_vote = 1; - if(cvar_string("sv_vote_singlecount") == "") { + if(!cvar("sv_vote_singlecount")) { VoteCount(); } } else { @@ -105,7 +136,7 @@ void SV_ParseClientCommand(string s) { } else if(self.vote_vote == 0 || cvar("sv_vote_change")) { self.vote_vote = -1; - if(cvar_string("sv_vote_singlecount") == "") { + if(!cvar("sv_vote_singlecount")) { VoteCount(); } } else { -- 2.39.2