Prettify long option values in /show output.
[freeciv.git] / common / team.h
blob98cdbcee8504e5c8831511553297425bf9da5e06
1 /**********************************************************************
2 Freeciv - Copyright (C) 2005 - The Freeciv Project
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12 ***********************************************************************/
14 #ifndef FC__TEAM_H
15 #define FC__TEAM_H
17 #ifdef __cplusplus
18 extern "C" {
19 #endif /* __cplusplus */
21 #include "fc_types.h"
23 #include "tech.h"
25 #define MAX_NUM_TEAM_SLOTS MAX_NUM_PLAYER_SLOTS
27 /* Opaque types. */
28 struct team;
29 struct team_slot;
31 /* General team slot accessor functions. */
32 void team_slots_init(void);
33 bool team_slots_initialised(void);
34 void team_slots_free(void);
35 int team_slot_count(void);
37 struct team_slot *team_slot_first(void);
38 struct team_slot *team_slot_next(struct team_slot *tslot);
40 /* Team slot accessor functions. */
41 int team_slot_index(const struct team_slot *tslot);
42 struct team *team_slot_get_team(const struct team_slot *tslot);
43 bool team_slot_is_used(const struct team_slot *tslot);
44 struct team_slot *team_slot_by_number(int team_id);
45 struct team_slot *team_slot_by_rule_name(const char *team_name);
46 const char *team_slot_rule_name(const struct team_slot *tslot);
47 const char *team_slot_name_translation(const struct team_slot *tslot);
48 const char *team_slot_defined_name(const struct team_slot *tslot);
49 void team_slot_set_defined_name(struct team_slot *tslot, const char *team_name);
51 /* Team accessor functions. */
52 struct team *team_new(struct team_slot *tslot);
53 void team_destroy(struct team *pteam);
54 int team_count(void);
55 int team_index(const struct team *pteam);
56 int team_number(const struct team *pteam);
57 struct team *team_by_number(const int team_id);
58 const char *team_rule_name(const struct team *pteam);
59 const char *team_name_translation(const struct team *pteam);
60 int team_pretty_name(const struct team *pteam, char *buf, size_t buf_len);
62 const struct player_list *team_members(const struct team *pteam);
64 /* Ancillary routines */
65 void team_add_player(struct player *pplayer, struct team *pteam);
66 void team_remove_player(struct player *pplayer);
68 /* iterate over all team slots */
69 #define team_slots_iterate(_tslot) \
70 if (team_slots_initialised()) { \
71 struct team_slot *_tslot = team_slot_first(); \
72 for (; NULL != _tslot; _tslot = team_slot_next(_tslot)) {
73 #define team_slots_iterate_end \
74 } \
77 /* iterate over all teams, which are used at the moment */
78 #define teams_iterate(_pteam) \
79 team_slots_iterate(_tslot) { \
80 if (!team_slot_is_used(_tslot)) { \
81 continue; \
82 } \
83 struct team *_pteam = team_slot_get_team(_tslot);
84 #define teams_iterate_end \
85 } team_slots_iterate_end;
87 #ifdef __cplusplus
89 #endif /* __cplusplus */
91 #endif /* FC__TEAM_H */