Freeciv-3.3: /fast/freeciv/nightly/main/common/team.h Source File

Freeciv-3.3

Loading...
Searching...
No Matches
team.h
Go to the documentation of this file.
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.
7
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***********************************************************************/
13
14#ifndef FC__TEAM_H
15#define FC__TEAM_H
16
17#ifdef __cplusplus
18extern "C" {
19#endif /* __cplusplus */
20
21/* common */
22#include "fc_types.h"
23
24/* Have +1 to give space to swap teams
25 * (for the moment when there's one playerless team)
26 * Affects network protocol and savegames */
27#define MAX_NUM_TEAM_SLOTS (MAX_NUM_PLAYER_SLOTS + 1)
28
29/* Opaque types. */
30struct team;
31struct team_slot;
32
33/* General team slot accessor functions. */
34void team_slots_init(void);
35bool team_slots_initialised(void);
36void team_slots_free(void);
37int team_slot_count(void);
38
39struct team_slot *team_slot_first(void);
40struct team_slot *team_slot_next(struct team_slot *tslot);
41
42/* Team slot accessor functions. */
43int team_slot_index(const struct team_slot *tslot);
44struct team *team_slot_get_team(const struct team_slot *tslot);
45bool team_slot_is_used(const struct team_slot *tslot);
46struct team_slot *team_slot_by_number(int team_id);
47struct team_slot *team_slot_by_rule_name(const char *team_name);
48const char *team_slot_rule_name(const struct team_slot *tslot);
49const char *team_slot_name_translation(const struct team_slot *tslot);
50const char *team_slot_defined_name(const struct team_slot *tslot);
51void team_slot_set_defined_name(struct team_slot *tslot, const char *team_name);
52
53/* Team accessor functions. */
54struct team *team_new(struct team_slot *tslot);
55void team_destroy(struct team *pteam)
56 fc__attribute((nonnull(1)));
57int team_count(void);
58int team_index(const struct team *pteam);
59int team_number(const struct team *pteam);
60struct team *team_by_number(const int team_id);
61const char *team_rule_name(const struct team *pteam);
62const char *team_name_translation(const struct team *pteam);
63int team_pretty_name(const struct team *pteam, char *buf, size_t buf_len);
64
65const struct player_list *team_members(const struct team *pteam);
66
67/* Ancillary routines */
68bool team_add_player(struct player *pplayer, struct team *pteam);
69void team_remove_player(struct player *pplayer);
70
71/* Iterate over all team slots */
72#define team_slots_iterate(_tslot) \
73 if (team_slots_initialised()) { \
74 struct team_slot *_tslot = team_slot_first(); \
75 for (; NULL != _tslot; _tslot = team_slot_next(_tslot)) {
76
77#define team_slots_iterate_end \
78 } \
79 }
80
81/* Iterate over all teams, which are used at the moment */
82#define teams_iterate(_pteam) \
83 team_slots_iterate(_tslot) { \
84 struct team *_pteam = team_slot_get_team(_tslot); \
85 if (_pteam != NULL) {
86
87#define teams_iterate_end \
88 } \
89 } team_slots_iterate_end;
90
91#ifdef __cplusplus
92}
93#endif /* __cplusplus */
94
95#endif /* FC__TEAM_H */
incite_cost
char * incite_cost
Definition comments.c:74
fc_types.h
player
Definition player.h:249
team_slot
Definition team.c:31
team
Definition team.c:40
fc__attribute
#define fc__attribute(x)
Definition support.h:99
team_count
int team_count(void)
Definition team.c:375
team_destroy
void team_destroy(struct team *pteam) fc__attribute((nonnull(1)))
Definition team.c:356
team_index
int team_index(const struct team *pteam)
Definition team.c:383
team_by_number
struct team * team_by_number(const int team_id)
Definition team.c:400
team_name_translation
const char * team_name_translation(const struct team *pteam)
Definition team.c:420
team_slot_by_number
struct team_slot * team_slot_by_number(int team_id)
Definition team.c:175
team_slots_free
void team_slots_free(void)
Definition team.c:85
team_rule_name
const char * team_rule_name(const struct team *pteam)
Definition team.c:410
team_slot_get_team
struct team * team_slot_get_team(const struct team_slot *tslot)
Definition team.c:150
team_slot_name_translation
const char * team_slot_name_translation(const struct team_slot *tslot)
Definition team.c:253
team_slot_first
struct team_slot * team_slot_first(void)
Definition team.c:120
team_slot_defined_name
const char * team_slot_defined_name(const struct team_slot *tslot)
Definition team.c:277
team_number
int team_number(const struct team *pteam)
Definition team.c:391
team_slots_initialised
bool team_slots_initialised(void)
Definition team.c:77
team_slot_next
struct team_slot * team_slot_next(struct team_slot *tslot)
Definition team.c:128
team_add_player
bool team_add_player(struct player *pplayer, struct team *pteam)
Definition team.c:467
team_new
struct team * team_new(struct team_slot *tslot)
Definition team.c:317
team_pretty_name
int team_pretty_name(const struct team *pteam, char *buf, size_t buf_len)
Definition team.c:432
team_slot_index
int team_slot_index(const struct team_slot *tslot)
Definition team.c:138
team_slot_by_rule_name
struct team_slot * team_slot_by_rule_name(const char *team_name)
Definition team.c:189
team_members
const struct player_list * team_members(const struct team *pteam)
Definition team.c:456
team_slots_init
void team_slots_init(void)
Definition team.c:53
team_remove_player
void team_remove_player(struct player *pplayer)
Definition team.c:502
team_slot_count
int team_slot_count(void)
Definition team.c:112
team_slot_is_used
bool team_slot_is_used(const struct team_slot *tslot)
Definition team.c:162
team_slot_set_defined_name
void team_slot_set_defined_name(struct team_slot *tslot, const char *team_name)
Definition team.c:288
team_slot_rule_name
const char * team_slot_rule_name(const struct team_slot *tslot)
Definition team.c:233