Freeciv-3.2: /fast/freeciv/nightly/S3_2/common/unitlist.h Source File

Freeciv-3.2

Loading...
Searching...
No Matches
unitlist.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__UNITLIST_H
15#define FC__UNITLIST_H
16
17#ifdef __cplusplus
18extern "C" {
19#endif /* __cplusplus */
20
21/* common */
22#include "fc_types.h"
23#include "unit.h" /* for diplomat_actions */
24#include "unittype.h" /* for unit_type_flag_id */
25
26/* get 'struct unit_list' and related functions: */
27#define SPECLIST_TAG unit
28#define SPECLIST_TYPE struct unit
29#include "speclist.h"
30
31#define unit_list_iterate(unitlist, punit) \
32 TYPED_LIST_ITERATE(struct unit, unitlist, punit)
33#define unit_list_iterate_end LIST_ITERATE_END
34#define unit_list_both_iterate(unitlist, plink, punit) \
35 TYPED_LIST_BOTH_ITERATE(struct unit_list_link, struct unit, unitlist, \
36 plink, punit)
37#define unit_list_both_iterate_end LIST_BOTH_ITERATE_END
38
39#define unit_list_iterate_safe(unitlist, _unit) \
40{ \
41 struct unit_list *_unit##_ul = unitlist; \
42 int _unit##_size = unit_list_size(_unit##_ul); \
43 \
44 if (_unit##_size > 0) { \
45 int _unit##_numbers[_unit##_size]; \
46 int _unit##_index; \
47 \
48 _unit##_size = 0; \
49 unit_list_iterate(_unit##_ul, _unit) { \
50 _unit##_numbers[_unit##_size++] = _unit->id; \
51 } unit_list_iterate_end; \
52 \
53 for (_unit##_index = 0; \
54 _unit##_index < _unit##_size; \
55 _unit##_index++) { \
56 struct unit *_unit = \
57 game_unit_by_number(_unit##_numbers[_unit##_index]); \
58 \
59 if (NULL != _unit) {
60
61#define unit_list_iterate_safe_end \
62 } \
63 } \
64 } \
65}
66
67struct unit *unit_list_find(const struct unit_list *punitlist, int unit_id);
68
69void unit_list_sort_ord_map(struct unit_list *punitlist);
70void unit_list_sort_ord_city(struct unit_list *punitlist);
71
72bool can_units_do(const struct unit_list *punits,
73 bool (can_fn)(const struct unit *punit));
74bool can_units_do_on_map(const struct civ_map *nmap,
75 const struct unit_list *punits,
76 bool (can_fn)(const struct civ_map *nmap,
77 const struct unit *punit));
78bool can_units_do_activity(const struct civ_map *nmap,
79 const struct unit_list *punits,
80 enum unit_activity activity);
81bool can_units_do_activity_targeted(const struct civ_map *nmap,
82 const struct unit_list *punits,
83 enum unit_activity activity,
84 struct extra_type *pextra);
85bool can_units_do_any_road(const struct civ_map *nmap,
86 const struct unit_list *punits);
87bool can_units_do_base_gui(const struct unit_list *punits,
88 enum base_gui_type base_gui);
89bool units_have_type_flag(const struct unit_list *punits,
90 enum unit_type_flag_id flag, bool has_flag);
91bool units_contain_cityfounder(const struct unit_list *punits);
92bool units_can_do_action(const struct unit_list *punits,
93 action_id act_id, bool can_do);
94bool units_can_do_action_with_result(const struct unit_list *punits,
95 enum action_result result,
96 bool can_do);
97bool units_are_occupied(const struct unit_list *punits);
98bool units_can_load(const struct unit_list *punits);
99bool units_can_unload(const struct unit_list *punits);
100bool units_have_activity_on_tile(const struct unit_list *punits,
101 enum unit_activity activity);
102
103bool units_can_upgrade(const struct civ_map *nmap,
104 const struct unit_list *punits);
105bool units_can_convert(const struct civ_map *nmap,
106 const struct unit_list *punits);
107
108#ifdef __cplusplus
109}
110#endif /* __cplusplus */
111
112#endif /* FC__UNITLIST_H */
incite_cost
char * incite_cost
Definition comments.c:74
punit
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
Definition dialogs_g.h:74
fc_types.h
action_id
int action_id
Definition fc_types.h:392
speclist.h
civ_map
Definition map_types.h:71
extra_type
Definition extras.h:88
unit
Definition unit.h:138
unit::activity
enum unit_activity activity
Definition unit.h:157
unit.h
units_can_convert
bool units_can_convert(const struct civ_map *nmap, const struct unit_list *punits)
Definition unitlist.c:349
units_are_occupied
bool units_are_occupied(const struct unit_list *punits)
Definition unitlist.c:273
units_can_do_action_with_result
bool units_can_do_action_with_result(const struct unit_list *punits, enum action_result result, bool can_do)
Definition unitlist.c:258
can_units_do_base_gui
bool can_units_do_base_gui(const struct unit_list *punits, enum base_gui_type base_gui)
Definition unitlist.c:180
units_contain_cityfounder
bool units_contain_cityfounder(const struct unit_list *punits)
Definition unitlist.c:217
unit_list_sort_ord_map
void unit_list_sort_ord_map(struct unit_list *punitlist)
Definition unitlist.c:73
can_units_do_any_road
bool can_units_do_any_road(const struct civ_map *nmap, const struct unit_list *punits)
Definition unitlist.c:161
can_units_do_activity
bool can_units_do_activity(const struct civ_map *nmap, const struct unit_list *punits, enum unit_activity activity)
Definition unitlist.c:128
unit_list_find
struct unit * unit_list_find(const struct unit_list *punitlist, int unit_id)
Definition unitlist.c:30
units_can_upgrade
bool units_can_upgrade(const struct civ_map *nmap, const struct unit_list *punits)
Definition unitlist.c:334
units_can_unload
bool units_can_unload(const struct unit_list *punits)
Definition unitlist.c:301
units_have_activity_on_tile
bool units_have_activity_on_tile(const struct unit_list *punits, enum unit_activity activity)
Definition unitlist.c:318
units_have_type_flag
bool units_have_type_flag(const struct unit_list *punits, enum unit_type_flag_id flag, bool has_flag)
Definition unitlist.c:202
can_units_do
bool can_units_do(const struct unit_list *punits, bool(can_fn)(const struct unit *punit))
Definition unitlist.c:95
units_can_do_action
bool units_can_do_action(const struct unit_list *punits, action_id act_id, bool can_do)
Definition unitlist.c:239
units_can_load
bool units_can_load(const struct unit_list *punits)
Definition unitlist.c:287
unit_list_sort_ord_city
void unit_list_sort_ord_city(struct unit_list *punitlist)
Definition unitlist.c:85
can_units_do_activity_targeted
bool can_units_do_activity_targeted(const struct civ_map *nmap, const struct unit_list *punits, enum unit_activity activity, struct extra_type *pextra)
Definition unitlist.c:144
can_units_do_on_map
bool can_units_do_on_map(const struct civ_map *nmap, const struct unit_list *punits, bool(can_fn)(const struct civ_map *nmap, const struct unit *punit))
Definition unitlist.c:111
unittype.h