21 #define SPECLIST_TAG unit
22 #define SPECLIST_TYPE struct unit
25 #define unit_list_iterate(unitlist, punit) \
26 TYPED_LIST_ITERATE(struct unit, unitlist, punit)
27 #define unit_list_iterate_end LIST_ITERATE_END
28 #define unit_list_both_iterate(unitlist, plink, punit) \
29 TYPED_LIST_BOTH_ITERATE(struct unit_list_link, struct unit, unitlist, \
31 #define unit_list_both_iterate_end LIST_BOTH_ITERATE_END
33 #define unit_list_iterate_safe(unitlist, _unit) \
35 int _unit##_size = unit_list_size(unitlist); \
37 if (_unit##_size > 0) { \
38 int _unit##_numbers[_unit##_size]; \
39 int _unit##_index = 0; \
41 unit_list_iterate(unitlist, _unit) \
43 _unit##_numbers[_unit##_index++] = _unit->id; \
45 unit_list_iterate_end; \
47 for (_unit##_index = 0; _unit##_index < _unit##_size; \
49 struct unit *_unit = \
50 game_unit_by_number(_unit##_numbers[_unit##_index]); \
52 if (nullptr != _unit) {
54 #define unit_list_iterate_safe_end \
66 bool(can_fn)(
const struct unit *punit));
74 enum base_gui_type base_gui);
76 enum unit_type_flag_id flag,
bool has_flag);
enum unit_activity activity
bool units_can_load(const std::vector< unit * > &units)
Returns TRUE iff any of these units can load.
bool can_units_do_base_gui(const std::vector< unit * > &units, enum base_gui_type base_gui)
Returns TRUE if any of the units can build base with given gui_type.
bool can_units_do_any_road(const std::vector< unit * > &units)
Returns TRUE if any of the units can build any road.
bool units_can_do_action(const std::vector< unit * > &units, action_id act_id, bool can_do)
If has_flag is true, returns true iff any of the units are able to do the specified action.
bool any_unit_in_city(const std::vector< unit * > &units)
bool can_units_do(const std::vector< unit * > &units, bool(can_fn)(const struct unit *punit))
Return TRUE if the function returns true for any of the units.
void unit_list_sort_ord_map(struct unit_list *punitlist)
Sorts the unit list by punit->server.ord_map values.
bool can_units_do_activity_targeted(const std::vector< unit * > &units, enum unit_activity activity, struct extra_type *pextra)
Returns TRUE if any of the units can do the targeted activity.
bool units_are_occupied(const std::vector< unit * > &units)
Return TRUE iff any of the units is a transporter that is occupied.
bool units_can_unload(const std::vector< unit * > &units)
Return TRUE iff any of these units can unload.
bool units_contain_cityfounder(const std::vector< unit * > &units)
Does the list contain any cityfounder units.
bool can_units_do_activity(const std::vector< unit * > &units, enum unit_activity activity)
Returns TRUE if any of the units can do the activity.
bool units_have_activity_on_tile(const std::vector< unit * > &units, enum unit_activity activity)
Return TRUE iff any of the units' tiles have the activity running on them.
bool units_can_upgrade(const std::vector< unit * > &units)
Return TRUE iff any of the units can be upgraded to another unit type (for money)
bool units_can_convert(const std::vector< unit * > &units)
Return TRUE iff any of the units can convert to another unit type.
bool units_have_type_flag(const std::vector< unit * > &units, enum unit_type_flag_id flag, bool has_flag)
If has_flag is true, returns true iff any of the units have the flag.
struct unit * unit_list_find(const struct unit_list *punitlist, int unit_id)
Look for a unit with the given ID in the unit list.
bool units_on_the_same_tile(const std::vector< unit * > &units)
void unit_list_sort_ord_city(struct unit_list *punitlist)
Sorts the unit list by punit->server.ord_city values.