Freeciv-3.4
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/* utility */
17#include "support.h" /* bool type */
18
21 VCF_NODISSENT = (1 << 0), /* No 'no' votes.' */
22 VCF_NOPASSALONE = (1 << 1), /* Can't pass with just one vote for,
23 * when there are multiple voters. */
24 VCF_TEAMONLY = (1 << 2) /* Only team members can vote on it. */
25};
26
30
31/* Forward declarations. */
32struct connection;
33struct conn_list;
34
35struct vote_cast {
36 enum vote_type vote_cast; /* See enum above */
37 int conn_id; /* User id */
38};
39
40#define SPECLIST_TAG vote_cast
41#define SPECLIST_TYPE struct vote_cast
42#include "speclist.h"
43#define vote_cast_list_iterate(alist, pvc) \
44 TYPED_LIST_ITERATE(struct vote_cast, alist, pvc)
45#define vote_cast_list_iterate_end LIST_ITERATE_END
46
47struct vote {
48 int caller_id; /* Caller connection id */
50 char cmdline[512]; /* Must match MAX_LEN_CONSOLE_LINE. */
51 int turn_count; /* Number of turns active. */
53 int vote_no; /* Place in the queue */
54 int yes;
55 int no;
57 int flags;
58 double need_pc;
59};
60
61#define SPECLIST_TAG vote
62#define SPECLIST_TYPE struct vote
63#include "speclist.h"
64#define vote_list_iterate(alist, pvote) \
65 TYPED_LIST_ITERATE(struct vote, alist, pvote)
66#define vote_list_iterate_end LIST_ITERATE_END
67
68extern struct vote_list *vote_list;
69extern int vote_number_sequence;
70
71void voting_init(void);
72void voting_free(void);
73void voting_turn(void);
74
75int count_voters(const struct vote *pvote);
76void clear_all_votes(void);
78bool conn_can_vote(const struct connection *pconn,
79 const struct vote *pvote);
80bool conn_can_see_vote(const struct connection *pconn,
81 const struct vote *pvote);
82struct vote *get_vote_by_no(int vote_no);
84 struct vote *pvote,
85 enum vote_type type);
86struct vote *get_vote_by_caller(const struct connection *caller);
87void remove_vote(struct vote *pvote);
88struct vote *vote_new(struct connection *caller,
89 const char *allargs,
90 int command_id);
91bool vote_would_pass_immediately(const struct connection *caller,
92 int command_id);
93const struct connection *vote_get_caller(const struct vote *pvote);
94bool vote_is_team_only(const struct vote *pvote);
95int describe_vote(struct vote *pvote, char *buf, int buflen);
98void send_updated_vote_totals(struct conn_list *dest);
99
100#endif /* FC__VOTING_H */
command_id
Definition commands.h:35
char * incite_cost
Definition comments.c:77
GType type
Definition repodlgs.c:1313
int conn_id
Definition voting.h:37
enum vote_type vote_cast
Definition voting.h:36
Definition voting.h:47
double need_pc
Definition voting.h:58
int no
Definition voting.h:55
int turn_count
Definition voting.h:51
int command_id
Definition voting.h:49
int caller_id
Definition voting.h:48
struct vote_cast_list * votes_cast
Definition voting.h:52
int abstain
Definition voting.h:56
int yes
Definition voting.h:54
int flags
Definition voting.h:57
char cmdline[512]
Definition voting.h:50
int vote_no
Definition voting.h:53
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:27
@ VOTE_ABSTAIN
Definition voting.h:28
@ VOTE_YES
Definition voting.h:28
@ VOTE_NUM
Definition voting.h:28
@ VOTE_NO
Definition voting.h:28
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:19
@ VCF_TEAMONLY
Definition voting.h:24
@ VCF_NOPASSALONE
Definition voting.h:22
@ VCF_NODISSENT
Definition voting.h:21
@ VCF_NONE
Definition voting.h:20
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