13 #include <fc_config.h>
30 #ifdef FREECIV_ENABLE_NLS
59 tslot->
team =
nullptr;
62 #ifdef FREECIV_ENABLE_NLS
63 tslot->name_translation =
nullptr;
81 if (
nullptr != tslot->team) {
84 delete[] tslot->defined_name;
85 delete[] tslot->rule_name;
87 #ifdef FREECIV_ENABLE_NLS
88 delete[] tslot->name_translation;
151 return nullptr != tslot->
team;
179 if (
nullptr != tname && 0 ==
fc_strcasecmp(tname, team_name)) {
197 #ifdef FREECIV_ENABLE_NLS
198 fc_assert(
nullptr == tslot->name_translation);
204 #ifdef FREECIV_ENABLE_NLS
206 tslot->name_translation =
fc_strdup(buf);
209 qDebug(
"No name defined for team %d! Creating a default name: %s.",
239 #ifdef FREECIV_ENABLE_NLS
243 if (
nullptr == tslot->name_translation) {
248 return changeable->name_translation;
251 return tslot->name_translation;
273 const char *team_name)
284 #ifdef FREECIV_ENABLE_NLS
285 delete[] tslot->name_translation;
286 tslot->name_translation =
fc_strdup(
Q_(team_name));
300 if (
nullptr == tslot) {
311 }
else if (
nullptr != tslot->
team) {
317 pteam =
new team[1]();
322 pteam->
plrlist = player_list_new();
344 player_list_destroy(pteam->
plrlist);
347 tslot->
team =
nullptr;
407 if (
nullptr != pteam) {
414 buf = QString(
_(
"team %1")).arg(QString::number(
team_number(pteam)));
420 buf = QStringLiteral(
"(null team)");
442 if (pteam ==
nullptr) {
448 if (pteam == pplayer->
team) {
460 pplayer->
team = pteam;
461 player_list_append(pteam->
plrlist, pplayer);
476 pteam = pplayer->
team;
478 log_debug(
"Removing player %d/%s from team %s (%d)",
481 player_list_remove(pteam->
plrlist, pplayer);
483 if (player_list_size(pteam->
plrlist) == 0) {
487 pplayer->
team =
nullptr;
#define fc_assert_ret(condition)
#define fc_assert(condition)
#define fc_assert_ret_val(condition, val)
#define log_debug(message,...)
int player_number(const struct player *pplayer)
Return the player index/number/id.
const char * player_name(const struct player *pplayer)
Return the leader name of the player.
char username[MAX_LEN_NAME]
struct player_list * plrlist
int fc_snprintf(char *str, size_t n, const char *format,...)
See also fc_utf8_snprintf_trunc(), fc_utf8_snprintf_rep().
int fc_strcasecmp(const char *str0, const char *str1)
Compare strings like strcmp(), but ignoring case.
int team_index(const struct team *pteam)
Return the team index.
struct team * team_by_number(const int team_id)
Return struct team pointer for the given team index.
struct team_slot * team_slot_next(struct team_slot *tslot)
Returns the next team slot.
static void team_slot_create_default_name(struct team_slot *tslot)
Creates a default name for this team slot.
const char * team_name_translation(const struct team *pteam)
Returns the name (translated) of the team.
const char * team_rule_name(const struct team *pteam)
Returns the name (untranslated) of the team.
void team_add_player(struct player *pplayer, struct team *pteam)
Set a player to a team.
struct team_slot * team_slot_first()
Returns the first team slot.
const char * team_slot_defined_name(const struct team_slot *tslot)
Returns the name defined in the ruleset for this slot.
int team_count()
Return the current number of teams.
struct team * team_slot_get_team(const struct team_slot *tslot)
Returns the team corresponding to the slot.
int team_pretty_name(const struct team *pteam, QString &buf)
Set in 'buf' the name of the team 'pteam' in a format like "team <team_name>".
struct team_slot * tslots
const char * team_slot_name_translation(const struct team_slot *tslot)
Returns the name (translated) of the slot.
int team_number(const struct team *pteam)
Return the team index/number/id.
void team_destroy(struct team *pteam)
Destroys a team.
void team_slots_init()
Initialise all team slots.
const char * team_slot_rule_name(const struct team_slot *tslot)
Returns the name (untranslated) of the slot.
bool team_slots_initialised()
Returns TRUE if the team slots have been initialized.
const struct player_list * team_members(const struct team *pteam)
Returns the member list of the team.
void team_slots_free()
Remove all team slots.
int team_slot_index(const struct team_slot *tslot)
Returns the index of the team slots.
struct team * team_new(struct team_slot *tslot)
Creates a new team for the slot.
void team_remove_player(struct player *pplayer)
Remove the player from the team.
int team_slot_count()
Returns the total number of team slots (including used slots).
struct team_slot * team_slot_by_rule_name(const char *team_name)
Does a linear search for a (defined) team name.
static struct @74 team_slots
struct team_slot * team_slot_by_number(int team_id)
Return the possibly unused and uninitialized team slot.
bool team_slot_is_used(const struct team_slot *tslot)
Returns TRUE is this slot is "used" i.e.
void team_slot_set_defined_name(struct team_slot *tslot, const char *team_name)
Set the name defined in the ruleset for this slot.
#define team_slots_iterate_end
#define team_slots_iterate(_tslot)
#define MAX_NUM_TEAM_SLOTS