Freeciv-3.2
Loading...
Searching...
No Matches
Macros | Functions | Variables
voteinfo.c File Reference
#include <time.h>
#include "log.h"
#include "packets.h"
#include "voteinfo_bar_g.h"
#include "client_main.h"
#include "clinet.h"
#include "options.h"
#include "voteinfo.h"
#include "speclist.h"

Go to the source code of this file.

Macros

#define SPECLIST_TAG   voteinfo
 
#define SPECLIST_TYPE   struct voteinfo
 
#define voteinfo_list_iterate(alist, pitem)    TYPED_LIST_ITERATE(struct voteinfo, alist, pitem)
 
#define voteinfo_list_iterate_end   LIST_ITERATE_END
 

Functions

void voteinfo_queue_delayed_remove (int vote_no)
 
void voteinfo_queue_check_removed (void)
 
void voteinfo_queue_remove (int vote_no)
 
void voteinfo_queue_add (int vote_no, const char *user, const char *desc, int percent_required, int flags)
 
struct voteinfovoteinfo_queue_find (int vote_no)
 
void voteinfo_queue_init (void)
 
void voteinfo_queue_free (void)
 
struct voteinfovoteinfo_queue_get_current (int *pindex)
 
void voteinfo_do_vote (int vote_no, enum client_vote_type vote)
 
void voteinfo_queue_next (void)
 
int voteinfo_queue_size (void)
 
bool voteinfo_bar_can_be_shown (void)
 

Variables

static struct voteinfo_listvoteinfo_queue = NULL
 
static int voteinfo_queue_current_index = 0
 

Macro Definition Documentation

◆ SPECLIST_TAG

#define SPECLIST_TAG   voteinfo

Definition at line 38 of file voteinfo.c.

◆ SPECLIST_TYPE

#define SPECLIST_TYPE   struct voteinfo

Definition at line 39 of file voteinfo.c.

◆ voteinfo_list_iterate

#define voteinfo_list_iterate (   alist,
  pitem 
)     TYPED_LIST_ITERATE(struct voteinfo, alist, pitem)

Definition at line 41 of file voteinfo.c.

◆ voteinfo_list_iterate_end

#define voteinfo_list_iterate_end   LIST_ITERATE_END

Definition at line 43 of file voteinfo.c.

Function Documentation

◆ voteinfo_bar_can_be_shown()

bool voteinfo_bar_can_be_shown ( void  )

Returns whether the voteinfo bar should be displayed or not.

Definition at line 299 of file voteinfo.c.

Referenced by voteinfo_gui_update().

◆ voteinfo_do_vote()

void voteinfo_do_vote ( int  vote_no,
enum client_vote_type  vote 
)

Convenience function for submitting a vote to the server. NB: Only to be used if the server has the "voteinfo" capability.

Definition at line 234 of file voteinfo.c.

Referenced by pregamevote::v_abstain(), pregamevote::v_no(), pregamevote::v_yes(), and voteinfo_bar_do_vote_callback().

◆ voteinfo_queue_add()

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 at line 123 of file voteinfo.c.

Referenced by handle_vote_new().

◆ voteinfo_queue_check_removed()

void voteinfo_queue_check_removed ( void  )

Check for old votes that should be removed from the queue. This function should be called periodically from a timer callback.

Definition at line 72 of file voteinfo.c.

Referenced by real_timer_callback().

◆ voteinfo_queue_delayed_remove()

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 was removed.

Definition at line 53 of file voteinfo.c.

Referenced by handle_vote_remove().

◆ voteinfo_queue_find()

struct voteinfo * voteinfo_queue_find ( int  vote_no)

Find the voteinfo record corresponding to the given vote number.

Definition at line 150 of file voteinfo.c.

Referenced by handle_vote_new(), handle_vote_resolve(), handle_vote_update(), voteinfo_do_vote(), voteinfo_queue_delayed_remove(), and voteinfo_queue_remove().

◆ voteinfo_queue_free()

void voteinfo_queue_free ( void  )

Free memory allocated by this module.

Definition at line 179 of file voteinfo.c.

Referenced by client_game_free(), and voteinfo_queue_init().

◆ voteinfo_queue_get_current()

struct voteinfo * voteinfo_queue_get_current ( int pindex)

Get the voteinfo record at the start of the vote queue. If 'pindex' is non-NULL, it is set to queue index of that record. This function is used in conjunction with voteinfo_queue_next().

Definition at line 201 of file voteinfo.c.

Referenced by pregamevote::update_vote(), pregamevote::v_abstain(), pregamevote::v_no(), pregamevote::v_yes(), voteinfo_bar_can_be_shown(), voteinfo_bar_do_vote_callback(), and voteinfo_gui_update().

◆ voteinfo_queue_init()

void voteinfo_queue_init ( void  )

Initialize data structures used by this module.

Definition at line 167 of file voteinfo.c.

Referenced by client_game_init().

◆ voteinfo_queue_next()

void voteinfo_queue_next ( void  )

Cycle through the votes in the queue.

Definition at line 272 of file voteinfo.c.

Referenced by voteinfo_bar_next_callback(), and voteinfo_queue_get_current().

◆ voteinfo_queue_remove()

void voteinfo_queue_remove ( int  vote_no)

Remove the given vote from the queue immediately.

Definition at line 103 of file voteinfo.c.

Referenced by voteinfo_queue_check_removed().

◆ voteinfo_queue_size()

int voteinfo_queue_size ( void  )

Returns the number of pending votes.

Definition at line 291 of file voteinfo.c.

Referenced by pregamevote::update_vote(), and voteinfo_gui_update().

Variable Documentation

◆ voteinfo_queue

struct voteinfo_list* voteinfo_queue = NULL
static

◆ voteinfo_queue_current_index

int voteinfo_queue_current_index = 0
static