Project

General

Profile

Feature #1971 ยป 0031-government.c-Replace-parameter-checking-fc_asserts-w.patch

Marko Lindqvist, 04/26/2026 10:43 AM

View differences:

common/government.c
**************************************************************************/
Government_type_id government_index(const struct government *pgovern)
{
fc_assert_ret_val(pgovern != nullptr, -1);
return pgovern - governments;
}
......
**************************************************************************/
Government_type_id government_number(const struct government *pgovern)
{
fc_assert_ret_val(pgovern != nullptr, -1);
return pgovern->item_number;
}
......
**************************************************************************/
struct government *government_of_player(const struct player *pplayer)
{
fc_assert_ret_val(pplayer != nullptr, nullptr);
return pplayer->government;
}
......
**************************************************************************/
struct government *government_of_city(const struct city *pcity)
{
fc_assert_ret_val(pcity != nullptr, nullptr);
return government_of_player(city_owner(pcity));
}
......
**************************************************************************/
const char *government_rule_name(const struct government *pgovern)
{
fc_assert_ret_val(pgovern != nullptr, nullptr);
return rule_name_get(&pgovern->name);
}
......
**************************************************************************/
const char *government_name_translation(const struct government *pgovern)
{
fc_assert_ret_val(pgovern != nullptr, nullptr);
return name_translation_get(&pgovern->name);
}
......
bool can_change_to_government(struct player *pplayer,
const struct government *gov)
{
fc_assert_ret_val(gov != nullptr, FALSE);
if (!pplayer) {
if (pplayer == nullptr) {
return FALSE;
}
......
const struct ruler_title_hash *
government_ruler_titles(const struct government *pgovern)
{
fc_assert_ret_val(pgovern != nullptr, nullptr);
return pgovern->ruler_titles;
}
......
const struct nation_type *pnation = nation_of_player(pplayer);
struct ruler_title *pruler_title;
fc_assert_ret_val(buf != nullptr, nullptr);
fc_assert_ret_val(0 < buf_len, nullptr);
/* Try specific nation ruler title. */
common/government.h
/* General government accessor functions. */
Government_type_id government_count(void);
Government_type_id government_index(const struct government *pgovern);
Government_type_id government_number(const struct government *pgovern);
Government_type_id government_index(const struct government *pgovern)
fc__attribute((nonnull(1)));
Government_type_id government_number(const struct government *pgovern)
fc__attribute((nonnull(1)));
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);
struct government *government_of_player(const struct player *pplayer)
fc__attribute((nonnull(1)));
struct government *government_of_city(const struct city *pcity)
fc__attribute((nonnull(1)));
struct government *government_by_rule_name(const char *name);
struct government *government_by_translated_name(const char *name);
const char *government_rule_name(const struct government *pgovern);
const char *government_name_translation(const struct government *pgovern);
const char *government_rule_name(const struct government *pgovern)
fc__attribute((nonnull(1)));
const char *government_name_translation(const struct government *pgovern)
fc__attribute((nonnull(1)));
const char *government_name_for_player(const struct player *pplayer);
/* Ruler titles. */
const struct ruler_title_hash *
government_ruler_titles(const struct government *pgovern);
government_ruler_titles(const struct government *pgovern)
fc__attribute((nonnull(1)));
struct ruler_title *
government_ruler_title_new(struct government *pgovern,
const struct nation_type *pnation,
......
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);
char *buf, size_t buf_len)
fc__attribute((nonnull(2)));
const char *default_title_for_player(const struct player *pplayer,
char *buf, size_t buf_len);
/* Ancillary routines */
bool can_change_to_government(struct player *pplayer,
const struct government *pgovern);
const struct government *pgovern)
fc__attribute((nonnull(2)));
/* Initialization and iteration */
void governments_alloc(int num);
    (1-1/1)