Freeciv-3.1: /fast/freeciv/nightly/S3_1/common/nation.c File Reference

Freeciv-3.1

Loading...
Searching...
No Matches
Data Structures | Macros | Functions | Variables
nation.c File Reference
`#include "fcintl.h"`
`#include "log.h"`
`#include "mem.h"`
`#include "support.h"`
`#include "connection.h"`
`#include "game.h"`
`#include "government.h"`
`#include "player.h"`
`#include "tech.h"`
`#include "traits.h"`
`#include "nation.h"`

Go to the source code of this file.

## Data Structures

struct | nation_set
struct | nation_leader
struct | nation_city
struct | nation_iter
struct | nation_set_iter
struct | nation_group_iter

## Macros

#define | NATION_CHECK(pnation, action) /* Do Nothing. */
#define | NATION_ITER(p) ((struct nation_iter *)(p))
#define | NATION_SET_ITER(p) ((struct nation_set_iter *)(p))
#define | NATION_GROUP_ITER(p) ((struct nation_group_iter *)(p))

## Functions

struct nation_type * | nation_by_translated_plural (const char *name)
struct nation_type * | nation_by_rule_name (const char *name)
const char * | nation_rule_name (const struct nation_type *pnation)
const char * | nation_adjective_translation (const struct nation_type *pnation)
const char * | nation_plural_translation (const struct nation_type *pnation)
const char * | nation_adjective_for_player (const struct player *pplayer)
const char * | nation_plural_for_player (const struct player *pplayer)
bool | is_nation_pickable (const struct nation_type *nation)
bool | is_nation_playable (const struct nation_type *nation)
enum barbarian_type | nation_barbarian_type (const struct nation_type *nation)
const struct nation_leader_list * | nation_leaders (const struct nation_type *pnation)
struct nation_leader * | nation_leader_new (struct nation_type *pnation, const char *name, bool is_male)
static void | nation_leader_destroy (struct nation_leader *pleader)
struct nation_leader * | nation_leader_by_name (const struct nation_type *pnation, const char *name)
const char * | nation_leader_name (const struct nation_leader *pleader)
bool | nation_leader_is_male (const struct nation_leader *pleader)
const char * | nation_legend_translation (const struct nation_type *pnation, const char *legend)
const struct nation_city_list * | nation_cities (const struct nation_type *pnation)
struct nation_city * | nation_city_new (struct nation_type *pnation, const char *name)
static void | nation_city_destroy (struct nation_city *pncity)
enum nation_city_preference | nation_city_preference_revert (enum nation_city_preference prefer)
void | nation_city_set_terrain_preference (struct nation_city *pncity, const struct terrain *pterrain, enum nation_city_preference prefer)
void | nation_city_set_river_preference (struct nation_city *pncity, enum nation_city_preference prefer)
const char * | nation_city_name (const struct nation_city *pncity)
enum nation_city_preference | nation_city_terrain_preference (const struct nation_city *pncity, const struct terrain *pterrain)
enum nation_city_preference | nation_city_river_preference (const struct nation_city *pncity)
struct nation_type * | nation_of_player (const struct player *pplayer)
struct nation_type * | nation_of_city (const struct city *pcity)
struct nation_type * | nation_of_unit (const struct unit *punit)
struct nation_type * | nation_by_number (const Nation_type_id nation)
Nation_type_id | nation_number (const struct nation_type *pnation)
Nation_type_id | nation_index (const struct nation_type *pnation)
Nation_type_id | nation_count (void)
size_t | nation_iter_sizeof (void)
static void | nation_iter_next (struct iterator *iter)
static void * | nation_iter_get (const struct iterator *iter)
static bool | nation_iter_valid (const struct iterator *iter)
struct iterator * | nation_iter_init (struct nation_iter *it)
static void | nation_init (struct nation_type *pnation)
static void | nation_free (struct nation_type *pnation)
void | nations_alloc (int num)
void | nations_free (void)
struct government * | init_government_of_nation (const struct nation_type *pnation)
struct nation_style * | style_of_nation (const struct nation_type *pnation)
const struct rgbcolor * | nation_color (const struct nation_type *pnation)
int | nation_set_count (void)
int | nation_set_index (const struct nation_set *pset)
int | nation_set_number (const struct nation_set *pset)
struct nation_set * | nation_set_new (const char *set_name, const char *set_rule_name, const char *set_description)
struct nation_set * | nation_set_by_number (int id)
struct nation_set * | nation_set_by_rule_name (const char *name)
const char * | nation_set_untranslated_name (const struct nation_set *pset)
const char * | nation_set_rule_name (const struct nation_set *pset)
const char * | nation_set_name_translation (const struct nation_set *pset)
const char * | nation_set_description (const struct nation_set *pset)
bool | nation_is_in_set (const struct nation_type *pnation, const struct nation_set *pset)
struct nation_set * | nation_set_by_setting_value (const char *setting)
size_t | nation_set_iter_sizeof (void)
static void | nation_set_iter_next (struct iterator *iter)
static void * | nation_set_iter_get (const struct iterator *iter)
static bool | nation_set_iter_valid (const struct iterator *iter)
struct iterator * | nation_set_iter_init (struct nation_set_iter *it)
int | nation_group_count (void)
int | nation_group_index (const struct nation_group *pgroup)
int | nation_group_number (const struct nation_group *pgroup)
struct nation_group * | nation_group_new (const char *name)
struct nation_group * | nation_group_by_number (int id)
struct nation_group * | nation_group_by_rule_name (const char *name)
void | nation_group_set_hidden (struct nation_group *pgroup, bool hidden)
void | nation_group_set_match (struct nation_group *pgroup, int match)
bool | is_nation_group_hidden (struct nation_group *pgroup)
const char * | nation_group_untranslated_name (const struct nation_group *pgroup)
const char * | nation_group_rule_name (const struct nation_group *pgroup)
const char * | nation_group_name_translation (const struct nation_group *pgroup)
bool | nation_is_in_group (const struct nation_type *pnation, const struct nation_group *pgroup)
size_t | nation_group_iter_sizeof (void)
static void | nation_group_iter_next (struct iterator *iter)
static void * | nation_group_iter_get (const struct iterator *iter)
static bool | nation_group_iter_valid (const struct iterator *iter)
struct iterator * | nation_group_iter_init (struct nation_group_iter *it)
void | nation_sets_groups_init (void)
void | nation_sets_groups_free (void)
bool | can_conn_edit_players_nation (const struct connection *pconn, const struct player *pplayer)
int | nations_match (const struct nation_type *pnation1, const struct nation_type *pnation2, bool ignore_conflicts)

## Variables

static struct nation_type * | nations = NULL
static int | num_nation_sets
static struct nation_set | nation_sets [MAX_NUM_NATION_SETS]
static int | num_nation_groups
static struct nation_group | nation_groups [MAX_NUM_NATION_GROUPS]

## Macro Definition Documentation

## ◆ NATION_CHECK

#define NATION_CHECK | ( |  | pnation,
|  |  | action
| ) |  | /* Do Nothing. */

Definition at line 98 of file nation.c.

## ◆ NATION_GROUP_ITER

#define NATION_GROUP_ITER | ( |  | p | ) | ((struct nation_group_iter *)(p))

Definition at line 1118 of file nation.c.

## ◆ NATION_ITER

#define NATION_ITER | ( |  | p | ) | ((struct nation_iter *)(p))

Definition at line 518 of file nation.c.

## ◆ NATION_SET_ITER

#define NATION_SET_ITER | ( |  | p | ) | ((struct nation_set_iter *)(p))

Definition at line 883 of file nation.c.

## Function Documentation

## ◆ can_conn_edit_players_nation()

bool can_conn_edit_players_nation | ( | const struct connection * | pconn,
|  | const struct player * | pplayer
| ) |  |

Return TRUE iff the editor is allowed to edit the player's nation in pregame.

Definition at line 1186 of file nation.c.

Referenced by create_conn_menu(), handle_nation_select_req(), and fc_client::start_page_menu().

## ◆ init_government_of_nation()

struct government * init_government_of_nation | ( | const struct nation_type * | pnation | ) |

Returns initial government type for this nation. Always returns non-NULL – nation-specific government or failing that ruleset default government.

Definition at line 658 of file nation.c.

Referenced by create_animals(), create_barbarian_player(), create_command_newcomer(), dai_manage_government(), final_ruleset_adjustments(), handle_edit_player_create(), and split_player().

## ◆ is_nation_group_hidden()

bool is_nation_group_hidden | ( | struct nation_group * | pgroup | ) |

Return whether this group should appear in the nation selection UI.

Definition at line 1056 of file nation.c.

Referenced by create_nation_selection_lists(), create_races_dialog(), and races_dialog::refresh().

## ◆ is_nation_pickable()

bool is_nation_pickable | ( | const struct nation_type * | nation | ) |

Return whether a nation is "pickable" – whether players can select it at game start. (Client only function – on the server, use client_can_pick_nation().)

Definition at line 187 of file nation.c.

Referenced by create_list_of_nations_in_group(), get_playable_nation_count(), popup_races_dialog(), races_toggles_set_sensitive(), races_update_pickable(), races_dialog::refresh(), and races_dialog::set_index().

## ◆ is_nation_playable()

bool is_nation_playable | ( | const struct nation_type * | nation | ) |

Return whether a nation is "playable"; i.e., whether a human player can choose this nation. Barbarian and observer nations are not playable.

This does not check whether a nation is "used" or "available".

Definition at line 199 of file nation.c.

Referenced by client_can_pick_nation(), count_playable_nations(), create_list_of_nations_in_group(), create_races_dialog(), extviewer_refresh_widgets(), generate_players(), handle_edit_player(), load_ruleset_nations(), pick_a_nation(), popup_races_dialog(), races_dialog::refresh(), races_dialog::set_index(), and show_nationsets().

## ◆ nation_adjective_for_player()

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

Return the (translated) adjective for the given nation of a player. You don't have to free the return pointer.

Definition at line 168 of file nation.c.

Referenced by announce_trade_route_removal(), check_city_migrations_player(), check_for_game_over(), col_nation(), col_nation(), cr_entry_nation(), debug_command(), diplomat_bribe(), diplomat_get_tech(), diplomat_incite(), diplomat_infiltrate_tile(), diplomat_sabotage(), do_attack(), do_capture_units(), do_city_migration(), do_expel_unit(), do_heal_unit(), do_nuke_tile(), endgame_report_dialog_player(), get_full_nation(), get_report_title(), get_unit_info_label_text2(), handle_diplomacy_accept_treaty_req(), kill_unit(), plr_widget::nation_selected(), notify_actor_caught(), notify_actor_success(), notify_illegal_armistice_units(), players_war_callback(), players_war_callback(), popup_action_selection(), popup_advanced_terrain_dialog(), popup_diplomacy_dialog(), popup_diplomatic_objects(), popup_goto_airlift_dialog(), popup_info_text(), popup_players_nations_dialog(), popup_spaceship_dialog(), popup_war_dialog(), real_conn_list_dialog_update(), redraw_unit_info_label(), report_achievements(), report_demographics(), report_top_five_cities(), report_wonders_of_the_world(), score_tooltip(), show_players(), spaceship_arrived(), spaceship_lost(), spy_nuke_city(), spy_poison(), spy_sabotage_unit(), spy_spread_plague(), spy_steal_gold(), spy_steal_some_maps(), tgt_extra_descr(), transfer_unit(), unit_bombard(), unit_description(), unit_do_help_build(), unit_select_dialog_popup(), pregame_options::update_buttons(), update_diplomacy_dialog(), update_info_label(), update_intel_dialog(), update_intel_wonder_dialog(), city_dialog::update_nation_table(), fc_client::update_start_page(), and wipe_unit_full().

## ◆ nation_adjective_translation()

const char * nation_adjective_translation | ( | const struct nation_type * | pnation | ) |

Return the (translated) adjective for the given nation. You don't have to free the return pointer.

Definition at line 148 of file nation.c.

Referenced by api_methods_nation_type_name_translation(), create_list_of_nations_in_group(), explain_why_no_action_enabled(), extviewer_refresh_widgets(), extviewer_view_cell_toggled(), goto_dialog::fill_tab(), handle_nation_select_req(), illegal_action_msg(), list_store_append_player_cities(), nation_adjective_for_player(), propval_as_string(), req_text_insert(), races_dialog::set_index(), universal_name_translation(), and worklist_item_postpone_req_vec().

## ◆ nation_barbarian_type()

enum barbarian_type nation_barbarian_type | ( | const struct nation_type * | nation | ) |

Returns which kind of barbarians can use this nation.

This does not check whether a nation is "used" or "available".

Definition at line 210 of file nation.c.

Referenced by assign_player_colors(), extviewer_refresh_widgets(), handle_edit_player(), hard_code_oblig_hard_reqs_ruleset(), load_ruleset_nations(), pick_a_nation(), rscompat_postprocess(), sanity_check_ruleset_data(), and update_nations_with_startpos().

## ◆ nation_by_number()

struct nation_type * nation_by_number | ( | const Nation_type_id | nation | ) |

Return the nation with the given index.

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

Definition at line 474 of file nation.c.

Referenced by api_find_nation_type(), change_nation_label(), extviewer_view_cell_toggled(), handle_edit_player(), handle_nation_availability(), handle_nation_select_req(), handle_player_info(), handle_ruleset_government_ruler_title(), handle_ruleset_nation(), load_nation_names(), nation_button_callback(), races_dialog::nation_selected(), next_name_callback(), races_dialog::ok_pressed(), populate_leader_list(), popup_races_dialog(), prev_name_callback(), races_leader_callback(), races_nation_callback(), races_toggles_set_sensitive(), races_update_pickable(), select_nation(), select_random_leader(), universal_by_number(), and universal_value_initial().

## ◆ nation_by_rule_name()

struct nation_type * nation_by_rule_name | ( | const char * | name | ) |

Returns the nation that has the given (untranslated) rule name (adjective). Returns NO_NATION_SELECTED if none match.

Definition at line 120 of file nation.c.

Referenced by api_find_nation_type_by_name(), load_ruleset_nations(), playernation_command(), sanity_check_ruleset_data(), save_nations_ruleset(), sg_load_map_startpos(), sg_load_map_startpos(), sg_load_player_main(), sg_load_player_main(), and universal_value_from_str().

## ◆ nation_by_translated_plural()

struct nation_type * nation_by_translated_plural | ( | const char * | name | ) |

Returns the nation that has the given (translated) plural noun. Returns NO_NATION_SELECTED if none match.

Definition at line 105 of file nation.c.

Referenced by help_update_dialog(), help_dialog::make_tree(), and help_widget::set_topic_nation().

## ◆ nation_cities()

const struct nation_city_list * nation_cities | ( | const struct nation_type * | pnation | ) |

Return the default cities of the nation (server only function).

Definition at line 330 of file nation.c.

Referenced by city_name_suggestion(), and is_default_city_name().

## ◆ nation_city_destroy()

static void nation_city_destroy | ( | struct nation_city * | pncity | ) |

static

Destroy a default nation city created with nation_city_new().

Definition at line 360 of file nation.c.

Referenced by nation_init().

## ◆ nation_city_name()

const char * nation_city_name | ( | const struct nation_city * | pncity | ) |

Return the name of the default nation city.

Definition at line 411 of file nation.c.

Referenced by is_default_city_name(), save_nation(), and search_for_city_name().

## ◆ nation_city_new()

struct nation_city * nation_city_new | ( | struct nation_type * | pnation,
|  | const char * | name
| ) |  |

Create a new default city for the nation (server only function).

Definition at line 341 of file nation.c.

Referenced by load_city_name_list().

## ◆ nation_city_preference_revert()

enum nation_city_preference nation_city_preference_revert | ( | enum nation_city_preference | prefer | ) |

Reverts the nation city preference.

Definition at line 370 of file nation.c.

Referenced by evaluate_city_name_priority().

## ◆ nation_city_river_preference()

enum nation_city_preference nation_city_river_preference | ( | const struct nation_city * | pncity | ) |

Return the default nation city preference for rivers.

Definition at line 433 of file nation.c.

Referenced by evaluate_city_name_priority(), and save_nation().

## ◆ nation_city_set_river_preference()

void nation_city_set_river_preference | ( | struct nation_city * | pncity,
|  | enum nation_city_preference | prefer
| ) |  |

Set the default nation city preference about rivers.

Definition at line 401 of file nation.c.

Referenced by load_city_name_list().

## ◆ nation_city_set_terrain_preference()

void nation_city_set_terrain_preference | ( | struct nation_city * | pncity,
|  | const struct terrain * | pterrain,
|  | enum nation_city_preference | prefer
| ) |  |

Set the default nation city preference for the terrain.

Definition at line 389 of file nation.c.

Referenced by load_city_name_list().

## ◆ nation_city_terrain_preference()

enum nation_city_preference nation_city_terrain_preference | ( | const struct nation_city * | pncity,
|  | const struct terrain * | pterrain
| ) |  |

Return the default nation city preference for the terrain.

Definition at line 421 of file nation.c.

Referenced by evaluate_city_name_priority(), and save_nation().

## ◆ nation_color()

const struct rgbcolor * nation_color | ( | const struct nation_type * | pnation | ) |

Returns nation's player color preference, or NULL if none. Server only function.

Definition at line 681 of file nation.c.

Referenced by assign_player_colors(), player_preferred_color(), and plrcol_validate().

## ◆ nation_count()

Nation_type_id nation_count | ( | void |  | ) |

Return the number of nations.

Definition at line 506 of file nation.c.

Referenced by city_name_suggestion(), extviewer_view_cell_toggled(), handle_edit_player_create(), handle_nation_availability(), nation_hash_val(), nation_iter_init(), pick_a_nation(), receive_packet_ruleset_control_100(), receive_packet_ruleset_control_101(), send_nation_availability_real(), send_ruleset_governments(), and tileset_setup_nation_flag().

## ◆ nation_free()

static void nation_free | ( | struct nation_type * | pnation | ) |

static

De-allocate resources associated with the given nation.

Definition at line 598 of file nation.c.

Referenced by nations_free().

## ◆ nation_group_by_number()

struct nation_group * nation_group_by_number | ( | int | id | ) |

Return the nation group with the given index.

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

Definition at line 1003 of file nation.c.

Referenced by create_nation_selection_lists(), handle_ruleset_nation(), races_dialog::refresh(), races_dialog::set_index(), universal_by_number(), and universal_value_initial().

## ◆ nation_group_by_rule_name()

struct nation_group * nation_group_by_rule_name | ( | const char * | name | ) |

Return the nation group that has the given (untranslated) rule name. Returns NULL if no group is found.

Definition at line 1020 of file nation.c.

Referenced by load_ruleset_nations(), nation_group_new(), nation_set_new(), and universal_value_from_str().

## ◆ nation_group_count()

int nation_group_count | ( | void |  | ) |

Return the number of nation groups.

Definition at line 934 of file nation.c.

Referenced by create_nation_selection_lists(), nation_group_iter_init(), races_toggles_set_sensitive(), races_update_pickable(), races_dialog::refresh(), send_ruleset_nations(), sync_tabs_to_nation(), and universal_value_initial().

## ◆ nation_group_index()

int nation_group_index | ( | const struct nation_group * | pgroup | ) |

Return the nation group index.

Definition at line 942 of file nation.c.

Referenced by handle_ruleset_nation_groups(), and nation_group_number().

## ◆ nation_group_iter_get()

static void * nation_group_iter_get | ( | const struct iterator * | iter | ) |

static

Implementation of iterator 'get' function.

Definition at line 1139 of file nation.c.

Referenced by nation_group_iter_init().

## ◆ nation_group_iter_init()

struct iterator * nation_group_iter_init | ( | struct nation_group_iter * | it | ) |

Implementation of iterator 'init' function.

Definition at line 1156 of file nation.c.

## ◆ nation_group_iter_next()

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

static

Implementation of iterator 'next' function.

Definition at line 1131 of file nation.c.

Referenced by nation_group_iter_init().

## ◆ nation_group_iter_sizeof()

size_t nation_group_iter_sizeof | ( | void |  | ) |

Implementation of iterator 'sizeof' function.

Definition at line 1123 of file nation.c.

## ◆ nation_group_iter_valid()

static bool nation_group_iter_valid | ( | const struct iterator * | iter | ) |

static

Implementation of iterator 'valid' function.

Definition at line 1147 of file nation.c.

Referenced by nation_group_iter_init().

## ◆ nation_group_name_translation()

const char * nation_group_name_translation | ( | const struct nation_group * | pgroup | ) |

Return the translated name of a nation group. You don't have to free the return pointer.

Definition at line 1089 of file nation.c.

Referenced by create_nation_selection_lists(), races_dialog::refresh(), req_text_insert(), universal_name_translation(), and worklist_item_postpone_req_vec().

## ◆ nation_group_new()

struct nation_group * nation_group_new | ( | const char * | name | ) |

Add new group into the array of groups.

Definition at line 959 of file nation.c.

Referenced by handle_ruleset_nation_groups(), and load_nation_names().

## ◆ nation_group_number()

int nation_group_number | ( | const struct nation_group * | pgroup | ) |

Return the nation group index.

Definition at line 951 of file nation.c.

Referenced by send_ruleset_nations(), and universal_number().

## ◆ nation_group_rule_name()

const char * nation_group_rule_name | ( | const struct nation_group * | pgroup | ) |

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

Definition at line 1078 of file nation.c.

Referenced by save_nation(), universal_kind_values(), and universal_rule_name().

## ◆ nation_group_set_hidden()

void nation_group_set_hidden | ( | struct nation_group * | pgroup,
|  | bool | hidden
| ) |  |

Set whether this group should appear in the nation selection UI.

Definition at line 1036 of file nation.c.

Referenced by load_ruleset_nations().

## ◆ nation_group_set_match()

void nation_group_set_match | ( | struct nation_group * | pgroup,
|  | int | match
| ) |  |

Set how much the AI will try to select a nation in the same group. Server only function.

Definition at line 1046 of file nation.c.

Referenced by load_ruleset_nations().

## ◆ nation_group_untranslated_name()

const char * nation_group_untranslated_name | ( | const struct nation_group * | pgroup | ) |

Return the untranslated name of a nation group (including qualifier, if any). You usually want nation_group_rule_name() instead. You don't have to free the return pointer.

Definition at line 1068 of file nation.c.

Referenced by send_ruleset_nations().

## ◆ nation_index()

Nation_type_id nation_index | ( | const struct nation_type * | pnation | ) |

Return the nation index.

Currently same as nation_number(), paired with nation_count() indicates use as an array index.

Definition at line 497 of file nation.c.

Referenced by city_name_suggestion(), extviewer_refresh_widgets(), extviewer_view_cell_toggled(), get_nation_flag_sprite(), get_nation_shield_sprite(), get_unit_nation_flag_sprite(), load_nation_names(), load_ruleset_nations(), objbind_pack_current_values(), objbind_pack_modified_value(), pick_a_nation(), popup_races_dialog(), races_toggles_set_sensitive(), send_nation_availability_real(), and tileset_setup_nation_flag().

## ◆ nation_init()

static void nation_init | ( | struct nation_type * | pnation | ) |

static

Allocate resources associated with the given nation.

Definition at line 573 of file nation.c.

Referenced by nations_alloc().

## ◆ nation_is_in_group()

bool nation_is_in_group | ( | const struct nation_type * | pnation,
|  | const struct nation_group * | pgroup
| ) |  |

Check if the given nation is in a given group

Definition at line 1098 of file nation.c.

Referenced by create_list_of_nations_in_group(), is_nationgroup_req_active(), nation_contra_group(), nation_found(), nations_match(), races_dialog::refresh(), save_nation(), and races_dialog::set_index().

## ◆ nation_is_in_set()

bool nation_is_in_set | ( | const struct nation_type * | pnation,
|  | const struct nation_set * | pset
| ) |  |

Check if the given nation is in a given set

Definition at line 836 of file nation.c.

Referenced by client_nation_is_in_current_set(), create_races_dialog(), fit_nationset_to_players(), load_ruleset_nations(), nation_is_in_current_set(), save_nation(), and show_nationsets().

## ◆ nation_iter_get()

static void * nation_iter_get | ( | const struct iterator * | iter | ) |

static

Implementation of iterator 'get' function.

Definition at line 539 of file nation.c.

Referenced by nation_iter_init().

## ◆ nation_iter_init()

struct iterator * nation_iter_init | ( | struct nation_iter * | it | ) |

Implementation of iterator 'init' function.

Definition at line 556 of file nation.c.

Referenced by startpos_iter_init().

## ◆ nation_iter_next()

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

static

Implementation of iterator 'next' function.

Definition at line 531 of file nation.c.

Referenced by nation_iter_init().

## ◆ nation_iter_sizeof()

size_t nation_iter_sizeof | ( | void |  | ) |

Implementation of iterator 'sizeof' function.

Definition at line 523 of file nation.c.

Referenced by startpos_iter_sizeof().

## ◆ nation_iter_valid()

static bool nation_iter_valid | ( | const struct iterator * | iter | ) |

static

Implementation of iterator 'valid' function.

Definition at line 547 of file nation.c.

Referenced by nation_iter_init().

## ◆ nation_leader_by_name()

struct nation_leader * nation_leader_by_name | ( | const struct nation_type * | pnation,
|  | const char * | name
| ) |  |

Returns the nation leader structure which match 'name' or NULL if not found.

Definition at line 266 of file nation.c.

Referenced by generate_players(), player_nation_defaults(), races_leader_callback(), and server_player_name_is_allowed().

## ◆ nation_leader_destroy()

static void nation_leader_destroy | ( | struct nation_leader * | pleader | ) |

static

Destroy a nation leader created with nation_leader_new().

Definition at line 255 of file nation.c.

Referenced by nation_init().

## ◆ nation_leader_is_male()

bool nation_leader_is_male | ( | const struct nation_leader * | pleader | ) |

Return the sex of the nation leader.

Definition at line 289 of file nation.c.

Referenced by races_dialog::nation_selected(), next_name_callback(), player_nation_defaults(), prev_name_callback(), races_leader_callback(), save_nation(), select_random_leader(), and send_ruleset_nations().

## ◆ nation_leader_name()

const char * nation_leader_name | ( | const struct nation_leader * | pleader | ) |

Return the name of the nation leader.

Definition at line 280 of file nation.c.

Referenced by check_leader_names(), races_dialog::nation_selected(), next_name_callback(), pick_random_player_name(), populate_leader_list(), prev_name_callback(), save_nation(), select_random_leader(), and send_ruleset_nations().

## ◆ nation_leader_new()

struct nation_leader * nation_leader_new | ( | struct nation_type * | pnation,
|  | const char * | name,
|  | bool | is_male
| ) |  |

Create a new leader for the nation.

Definition at line 238 of file nation.c.

Referenced by handle_ruleset_nation(), and load_ruleset_nations().

## ◆ nation_leaders()

const struct nation_leader_list * nation_leaders | ( | const struct nation_type * | pnation | ) |

Returns the list the nation leader names.

Definition at line 229 of file nation.c.

Referenced by check_leader_names(), races_dialog::nation_selected(), next_name_callback(), pick_random_player_name(), populate_leader_list(), prev_name_callback(), select_nation(), select_random_leader(), and send_ruleset_nations().

## ◆ nation_legend_translation()

const char * nation_legend_translation | ( | const struct nation_type * | pnation,
|  | const char * | legend
| ) |  |

Return translated version of nation legend.

Definition at line 298 of file nation.c.

Referenced by handle_ruleset_nation().

## ◆ nation_number()

Nation_type_id nation_number | ( | const struct nation_type * | pnation | ) |

Return the nation index.

Definition at line 485 of file nation.c.

Referenced by create_list_of_nations_in_group(), create_races_dialog(), extviewer_refresh_widgets(), government_ruler_title_new(), hard_code_oblig_hard_reqs_ruleset(), nation_hash_val(), objbind_pack_modified_value(), package_player_common(), pick_a_nation(), ruler_title_check(), ruler_title_for_player(), send_ruleset_governments(), send_ruleset_nations(), races_dialog::set_index(), startpos_pack(), startpos_unpack(), and universal_number().

## ◆ nation_of_city()

struct nation_type * nation_of_city | ( | const struct city * | pcity | ) |

Return the nation of the player who owns the city.

Definition at line 453 of file nation.c.

Referenced by agents_city_changed(), agents_city_new(), agents_city_remove(), city_build_unit(), city_packet_common(), client_remove_unit(), game_remove_unit(), get_city_flag_sprite(), handle_city(), and real_city_log().

## ◆ nation_of_player()

struct nation_type * nation_of_player | ( | const struct player * | pplayer | ) |

Return the nation of a player.

Definition at line 443 of file nation.c.

Referenced by add_clause(), diplo_dlg::add_widget(), auto_settlers_player(), citizens_dialog_row(), city_build_free_buildings(), city_name_suggestion(), civil_war(), create_barbarian_player(), create_command_newcomer(), create_diplomacy_dialog(), dai_manage_government(), plr_item::data(), diplo_wdg::diplo_wdg(), do_attack(), endgame_report_dialog_player(), fill_row(), fill_sprite_array(), goto_dialog::fill_tab(), final_ruleset_adjustments(), game_remove_city(), give_initial_techs(), handle_diplomacy_accept_treaty_req(), handle_diplomacy_init_meeting(), handle_edit_player(), init_new_game(), is_default_city_name(), is_nation_req_active(), is_nationgroup_req_active(), list_store_append_player_cities(), map_generate_fair_islands(), nation_adjective_for_player(), nation_of_city(), nation_of_unit(), nation_plural_for_player(), objbind_get_value_from_object(), objbind_pack_current_values(), pick_a_nation(), player_preferred_color(), popup_find_dialog(), popup_players_dialog(), popup_players_nations_dialog(), ruler_title_for_player(), sg_load_players(), sg_load_players(), sg_load_sanitycheck(), sg_load_sanitycheck(), sg_save_player_main(), split_player(), transfer_unit(), unit_bombard(), unit_nuke(), update_goto_dialog(), update_intel_dialog(), city_dialog::update_nation_table(), and endgame_report::update_report().

## ◆ nation_of_unit()

struct nation_type * nation_of_unit | ( | const struct unit * | punit | ) |

Return the nation of the player who owns the unit.

Definition at line 462 of file nation.c.

Referenced by caravan_optimize_callback(), check_units_single_tile(), client_remove_unit(), dai_caravan_goto(), dai_diplomat_city(), dai_hunter_manage(), dai_manage_caravan(), debug_command(), do_attack(), game_remove_unit(), get_unit_nation_flag_sprite(), handle_unit_packet_common(), immediate_destination(), real_bodyguard_log(), real_unit_log(), teleport_unit_to_city(), terrain_change_bounce_single_unit(), and transfer_city_units().

## ◆ nation_plural_for_player()

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

Return the (translated) plural noun of the given nation of a player. You don't have to free the return pointer.

Definition at line 177 of file nation.c.

Referenced by diplo_dlg::add_widget(), announce_player(), announce_trade_route_removal(), api_edit_give_technology(), change_build_target(), check_for_game_over(), city_build_building(), civil_war(), client_diplomacy_clause_string(), create_barbarian_player(), create_command_newcomer(), create_diplomacy_dialog(), dem_line_item(), diplo_wdg::diplo_wdg(), diplomat_bribe(), diplomat_embassy(), diplomat_sabotage(), do_capture_units(), do_expel_unit(), do_nuclear_explosion(), do_nuke_tile(), do_unit_establish_trade(), do_unit_strike_city_building(), do_unit_strike_city_production(), fit_nationset_to_players(), forget_tech_transferred(), government_change(), handle_diplomacy_accept_treaty_req(), handle_diplomacy_cancel_pact(), handle_diplomacy_init_meeting(), handle_player_change_government(), handle_spaceship_launch(), historian_generic(), is_allowed_city_name(), kill_player(), make_contact(), plr_widget::nation_selected(), notify_global_caught(), notify_global_success(), notify_victim_caught(), notify_victim_success(), players_vision_callback(), players_vision_callback(), players_war_callback(), players_war_callback(), redraw_unit_info_label(), remove_illegal_armistice_units(), research_pretty_name(), mr_menu::save_image(), sg_load_players(), sg_load_players(), show_new_turn_info(), spy_nuke_city(), spy_sabotage_unit(), spy_spread_plague(), spy_steal_gold(), spy_steal_some_maps(), steal_a_tech(), tech_transfer(), transfer_unit(), update_diplomatics(), update_info_label(), and fc_client::update_sidebar_tooltips().

## ◆ nation_plural_translation()

const char * nation_plural_translation | ( | const struct nation_type * | pnation | ) |

Return the (translated) plural noun of the given nation. You don't have to free the return pointer.

Definition at line 158 of file nation.c.

Referenced by api_methods_nation_type_plural_translation(), boot_help_texts(), change_nation_label(), create_command_newcomer(), handle_edit_player(), helptext_advance(), helptext_building(), helptext_unit(), nation_button_callback(), nation_by_translated_plural(), nation_plural_for_player(), popup_races_dialog(), req_text_insert(), side_right_click_diplomacy(), and worklist_item_postpone_req_vec().

## ◆ nation_rule_name()

const char * nation_rule_name | ( | const struct nation_type * | pnation | ) |

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

Definition at line 137 of file nation.c.

Referenced by add_clause(), agents_city_changed(), agents_city_new(), agents_city_remove(), api_methods_nation_type_rule_name(), auto_settlers_player(), caravan_optimize_callback(), check_units_single_tile(), city_build_unit(), city_name_suggestion(), city_packet_common(), civil_war(), client_remove_unit(), create_command_newcomer(), dai_caravan_goto(), dai_diplomat_city(), dai_hunter_manage(), dai_manage_caravan(), debug_command(), do_attack(), game_remove_city(), game_remove_unit(), government_ruler_title_new(), handle_city(), handle_diplomacy_accept_treaty_req(), handle_ruleset_nation(), handle_unit_packet_common(), immediate_destination(), init_new_game(), load_ruleset_nations(), nation_by_rule_name(), pick_a_nation(), playernation_command(), races_toggles_set_sensitive(), real_bodyguard_log(), real_city_log(), real_unit_log(), rscompat_postprocess(), ruler_title_check(), ruler_title_for_player(), sanity_check_ruleset_data(), save_nation(), sg_load_players(), sg_load_players(), sg_load_sanitycheck(), sg_load_sanitycheck(), sg_save_map_startpos(), sg_save_player_main(), teleport_unit_to_city(), terrain_change_bounce_single_unit(), tileset_setup_nation_flag(), transfer_city_units(), transfer_unit(), unit_bombard(), unit_nuke(), universal_kind_values(), and universal_rule_name().

## ◆ nation_set_by_number()

struct nation_set * nation_set_by_number | ( | int | id | ) |

Return the nation set with the given index.

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

Definition at line 761 of file nation.c.

Referenced by fit_nationset_to_players(), handle_ruleset_nation(), load_ruleset_nations(), nation_set_by_setting_value(), next_set_callback(), and prev_set_callback().

## ◆ nation_set_by_rule_name()

struct nation_set * nation_set_by_rule_name | ( | const char * | name | ) |

Return the nation set that has the given (untranslated) rule name. Returns NULL if no set is found.

Definition at line 778 of file nation.c.

Referenced by load_ruleset_nations(), nation_group_new(), nation_set_by_setting_value(), nation_set_new(), nationset_callback(), nationset_callback(), and races_dialog::nationset_changed().

## ◆ nation_set_by_setting_value()

struct nation_set * nation_set_by_setting_value | ( | const char * | setting | ) |

Returns the nation set that would be selected by the given value of the 'nationset' server setting. This differs from nation_set_by_rule_name() for the empty string, where the first (ruleset default) nationset will be used; and similarly for a nationset not matched in the ruleset. The knowledge of the interpretation of this setting encapsulated here is required on both server and client.

Definition at line 858 of file nation.c.

Referenced by client_current_nation_set(), current_nationset(), nationset_callback(), races_dialog::nationset_changed(), nationset_sync_to_server(), popup_races_dialog(), and races_dialog::update_nationset_combo().

## ◆ nation_set_count()

int nation_set_count | ( | void |  | ) |

Return the number of nation sets.

Definition at line 690 of file nation.c.

Referenced by aifill(), create_command_pregame(), create_races_dialog(), fit_nationset_to_players(), load_ruleset_nations(), nation_set_iter_init(), next_set_callback(), popup_races_dialog(), races_dialog::races_dialog(), send_ruleset_nations(), and start_command().

## ◆ nation_set_description()

const char * nation_set_description | ( | const struct nation_set * | pset | ) |

Return the (untranslated) user description of a nation set. You don't have to free the return pointer.

Definition at line 827 of file nation.c.

Referenced by create_races_dialog(), save_nations_ruleset(), send_ruleset_nations(), show_nationsets(), and races_dialog::update_nationset_combo().

## ◆ nation_set_index()

int nation_set_index | ( | const struct nation_set * | pset | ) |

Return the nation set index.

Definition at line 698 of file nation.c.

Referenced by fit_nationset_to_players(), handle_ruleset_nation_sets(), nation_set_number(), nationset_sync_to_server(), next_set_callback(), popup_races_dialog(), prev_set_callback(), and races_dialog::update_nationset_combo().

## ◆ nation_set_iter_get()

static void * nation_set_iter_get | ( | const struct iterator * | iter | ) |

static

Implementation of iterator 'get' function.

Definition at line 904 of file nation.c.

Referenced by nation_set_iter_init().

## ◆ nation_set_iter_init()

struct iterator * nation_set_iter_init | ( | struct nation_set_iter * | it | ) |

Implementation of iterator 'init' function.

Definition at line 921 of file nation.c.

## ◆ nation_set_iter_next()

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

static

Implementation of iterator 'next' function.

Definition at line 896 of file nation.c.

Referenced by nation_set_iter_init().

## ◆ nation_set_iter_sizeof()

size_t nation_set_iter_sizeof | ( | void |  | ) |

Implementation of iterator 'sizeof' function.

Definition at line 888 of file nation.c.

## ◆ nation_set_iter_valid()

static bool nation_set_iter_valid | ( | const struct iterator * | iter | ) |

static

Implementation of iterator 'valid' function.

Definition at line 912 of file nation.c.

Referenced by nation_set_iter_init().

## ◆ nation_set_name_translation()

const char * nation_set_name_translation | ( | const struct nation_set * | pset | ) |

Return the translated name of a nation set. You don't have to free the return pointer.

Definition at line 817 of file nation.c.

Referenced by create_races_dialog(), popup_races_dialog(), races_dialog::races_dialog(), and show_nationsets().

## ◆ nation_set_new()

struct nation_set * nation_set_new | ( | const char * | set_name,
|  | const char * | set_rule_name,
|  | const char * | set_description
| ) |  |

Add new set into the array of nation sets.

Definition at line 715 of file nation.c.

Referenced by handle_ruleset_nation_sets(), and load_ruleset_nations().

## ◆ nation_set_number()

int nation_set_number | ( | const struct nation_set * | pset | ) |

Return the nation set index.

Definition at line 707 of file nation.c.

Referenced by load_ruleset_nations(), and send_ruleset_nations().

## ◆ nation_set_rule_name()

const char * nation_set_rule_name | ( | const struct nation_set * | pset | ) |

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

Definition at line 806 of file nation.c.

Referenced by create_races_dialog(), fit_nationset_to_players(), load_ruleset_nations(), next_set_callback(), prev_set_callback(), races_dialog::races_dialog(), save_nation(), save_nations_ruleset(), send_ruleset_nations(), and show_nationsets().

## ◆ nation_set_untranslated_name()

const char * nation_set_untranslated_name | ( | const struct nation_set * | pset | ) |

Return the untranslated name of a nation set (including qualifier, if any). You usually want nation_set_rule_name() instead. You don't have to free the return pointer.

Definition at line 796 of file nation.c.

Referenced by save_nations_ruleset(), and send_ruleset_nations().

## ◆ nation_sets_groups_free()

void nation_sets_groups_free | ( | void |  | ) |

Frees and resets all nation set/group data.

Definition at line 1177 of file nation.c.

Referenced by game_ruleset_free().

## ◆ nation_sets_groups_init()

void nation_sets_groups_init | ( | void |  | ) |

Initializes all nation set/group data.

Definition at line 1169 of file nation.c.

Referenced by game_ruleset_init().

## ◆ nations_alloc()

void nations_alloc | ( | int | num | ) |

Allocate space for the given number of nations.

Definition at line 621 of file nation.c.

Referenced by handle_ruleset_control(), and load_nation_names().

## ◆ nations_free()

void nations_free | ( | void |  | ) |

De-allocate the currently allocated nations.

Definition at line 636 of file nation.c.

Referenced by game_ruleset_free().

## ◆ nations_match()

int nations_match | ( | const struct nation_type * | pnation1,
|  | const struct nation_type * | pnation2,
|  | bool | ignore_conflicts
| ) |  |

Returns how much two nations look good in the same game. Nations in the same group are considered to match, if that nation group has a 'match' greater than zero. Negative return value means that we really really don't want these nations together. This is dictated by "conflicts_with" in individual nation definitions. (If 'ignore_conflicts' is set, conflicts are not taken into account at all.) Server side function.

Definition at line 1205 of file nation.c.

Referenced by create_command_newcomer(), and pick_a_nation().

## ◆ style_of_nation()

struct nation_style * style_of_nation | ( | const struct nation_type * | pnation | ) |

Returns nation's style.

Definition at line 671 of file nation.c.

Referenced by nation_button_callback(), races_dialog::nation_selected(), player_nation_defaults(), playernation_command(), popup_races_dialog(), races_nation_callback(), and races_toggles_set_sensitive().

## Variable Documentation

## ◆ nation_groups

struct nation_group nation_groups[MAX_NUM_NATION_GROUPS]

static

Definition at line 50 of file nation.c.

Referenced by nation_group_by_number(), nation_group_index(), nation_group_iter_init(), and nation_group_new().

## ◆ nation_sets

struct nation_set nation_sets[MAX_NUM_NATION_SETS]

static

Definition at line 48 of file nation.c.

Referenced by nation_set_by_number(), nation_set_index(), nation_set_iter_init(), and nation_set_new().

## ◆ nations

struct nation_type* nations = NULL

static

Definition at line 45 of file nation.c.

Referenced by nation_by_number(), nation_index(), nation_init(), nation_iter_init(), nations_alloc(), nations_free(), receive_packet_edit_startpos_full_100(), sg_save_map_startpos(), and sg_save_player_cities().

## ◆ num_nation_groups

int num_nation_groups

static

Definition at line 49 of file nation.c.

Referenced by nation_group_count(), nation_group_new(), nation_sets_groups_free(), nation_sets_groups_init(), receive_packet_ruleset_control_100(), and receive_packet_ruleset_control_101().

## ◆ num_nation_sets

int num_nation_sets

static

Definition at line 47 of file nation.c.

Referenced by nation_set_count(), nation_set_new(), nation_sets_groups_free(), nation_sets_groups_init(), receive_packet_ruleset_control_100(), and receive_packet_ruleset_control_101().