Freeciv-3.1: /fast/freeciv/nightly/S3_1/common/citizens.h Source File

Freeciv-3.1

Loading...
Searching...
No Matches
citizens.h
Go to the documentation of this file.
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.
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#ifndef FC__CITIZENS_H
14#define FC__CITIZENS_H
15
16#ifdef __cplusplus
17extern "C" {
18#endif /* __cplusplus */
19
20/* utility */
21#include "shared.h" /* bool */
22
23/* common */
24#include "fc_types.h"
25
26struct player_slot;
27struct city;
28
29void citizens_init(struct city *pcity);
30void citizens_free(struct city *pcity);
31
32 citizens citizens_nation_get(const struct city *pcity,
33 const struct player_slot *pslot);
34 citizens citizens_nation_foreign(const struct city *pcity);
35void citizens_nation_set(struct city *pcity, const struct player_slot *pslot,
36 citizens count);
37void citizens_nation_add(struct city *pcity, const struct player_slot *pslot,
38 int add);
39void citizens_nation_move(struct city *pcity,
40 const struct player_slot *pslot_from,
41 const struct player_slot *pslot_to,
42 int move);
43
44 citizens citizens_count(const struct city *pcity);
45struct player_slot *citizens_random(const struct city *pcity);
46
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; \
53 }
54#define citizens_iterate_end \
55 } player_slots_iterate_end;
56
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; \
62 }
63#define citizens_foreign_iterate_end \
64 } citizens_iterate_end;
65
66#ifdef __cplusplus
67}
68#endif /* __cplusplus */
69
70#endif /* FC__CITIZENS_H */
citizens_random
struct player_slot * citizens_random(const struct city *pcity)
Definition citizens.c:190
citizens_free
void citizens_free(struct city *pcity)
Definition citizens.c:58
citizens_nation_move
void citizens_nation_move(struct city *pcity, const struct player_slot *pslot_from, const struct player_slot *pslot_to, int move)
Definition citizens.c:130
citizens_nation_add
void citizens_nation_add(struct city *pcity, const struct player_slot *pslot, int add)
Definition citizens.c:104
citizens_nation_get
citizens citizens_nation_get(const struct city *pcity, const struct player_slot *pslot)
Definition citizens.c:74
citizens_nation_set
void citizens_nation_set(struct city *pcity, const struct player_slot *pslot, citizens count)
Definition citizens.c:145
citizens_nation_foreign
citizens citizens_nation_foreign(const struct city *pcity)
Definition citizens.c:91
citizens_count
citizens citizens_count(const struct city *pcity)
Definition citizens.c:162
citizens_init
void citizens_init(struct city *pcity)
Definition citizens.c:32
fc_types.h
citizens
unsigned char citizens
Definition fc_types.h:358
shared.h
city
Definition city.h:309
move
Definition widget_window.c:39
player_slot
Definition player.c:45