![]() |
Freeciv21
Develop your civilization from humble roots to a global empire
|
#include <fc_config.h>#include "fcintl.h"#include "log.h"#include "shared.h"#include "support.h"#include "game.h"#include "player.h"#include "team.h"
Include dependency graph for team.cpp:Go to the source code of this file.
Classes | |
| struct | team_slot |
| struct | team |
Functions | |
| void | team_slots_init () |
| Initialise all team slots. More... | |
| bool | team_slots_initialised () |
| Returns TRUE if the team slots have been initialized. More... | |
| void | team_slots_free () |
| Remove all team slots. More... | |
| int | team_slot_count () |
| Returns the total number of team slots (including used slots). More... | |
| struct team_slot * | team_slot_first () |
| Returns the first team slot. More... | |
| struct team_slot * | team_slot_next (struct team_slot *tslot) |
| Returns the next team slot. More... | |
| int | team_slot_index (const struct team_slot *tslot) |
| Returns the index of the team slots. More... | |
| struct team * | team_slot_get_team (const struct team_slot *tslot) |
| Returns the team corresponding to the slot. More... | |
| bool | team_slot_is_used (const struct team_slot *tslot) |
| Returns TRUE is this slot is "used" i.e. More... | |
| struct team_slot * | team_slot_by_number (int team_id) |
| Return the possibly unused and uninitialized team slot. More... | |
| struct team_slot * | team_slot_by_rule_name (const char *team_name) |
| Does a linear search for a (defined) team name. More... | |
| static void | team_slot_create_default_name (struct team_slot *tslot) |
| Creates a default name for this team slot. More... | |
| const char * | team_slot_rule_name (const struct team_slot *tslot) |
| Returns the name (untranslated) of the slot. More... | |
| const char * | team_slot_name_translation (const struct team_slot *tslot) |
| Returns the name (translated) of the slot. More... | |
| const char * | team_slot_defined_name (const struct team_slot *tslot) |
| Returns the name defined in the ruleset for this slot. More... | |
| void | team_slot_set_defined_name (struct team_slot *tslot, const char *team_name) |
| Set the name defined in the ruleset for this slot. More... | |
| struct team * | team_new (struct team_slot *tslot) |
| Creates a new team for the slot. More... | |
| void | team_destroy (struct team *pteam) |
| Destroys a team. More... | |
| int | team_count () |
| Return the current number of teams. More... | |
| int | team_index (const struct team *pteam) |
| Return the team index. More... | |
| int | team_number (const struct team *pteam) |
| Return the team index/number/id. More... | |
| struct team * | team_by_number (const int team_id) |
| Return struct team pointer for the given team index. More... | |
| const char * | team_rule_name (const struct team *pteam) |
| Returns the name (untranslated) of the team. More... | |
| const char * | team_name_translation (const struct team *pteam) |
| Returns the name (translated) of the team. More... | |
| 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>". More... | |
| const struct player_list * | team_members (const struct team *pteam) |
| Returns the member list of the team. More... | |
| void | team_add_player (struct player *pplayer, struct team *pteam) |
| Set a player to a team. More... | |
| void | team_remove_player (struct player *pplayer) |
| Remove the player from the team. More... | |
Variables | |
| struct { | |
| struct team_slot * tslots | |
| int used_slots | |
| } | team_slots |
Set a player to a team.
Removes the previous team affiliation if necessary.
Definition at line 438 of file team.cpp.
Referenced by handle_player_info(), server_player_init(), sg_load_players_basic(), and team_command().
| struct team* team_by_number | ( | const int | team_id | ) |
Return struct team pointer for the given team index.
Definition at line 373 of file team.cpp.
Referenced by get_info_label_text(), init_new_game(), research_is_valid(), research_name_translation(), research_pretty_name(), and research_rule_name().
| int team_count | ( | ) |
Return the current number of teams.
Definition at line 354 of file team.cpp.
Referenced by begin_turn(), check_for_game_over(), get_info_label_text(), handle_start_phase(), init_new_game(), package_player_common(), report_top_five_cities(), and report_wonders_of_the_world().
| void team_destroy | ( | struct team * | pteam | ) |
Destroys a team.
Definition at line 333 of file team.cpp.
Referenced by team_remove_player(), and team_slots_free().
| int team_index | ( | const struct team * | pteam | ) |
Return the team index.
Definition at line 359 of file team.cpp.
Referenced by sg_save_player_main(), and show_teams().
| const struct player_list* team_members | ( | const struct team * | pteam | ) |
Returns the member list of the team.
Definition at line 427 of file team.cpp.
Referenced by check_for_game_over(), init_new_game(), kill_player(), package_player_diplstate(), package_player_info(), rank_users(), research_pretty_name(), send_city_info(), send_research_info(), sg_load_player_vision(), show_teams(), and page_pregame::start_page_menu().
| const char* team_name_translation | ( | const struct team * | pteam | ) |
Returns the name (translated) of the team.
Definition at line 393 of file team.cpp.
Referenced by check_for_game_over(), col_team(), get_full_nation(), get_info_label_text(), research_name_translation(), show_players(), show_teams(), and page_pregame::update_start_page().
Creates a new team for the slot.
If slot is nullptr, it will lookup to a free slot. If the slot already used, then just return the team.
Definition at line 294 of file team.cpp.
Referenced by handle_player_info(), sg_load_players_basic(), team_add_player(), and team_command().
| int team_number | ( | const struct team * | pteam | ) |
Return the team index/number/id.
Definition at line 364 of file team.cpp.
Referenced by init_new_game(), is_player_phase(), package_player_common(), player_preferred_color(), research_get(), team_index(), and team_pretty_name().
| 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>".
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 405 of file team.cpp.
Referenced by report_top_five_cities(), report_wonders_of_the_world(), and research_pretty_name().
| 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 471 of file team.cpp.
Referenced by connection_attach_real(), player_clear(), and team_add_player().
| const char* team_rule_name | ( | const struct team * | pteam | ) |
Returns the name (untranslated) of the team.
Definition at line 383 of file team.cpp.
Referenced by init_new_game(), research_rule_name(), team_add_player(), and team_remove_player().
| struct team_slot* team_slot_by_number | ( | int | team_id | ) |
Return the possibly unused and uninitialized team slot.
Definition at line 157 of file team.cpp.
Referenced by handle_player_info(), handle_team_name_info(), load_ruleset_game(), save_game_ruleset(), sg_load_players_basic(), team_by_number(), team_command(), team_slot_name_translation(), and team_slot_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 171 of file team.cpp.
Referenced by team_command().
| int team_slot_count | ( | ) |
Returns the total number of team slots (including used slots).
Definition at line 101 of file team.cpp.
Referenced by compat_load_020600(), load_ruleset_game(), researches_init(), team_slot_by_number(), team_slot_next(), and team_slots_init().
|
inlinestatic |
Creates a default name for this team slot.
Definition at line 191 of file team.cpp.
Referenced by team_slot_name_translation(), and team_slot_rule_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 261 of file team.cpp.
Referenced by send_ruleset_team_names().
| struct team_slot* team_slot_first | ( | ) |
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 132 of file team.cpp.
Referenced by team_by_number().
| int team_slot_index | ( | const struct team_slot * | tslot | ) |
Returns the index of the team slots.
Definition at line 120 of file team.cpp.
Referenced by send_ruleset_team_names(), team_new(), team_number(), team_slot_create_default_name(), team_slot_name_translation(), and team_slot_rule_name().
| 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 144 of file team.cpp.
Referenced by page_pregame::start_page_menu(), and team_new().
| 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 237 of file team.cpp.
Referenced by page_pregame::start_page_menu(), team_command(), team_name_translation(), and team_pretty_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 217 of file team.cpp.
Referenced by save_game_ruleset(), page_pregame::start_page_menu(), team_rule_name(), team_slot_by_rule_name(), and team_slot_name_translation().
| void team_slot_set_defined_name | ( | struct team_slot * | tslot, |
| const char * | team_name | ||
| ) |
Set the name defined in the ruleset for this slot.
Definition at line 272 of file team.cpp.
Referenced by handle_team_name_info(), and load_ruleset_game().
| void team_slots_free | ( | ) |
| void team_slots_init | ( | ) |
| bool team_slots_initialised | ( | ) |
Returns TRUE if the team slots have been initialized.
Definition at line 72 of file team.cpp.
Referenced by team_destroy(), team_new(), team_slot_by_number(), team_slot_defined_name(), team_slot_get_team(), team_slot_index(), team_slot_is_used(), team_slot_name_translation(), team_slot_rule_name(), and team_slot_set_defined_name().
| struct { ... } team_slots |