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