1 /***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12 ***********************************************************************/
16 #include "support.h" /* bool type */
18 enum vote_condition_flags
{
20 VCF_NODISSENT
= (1 << 0), /* No 'no' votes.' */
21 VCF_NOPASSALONE
= (1 << 1), /* Can't pass with just one vote for,
22 * when there are multiple voters. */
23 VCF_TEAMONLY
= (1 << 2) /* Only team members can vote on it. */
27 VOTE_YES
, VOTE_NO
, VOTE_ABSTAIN
, VOTE_NUM
30 /* Forward declarations. */
35 enum vote_type vote_cast
; /* see enum above */
36 int conn_id
; /* user id */
39 #define SPECLIST_TAG vote_cast
40 #define SPECLIST_TYPE struct vote_cast
42 #define vote_cast_list_iterate(alist, pvc) \
43 TYPED_LIST_ITERATE(struct vote_cast, alist, pvc)
44 #define vote_cast_list_iterate_end LIST_ITERATE_END
47 int caller_id
; /* caller connection id */
49 char cmdline
[512]; /* Must match MAX_LEN_CONSOLE_LINE. */
50 int turn_count
; /* Number of turns active. */
51 struct vote_cast_list
*votes_cast
;
52 int vote_no
; /* place in the queue */
60 #define SPECLIST_TAG vote
61 #define SPECLIST_TYPE struct vote
63 #define vote_list_iterate(alist, pvote) \
64 TYPED_LIST_ITERATE(struct vote, alist, pvote)
65 #define vote_list_iterate_end LIST_ITERATE_END
67 extern struct vote_list
*vote_list
;
68 extern int vote_number_sequence
;
70 void voting_init(void);
71 void voting_free(void);
72 void voting_turn(void);
74 int count_voters(const struct vote
*pvote
);
75 void clear_all_votes(void);
76 void cancel_connection_votes(struct connection
*pconn
);
77 bool conn_can_vote(const struct connection
*pconn
,
78 const struct vote
*pvote
);
79 bool conn_can_see_vote(const struct connection
*pconn
,
80 const struct vote
*pvote
);
81 struct vote
*get_vote_by_no(int vote_no
);
82 void connection_vote(struct connection
*pconn
,
85 struct vote
*get_vote_by_caller(const struct connection
*caller
);
86 void remove_vote(struct vote
*pvote
);
87 struct vote
*vote_new(struct connection
*caller
,
90 bool vote_would_pass_immediately(const struct connection
*caller
,
92 const struct connection
*vote_get_caller(const struct vote
*pvote
);
93 bool vote_is_team_only(const struct vote
*pvote
);
94 int describe_vote(struct vote
*pvote
, char *buf
, int buflen
);
95 void send_running_votes(struct connection
*pconn
, bool only_team_votes
);
96 void send_remove_team_votes(struct connection
*pconn
);
97 void send_updated_vote_totals(struct conn_list
*dest
);
99 #endif /* FC__VOTING_H */