Freeciv-3.2
Loading...
Searching...
No Matches
voting.h
Go to the documentation of this file.
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.
7
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
15
16#include "support.h" /* bool type */
17
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. */
24};
25
29
30/* Forward declarations. */
31struct connection;
32struct conn_list;
33
34struct vote_cast {
35 enum vote_type vote_cast; /* see enum above */
36 int conn_id; /* user id */
37};
38
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
45
46struct vote {
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. */
52 int vote_no; /* place in the queue */
53 int yes;
54 int no;
56 int flags;
57 double need_pc;
58};
59
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
66
67extern struct vote_list *vote_list;
68extern int vote_number_sequence;
69
70void voting_init(void);
71void voting_free(void);
72void voting_turn(void);
73
74int count_voters(const struct vote *pvote);
75void clear_all_votes(void);
77bool conn_can_vote(const struct connection *pconn,
78 const struct vote *pvote);
79bool conn_can_see_vote(const struct connection *pconn,
80 const struct vote *pvote);
81struct vote *get_vote_by_no(int vote_no);
83 struct vote *pvote,
84 enum vote_type type);
85struct vote *get_vote_by_caller(const struct connection *caller);
86void remove_vote(struct vote *pvote);
87struct vote *vote_new(struct connection *caller,
88 const char *allargs,
89 int command_id);
90bool vote_would_pass_immediately(const struct connection *caller,
91 int command_id);
92const struct connection *vote_get_caller(const struct vote *pvote);
93bool vote_is_team_only(const struct vote *pvote);
94int describe_vote(struct vote *pvote, char *buf, int buflen);
97void send_updated_vote_totals(struct conn_list *dest);
98
99#endif /* FC__VOTING_H */
command_id
Definition commands.h:35
char * incite_cost
Definition comments.c:75
GType type
Definition repodlgs.c:1313
int conn_id
Definition voting.h:36
enum vote_type vote_cast
Definition voting.h:35
Definition voting.h:46
double need_pc
Definition voting.h:57
int no
Definition voting.h:54
int turn_count
Definition voting.h:50
int command_id
Definition voting.h:48
int caller_id
Definition voting.h:47
struct vote_cast_list * votes_cast
Definition voting.h:51
int abstain
Definition voting.h:55
int yes
Definition voting.h:53
int flags
Definition voting.h:56
char cmdline[512]
Definition voting.h:49
int vote_no
Definition voting.h:52
void send_running_votes(struct connection *pconn, bool only_team_votes)
Definition voting.c:810
void send_remove_team_votes(struct connection *pconn)
Definition voting.c:841
int describe_vote(struct vote *pvote, char *buf, int buflen)
Definition voting.c:748
vote_type
Definition voting.h:26
@ VOTE_ABSTAIN
Definition voting.h:27
@ VOTE_YES
Definition voting.h:27
@ VOTE_NUM
Definition voting.h:27
@ VOTE_NO
Definition voting.h:27
bool conn_can_vote(const struct connection *pconn, const struct vote *pvote)
Definition voting.c:248
struct vote * vote_new(struct connection *caller, const char *allargs, int command_id)
Definition voting.c:338
bool vote_is_team_only(const struct vote *pvote)
Definition voting.c:235
vote_condition_flags
Definition voting.h:18
@ VCF_TEAMONLY
Definition voting.h:23
@ VCF_NOPASSALONE
Definition voting.h:21
@ VCF_NODISSENT
Definition voting.h:20
@ VCF_NONE
Definition voting.h:19
void cancel_connection_votes(struct connection *pconn)
Definition voting.c:691
struct vote * get_vote_by_no(int vote_no)
Definition voting.c:301
int vote_number_sequence
Definition voting.c:42
bool vote_would_pass_immediately(const struct connection *caller, int command_id)
Definition voting.c:391
void send_updated_vote_totals(struct conn_list *dest)
Definition voting.c:866
void voting_turn(void)
Definition voting.c:718
void clear_all_votes(void)
Definition voting.c:219
struct vote * get_vote_by_caller(const struct connection *caller)
Definition voting.c:319
void voting_init(void)
Definition voting.c:707
void connection_vote(struct connection *pconn, struct vote *pvote, enum vote_type type)
Definition voting.c:663
struct vote_list * vote_list
Definition voting.c:41
const struct connection * vote_get_caller(const struct vote *pvote)
Definition voting.c:891
int count_voters(const struct vote *pvote)
Definition voting.c:48
void remove_vote(struct vote *pvote)
Definition voting.c:205
void voting_free(void)
Definition voting.c:734
bool conn_can_see_vote(const struct connection *pconn, const struct vote *pvote)
Definition voting.c:272