Freeciv-3.4
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)
45struct team *team_slot_get_team(const struct team_slot *tslot)
47bool team_slot_is_used(const struct team_slot *tslot);
48struct team_slot *team_slot_by_number(int team_id);
49struct team_slot *team_slot_by_rule_name(const char *team_name)
51const char *team_slot_rule_name(const struct team_slot *tslot)
53const char *team_slot_name_translation(const struct team_slot *tslot)
55const char *team_slot_defined_name(const struct team_slot *tslot)
57void team_slot_set_defined_name(struct team_slot *tslot, const char *team_name)
58 fc__attribute((nonnull(1, 2)));
59
60/* Team accessor functions. */
61struct team *team_new(struct team_slot *tslot);
62void team_destroy(struct team *pteam)
64int team_count(void);
65int team_index(const struct team *pteam);
66int team_number(const struct team *pteam)
68struct team *team_by_number(const int team_id);
69const char *team_rule_name(const struct team *pteam)
71const char *team_name_translation(const struct team *pteam)
73int team_pretty_name(const struct team *pteam, char *buf, size_t buf_len);
74
75const struct player_list *team_members(const struct team *pteam)
77
78/* Ancillary routines */
79bool team_add_player(struct player *pplayer, struct team *pteam)
81void team_remove_player(struct player *pplayer);
82
83/* Iterate over all team slots */
84#define team_slots_iterate(_tslot) \
85 if (team_slots_initialised()) { \
86 struct team_slot *_tslot = team_slot_first(); \
87 for (; _tslot != nullptr; _tslot = team_slot_next(_tslot)) {
88
89#define team_slots_iterate_end \
90 } \
91 }
92
93/* Iterate over all teams, which are used at the moment */
94#define teams_iterate(_pteam) \
95 team_slots_iterate(_tslot) { \
96 struct team *_pteam = team_slot_get_team(_tslot); \
97 if (_pteam != nullptr) {
98
99#define teams_iterate_end \
100 } \
101 } team_slots_iterate_end;
102
103#ifdef __cplusplus
104}
105#endif /* __cplusplus */
106
107#endif /* FC__TEAM_H */
char * incite_cost
Definition comments.c:77
Definition team.c:40
#define fc__attribute(x)
Definition support.h:99
int team_count(void)
Definition team.c:366
void team_destroy(struct team *pteam) fc__attribute((nonnull(1)))
Definition team.c:347
int team_index(const struct team *pteam)
Definition team.c:374
struct team * team_by_number(const int team_id)
Definition team.c:390
const char * team_slot_rule_name(const struct team_slot *tslot) fc__attribute((nonnull(1)))
Definition team.c:229
struct team_slot * team_slot_by_number(int team_id)
Definition team.c:173
const struct player_list * team_members(const struct team *pteam) fc__attribute((nonnull(1)))
Definition team.c:442
void team_slots_free(void)
Definition team.c:85
void team_slot_set_defined_name(struct team_slot *tslot, const char *team_name) fc__attribute((nonnull(1
int team_slot_index(const struct team_slot *tslot) fc__attribute((nonnull(1)))
Definition team.c:138
const char * team_slot_defined_name(const struct team_slot *tslot) fc__attribute((nonnull(1)))
Definition team.c:271
const char * team_rule_name(const struct team *pteam) fc__attribute((nonnull(1)))
Definition team.c:400
struct team_slot * team_slot_first(void)
Definition team.c:120
struct team_slot * team_slot_by_rule_name(const char *team_name) fc__attribute((nonnull(1)))
Definition team.c:187
bool team_slots_initialised(void)
Definition team.c:77
bool team_add_player(struct player *pplayer, struct team *pteam) fc__attribute((nonnull(1)))
Definition team.c:451
struct team_slot * team_slot_next(struct team_slot *tslot)
Definition team.c:128
struct team * team_slot_get_team(const struct team_slot *tslot) fc__attribute((nonnull(1)))
Definition team.c:149
const char * team_slot_name_translation(const struct team_slot *tslot) fc__attribute((nonnull(1)))
Definition team.c:248
int team_pretty_name(const struct team *pteam, char *buf, size_t buf_len)
Definition team.c:418
void team_slots_init(void)
Definition team.c:53
void team_remove_player(struct player *pplayer)
Definition team.c:484
void struct team * team_new(struct team_slot *tslot)
Definition team.c:308
int team_slot_count(void)
Definition team.c:112
const char * team_name_translation(const struct team *pteam) fc__attribute((nonnull(1)))
Definition team.c:408
int team_number(const struct team *pteam) fc__attribute((nonnull(1)))
Definition team.c:382
bool team_slot_is_used(const struct team_slot *tslot)
Definition team.c:160