Freeciv21
Develop your civilization from humble roots to a global empire
voteinfo.h
Go to the documentation of this file.
1 /*__ ___ ***************************************
2 / \ / \ Copyright (c) 1996-2020 Freeciv21 and Freeciv
3 \_ \ / __/ contributors. This file is part of Freeciv21.
4  _\ \ / /__ Freeciv21 is free software: you can redistribute it
5  \___ \____/ __/ and/or modify it under the terms of the GNU General
6  \_ _/ Public License as published by the Free Software
7  | @ @ \_ Foundation, either version 3 of the License,
8  | or (at your option) any later version.
9  _/ /\ You should have received a copy of the GNU
10  /o) (o/\ \_ General Public License along with Freeciv21.
11  \_____/ / If not, see https://www.gnu.org/licenses/.
12  \____/ ********************************************************/
13 #pragma once
14 
15 #include "fc_types.h"
16 
18 
19 struct voteinfo {
20  // Set by the server via packets.
21  int vote_no;
23  char desc[512];
25  int flags;
26  int yes;
27  int no;
28  int abstain;
30  bool resolved;
31  bool passed;
32 
33  /* Set/used by the client. */
35  time_t remove_time;
36 };
37 
38 void voteinfo_queue_init();
39 void voteinfo_queue_free();
40 void voteinfo_queue_remove(int vote_no);
41 void voteinfo_queue_delayed_remove(int vote_no);
43 void voteinfo_queue_add(int vote_no, const char *user, const char *desc,
44  int percent_required, int flags);
47 struct voteinfo *voteinfo_queue_get_current(int *pindex);
48 void voteinfo_queue_next();
#define MAX_LEN_NAME
Definition: fc_types.h:61
Definition: voting.h:43
int yes
Definition: voteinfo.h:26
int num_voters
Definition: voteinfo.h:29
bool passed
Definition: voteinfo.h:31
char desc[512]
Definition: voteinfo.h:23
int abstain
Definition: voteinfo.h:28
bool resolved
Definition: voteinfo.h:30
int flags
Definition: voteinfo.h:25
int vote_no
Definition: voteinfo.h:21
int no
Definition: voteinfo.h:27
time_t remove_time
Definition: voteinfo.h:35
int percent_required
Definition: voteinfo.h:24
enum client_vote_type client_vote
Definition: voteinfo.h:34
char user[MAX_LEN_NAME]
Definition: voteinfo.h:22
void voteinfo_queue_delayed_remove(int vote_no)
Remove the vote with number 'vote_no' after a small amount of time so that the user can see that it w...
Definition: voteinfo.cpp:46
void voteinfo_do_vote(int vote_no, enum client_vote_type vote)
Convenience function for submitting a vote to the server.
Definition: voteinfo.cpp:231
struct voteinfo * voteinfo_queue_get_current(int *pindex)
Get the voteinfo record at the start of the vote queue.
Definition: voteinfo.cpp:198
void voteinfo_queue_init()
Initialize data structures used by this module.
Definition: voteinfo.cpp:163
void voteinfo_queue_remove(int vote_no)
Remove the given vote from the queue immediately.
Definition: voteinfo.cpp:97
client_vote_type
Definition: voteinfo.h:17
@ CVT_YES
Definition: voteinfo.h:17
@ CVT_NO
Definition: voteinfo.h:17
@ CVT_NONE
Definition: voteinfo.h:17
@ CVT_ABSTAIN
Definition: voteinfo.h:17
void voteinfo_queue_next()
Cycle through the votes in the queue.
Definition: voteinfo.cpp:269
void voteinfo_queue_free()
Free memory allocated by this module.
Definition: voteinfo.cpp:175
int voteinfo_queue_size()
Returns the number of pending votes.
Definition: voteinfo.cpp:288
struct voteinfo * voteinfo_queue_find(int vote_no)
Find the voteinfo record corresponding to the given vote number.
Definition: voteinfo.cpp:144
void voteinfo_queue_check_removed()
Check for old votes that should be removed from the queue.
Definition: voteinfo.cpp:65
void voteinfo_queue_add(int vote_no, const char *user, const char *desc, int percent_required, int flags)
Create a new voteinfo record and place it in the queue.
Definition: voteinfo.cpp:117