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);
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)
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 */
char * incite_cost
Definition comments.c:76
Definition team.c:40
#define fc__attribute(x)
Definition support.h:99
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