Freeciv-3.4
Loading...
Searching...
No Matches
Macros | Functions
team.h File Reference
#include "fc_types.h"

Go to the source code of this file.

Macros

#define MAX_NUM_TEAM_SLOTS   (MAX_NUM_PLAYER_SLOTS + 1)
 
#define team_slots_iterate(_tslot)
 
#define team_slots_iterate_end
 
#define teams_iterate(_pteam)
 
#define teams_iterate_end
 

Functions

void team_slots_init (void)
 
bool team_slots_initialised (void)
 
void team_slots_free (void)
 
int team_slot_count (void)
 
struct team_slotteam_slot_first (void)
 
struct team_slotteam_slot_next (struct team_slot *tslot)
 
int team_slot_index (const struct team_slot *tslot) fc__attribute((nonnull(1)))
 
struct teamteam_slot_get_team (const struct team_slot *tslot) fc__attribute((nonnull(1)))
 
bool team_slot_is_used (const struct team_slot *tslot)
 
struct team_slotteam_slot_by_number (int team_id)
 
struct team_slotteam_slot_by_rule_name (const char *team_name) fc__attribute((nonnull(1)))
 
const charteam_slot_rule_name (const struct team_slot *tslot) fc__attribute((nonnull(1)))
 
const charteam_slot_name_translation (const struct team_slot *tslot) fc__attribute((nonnull(1)))
 
const charteam_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
 
void struct teamteam_new (struct team_slot *tslot)
 
void team_destroy (struct team *pteam) fc__attribute((nonnull(1)))
 
int team_count (void)
 
int team_index (const struct team *pteam)
 
int team_number (const struct team *pteam) fc__attribute((nonnull(1)))
 
struct teamteam_by_number (const int team_id)
 
const charteam_rule_name (const struct team *pteam) fc__attribute((nonnull(1)))
 
const charteam_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_listteam_members (const struct team *pteam) fc__attribute((nonnull(1)))
 
bool team_add_player (struct player *pplayer, struct team *pteam) fc__attribute((nonnull(1)))
 
void team_remove_player (struct player *pplayer)
 

Macro Definition Documentation

◆ MAX_NUM_TEAM_SLOTS

#define MAX_NUM_TEAM_SLOTS   (MAX_NUM_PLAYER_SLOTS + 1)

Definition at line 27 of file team.h.

◆ team_slots_iterate

#define team_slots_iterate (   _tslot)
Value:
for (; _tslot != nullptr; _tslot = team_slot_next(_tslot)) {
char * incite_cost
Definition comments.c:77
struct team_slot * team_slot_first(void)
Definition team.c:120
bool team_slots_initialised(void)
Definition team.c:77
struct team_slot * team_slot_next(struct team_slot *tslot)
Definition team.c:128

Definition at line 84 of file team.h.

◆ team_slots_iterate_end

#define team_slots_iterate_end
Value:
} \
}

Definition at line 89 of file team.h.

◆ teams_iterate

#define teams_iterate (   _pteam)
Value:
if (_pteam != nullptr) {
Definition team.c:40
#define team_slots_iterate(_tslot)
Definition team.h:84
struct team * team_slot_get_team(const struct team_slot *tslot) fc__attribute((nonnull(1)))
Definition team.c:149

Definition at line 94 of file team.h.

◆ teams_iterate_end

#define teams_iterate_end
Value:
} \
#define team_slots_iterate_end
Definition team.h:89

Definition at line 99 of file team.h.

Function Documentation

◆ team_add_player()

bool team_add_player ( struct player pplayer,
struct team pteam 
)

Set a player to a team. Removes the previous team affiliation if necessary.

Definition at line 451 of file team.c.

Referenced by handle_player_info(), server_player_init(), sg_load_players_basic(), sg_load_players_basic(), and team_command().

◆ team_by_number()

struct team * team_by_number ( const int  team_id)

◆ team_count()

int team_count ( void  )

◆ team_destroy()

void team_destroy ( struct team pteam)

Destroys a team.

Definition at line 347 of file team.c.

Referenced by team_remove_player(), and team_slots_free().

◆ team_index()

int team_index ( const struct team pteam)

Return the team index.

Definition at line 374 of file team.c.

Referenced by sg_save_player_main(), and show_teams().

◆ team_members()

const struct player_list * team_members ( const struct team pteam)

◆ team_name_translation()

const char * team_name_translation ( const struct team pteam)

◆ team_new()

void struct team * team_new ( struct team_slot tslot)

Creates a new team for the slot. If slot is nullptr, it will lookup to a free slot. If the slot is already used, then just return the team.

Definition at line 308 of file team.c.

Referenced by handle_player_info(), sg_load_players_basic(), sg_load_players_basic(), team_add_player(), and team_command().

◆ team_number()

int team_number ( const struct team pteam)

◆ team_pretty_name()

int team_pretty_name ( const struct team pteam,
char buf,
size_t  buf_len 
)

Set in 'buf' the name of the team 'pteam' in a format like "team <team_name>". To avoid to see "team Team 0", it only prints the the team number when the name of this team is not defined in the ruleset.

Definition at line 418 of file team.c.

Referenced by report_top_cities(), report_wonders_of_the_world(), report_wonders_of_the_world_long(), and research_pretty_name().

◆ team_remove_player()

void team_remove_player ( struct player pplayer)

Remove the player from the team. This should only be called when deleting a player; since every player must always be on a team.

Note in some very rare cases a player may not be on a team. It's safe to call this function anyway.

Definition at line 484 of file team.c.

Referenced by connection_attach_real(), create_command_pregame(), player_clear(), and team_add_player().

◆ team_rule_name()

const char * team_rule_name ( const struct team pteam)

Returns the name (untranslated) of the team.

Definition at line 400 of file team.c.

Referenced by init_new_game(), map_generate_fair_islands(), research_rule_name(), team_add_player(), and team_remove_player().

◆ team_slot_by_number()

struct team_slot * team_slot_by_number ( int  team_id)

◆ team_slot_by_rule_name()

struct team_slot * team_slot_by_rule_name ( const char team_name)

Does a linear search for a (defined) team name. Returns nullptr when none match.

Definition at line 187 of file team.c.

Referenced by team_command().

◆ team_slot_count()

int team_slot_count ( void  )

Returns the total number of team slots (including used slots).

Definition at line 112 of file team.c.

Referenced by compat_load_020600(), load_ruleset_game(), researches_init(), team_slot_by_number(), team_slot_next(), and team_slots_init().

◆ team_slot_defined_name()

const char * team_slot_defined_name ( const struct team_slot tslot)

Returns the name defined in the ruleset for this slot. It may return nullptr if the ruleset didn't defined a such name.

Definition at line 271 of file team.c.

Referenced by send_ruleset_team_names().

◆ team_slot_first()

struct team_slot * team_slot_first ( void  )

Returns the first team slot.

Definition at line 120 of file team.c.

◆ team_slot_get_team()

struct team * team_slot_get_team ( const struct team_slot tslot)

Returns the team corresponding to the slot. If the slot is not used, it will return nullptr. See also team_slot_is_used().

Definition at line 149 of file team.c.

Referenced by create_conn_menu(), and team_by_number().

◆ team_slot_index()

int team_slot_index ( const struct team_slot tslot)

◆ team_slot_is_used()

bool team_slot_is_used ( const struct team_slot tslot)

Returns TRUE is this slot is "used" i.e. corresponds to a valid, initialized team that exists in the game.

Definition at line 160 of file team.c.

Referenced by create_conn_menu(), fc_client::start_page_menu(), and team_new().

◆ team_slot_name_translation()

const char * team_slot_name_translation ( const struct team_slot tslot)

Returns the name (translated) of the slot. Creates a default one if it doesn't exist currently.

Definition at line 248 of file team.c.

Referenced by create_conn_menu(), fc_client::start_page_menu(), team_command(), team_name_translation(), and team_pretty_name().

◆ team_slot_next()

struct team_slot * team_slot_next ( struct team_slot tslot)

Returns the next team slot.

Definition at line 128 of file team.c.

◆ team_slot_rule_name()

const char * team_slot_rule_name ( const struct team_slot tslot)

Returns the name (untranslated) of the slot. Creates a default one if it doesn't exist currently.

Definition at line 229 of file team.c.

Referenced by conn_menu_team_chosen(), conn_menu_team_chosen(), save_game_ruleset(), fc_client::start_page_menu(), team_rule_name(), team_slot_by_rule_name(), and team_slot_name_translation().

◆ team_slot_set_defined_name()

void team_slot_set_defined_name ( struct team_slot tslot,
const char team_name 
)

◆ team_slots_free()

void team_slots_free ( void  )

Remove all team slots.

Definition at line 85 of file team.c.

Referenced by game_free().

◆ team_slots_init()

void team_slots_init ( void  )

Initialise all team slots.

Definition at line 53 of file team.c.

Referenced by game_init().

◆ team_slots_initialised()

bool team_slots_initialised ( void  )