Project

General

Profile

Feature #1720 » 0036-team.c-Replace-parameter-checking-fc_asserts-with-no.patch

Marko Lindqvist, 11/15/2025 05:20 PM

View differences:

common/team.c
int team_slot_index(const struct team_slot *tslot)
{
fc_assert_ret_val(team_slots_initialised(), -1);
fc_assert_ret_val(tslot != nullptr, -1);
return tslot - team_slots.slots;
}
......
struct team *team_slot_get_team(const struct team_slot *tslot)
{
fc_assert_ret_val(team_slots_initialised(), nullptr);
fc_assert_ret_val(tslot != nullptr, nullptr);
return tslot->team;
}
......
****************************************************************************/
struct team_slot *team_slot_by_rule_name(const char *team_name)
{
fc_assert_ret_val(team_name != nullptr, nullptr);
team_slots_iterate(tslot) {
const char *tname = team_slot_rule_name(tslot);
......
const char *team_slot_rule_name(const struct team_slot *tslot)
{
fc_assert_ret_val(team_slots_initialised(), nullptr);
fc_assert_ret_val(tslot != nullptr, nullptr);
if (tslot->rule_name == nullptr) {
/* Get the team slot as changeable (not _const_) struct. */
......
{
#ifdef FREECIV_ENABLE_NLS
fc_assert_ret_val(team_slots_initialised(), nullptr);
fc_assert_ret_val(tslot != nullptr, nullptr);
if (tslot->name_translation == nullptr) {
/* Get the team slot as changeable (not _const_) struct. */
......
const char *team_slot_defined_name(const struct team_slot *tslot)
{
fc_assert_ret_val(team_slots_initialised(), nullptr);
fc_assert_ret_val(tslot != nullptr, nullptr);
return tslot->defined_name;
}
......
const char *team_name)
{
fc_assert_ret(team_slots_initialised());
fc_assert_ret(tslot != nullptr);
fc_assert_ret(team_name != nullptr);
if (tslot->defined_name != nullptr) {
free(tslot->defined_name);
......
****************************************************************************/
int team_number(const struct team *pteam)
{
fc_assert_ret_val(pteam != nullptr, -1);
return team_slot_index(pteam->slot);
}
......
****************************************************************************/
const char *team_rule_name(const struct team *pteam)
{
fc_assert_ret_val(pteam != nullptr, nullptr);
return team_slot_rule_name(pteam->slot);
}
......
****************************************************************************/
const char *team_name_translation(const struct team *pteam)
{
fc_assert_ret_val(pteam != nullptr, nullptr);
return team_slot_name_translation(pteam->slot);
}
......
****************************************************************************/
const struct player_list *team_members(const struct team *pteam)
{
fc_assert_ret_val(pteam != nullptr, nullptr);
return pteam->plrlist;
}
......
****************************************************************************/
bool team_add_player(struct player *pplayer, struct team *pteam)
{
fc_assert_ret_val(pplayer != nullptr, FALSE);
if (pteam == nullptr) {
pteam = team_new(nullptr);
} else if (pteam == pplayer->team) {
common/team.h
struct team_slot *team_slot_next(struct team_slot *tslot);
/* Team slot accessor functions. */
int team_slot_index(const struct team_slot *tslot);
struct team *team_slot_get_team(const struct team_slot *tslot);
int team_slot_index(const struct team_slot *tslot)
fc__attribute((nonnull(1)));
struct team *team_slot_get_team(const struct team_slot *tslot)
fc__attribute((nonnull(1)));
bool team_slot_is_used(const struct team_slot *tslot);
struct team_slot *team_slot_by_number(int team_id);
struct team_slot *team_slot_by_rule_name(const char *team_name);
const char *team_slot_rule_name(const struct team_slot *tslot);
const char *team_slot_name_translation(const struct team_slot *tslot);
const char *team_slot_defined_name(const struct team_slot *tslot);
void team_slot_set_defined_name(struct team_slot *tslot, const char *team_name);
struct team_slot *team_slot_by_rule_name(const char *team_name)
fc__attribute((nonnull(1)));
const char *team_slot_rule_name(const struct team_slot *tslot)
fc__attribute((nonnull(1)));
const char *team_slot_name_translation(const struct team_slot *tslot)
fc__attribute((nonnull(1)));
const char *team_slot_defined_name(const struct team_slot *tslot)
fc__attribute((nonnull(1)));
void team_slot_set_defined_name(struct team_slot *tslot, const char *team_name)
fc__attribute((nonnull(1, 2)));
/* Team accessor functions. */
struct team *team_new(struct team_slot *tslot);
......
fc__attribute((nonnull(1)));
int team_count(void);
int team_index(const struct team *pteam);
int team_number(const struct team *pteam);
int team_number(const struct team *pteam)
fc__attribute((nonnull(1)));
struct team *team_by_number(const int team_id);
const char *team_rule_name(const struct team *pteam);
const char *team_name_translation(const struct team *pteam);
const char *team_rule_name(const struct team *pteam)
fc__attribute((nonnull(1)));
const char *team_name_translation(const struct team *pteam)
fc__attribute((nonnull(1)));
int team_pretty_name(const struct team *pteam, char *buf, size_t buf_len);
const struct player_list *team_members(const struct team *pteam);
const struct player_list *team_members(const struct team *pteam)
fc__attribute((nonnull(1)));
/* Ancillary routines */
bool team_add_player(struct player *pplayer, struct team *pteam);
bool team_add_player(struct player *pplayer, struct team *pteam)
fc__attribute((nonnull(1)));
void team_remove_player(struct player *pplayer);
/* Iterate over all team slots */
(2-2/2)