[Freeciv-Dev] Re: (PR#11733) Vote Bug
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=11733 >
On Thu, 30 Dec 2004, Michael Mielke wrote:
> /vote: You voted against "set size 5"
> Vote "set size 5" is passed 1 to 1 with -1 abstentions.
> (server prompt): 'set size 5'
> Option: size has been set to 5.
>
> The guy who proposed this vote had left before, thus making only 1
> player left to vote.
Thanks for the bug report. Patch attached.
- Per
Index: server/stdinhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/stdinhand.c,v
retrieving revision 1.374
diff -u -r1.374 stdinhand.c
--- server/stdinhand.c 1 Jan 2005 16:39:22 -0000 1.374
+++ server/stdinhand.c 1 Jan 2005 20:50:00 -0000
@@ -94,9 +94,12 @@
static bool start_command(struct connection *caller, char *name, bool check);
static bool end_command(struct connection *caller, char *str, bool check);
+enum {
+ VOTE_NONE, VOTE_BLANK, VOTE_YES, VOTE_NO
+};
struct voting {
char command[MAX_LEN_CONSOLE_LINE]; /* [0] == \0 if none in action */
- char votes_cast[MAX_NUM_PLAYERS]; /* 0-not voted, 1-blank, 2-yes, 3-no */
+ char votes_cast[MAX_NUM_PLAYERS]; /* see enum above */
int vote_no; /* place in the queue */
bool full_turn; /* has a full turn begun for this vote yet? */
int yes, no;
@@ -206,12 +209,15 @@
for (i = 0; i < MAX_NUM_PLAYERS; i++) {
if (game.players[i].is_alive && game.players[i].is_connected) {
num_voters++;
+ } else {
+ /* Disqualify already given vote (eg if disconnected after voting) */
+ vote->votes_cast[i] = VOTE_NONE;
}
}
for (i = 0; i < MAX_NUM_PLAYERS; i++) {
- num_cast = (vote->votes_cast[i] > 0) ? num_cast + 1 : num_cast;
- vote->yes = (vote->votes_cast[i] == 2) ? vote->yes + 1 : vote->yes;
- vote->no = (vote->votes_cast[i] == 3) ? vote->no + 1 : vote->no;
+ num_cast = (vote->votes_cast[i] > VOTE_NONE) ? num_cast + 1 : num_cast;
+ vote->yes = (vote->votes_cast[i] == VOTE_YES) ? vote->yes + 1 : vote->yes;
+ vote->no = (vote->votes_cast[i] == VOTE_NO) ? vote->no + 1 : vote->no;
}
/* Check if we should resolve the vote */
@@ -2149,11 +2155,11 @@
if (strcmp(arg[0], "yes") == 0) {
cmd_reply(CMD_VOTE, caller, C_COMMENT, _("You voted for \"%s\""),
vote->command);
- vote->votes_cast[caller->player->player_no] = 2;
+ vote->votes_cast[caller->player->player_no] = VOTE_YES;
} else if (strcmp(arg[0], "no") == 0) {
cmd_reply(CMD_VOTE, caller, C_COMMENT, _("You voted against \"%s\""),
vote->command);
- vote->votes_cast[caller->player->player_no] = 3;
+ vote->votes_cast[caller->player->player_no] = VOTE_NO;
}
check_vote(vote);
} else {
@@ -3323,8 +3329,8 @@
sz_strlcpy(votes[idx].command, full_command);
votes[idx].vote_no = last_vote;
votes[idx].full_turn = FALSE; /* just to be sure */
- memset(votes[idx].votes_cast, 0, sizeof(votes[idx].votes_cast));
- votes[idx].votes_cast[idx] = 2; /* vote yes to your own suggestion */
+ memset(votes[idx].votes_cast, VOTE_NONE, sizeof(votes[idx].votes_cast));
+ votes[idx].votes_cast[idx] = VOTE_YES; /* vote on your own suggestion */
check_vote(&votes[idx]); /* update vote numbers, maybe auto-accept */
return TRUE;
} else {
- [Freeciv-Dev] Re: (PR#11733) Vote Bug,
Per I. Mathisen <=
|
|