Freeciv-3.1: /fast/freeciv/nightly/S3_1/server/voting.h Source File

Freeciv-3.1

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
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. */
24};
25
26 enum vote_type {
27 VOTE_YES, VOTE_NO, VOTE_ABSTAIN, VOTE_NUM
28};
29
30/* Forward declarations. */
31struct connection;
32struct conn_list;
33
34 struct 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
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;
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);
76void cancel_connection_votes(struct connection *pconn);
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);
82void connection_vote(struct connection *pconn,
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);
95void send_running_votes(struct connection *pconn, bool only_team_votes);
96void send_remove_team_votes(struct connection *pconn);
97void send_updated_vote_totals(struct conn_list *dest);
98
99#endif /* FC__VOTING_H */
command_id
command_id
Definition commands.h:34
type
GType type
Definition repodlgs.c:1312
speclist.h
connection
Definition connection.h:141
vote_cast
Definition voting.h:34
vote_cast::conn_id
int conn_id
Definition voting.h:36
vote_cast::vote_cast
enum vote_type vote_cast
Definition voting.h:35
vote
Definition voting.h:46
vote::need_pc
double need_pc
Definition voting.h:57
vote::no
int no
Definition voting.h:54
vote::turn_count
int turn_count
Definition voting.h:50
vote::command_id
int command_id
Definition voting.h:48
vote::caller_id
int caller_id
Definition voting.h:47
vote::votes_cast
struct vote_cast_list * votes_cast
Definition voting.h:51
vote::abstain
int abstain
Definition voting.h:55
vote::yes
int yes
Definition voting.h:53
vote::flags
int flags
Definition voting.h:56
vote::cmdline
char cmdline[512]
Definition voting.h:49
vote::vote_no
int vote_no
Definition voting.h:52
support.h
send_running_votes
void send_running_votes(struct connection *pconn, bool only_team_votes)
Definition voting.c:810
send_remove_team_votes
void send_remove_team_votes(struct connection *pconn)
Definition voting.c:841
describe_vote
int describe_vote(struct vote *pvote, char *buf, int buflen)
Definition voting.c:748
vote_type
vote_type
Definition voting.h:26
VOTE_ABSTAIN
@ VOTE_ABSTAIN
Definition voting.h:27
VOTE_YES
@ VOTE_YES
Definition voting.h:27
VOTE_NUM
@ VOTE_NUM
Definition voting.h:27
VOTE_NO
@ VOTE_NO
Definition voting.h:27
conn_can_vote
bool conn_can_vote(const struct connection *pconn, const struct vote *pvote)
Definition voting.c:248
vote_new
struct vote * vote_new(struct connection *caller, const char *allargs, int command_id)
Definition voting.c:338
vote_is_team_only
bool vote_is_team_only(const struct vote *pvote)
Definition voting.c:235
vote_condition_flags
vote_condition_flags
Definition voting.h:18
VCF_TEAMONLY
@ VCF_TEAMONLY
Definition voting.h:23
VCF_NOPASSALONE
@ VCF_NOPASSALONE
Definition voting.h:21
VCF_NODISSENT
@ VCF_NODISSENT
Definition voting.h:20
VCF_NONE
@ VCF_NONE
Definition voting.h:19
cancel_connection_votes
void cancel_connection_votes(struct connection *pconn)
Definition voting.c:691
get_vote_by_no
struct vote * get_vote_by_no(int vote_no)
Definition voting.c:301
vote_number_sequence
int vote_number_sequence
Definition voting.c:42
vote_would_pass_immediately
bool vote_would_pass_immediately(const struct connection *caller, int command_id)
Definition voting.c:391
send_updated_vote_totals
void send_updated_vote_totals(struct conn_list *dest)
Definition voting.c:866
voting_turn
void voting_turn(void)
Definition voting.c:718
clear_all_votes
void clear_all_votes(void)
Definition voting.c:219
get_vote_by_caller
struct vote * get_vote_by_caller(const struct connection *caller)
Definition voting.c:319
voting_init
void voting_init(void)
Definition voting.c:707
connection_vote
void connection_vote(struct connection *pconn, struct vote *pvote, enum vote_type type)
Definition voting.c:663
vote_list
struct vote_list * vote_list
Definition voting.c:41
vote_get_caller
const struct connection * vote_get_caller(const struct vote *pvote)
Definition voting.c:891
count_voters
int count_voters(const struct vote *pvote)
Definition voting.c:48
remove_vote
void remove_vote(struct vote *pvote)
Definition voting.c:205
voting_free
void voting_free(void)
Definition voting.c:734
conn_can_see_vote
bool conn_can_see_vote(const struct connection *pconn, const struct vote *pvote)
Definition voting.c:272