Stop sharing requirement_unit_state_ereq().
[freeciv.git] / common / citizens.h
blobb8b4016344f2614d335dd0e3f5860fc246c6e133
1 /*****************************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
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 *****************************************************************************/
13 #ifndef FC__CITIZENS_H
14 #define FC__CITIZENS_H
16 #ifdef __cplusplus
17 extern "C" {
18 #endif /* __cplusplus */
20 /* utility */
21 #include "shared.h" /* bool */
23 /* common */
24 #include "fc_types.h"
26 struct player_slot;
27 struct city;
29 void citizens_init(struct city *pcity);
30 void citizens_free(struct city *pcity);
32 citizens citizens_nation_get(const struct city *pcity,
33 const struct player_slot *pslot);
34 citizens citizens_nation_foreign(const struct city *pcity);
35 void citizens_nation_set(struct city *pcity, const struct player_slot *pslot,
36 citizens count);
37 void citizens_nation_add(struct city *pcity, const struct player_slot *pslot,
38 int add);
39 void citizens_nation_move(struct city *pcity,
40 const struct player_slot *pslot_from,
41 const struct player_slot *pslot_to,
42 int move);
44 citizens citizens_count(const struct city *pcity);
45 struct player_slot *citizens_random(const struct city *pcity);
47 /* Iterates over all player slots (nationalities) with citizens. */
48 #define citizens_iterate(_pcity, _pslot, _nationality) \
49 player_slots_iterate(_pslot) { \
50 citizens _nationality = citizens_nation_get(_pcity, _pslot); \
51 if (_nationality == 0) { \
52 continue; \
54 #define citizens_iterate_end \
55 } player_slots_iterate_end;
57 /* Like above but only foreign citizens. */
58 #define citizens_foreign_iterate(_pcity, _pslot, _nationality) \
59 citizens_iterate(_pcity, _pslot, _nationality) { \
60 if (_pslot == city_owner(_pcity)->slot) { \
61 continue; \
63 #define citizens_foreign_iterate_end \
64 } citizens_iterate_end;
66 #ifdef __cplusplus
68 #endif /* __cplusplus */
70 #endif /* FC__CITIZENS_H */