Freeciv-3.3
Loading...
Searching...
No Matches
Data Structures | Macros | Enumerations | Functions | Variables
voting.h File Reference
#include "support.h"
#include "speclist.h"

Go to the source code of this file.

Data Structures

struct  vote_cast
 
struct  vote
 

Macros

#define SPECLIST_TAG   vote_cast
 
#define SPECLIST_TYPE   struct vote_cast
 
#define vote_cast_list_iterate(alist, pvc)    TYPED_LIST_ITERATE(struct vote_cast, alist, pvc)
 
#define vote_cast_list_iterate_end   LIST_ITERATE_END
 
#define SPECLIST_TAG   vote
 
#define SPECLIST_TYPE   struct vote
 
#define vote_list_iterate(alist, pvote)    TYPED_LIST_ITERATE(struct vote, alist, pvote)
 
#define vote_list_iterate_end   LIST_ITERATE_END
 

Enumerations

enum  vote_condition_flags { VCF_NONE = 0 , VCF_NODISSENT = (1 << 0) , VCF_NOPASSALONE = (1 << 1) , VCF_TEAMONLY = (1 << 2) }
 
enum  vote_type { VOTE_YES , VOTE_NO , VOTE_ABSTAIN , VOTE_NUM }
 

Functions

void voting_init (void)
 
void voting_free (void)
 
void voting_turn (void)
 
int count_voters (const struct vote *pvote)
 
void clear_all_votes (void)
 
void cancel_connection_votes (struct connection *pconn)
 
bool conn_can_vote (const struct connection *pconn, const struct vote *pvote)
 
bool conn_can_see_vote (const struct connection *pconn, const struct vote *pvote)
 
struct voteget_vote_by_no (int vote_no)
 
void connection_vote (struct connection *pconn, struct vote *pvote, enum vote_type type)
 
struct voteget_vote_by_caller (const struct connection *caller)
 
void remove_vote (struct vote *pvote)
 
struct votevote_new (struct connection *caller, const char *allargs, int command_id)
 
bool vote_would_pass_immediately (const struct connection *caller, int command_id)
 
const struct connectionvote_get_caller (const struct vote *pvote)
 
bool vote_is_team_only (const struct vote *pvote)
 
int describe_vote (struct vote *pvote, char *buf, int buflen)
 
void send_running_votes (struct connection *pconn, bool only_team_votes)
 
void send_remove_team_votes (struct connection *pconn)
 
void send_updated_vote_totals (struct conn_list *dest)
 

Variables

struct vote_list * vote_list
 
int vote_number_sequence
 

Macro Definition Documentation

◆ SPECLIST_TAG [1/2]

#define SPECLIST_TAG   vote_cast

Definition at line 39 of file voting.h.

◆ SPECLIST_TAG [2/2]

#define SPECLIST_TAG   vote

Definition at line 39 of file voting.h.

◆ SPECLIST_TYPE [1/2]

#define SPECLIST_TYPE   struct vote_cast

Definition at line 40 of file voting.h.

◆ SPECLIST_TYPE [2/2]

#define SPECLIST_TYPE   struct vote

Definition at line 40 of file voting.h.

◆ vote_cast_list_iterate

#define vote_cast_list_iterate (   alist,
  pvc 
)     TYPED_LIST_ITERATE(struct vote_cast, alist, pvc)

Definition at line 42 of file voting.h.

◆ vote_cast_list_iterate_end

#define vote_cast_list_iterate_end   LIST_ITERATE_END

Definition at line 44 of file voting.h.

◆ vote_list_iterate

#define vote_list_iterate (   alist,
  pvote 
)     TYPED_LIST_ITERATE(struct vote, alist, pvote)

Definition at line 63 of file voting.h.

◆ vote_list_iterate_end

#define vote_list_iterate_end   LIST_ITERATE_END

Definition at line 65 of file voting.h.

Enumeration Type Documentation

◆ vote_condition_flags

Enumerator
VCF_NONE 
VCF_NODISSENT 
VCF_NOPASSALONE 
VCF_TEAMONLY 

Definition at line 18 of file voting.h.

◆ vote_type

Enumerator
VOTE_YES 
VOTE_NO 
VOTE_ABSTAIN 
VOTE_NUM 

Definition at line 26 of file voting.h.

Function Documentation

◆ cancel_connection_votes()

void cancel_connection_votes ( struct connection pconn)

Cancel the votes of a lost or a detached connection.

Definition at line 691 of file voting.c.

Referenced by connection_detach().

◆ clear_all_votes()

void clear_all_votes ( void  )

Remove all votes. Sends vote_remove packets to clients.

Definition at line 219 of file voting.c.

Referenced by cancelvote_command(), start_game(), and voting_free().

◆ conn_can_see_vote()

bool conn_can_see_vote ( const struct connection pconn,
const struct vote pvote 
)

Usually, all users can see, except in the team vote case.

Definition at line 272 of file voting.c.

Referenced by lsend_vote_new(), lsend_vote_resolve(), lsend_vote_update(), send_remove_team_votes(), send_running_votes(), and show_votes().

◆ conn_can_vote()

bool conn_can_vote ( const struct connection pconn,
const struct vote pvote 
)

A user cannot vote if: is not connected access level < basic isn't a player the vote is a team vote and not on the caller's team NB: If 'pvote' is NULL, then the team condition is not checked.

Definition at line 248 of file voting.c.

Referenced by check_vote(), connection_vote(), count_voters(), handle_stdin_input_real(), vote_command(), vote_new(), and vote_would_pass_immediately().

◆ connection_vote()

void connection_vote ( struct connection pconn,
struct vote pvote,
enum vote_type  type 
)

Make the given connection vote 'type' on 'pvote', and check the vote.

Definition at line 663 of file voting.c.

Referenced by handle_stdin_input_real(), handle_vote_submit(), and vote_command().

◆ count_voters()

int count_voters ( const struct vote pvote)

Helper function that returns the current number of eligible voters.

Definition at line 48 of file voting.c.

Referenced by check_vote(), send_running_votes(), send_updated_vote_totals(), show_votes(), vote_new(), and vote_would_pass_immediately().

◆ describe_vote()

int describe_vote ( struct vote pvote,
char buf,
int  buflen 
)

Fills the supplied buffer with a string describing the given vote. This includes the vote command line, the percent required to pass, and any special conditions.

Definition at line 748 of file voting.c.

Referenced by handle_stdin_input_real(), and lsend_vote_new().

◆ get_vote_by_caller()

struct vote * get_vote_by_caller ( const struct connection caller)

Returns the vote called by 'caller', or NULL if none exists.

Definition at line 319 of file voting.c.

Referenced by cancel_connection_votes(), cancelvote_command(), handle_stdin_input_real(), and vote_new().

◆ get_vote_by_no()

struct vote * get_vote_by_no ( int  vote_no)

Returns the vote with vote number 'vote_no', or NULL.

Definition at line 301 of file voting.c.

Referenced by cancelvote_command(), handle_vote_submit(), and vote_command().

◆ remove_vote()

void remove_vote ( struct vote pvote)

Remove the given vote and send a vote_remove packet to clients.

Definition at line 205 of file voting.c.

Referenced by cancel_connection_votes(), cancelvote_command(), check_vote(), and vote_new().

◆ send_remove_team_votes()

void send_remove_team_votes ( struct connection pconn)

Sends a packet_vote_remove to pconn for every currently running team vote 'pconn' can see.

Definition at line 841 of file voting.c.

Referenced by connection_detach().

◆ send_running_votes()

void send_running_votes ( struct connection pconn,
bool  only_team_votes 
)

Sends a packet_vote_new to pconn for every currently running votes.

Definition at line 810 of file voting.c.

Referenced by connection_attach_real(), and establish_new_connection().

◆ send_updated_vote_totals()

void send_updated_vote_totals ( struct conn_list dest)

Sends a packet_vote_update to every conn in dest. If dest is NULL, then sends to all established connections.

Definition at line 866 of file voting.c.

Referenced by close_connection(), connection_attach_real(), connection_detach(), kill_dying_players(), and server_remove_player().

◆ vote_get_caller()

const struct connection * vote_get_caller ( const struct vote pvote)

Returns the connection that called this vote.

Definition at line 891 of file voting.c.

Referenced by cancelvote_command(), check_vote(), conn_can_see_vote(), and conn_can_vote().

◆ vote_is_team_only()

bool vote_is_team_only ( const struct vote pvote)

Returns TRUE if this vote is a "teamvote".

Definition at line 235 of file voting.c.

Referenced by check_vote(), conn_can_see_vote(), conn_can_vote(), handle_stdin_input_real(), send_remove_team_votes(), send_running_votes(), and show_votes().

◆ vote_new()

struct vote * vote_new ( struct connection caller,
const char allargs,
int  command_id 
)

Create and return a newly allocated vote for the command with id 'command_id' and all arguments in the string 'allargs'.

Definition at line 338 of file voting.c.

Referenced by handle_stdin_input_real().

◆ vote_would_pass_immediately()

bool vote_would_pass_immediately ( const struct connection caller,
int  command_id 
)

Return whether the vote would pass immediately when the caller will vote for.

Definition at line 391 of file voting.c.

Referenced by handle_stdin_input_real().

◆ voting_free()

void voting_free ( void  )

Free all memory used by this module.

Definition at line 734 of file voting.c.

Referenced by server_quit().

◆ voting_init()

void voting_init ( void  )

Initialize data structures used by this module.

Definition at line 707 of file voting.c.

Referenced by srv_prepare().

◆ voting_turn()

void voting_turn ( void  )

Check running votes. This should be called every turn.

Definition at line 718 of file voting.c.

Referenced by end_turn().

Variable Documentation

◆ vote_list

struct vote_list* vote_list
extern

◆ vote_number_sequence

int vote_number_sequence
extern

Definition at line 42 of file voting.c.

Referenced by vote_command(), vote_new(), and voting_init().