Stop sharing requirement_unit_state_ereq().
[freeciv.git] / common / base.h
blob70ccf9de921897c6868d28cfdb23a6cf8094d54a
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__BASE_H
14 #define FC__BASE_H
16 #ifdef __cplusplus
17 extern "C" {
18 #endif /* __cplusplus */
20 /* utility */
21 #include "bitvector.h"
23 /* common */
24 #include "fc_types.h"
25 #include "requirements.h"
27 struct strvec; /* Actually defined in "utility/string_vector.h". */
29 /* Used in the network protocol. */
30 #define SPECENUM_NAME base_gui_type
31 #define SPECENUM_VALUE0 BASE_GUI_FORTRESS
32 #define SPECENUM_VALUE0NAME "Fortress"
33 #define SPECENUM_VALUE1 BASE_GUI_AIRBASE
34 #define SPECENUM_VALUE1NAME "Airbase"
35 #define SPECENUM_VALUE2 BASE_GUI_OTHER
36 #define SPECENUM_VALUE2NAME "Other"
37 #include "specenum_gen.h"
39 /* Used in the network protocol. */
40 #define SPECENUM_NAME base_flag_id
41 /* Unit inside are not considered aggressive if base is close to city */
42 #define SPECENUM_VALUE0 BF_NOT_AGGRESSIVE
43 /* TRANS: this and following strings are 'base flags', which may rarely
44 * be presented to the player in ruleset help text */
45 #define SPECENUM_VALUE0NAME N_("NoAggressive")
47 /* Flags below this comment are retired in 3.0. */
49 /* Units inside will not die all at once */
50 #define SPECENUM_VALUE1 BF_RETIRED_NO_STACK_DEATH
51 #define SPECENUM_VALUE1NAME N_("NoStackDeath")
52 /* Base provides bonus for defending diplomat */
53 #define SPECENUM_VALUE2 BF_RETIRED_DIPLOMAT_DEFENSE
54 #define SPECENUM_VALUE2NAME N_("DiplomatDefense")
55 /* Paratroopers can use base for paradrop. Now an extra user flag. */
56 #define SPECENUM_VALUE3 BF_RETIRED_PARADROP_FROM
57 #define SPECENUM_VALUE3NAME N_("ParadropFrom")
59 #define SPECENUM_COUNT BF_COUNT
60 #define SPECENUM_BITVECTOR bv_base_flags
61 #include "specenum_gen.h"
63 struct extra_type;
65 struct base_type {
66 Base_type_id item_number;
67 enum base_gui_type gui_type;
68 int border_sq;
69 int vision_main_sq;
70 int vision_invis_sq;
72 bv_base_flags flags;
74 struct extra_type *self;
77 #define BASE_NONE -1
79 /* General base accessor functions. */
80 Base_type_id base_count(void);
81 Base_type_id base_number(const struct base_type *pbase);
83 struct base_type *base_by_number(const Base_type_id id);
85 struct extra_type *base_extra_get(const struct base_type *pbase);
87 /* Functions to operate on a base flag. */
88 bool base_has_flag(const struct base_type *pbase, enum base_flag_id flag);
89 bool is_base_flag_card_near(const struct tile *ptile,
90 enum base_flag_id flag);
91 bool is_base_flag_near_tile(const struct tile *ptile,
92 enum base_flag_id flag);
93 bool base_flag_is_retired(enum base_flag_id flag);
94 bool base_has_flag_for_utype(const struct base_type *pbase,
95 enum base_flag_id flag,
96 const struct unit_type *punittype);
97 bool is_native_tile_to_base(const struct base_type *pbase,
98 const struct tile *ptile);
100 /* Ancillary functions */
101 bool base_can_be_built(const struct base_type *pbase,
102 const struct tile *ptile);
103 bool can_build_base(const struct unit *punit, const struct base_type *pbase,
104 const struct tile *ptile);
105 bool player_can_build_base(const struct base_type *pbase,
106 const struct player *pplayer,
107 const struct tile *ptile);
109 struct base_type *get_base_by_gui_type(enum base_gui_type type,
110 const struct unit *punit,
111 const struct tile *ptile);
113 bool territory_claiming_base(const struct base_type *pbase);
115 /* Initialization and iteration */
116 void base_type_init(struct extra_type *pextra, int idx);
117 void base_types_free(void);
119 #define base_deps_iterate(_reqs, _dep) \
121 requirement_vector_iterate(_reqs, preq) { \
122 if (preq->source.kind == VUT_EXTRA \
123 && preq->present \
124 && is_extra_caused_by(preq->source.value.extra, EC_BASE)) { \
125 struct base_type *_dep = extra_base_get(preq->source.value.extra);
127 #define base_deps_iterate_end \
129 } requirement_vector_iterate_end; \
132 #ifdef __cplusplus
134 #endif /* __cplusplus */
136 #endif /* FC__BASE_H */