48 #define NATION_CHECK(pnation, action) \
49 fc_assert_action(nation_check(pnation), action)
55 static bool nation_check(
const nation_type *pnation)
58 qCritical(
"Function called before nations setup.");
61 if (
nullptr == pnation) {
62 qCritical(
"This function has nullptr nation argument.");
68 qCritical(
"This function has bad nation number %d (count %d).",
76 #define NATION_CHECK(pnation, action)
102 for (
auto &pnation :
nations) {
168 return nation->
client.is_pickable;
205 const struct nation_leader_list *
223 nation_leader_list_append(pnation->
leaders, pleader);
232 delete[] pleader->
name;
260 return pleader->
name;
306 const struct nation_city_list *
312 return pnation->
server.default_cities;
330 nation_city_list_append(pnation->
server.default_cities, pncity);
339 delete[] pncity->
name;
358 qCritical(
"%s(): Wrong nation_city_preference variant (%d).", __FUNCTION__,
367 const struct terrain *pterrain,
382 pncity->
river = prefer;
399 const struct terrain *pterrain)
413 return pncity->
river;
452 if (nation < 0 || nation >=
game.
control.nation_count) {
480 sets = nation_set_list_new();
481 groups = nation_group_list_new();
485 server.civilwar_nations = nation_list_new();
486 server.parent_nations = nation_list_new();
487 server.conflicts_with = nation_list_new();
491 client.is_pickable =
true;
503 nation_leader_list_destroy(
leaders);
504 nation_set_list_destroy(
sets);
505 nation_group_list_destroy(
groups);
508 nation_city_list_destroy(
server.default_cities);
509 nation_list_destroy(
server.civilwar_nations);
510 nation_list_destroy(
server.parent_nations);
511 nation_list_destroy(
server.conflicts_with);
525 for (
auto &pnation :
nations) {
561 return pnation->
style;
571 return pnation->
server.rgb;
600 const char *set_rule_name,
601 const char *set_description)
606 qCritical(
"Too many nation sets (%d is the maximum).",
616 "Nation set description \"%s\" too long; truncating.");
624 qCritical(
"Nation set name %s is already used for a group.",
743 if (pset ==
nullptr) {
761 #define NATION_SET_ITER(p) ((struct nation_set_iter *) (p))
790 return it->
p < it->
end;
836 qCritical(
"Too many nation groups (%d is the maximum).",
845 qCritical(
"Duplicate nation group name %s.",
851 qCritical(
"Nation group name %s is already used for a set.",
969 if (agroup == pgroup) {
984 #define NATION_GROUP_ITER(p) ((struct nation_group_iter *) (p))
1016 return it->
p < it->
end;
1047 const struct player *pplayer)
1066 const struct nation_type *pnation2,
bool ignore_conflicts)
1068 bool in_conflict =
false;
1075 if (!ignore_conflicts) {
1078 if (pnation0 == pnation2) {
1089 if (pnation0 == pnation1) {
1102 sum += pgroup->server.match;
1107 return (in_conflict ? -sum : sum);
struct player * city_owner(const struct city *pcity)
Return the owner of the city.
bool can_conn_edit(const struct connection *pconn)
Return TRUE iff the connection is currently allowed to edit.
#define MAX_NUM_NATION_SETS
#define MAX_NUM_NATION_GROUPS
#define DG_(domain, String)
bool is_server()
Is program type server?
#define fc_assert_ret(condition)
#define fc_assert(condition)
#define fc_assert_ret_val(condition, val)
static void name_set(struct name_translation *ptrans, const char *domain, const char *vernacular_name)
static const char * untranslated_name(const struct name_translation *ptrans)
static const char * rule_name_get(const struct name_translation *ptrans)
static const char * name_translation_get(const struct name_translation *ptrans)
static void names_set(struct name_translation *ptrans, const char *domain, const char *vernacular_name, const char *rule_name)
static void name_init(struct name_translation *ptrans)
struct nation_set * nation_set_by_number(int id)
Return the nation set with the given index.
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.
struct nation_type * nation_by_number(const Nation_type_id nation)
Return the nation with the given index.
void nation_sets_groups_init()
size_t nation_set_iter_sizeof()
Implementation of iterator 'sizeof' function.
void nation_sets_groups_free()
Frees and resets all nation set/group data.
struct nation_style * style_of_nation(const struct nation_type *pnation)
Returns nation's style.
static void nation_city_destroy(struct nation_city *pncity)
Destroy a default nation city created with nation_city_new().
const char * nation_set_name_translation(const struct nation_set *pset)
Return the translated name of a nation set.
struct nation_type * nation_of_city(const struct city *pcity)
Return the nation of the player who owns the city.
const char * nation_group_name_translation(const struct nation_group *pgroup)
Return the translated name of a nation group.
enum nation_city_preference nation_city_preference_revert(enum nation_city_preference prefer)
Reverts the nation city preference.
struct nation_leader * nation_leader_by_name(const struct nation_type *pnation, const char *name)
Returns the nation leader structure which match 'name' or nullptr if not found.
int nation_group_index(const struct nation_group *pgroup)
Return the nation group index.
struct nation_leader * nation_leader_new(struct nation_type *pnation, const char *name, bool is_male)
Create a new leader for the nation.
size_t nation_group_iter_sizeof()
Implementation of iterator 'sizeof' function.
struct iterator * nation_group_iter_init(struct nation_group_iter *it)
Implementation of iterator 'init' function.
const char * nation_set_untranslated_name(const struct nation_set *pset)
Return the untranslated name of a nation set (including qualifier, if any).
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.
bool nation_leader_is_male(const struct nation_leader *pleader)
Return the sex of the nation leader.
struct government * init_government_of_nation(const struct nation_type *pnation)
Returns initial government type for this nation.
int nation_set_count()
Return the number of nation sets.
static struct nation_set nation_sets[MAX_NUM_NATION_SETS]
int nation_set_index(const struct nation_set *pset)
Return the nation set index.
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.
bool is_nation_pickable(const struct nation_type *nation)
Return whether a nation is "pickable" – whether players can select it at game start.
const char * nation_rule_name(const struct nation_type *pnation)
Return the (untranslated) rule name of the nation (adjective form).
std::vector< nation_type > nations
static void nation_group_iter_next(struct iterator *iter)
Implementation of iterator 'next' function.
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.
struct nation_city * nation_city_new(struct nation_type *pnation, const char *name)
Create a new default city for the nation (server only function).
int nation_group_count()
Return the number of nation groups.
static struct nation_group nation_groups[MAX_NUM_NATION_GROUPS]
struct nation_group * nation_group_new(const char *name)
Add new group into the array of groups.
int nation_set_number(const struct nation_set *pset)
Return the nation set index.
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.
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.
#define NATION_SET_ITER(p)
const char * nation_adjective_translation(const struct nation_type *pnation)
Return the (translated) adjective for the given nation.
struct nation_group * nation_group_by_rule_name(const char *name)
Return the nation group that has the given (untranslated) rule name.
const char * nation_plural_for_player(const struct player *pplayer)
Return the (translated) plural noun of the given nation of a player.
static int num_nation_sets
void nation_city_set_river_preference(struct nation_city *pncity, enum nation_city_preference prefer)
Set the default nation city preference about rivers.
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.
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.
const struct rgbcolor * nation_color(const struct nation_type *pnation)
Returns nation's player color preference, or nullptr if none.
struct nation_type * nation_of_unit(const struct unit *punit)
Return the nation of the player who owns the unit.
enum nation_city_preference nation_city_river_preference(const struct nation_city *pncity)
Return the default nation city preference for rivers.
static int num_nation_groups
const char * nation_set_rule_name(const struct nation_set *pset)
Return the (untranslated) rule name of a nation set.
struct iterator * nation_set_iter_init(struct nation_set_iter *it)
Implementation of iterator 'init' function.
const char * nation_adjective_for_player(const struct player *pplayer)
Return the (translated) adjective for the given nation of a player.
const char * nation_legend_translation(const struct nation_type *pnation, const char *legend)
Return translated version of nation legend.
static void nation_leader_destroy(struct nation_leader *pleader)
Destroy a nation leader created with nation_leader_new().
#define NATION_GROUP_ITER(p)
struct nation_group * nation_group_by_number(int id)
Return the nation group with the given index.
const char * nation_set_description(const struct nation_set *pset)
Return the (untranslated) user description of a nation set.
static void nation_set_iter_next(struct iterator *iter)
Implementation of iterator 'next' function.
static bool nation_set_iter_valid(const struct iterator *iter)
Implementation of iterator 'valid' function.
bool is_nation_group_hidden(struct nation_group *pgroup)
Return whether this group should appear in the nation selection UI.
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.
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.
struct nation_type * nation_by_rule_name(const char *name)
Returns the nation that has the given (untranslated) rule name (adjective).
Nation_type_id nation_index(const struct nation_type *pnation)
Return the nation index.
const char * nation_leader_name(const struct nation_leader *pleader)
Return the name of the nation leader.
const char * nation_plural_translation(const struct nation_type *pnation)
Return the (translated) plural noun of the given nation.
struct nation_type * nation_of_player(const struct player *pplayer)
Return the nation of a player.
static bool nation_group_iter_valid(const struct iterator *iter)
Implementation of iterator 'valid' function.
const char * nation_city_name(const struct nation_city *pncity)
Return the name of the default nation city.
void nations_free()
De-allocate the currently allocated nations.
const struct nation_city_list * nation_cities(const struct nation_type *pnation)
Return the default cities of the nation (server only function).
const char * nation_group_untranslated_name(const struct nation_group *pgroup)
Return the untranslated name of a nation group (including qualifier, if any).
const struct nation_leader_list * nation_leaders(const struct nation_type *pnation)
Returns the list the nation leader names.
struct nation_type * nation_by_translated_plural(const char *name)
Returns the nation that has the given (translated) plural noun.
#define NATION_CHECK(pnation, action)
Runs action if the nation is not valid.
void nation_group_set_hidden(struct nation_group *pgroup, bool hidden)
Set whether this group should appear in the nation selection UI.
static void * nation_group_iter_get(const struct iterator *iter)
Implementation of iterator 'get' function.
struct nation_set * nation_set_by_rule_name(const char *name)
Return the nation set that has the given (untranslated) rule name.
void nations_alloc(int num)
Allocate space for the given number of nations.
enum barbarian_type nation_barbarian_type(const struct nation_type *nation)
Returns which kind of barbarians can use this nation.
const char * nation_group_rule_name(const struct nation_group *pgroup)
Return the (untranslated) rule name of a nation group.
static void * nation_set_iter_get(const struct iterator *iter)
Implementation of iterator 'get' function.
int nation_group_number(const struct nation_group *pgroup)
Return the nation group index.
#define nation_leader_list_iterate(leaderlist, pleader)
#define nation_list_iterate(nationlist, pnation)
#define nation_sets_iterate_end
#define nation_set_list_iterate_end
#define nation_group_list_iterate(grouplist, pgroup)
#define nation_sets_iterate(NAME_pset)
#define nation_list_iterate_end
#define nation_leader_list_iterate_end
#define nation_group_list_iterate_end
#define nation_set_list_iterate(setlist, pset)
#define nation_groups_iterate(NAME_pgroup)
#define nation_groups_iterate_end
#define NO_NATION_SELECTED
void rgbcolor_destroy(struct rgbcolor *prgbcolor)
Free rgbcolor structure.
#define sz_loud_strlcpy(buffer, str, errmsg)
struct packet_ruleset_control control
struct packet_game_info info
struct government * default_government
enum cmdlevel access_level
bool(* valid)(const struct iterator *it)
void *(* get)(const struct iterator *it)
void(* next)(struct iterator *it)
enum nation_city_preference river
enum nation_city_preference terrain[MAX_NUM_TERRAINS]
struct nation_group * end
struct name_translation name
struct nation_group::@52::@54 server
Functions for handling the nations.
struct name_translation name
char description[MAX_LEN_MSG]
struct nation_group_list * groups
struct name_translation noun_plural
struct nation_set_list * sets
struct name_translation adjective
struct nation_leader_list * leaders
struct nation_type::@48::@50 server
Nation_type_id item_number
enum barbarian_type barb_type
char * translation_domain
nation_type()
Allocate resources associated with the given nation.
struct nation_type::@48::@51 client
struct nation_style * style
~nation_type()
De-allocate resources associated with the given nation.
government * init_government
struct nation_type * nation
int fc_strcasecmp(const char *str0, const char *str1)
Compare strings like strcmp(), but ignoring case.
Terrain_type_id terrain_index(const struct terrain *pterrain)
Return the terrain index.