Do not build gtk3.22-client by default
[freeciv.git] / server / voting.h
blobd17e440a0beaeb3f45ce96673229bdef95c11d5c
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)
6 any later version.
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 ***********************************************************************/
13 #ifndef FC__VOTING_H
14 #define FC__VOTING_H
16 #include "support.h" /* bool type */
18 enum vote_condition_flags {
19 VCF_NONE = 0,
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. */
26 enum vote_type {
27 VOTE_YES, VOTE_NO, VOTE_ABSTAIN, VOTE_NUM
30 /* Forward declarations. */
31 struct connection;
32 struct conn_list;
34 struct vote_cast {
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
41 #include "speclist.h"
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
46 struct vote {
47 int caller_id; /* caller connection id */
48 int command_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 */
53 int yes;
54 int no;
55 int abstain;
56 int flags;
57 double need_pc;
60 #define SPECLIST_TAG vote
61 #define SPECLIST_TYPE struct vote
62 #include "speclist.h"
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,
83 struct vote *pvote,
84 enum vote_type type);
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,
88 const char *allargs,
89 int command_id);
90 bool vote_would_pass_immediately(const struct connection *caller,
91 int command_id);
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 */