Freeciv21
Develop your civilization from humble roots to a global empire
government.cpp File Reference
#include "fcintl.h"
#include "log.h"
#include "shared.h"
#include "support.h"
#include "game.h"
#include "nation.h"
#include "player.h"
#include "tech.h"
#include "government.h"
+ Include dependency graph for government.cpp:

Go to the source code of this file.

Classes

struct  ruler_title
 Ruler titles. More...
 

Functions

struct governmentgovernment_by_translated_name (const char *name)
 Returns the government that has the given (translated) name. More...
 
struct governmentgovernment_by_rule_name (const char *name)
 Returns the government that has the given (untranslated) rule name. More...
 
Government_type_id government_count ()
 Return the number of governments. More...
 
Government_type_id government_index (const struct government *pgovern)
 Return the government index. More...
 
Government_type_id government_number (const struct government *pgovern)
 Return the government index. More...
 
struct governmentgovernment_by_number (const Government_type_id gov)
 Return the government with the given index. More...
 
struct governmentgovernment_of_player (const struct player *pplayer)
 Return the government of a player. More...
 
struct governmentgovernment_of_city (const struct city *pcity)
 Return the government of the player who owns the city. More...
 
const char * government_rule_name (const struct government *pgovern)
 Return the (untranslated) rule name of the government. More...
 
const char * government_name_translation (const struct government *pgovern)
 Return the (translated) name of the given government. More...
 
const char * government_name_for_player (const struct player *pplayer)
 Return the (translated) name of the given government of a player. More...
 
bool can_change_to_government (struct player *pplayer, const struct government *gov)
 Can change to government if appropriate tech exists, and one of: More...
 
static struct ruler_titleruler_title_new (const struct nation_type *pnation, const char *domain, const char *ruler_male_title, const char *ruler_female_title)
 Create a new ruler title. More...
 
static void ruler_title_destroy (struct ruler_title *pruler_title)
 Free a ruler title. More...
 
static bool ruler_title_check (const struct ruler_title *pruler_title)
 Return TRUE if the ruler title is valid. More...
 
QHash< const struct nation_type *, struct ruler_title * > * government_ruler_titles (const struct government *pgovern)
 Returns all ruler titles for a government type. More...
 
struct ruler_titlegovernment_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. More...
 
const struct nation_typeruler_title_nation (const struct ruler_title *pruler_title)
 Return the nation of the rule title. More...
 
const char * ruler_title_male_untranslated_name (const struct ruler_title *pruler_title)
 Return the male rule title name. More...
 
const char * ruler_title_female_untranslated_name (const struct ruler_title *pruler_title)
 Return the female rule title name. More...
 
const char * ruler_title_for_player (const struct player *pplayer, char *buf, size_t buf_len)
 Return the ruler title of the player (translated). More...
 
void governments_alloc (int num)
 Allocate the governments. More...
 
void governments_free ()
 De-allocate the currently allocated governments. More...
 
bool untargeted_revolution_allowed ()
 Is it possible to start a revolution without specifying the target government in the current game? More...
 

Variables

std::vector< governmentgovernments
 

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 nullptr (used for observers).

Definition at line 159 of file government.cpp.

Referenced by adv_best_government(), dai_effect_value(), found_new_tech(), handle_player_change_government(), research_tech_lost(), and gov_menu::update().

◆ 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 nullptr if none match.

Definition at line 48 of file government.cpp.

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_ruledata(), and universal_by_number().

◆ government_by_translated_name()

struct government* government_by_translated_name ( const char *  name)

Returns the government that has the given (translated) name.

Returns nullptr if none match.

Definition at line 33 of file government.cpp.

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

◆ government_count()

◆ 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 75 of file government.cpp.

Referenced by adv_best_government(), found_new_tech(), get_government_sprite(), load_government_names(), load_ruleset_governments(), tab_gov::refresh(), and tileset_setup_government().

◆ 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 147 of file government.cpp.

Referenced by col_government(), get_info_label_text_popup(), handle_player_rates(), plr_widget::nation_selected(), national_budget_dialog::refresh(), report_achievements(), report_demographics(), and pageGame::updateSidebarTooltips().

◆ government_name_translation()

◆ government_number()

◆ 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 116 of file government.cpp.

Referenced by city_handle_disorder().

◆ government_of_player()

◆ government_rule_name()

◆ 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 nullptr for pnation for defining the default title.

Definition at line 300 of file government.cpp.

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

◆ government_ruler_titles()

QHash<const struct nation_type *, struct ruler_title *>* government_ruler_titles ( const struct government pgovern)

Returns all ruler titles for a government type.

Definition at line 290 of file government.cpp.

Referenced by send_ruleset_governments().

◆ governments_alloc()

void governments_alloc ( int  num)

Allocate the governments.

Definition at line 437 of file government.cpp.

Referenced by handle_ruleset_control(), and load_government_names().

◆ governments_free()

void governments_free ( )

De-allocate the currently allocated governments.

Definition at line 452 of file government.cpp.

Referenced by game_ruleset_free().

◆ 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 215 of file government.cpp.

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 207 of file government.cpp.

Referenced by 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 rule title name.

Definition at line 358 of file government.cpp.

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 366 of file government.cpp.

Referenced by diplo_wdg::diplo_wdg(), plr_widget::nation_selected(), and update_city_activities().

◆ ruler_title_male_untranslated_name()

const char* ruler_title_male_untranslated_name ( const struct ruler_title pruler_title)

Return the male rule title name.

Definition at line 349 of file government.cpp.

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 rule title.

Returns nullptr if this is default.

Definition at line 340 of file government.cpp.

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 190 of file government.cpp.

Referenced by government_ruler_title_new().

◆ untargeted_revolution_allowed()

bool untargeted_revolution_allowed ( )

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

Definition at line 462 of file government.cpp.

Referenced by revolution_length().

Variable Documentation

◆ governments