Project

General

Profile

Feature #1649 ยป 0029-player.c-Replace-parameter-checking-fc_asserts-with-.patch

Marko Lindqvist, 11/08/2025 10:04 PM

View differences:

common/player.c
static void player_diplstate_defaults(const struct player *plr1,
const struct player *plr2);
static void player_diplstate_destroy(const struct player *plr1,
const struct player *plr2);
const struct player *plr2)
fc__attribute((nonnull(1, 2)));
static void player_diplstate_new(const struct player *plr1,
const struct player *plr2)
fc__attribute((nonnull(1, 2)));
/*******************************************************************//**
Return the diplomatic state that cancelling a pact will
......
const struct player *plr2)
{
struct player_diplstate *diplstate;
fc_assert_ret(plr1 != nullptr);
fc_assert_ret(plr2 != nullptr);
const struct player_diplstate **diplstate_slot
= plr1->diplstates + player_index(plr2);
......
struct player_diplstate *player_diplstate_get(const struct player *plr1,
const struct player *plr2)
{
fc_assert_ret_val(plr1 != nullptr, nullptr);
fc_assert_ret_val(plr2 != nullptr, nullptr);
const struct player_diplstate **diplstate_slot
= plr1->diplstates + player_index(plr2);
......
static void player_diplstate_destroy(const struct player *plr1,
const struct player *plr2)
{
fc_assert_ret(plr1 != nullptr);
fc_assert_ret(plr2 != nullptr);
const struct player_diplstate **diplstate_slot
= plr1->diplstates + player_index(plr2);
......
***********************************************************************/
int player_slot_index(const struct player_slot *pslot)
{
fc_assert_ret_val(pslot != nullptr, -1);
return pslot - player_slots.slots;
}
......
***********************************************************************/
struct player *player_slot_get_player(const struct player_slot *pslot)
{
fc_assert_ret_val(pslot != nullptr, nullptr);
return pslot->player;
}
......
***********************************************************************/
bool player_slot_is_used(const struct player_slot *pslot)
{
fc_assert_ret_val(pslot != nullptr, FALSE);
/* No player slot available, if the game is not initialised. */
if (!player_slots_initialised()) {
return FALSE;
......
{
struct player_slot *pslot;
fc_assert_ret(pplayer != nullptr);
pslot = pplayer->slot;
fc_assert(pslot->player == pplayer);
......
***********************************************************************/
int player_number(const struct player *pplayer)
{
fc_assert_ret_val(pplayer != nullptr, -1);
return player_slot_index(pplayer->slot);
}
......
***********************************************************************/
int player_age(const struct player *pplayer)
{
fc_assert_ret_val(pplayer != nullptr, 0);
return pplayer->turns_alive;
}
......
bool player_can_see_city_externals(const struct player *pow_player,
const struct city *target_city)
{
fc_assert_ret_val(target_city, FALSE);
fc_assert_ret_val(pow_player, FALSE);
if (can_player_see_city_internals(pow_player, target_city)) {
/* City internals includes city externals. */
return TRUE;
......
const struct player *player2,
int diplrel)
{
fc_assert(player1 != nullptr);
fc_assert(player2 != nullptr);
/* No relationship to it self. */
if (player1 == player2 && diplrel != DRO_FOREIGN) {
return FALSE;
......
***********************************************************************/
bool is_diplrel_to_other(const struct player *pplayer, int diplrel)
{
fc_assert(pplayer != nullptr);
players_iterate_alive(oplayer) {
if (oplayer == pplayer) {
continue;
common/player.h
/* A player slot contains a possibly uninitialized player. */
int player_slot_count(void);
int player_slot_index(const struct player_slot *pslot);
struct player *player_slot_get_player(const struct player_slot *pslot);
bool player_slot_is_used(const struct player_slot *pslot);
int player_slot_index(const struct player_slot *pslot)
fc__attribute((nonnull(1)));
struct player *player_slot_get_player(const struct player_slot *pslot)
fc__attribute((nonnull(1)));
bool player_slot_is_used(const struct player_slot *pslot)
fc__attribute((nonnull(1)));
struct player_slot *player_slot_by_number(int player_id);
int player_slot_max_used_number(void);
......
const struct rgbcolor *prgbcolor);
void player_clear(struct player *pplayer, bool full);
void player_ruleset_close(struct player *pplayer);
void player_destroy(struct player *pplayer);
void player_destroy(struct player *pplayer)
fc__attribute((nonnull(1)));
int player_count(void);
int player_index(const struct player *pplayer);
int player_number(const struct player *pplayer);
int player_number(const struct player *pplayer)
fc__attribute((nonnull(1)));
struct player *player_by_number(const int player_id);
const char *player_name(const struct player *pplayer);
......
const struct player *pplayer2);
bool team_has_embassy(const struct team *pteam, const struct player *tgt_player);
int player_age(const struct player *pplayer);
int player_age(const struct player *pplayer)
fc__attribute((nonnull(1)));
bool player_can_trust_tile_has_no_units(const struct player *pplayer,
const struct tile *ptile);
......
bool can_player_see_city_internals(const struct player *pplayer,
const struct city *pcity);
bool player_can_see_city_externals(const struct player *pow_player,
const struct city *target_city);
const struct city *target_city)
fc__attribute((nonnull(1, 2)));
bool player_owns_city(const struct player *pplayer,
const struct city *pcity);
......
enum diplstate_type cancel_pact_result(enum diplstate_type oldstate);
struct player_diplstate *player_diplstate_get(const struct player *plr1,
const struct player *plr2);
const struct player *plr2)
fc__attribute((nonnull(1, 2)));
bool are_diplstates_equal(const struct player_diplstate *pds1,
const struct player_diplstate *pds2);
enum dipl_reason pplayer_can_make_treaty(const struct player *p1,
......
void diplrel_mess_close(void);
bool is_diplrel_between(const struct player *player1,
const struct player *player2,
int diplrel);
bool is_diplrel_to_other(const struct player *pplayer, int diplrel);
int diplrel)
fc__attribute((nonnull(1, 2)));
bool is_diplrel_to_other(const struct player *pplayer, int diplrel)
fc__attribute((nonnull(1)));
int diplrel_by_rule_name(const char *value);
const char *diplrel_rule_name(int value);
const char *diplrel_name_translation(int value);
    (1-1/1)