Feature #1437 ยป 0017-nation.c-Replace-parameter-checking-fc_asserts-with-.patch
| common/nation.c | ||
|---|---|---|
|
bool is_nation_pickable(const struct nation_type *nation)
|
||
|
{
|
||
|
fc_assert_ret_val(!is_server(), FALSE);
|
||
|
return nation->client.is_pickable;
|
||
|
}
|
||
| ... | ... | |
|
****************************************************************************/
|
||
|
const char *nation_leader_name(const struct nation_leader *pleader)
|
||
|
{
|
||
|
fc_assert_ret_val(pleader != nullptr, nullptr);
|
||
|
return pleader->name;
|
||
|
}
|
||
| ... | ... | |
|
****************************************************************************/
|
||
|
bool nation_leader_is_male(const struct nation_leader *pleader)
|
||
|
{
|
||
|
fc_assert_ret_val(pleader != nullptr, TRUE);
|
||
|
return pleader->is_male;
|
||
|
}
|
||
| ... | ... | |
|
const struct terrain *pterrain,
|
||
|
enum nation_city_preference prefer)
|
||
|
{
|
||
|
fc_assert_ret(pncity != nullptr);
|
||
|
fc_assert_ret(pterrain != nullptr);
|
||
|
pncity->terrain[terrain_index(pterrain)] = prefer;
|
||
|
}
|
||
| ... | ... | |
|
void nation_city_set_river_preference(struct nation_city *pncity,
|
||
|
enum nation_city_preference prefer)
|
||
|
{
|
||
|
fc_assert_ret(pncity != nullptr);
|
||
|
pncity->river = prefer;
|
||
|
}
|
||
| ... | ... | |
|
****************************************************************************/
|
||
|
const char *nation_city_name(const struct nation_city *pncity)
|
||
|
{
|
||
|
fc_assert_ret_val(pncity != nullptr, nullptr);
|
||
|
return pncity->name;
|
||
|
}
|
||
| ... | ... | |
|
nation_city_terrain_preference(const struct nation_city *pncity,
|
||
|
const struct terrain *pterrain)
|
||
|
{
|
||
|
fc_assert_ret_val(pncity != nullptr, NCP_DISLIKE);
|
||
|
fc_assert_ret_val(pterrain != nullptr, NCP_DISLIKE);
|
||
|
return pncity->terrain[terrain_index(pterrain)];
|
||
|
}
|
||
| ... | ... | |
|
enum nation_city_preference
|
||
|
nation_city_river_preference(const struct nation_city *pncity)
|
||
|
{
|
||
|
fc_assert_ret_val(pncity != nullptr, NCP_DISLIKE);
|
||
|
return pncity->river;
|
||
|
}
|
||
| ... | ... | |
|
****************************************************************************/
|
||
|
struct nation_type *nation_of_player(const struct player *pplayer)
|
||
|
{
|
||
|
fc_assert_ret_val(pplayer != nullptr, nullptr);
|
||
|
NATION_CHECK(pplayer->nation, return nullptr);
|
||
|
return pplayer->nation;
|
||
| ... | ... | |
|
****************************************************************************/
|
||
|
struct nation_type *nation_of_city(const struct city *pcity)
|
||
|
{
|
||
|
fc_assert_ret_val(pcity != nullptr, nullptr);
|
||
|
return nation_of_player(city_owner(pcity));
|
||
|
}
|
||
| ... | ... | |
|
****************************************************************************/
|
||
|
struct nation_type *nation_of_unit(const struct unit *punit)
|
||
|
{
|
||
|
fc_assert_ret_val(punit != nullptr, nullptr);
|
||
|
return nation_of_player(unit_owner(punit));
|
||
|
}
|
||
| ... | ... | |
|
****************************************************************************/
|
||
|
Nation_type_id nation_number(const struct nation_type *pnation)
|
||
|
{
|
||
|
fc_assert_ret_val(pnation != nullptr, -1);
|
||
|
return pnation->item_number;
|
||
|
}
|
||
| ... | ... | |
|
****************************************************************************/
|
||
|
Nation_type_id nation_index(const struct nation_type *pnation)
|
||
|
{
|
||
|
fc_assert_ret_val(pnation != nullptr, -1);
|
||
|
return pnation - nations;
|
||
|
}
|
||
| ... | ... | |
|
****************************************************************************/
|
||
|
int nation_set_index(const struct nation_set *pset)
|
||
|
{
|
||
|
fc_assert_ret_val(pset != nullptr, -1);
|
||
|
return pset - nation_sets;
|
||
|
}
|
||
| ... | ... | |
|
****************************************************************************/
|
||
|
const char *nation_set_untranslated_name(const struct nation_set *pset)
|
||
|
{
|
||
|
fc_assert_ret_val(pset != nullptr, nullptr);
|
||
|
return untranslated_name(&pset->name);
|
||
|
}
|
||
| ... | ... | |
|
****************************************************************************/
|
||
|
const char *nation_set_rule_name(const struct nation_set *pset)
|
||
|
{
|
||
|
fc_assert_ret_val(pset != nullptr, nullptr);
|
||
|
return rule_name_get(&pset->name);
|
||
|
}
|
||
| ... | ... | |
|
****************************************************************************/
|
||
|
const char *nation_set_name_translation(const struct nation_set *pset)
|
||
|
{
|
||
|
fc_assert_ret_val(pset != nullptr, nullptr);
|
||
|
return name_translation_get(&pset->name);
|
||
|
}
|
||
| ... | ... | |
|
****************************************************************************/
|
||
|
const char *nation_set_description(const struct nation_set *pset)
|
||
|
{
|
||
|
fc_assert_ret_val(pset != nullptr, nullptr);
|
||
|
return pset->description;
|
||
|
}
|
||
| ... | ... | |
|
bool nation_is_in_set(const struct nation_type *pnation,
|
||
|
const struct nation_set *pset)
|
||
|
{
|
||
|
fc_assert_ret_val(pnation != nullptr, FALSE);
|
||
|
nation_set_list_iterate(pnation->sets, aset) {
|
||
|
if (aset == pset) {
|
||
|
return TRUE;
|
||
| ... | ... | |
|
****************************************************************************/
|
||
|
int nation_group_index(const struct nation_group *pgroup)
|
||
|
{
|
||
|
fc_assert_ret_val(pgroup != nullptr, -1);
|
||
|
return pgroup - nation_groups;
|
||
|
}
|
||
| ... | ... | |
|
****************************************************************************/
|
||
|
void nation_group_set_hidden(struct nation_group *pgroup, bool hidden)
|
||
|
{
|
||
|
fc_assert_ret(pgroup != nullptr);
|
||
|
pgroup->hidden = hidden;
|
||
|
}
|
||
| ... | ... | |
|
void nation_group_set_match(struct nation_group *pgroup, int match)
|
||
|
{
|
||
|
fc_assert_ret(is_server());
|
||
|
fc_assert_ret(pgroup != nullptr);
|
||
|
pgroup->server.match = match;
|
||
|
}
|
||
| ... | ... | |
|
****************************************************************************/
|
||
|
bool is_nation_group_hidden(struct nation_group *pgroup)
|
||
|
{
|
||
|
fc_assert_ret_val(pgroup != nullptr, TRUE);
|
||
|
return pgroup->hidden;
|
||
|
}
|
||
| ... | ... | |
|
****************************************************************************/
|
||
|
const char *nation_group_untranslated_name(const struct nation_group *pgroup)
|
||
|
{
|
||
|
fc_assert_ret_val(pgroup != nullptr, nullptr);
|
||
|
return untranslated_name(&pgroup->name);
|
||
|
}
|
||
| ... | ... | |
|
****************************************************************************/
|
||
|
const char *nation_group_rule_name(const struct nation_group *pgroup)
|
||
|
{
|
||
|
fc_assert_ret_val(pgroup != nullptr, nullptr);
|
||
|
return rule_name_get(&pgroup->name);
|
||
|
}
|
||
| ... | ... | |
|
****************************************************************************/
|
||
|
const char *nation_group_name_translation(const struct nation_group *pgroup)
|
||
|
{
|
||
|
fc_assert_ret_val(pgroup != nullptr, nullptr);
|
||
|
return name_translation_get(&pgroup->name);
|
||
|
}
|
||
| ... | ... | |
|
bool nation_is_in_group(const struct nation_type *pnation,
|
||
|
const struct nation_group *pgroup)
|
||
|
{
|
||
|
fc_assert_ret_val(pnation != nullptr, FALSE);
|
||
|
nation_group_list_iterate(pnation->groups, agroup) {
|
||
|
if (agroup == pgroup) {
|
||
|
return TRUE;
|
||
| common/nation.h | ||
|---|---|---|
|
/* General nation accessor functions. */
|
||
|
Nation_type_id nation_count(void);
|
||
|
Nation_type_id nation_index(const struct nation_type *pnation);
|
||
|
Nation_type_id nation_number(const struct nation_type *pnation);
|
||
|
Nation_type_id nation_index(const struct nation_type *pnation)
|
||
|
fc__attribute((nonnull(1)));
|
||
|
Nation_type_id nation_number(const struct nation_type *pnation)
|
||
|
fc__attribute((nonnull(1)));
|
||
|
struct nation_type *nation_by_number(const Nation_type_id nation);
|
||
|
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_of_player(const struct player *pplayer)
|
||
|
fc__attribute((nonnull(1)));
|
||
|
struct nation_type *nation_of_city(const struct city *pcity)
|
||
|
fc__attribute((nonnull(1)));
|
||
|
struct nation_type *nation_of_unit(const struct unit *punit)
|
||
|
fc__attribute((nonnull(1)));
|
||
|
struct nation_type *nation_by_rule_name(const char *name);
|
||
|
struct nation_type *nation_by_translated_plural(const char *name);
|
||
| ... | ... | |
|
const char *name, bool is_male);
|
||
|
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_leader_name(const struct nation_leader *pleader)
|
||
|
fc__attribute((nonnull(1)));
|
||
|
bool nation_leader_is_male(const struct nation_leader *pleader)
|
||
|
fc__attribute((nonnull(1)));
|
||
|
const char *nation_legend_translation(const struct nation_type *pnation,
|
||
|
const char *legend);
|
||
| ... | ... | |
|
struct nation_city *nation_city_new(struct nation_type *pnation,
|
||
|
const char *name);
|
||
|
const char *nation_city_name(const struct nation_city *pncity);
|
||
|
const char *nation_city_name(const struct nation_city *pncity)
|
||
|
fc__attribute((nonnull(1)));
|
||
|
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);
|
||
|
enum nation_city_preference prefer)
|
||
|
fc__attribute((nonnull(1, 2)));
|
||
|
void nation_city_set_river_preference(struct nation_city *pncity,
|
||
|
enum nation_city_preference prefer);
|
||
|
enum nation_city_preference prefer)
|
||
|
fc__attribute((nonnull(1)));
|
||
|
enum nation_city_preference
|
||
|
nation_city_terrain_preference(const struct nation_city *pncity,
|
||
|
const struct terrain *pterrain);
|
||
|
const struct terrain *pterrain)
|
||
|
fc__attribute((nonnull(1, 2)));
|
||
|
enum nation_city_preference
|
||
|
nation_city_river_preference(const struct nation_city *pncity);
|
||
|
nation_city_river_preference(const struct nation_city *pncity)
|
||
|
fc__attribute((nonnull(1)));
|
||
|
/* General nation set accessor routines */
|
||
|
int nation_set_count(void);
|
||
|
int nation_set_index(const struct nation_set *pset);
|
||
|
int nation_set_index(const struct nation_set *pset)
|
||
|
fc__attribute((nonnull(1)));
|
||
|
int nation_set_number(const struct nation_set *pset);
|
||
|
struct nation_set *nation_set_new(const char *set_name,
|
||
| ... | ... | |
|
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);
|
||
|
const char *nation_set_untranslated_name(const struct nation_set *pset)
|
||
|
fc__attribute((nonnull(1)));
|
||
|
const char *nation_set_rule_name(const struct nation_set *pset)
|
||
|
fc__attribute((nonnull(1)));
|
||
|
const char *nation_set_name_translation(const struct nation_set *pset)
|
||
|
fc__attribute((nonnull(1)));
|
||
|
const char *nation_set_description(const struct nation_set *pset)
|
||
|
fc__attribute((nonnull(1)));
|
||
|
bool nation_is_in_set(const struct nation_type *pnation,
|
||
|
const struct nation_set *pset);
|
||
|
const struct nation_set *pset)
|
||
|
fc__attribute((nonnull(1)));
|
||
|
struct nation_set *nation_set_by_setting_value(const char *setting);
|
||
|
/* General nation group accessor routines */
|
||
|
int nation_group_count(void);
|
||
|
int nation_group_index(const struct nation_group *pgroup);
|
||
|
int nation_group_index(const struct nation_group *pgroup)
|
||
|
fc__attribute((nonnull(1)));
|
||
|
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);
|
||
|
void nation_group_set_hidden(struct nation_group *pgroup, bool hidden)
|
||
|
fc__attribute((nonnull(1)));
|
||
|
void nation_group_set_match(struct nation_group *pgroup, int match)
|
||
|
fc__attribute((nonnull(1)));
|
||
|
bool is_nation_group_hidden(struct nation_group *pgroup)
|
||
|
fc__attribute((nonnull(1)));
|
||
|
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);
|
||
|
const char *nation_group_untranslated_name(const struct nation_group *pgroup)
|
||
|
fc__attribute((nonnull(1)));
|
||
|
const char *nation_group_rule_name(const struct nation_group *pgroup)
|
||
|
fc__attribute((nonnull(1)));
|
||
|
const char *nation_group_name_translation(const struct nation_group *pgroup)
|
||
|
fc__attribute((nonnull(1)));
|
||
|
bool nation_is_in_group(const struct nation_type *pnation,
|
||
|
const struct nation_group *pgroup);
|
||
|
const struct nation_group *pgroup)
|
||
|
fc__attribute((nonnull(1)));
|
||
|
/* Initialization and iteration */
|
||
|
void nation_sets_groups_init(void);
|
||