Freeciv-3.3: /fast/freeciv/nightly/main/common/government.c File Reference

Freeciv-3.3

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 government * | government_by_translated_name (const char *name)
struct government * | government_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 government * | government_by_number (const Government_type_id gov)
struct government * | government_of_player (const struct player *pplayer)
struct government * | government_of_city (const struct city *pcity)
const char * | government_rule_name (const struct government *pgovern)
const char * | government_name_translation (const struct government *pgovern)
const char * | government_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_title * | ruler_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_hash * | government_ruler_titles (const struct government *pgovern)
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)
const struct nation_type * | ruler_title_nation (const struct ruler_title *pruler_title)
const char * | ruler_title_male_untranslated_name (const struct ruler_title *pruler_title)
const char * | ruler_title_female_untranslated_name (const struct ruler_title *pruler_title)
const char * | ruler_title_for_player (const struct player *pplayer, char *buf, size_t buf_len)
const char * | default_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 void * | government_iter_get (const struct iterator *iter)
static bool | government_iter_valid (const struct iterator *iter)
struct iterator * | government_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)

## Variables

struct government * | governments = NULL

## Macro Definition Documentation

## ◆ GOVERNMENT_ITER

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

Definition at line 445 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 166 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 426 of file government.c.

Referenced by ruler_title_for_player(), and title_for_player().

## ◆ government_by_number()

struct government * government_by_number | ( | const Government_type_id | gov | ) |

Return the government with the given index.

This function returns NULL for an out-of-range index (some callers rely on this).

Definition at line 103 of file government.c.

Referenced by tab_gov::add_now(), api_find_government(), gov_menu::change_gov(), gov_menu::create(), extviewer_view_cell_toggled(), government_dlg_callback(), handle_edit_player(), handle_game_info(), handle_player_change_government(), handle_player_info(), handle_ruleset_government(), handle_ruleset_government_ruler_title(), handle_ruleset_nation(), popup_revolution_dialog(), universal_by_number(), and gov_menu::update().

## ◆ 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 55 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 40 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 |  | ) |

Return the number of governments.

Definition at line 71 of file government.c.

Referenced by adv_data_default(), client_government_sprite(), gov_menu::create(), create_current_governments_data(), create_current_governments_data_all(), extviewer_view_cell_toggled(), get_req_source_effects(), government_iter_init(), package_player_info(), receive_packet_ruleset_control_100(), send_ruleset_nations(), and gov_menu::update().

## ◆ government_free()

static void government_free | ( | struct government * | pgovern | ) |

inlinestatic

De-allocate resources associated with the given government.

Definition at line 512 of file government.c.

Referenced by governments_free().

## ◆ government_index()

Government_type_id government_index | ( | const struct government * | pgovern | ) |

Return the government index.

Currently same as government_number(), paired with government_count() indicates use as an array index.

Definition at line 82 of file government.c.

Referenced by adv_best_government(), create_current_governments_data(), create_current_governments_data_all(), create_tech_info(), extviewer_refresh_widgets(), extviewer_view_cell_toggled(), get_government_sprite(), load_government_names(), load_ruleset_governments(), notify_new_government_options(), objbind_pack_current_values(), objbind_pack_modified_value(), tab_gov::refresh(), and tileset_setup_government().

## ◆ government_init()

static void government_init | ( | struct government * | pgovern | ) |

inlinestatic

Allocate resources associated with the given government.

Definition at line 496 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 466 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 483 of file government.c.

## ◆ government_iter_next()

static void government_iter_next | ( | struct iterator * | iter | ) |

static

Implementation of iterator 'next' function.

Definition at line 458 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 450 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 474 of file government.c.

Referenced by government_iter_init().

## ◆ government_name_for_player()

const char * government_name_for_player | ( | const struct player * | pplayer | ) |

Return the (translated) name of the given government of a player. You don't have to free the return pointer.

Definition at line 154 of file government.c.

Referenced by col_government(), get_government_tooltip(), get_info_label_text_popup(), get_report_title(), handle_player_rates(), plr_widget::nation_selected(), popup_rates_dialog(), report_achievements(), report_demographics(), set_indicator_icons(), tax_rates_dialog::tax_rates_dialog(), update_intel_dialog(), and fc_client::update_sidebar_tooltips().

## ◆ government_name_translation()

const char * government_name_translation | ( | const struct government * | pgovern | ) |

Return the (translated) name of the given government. You don't have to free the return pointer.

Definition at line 143 of file government.c.

Referenced by api_methods_government_name_translation(), boot_help_texts(), gov_menu::create(), create_tech_info(), economy_report_dialog_popup(), extviewer_refresh_widgets(), extviewer_view_cell_toggled(), government_by_translated_name(), government_change(), government_name_for_player(), handle_player_change_government(), help_update_tech(), helptext_nation(), insert_allows(), manual_governments(), research_diagram::mouseMoveEvent(), research_diagram::mousePressEvent(), notify_new_government_options(), popup_government_dialog(), propval_as_string(), real_menus_init(), real_menus_update(), req_text_insert(), research_tech_lost(), help_widget::set_topic_tech(), universal_name_translation(), update_city_activity(), and worklist_item_postpone_req_vec().

## ◆ government_number()

Government_type_id government_number | ( | const struct government * | pgovern | ) |

Return the government index.

Definition at line 91 of file government.c.

Referenced by dai_government_change(), get_gov(), government_ruler_title_new(), load_ruleset_governments(), load_ruleset_nations(), package_player_info(), popup_government_dialog(), popup_revolution_dialog(), research_tech_lost(), ruler_title_for_player(), send_ruleset_governments(), send_ruleset_nations(), set_government_choice(), universal_number(), and update_city_activity().

## ◆ 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 123 of file government.c.

Referenced by update_city_activity().

## ◆ government_of_player()

struct government * government_of_player | ( | const struct player * | pplayer | ) |

Return the government of a player.

Definition at line 114 of file government.c.

Referenced by add_tax_income(), adv_best_government(), cityresult_fill(), client_government_sprite(), dai_government_change(), dai_manage_government(), dai_manage_taxes(), economy_report_dialog_popup(), get_economy_report_data(), get_gov(), get_tax_rates(), government_name_for_player(), government_of_city(), handle_player_change_government(), is_gov_req_active(), package_player_info(), research_tech_lost(), ruler_title_for_player(), set_government_choice(), sg_save_player_main(), split_player(), and update_revolution().

## ◆ government_rule_name()

const char * government_rule_name | ( | const struct government * | pgovern | ) |

Return the (untranslated) rule name of the government. You don't have to free the return pointer.

Definition at line 133 of file government.c.

Referenced by api_methods_government_rule_name(), dai_manage_government(), tab_gov::delete_now(), tab_gov::edit_effects(), tab_gov::edit_reqs(), government_by_rule_name(), government_change(), government_ruler_title_new(), handle_player_change_government(), is_universal_needed(), load_ruleset_governments(), load_ruleset_nations(), tab_gov::name_given(), tab_gov::refresh(), ruler_title_for_player(), sanity_check_ruleset_data(), save_gov_ref(), save_nation(), save_nations_ruleset(), sg_save_player_main(), sg_save_ruledata(), tileset_setup_government(), universal_kind_values(), universal_rule_name(), tab_gov::update_gov_info(), and update_revolution().

## ◆ 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 325 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 314 of file government.c.

Referenced by send_ruleset_governments().

## ◆ governments_alloc()

void governments_alloc | ( | int | num | ) |

Allocate the governments.

Definition at line 528 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 544 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 205 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 197 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 239 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 231 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 383 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 391 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 374 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 365 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 214 of file government.c.

Referenced by government_ruler_title_new().

## ◆ 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 565 of file government.c.

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

## Variable Documentation

## ◆ governments

struct government* governments = NULL

Definition at line 34 of file government.c.

Referenced by government_by_number(), government_index(), government_init(), government_iter_init(), governments_alloc(), and governments_free().