Freeciv-3.4
Loading...
Searching...
No Matches
Data Structures | Macros | Functions | Variables
government.c File Reference
#include "fcintl.h"
#include "log.h"
#include "mem.h"
#include "shared.h"
#include "string_vector.h"
#include "support.h"
#include "game.h"
#include "nation.h"
#include "player.h"
#include "tech.h"
#include "government.h"

Go to the source code of this file.

Data Structures

struct  ruler_title
 
struct  government_iter
 

Macros

#define GOVERNMENT_ITER(p)   ((struct government_iter *) (p))
 

Functions

struct governmentgovernment_by_translated_name (const char *name)
 
struct governmentgovernment_by_rule_name (const char *name)
 
Government_type_id government_count (void)
 
Government_type_id government_index (const struct government *pgovern)
 
Government_type_id government_number (const struct government *pgovern)
 
struct governmentgovernment_by_number (const Government_type_id gov)
 
struct governmentgovernment_of_player (const struct player *pplayer)
 
struct governmentgovernment_of_city (const struct city *pcity)
 
const chargovernment_rule_name (const struct government *pgovern)
 
const chargovernment_name_translation (const struct government *pgovern)
 
const chargovernment_name_for_player (const struct player *pplayer)
 
bool can_change_to_government (struct player *pplayer, const struct government *gov)
 
static genhash_val_t nation_hash_val (const struct nation_type *pnation)
 
static bool nation_hash_comp (const struct nation_type *pnation1, const struct nation_type *pnation2)
 
static struct ruler_titleruler_title_new (const struct nation_type *pnation, const char *domain, const char *ruler_male_title, const char *ruler_female_title)
 
static void ruler_title_destroy (struct ruler_title *pruler_title)
 
static bool ruler_title_check (const struct ruler_title *pruler_title)
 
const struct ruler_title_hashgovernment_ruler_titles (const struct government *pgovern)
 
struct ruler_titlegovernment_ruler_title_new (struct government *pgovern, const struct nation_type *pnation, const char *ruler_male_title, const char *ruler_female_title)
 
const struct nation_typeruler_title_nation (const struct ruler_title *pruler_title)
 
const charruler_title_male_untranslated_name (const struct ruler_title *pruler_title)
 
const charruler_title_female_untranslated_name (const struct ruler_title *pruler_title)
 
const charruler_title_for_player (const struct player *pplayer, char *buf, size_t buf_len)
 
const chardefault_title_for_player (const struct player *pplayer, char *buf, size_t buf_len)
 
size_t government_iter_sizeof (void)
 
static void government_iter_next (struct iterator *iter)
 
static voidgovernment_iter_get (const struct iterator *iter)
 
static bool government_iter_valid (const struct iterator *iter)
 
struct iteratorgovernment_iter_init (struct government_iter *it)
 
static void government_init (struct government *pgovern)
 
static void government_free (struct government *pgovern)
 
void governments_alloc (int num)
 
void governments_free (void)
 
bool untargeted_revolution_allowed (void)
 
bool government_has_flag (const struct government *pgov, enum gov_flag_id flag)
 
void user_gov_flags_init (void)
 
void gov_flags_free (void)
 
void set_user_gov_flag_name (enum gov_flag_id id, const char *name, const char *helptxt)
 
const chargov_flag_id_name_cb (enum gov_flag_id flag)
 
const chargov_flag_helptxt (enum gov_flag_id id)
 

Variables

struct governmentgovernments = NULL
 
static struct user_flag user_gov_flags [MAX_NUM_USER_GOVERNMENT_FLAGS]
 

Macro Definition Documentation

◆ GOVERNMENT_ITER

#define GOVERNMENT_ITER (   p)    ((struct government_iter *) (p))

Definition at line 447 of file government.c.

Function Documentation

◆ can_change_to_government()

bool can_change_to_government ( struct player pplayer,
const struct government gov 
)

Can change to government if appropriate tech exists, and one of:

  • no required tech (required is A_NONE)
  • player has required tech
  • we have an appropriate wonder Returns FALSE if pplayer is NULL (used for observers).

Definition at line 168 of file government.c.

Referenced by adv_best_government(), create_current_governments_data(), create_current_governments_data_all(), dai_effect_value(), handle_player_change_government(), notify_new_government_options(), pick_random_government(), popup_government_dialog(), real_menus_update(), research_tech_lost(), and gov_menu::update().

◆ default_title_for_player()

const char * default_title_for_player ( const struct player pplayer,
char buf,
size_t  buf_len 
)

Return default ruler title of the player (translated).

Definition at line 428 of file government.c.

Referenced by ruler_title_for_player(), and title_for_player().

◆ gov_flag_helptxt()

const char * gov_flag_helptxt ( enum gov_flag_id  id)

Return the (untranslated) help text of the user government flag.

Definition at line 656 of file government.c.

Referenced by save_governments_ruleset(), and send_ruleset_governments().

◆ gov_flag_id_name_cb()

const char * gov_flag_id_name_cb ( enum gov_flag_id  flag)

Government flag name callback, called from specenum code.

Definition at line 644 of file government.c.

Referenced by save_governments_ruleset().

◆ gov_flags_free()

void gov_flags_free ( void  )

Frees the memory associated with all government flags

Definition at line 607 of file government.c.

◆ government_by_number()

struct government * government_by_number ( const Government_type_id  gov)

◆ government_by_rule_name()

struct government * government_by_rule_name ( const char name)

Returns the government that has the given (untranslated) rule name. Returns NULL if none match.

Definition at line 57 of file government.c.

Referenced by api_find_government_by_name(), tab_gov::initialize_new_gov(), load_ruleset_nations(), lookup_government(), tab_gov::select_gov(), sg_load_player_main(), sg_load_player_main(), sg_load_ruledata(), sg_load_ruledata(), and universal_value_from_str().

◆ government_by_translated_name()

struct government * government_by_translated_name ( const char name)

Returns the government that has the given (translated) name. Returns NULL if none match.

Definition at line 42 of file government.c.

Referenced by help_update_government(), help_dialog::make_tree(), and help_widget::set_topic_government().

◆ government_count()

Government_type_id government_count ( void  )

◆ government_free()

static void government_free ( struct government pgovern)
inlinestatic

De-allocate resources associated with the given government.

Definition at line 515 of file government.c.

Referenced by governments_free().

◆ government_has_flag()

bool government_has_flag ( const struct government pgov,
enum gov_flag_id  flag 
)

Return TRUE if the government has this flag, otherwise FALSE

Definition at line 583 of file government.c.

◆ government_index()

Government_type_id government_index ( const struct government pgovern)

◆ government_init()

static void government_init ( struct government pgovern)
inlinestatic

Allocate resources associated with the given government.

Definition at line 498 of file government.c.

Referenced by governments_alloc().

◆ government_iter_get()

static void * government_iter_get ( const struct iterator iter)
static

Implementation of iterator 'get' function.

Definition at line 468 of file government.c.

Referenced by government_iter_init().

◆ government_iter_init()

struct iterator * government_iter_init ( struct government_iter it)

Implementation of iterator 'init' function.

Definition at line 485 of file government.c.

◆ government_iter_next()

static void government_iter_next ( struct iterator iter)
static

Implementation of iterator 'next' function.

Definition at line 460 of file government.c.

Referenced by government_iter_init().

◆ government_iter_sizeof()

size_t government_iter_sizeof ( void  )

Implementation of iterator 'sizeof' function.

Definition at line 452 of file government.c.

◆ government_iter_valid()

static bool government_iter_valid ( const struct iterator iter)
static

Implementation of iterator 'valid' function.

Definition at line 476 of file government.c.

Referenced by government_iter_init().

◆ government_name_for_player()

const char * government_name_for_player ( const struct player pplayer)

◆ government_name_translation()

const char * government_name_translation ( const struct government pgovern)

◆ government_number()

Government_type_id government_number ( const struct government pgovern)

◆ government_of_city()

struct government * government_of_city ( const struct city pcity)

Return the government of the player who owns the city.

Definition at line 125 of file government.c.

Referenced by update_city_activity().

◆ government_of_player()

struct government * government_of_player ( const struct player pplayer)

◆ government_rule_name()

const char * government_rule_name ( const struct government pgovern)

◆ government_ruler_title_new()

struct ruler_title * government_ruler_title_new ( struct government pgovern,
const struct nation_type pnation,
const char ruler_male_title,
const char ruler_female_title 
)

Add a new ruler title for the nation. Pass NULL for pnation for defining the default title.

Definition at line 327 of file government.c.

Referenced by handle_ruleset_government_ruler_title(), load_ruleset_governments(), and load_ruleset_nations().

◆ government_ruler_titles()

const struct ruler_title_hash * government_ruler_titles ( const struct government pgovern)

Returns all ruler titles for a government type.

Definition at line 316 of file government.c.

Referenced by send_ruleset_governments().

◆ governments_alloc()

void governments_alloc ( int  num)

Allocate the governments.

Definition at line 531 of file government.c.

Referenced by handle_ruleset_control(), and load_government_names().

◆ governments_free()

void governments_free ( void  )

De-allocate the currently allocated governments.

Definition at line 547 of file government.c.

Referenced by game_ruleset_free().

◆ nation_hash_comp()

static bool nation_hash_comp ( const struct nation_type pnation1,
const struct nation_type pnation2 
)
static

Hash function.

Definition at line 207 of file government.c.

Referenced by government_init().

◆ nation_hash_val()

static genhash_val_t nation_hash_val ( const struct nation_type pnation)
static

Hash function.

Definition at line 199 of file government.c.

Referenced by government_init().

◆ ruler_title_check()

static bool ruler_title_check ( const struct ruler_title pruler_title)
static

Return TRUE if the ruler title is valid.

Definition at line 241 of file government.c.

Referenced by government_ruler_title_new().

◆ ruler_title_destroy()

static void ruler_title_destroy ( struct ruler_title pruler_title)
static

Free a ruler title.

Definition at line 233 of file government.c.

Referenced by government_init(), and government_ruler_title_new().

◆ ruler_title_female_untranslated_name()

const char * ruler_title_female_untranslated_name ( const struct ruler_title pruler_title)

Return the female ruler title name.

Definition at line 385 of file government.c.

Referenced by save_governments_ruleset(), save_nation(), and send_ruleset_governments().

◆ ruler_title_for_player()

const char * ruler_title_for_player ( const struct player pplayer,
char buf,
size_t  buf_len 
)

Return the ruler title of the player (translated).

Definition at line 393 of file government.c.

Referenced by create_diplomacy_dialog(), diplo_wdg::diplo_wdg(), get_report_title(), title_for_player(), update_intel_dialog(), and update_national_activities().

◆ ruler_title_male_untranslated_name()

const char * ruler_title_male_untranslated_name ( const struct ruler_title pruler_title)

Return the male ruler title name.

Definition at line 376 of file government.c.

Referenced by save_governments_ruleset(), save_nation(), and send_ruleset_governments().

◆ ruler_title_nation()

const struct nation_type * ruler_title_nation ( const struct ruler_title pruler_title)

Return the nation of the ruler title. Returns NULL if this is default.

Definition at line 367 of file government.c.

Referenced by send_ruleset_governments().

◆ ruler_title_new()

static struct ruler_title * ruler_title_new ( const struct nation_type pnation,
const char domain,
const char ruler_male_title,
const char ruler_female_title 
)
static

Create a new ruler title.

Definition at line 216 of file government.c.

Referenced by government_ruler_title_new().

◆ set_user_gov_flag_name()

void set_user_gov_flag_name ( enum gov_flag_id  id,
const char name,
const char helptxt 
)

Sets user defined name for government flag.

Definition at line 619 of file government.c.

Referenced by handle_ruleset_gov_flag(), and load_government_names().

◆ untargeted_revolution_allowed()

bool untargeted_revolution_allowed ( void  )

Is it possible to start a revolution without specifying the target government in the current game?

Definition at line 568 of file government.c.

Referenced by real_menus_update(), revolution_length(), and gov_menu::update().

◆ user_gov_flags_init()

void user_gov_flags_init ( void  )

Initialize user government flags.

Definition at line 595 of file government.c.

Variable Documentation

◆ governments

struct government* governments = NULL

◆ user_gov_flags