Freeciv-3.2
Loading...
Searching...
No Matches
Macros | Functions
unitlist.h File Reference
#include "fc_types.h"
#include "unit.h"
#include "unittype.h"
#include "speclist.h"

Go to the source code of this file.

Macros

#define SPECLIST_TAG   unit
 
#define SPECLIST_TYPE   struct unit
 
#define unit_list_iterate(unitlist, punit)    TYPED_LIST_ITERATE(struct unit, unitlist, punit)
 
#define unit_list_iterate_end   LIST_ITERATE_END
 
#define unit_list_both_iterate(unitlist, plink, punit)
 
#define unit_list_both_iterate_end   LIST_BOTH_ITERATE_END
 
#define unit_list_iterate_safe(unitlist, _unit)
 
#define unit_list_iterate_safe_end
 

Functions

struct unitunit_list_find (const struct unit_list *punitlist, int unit_id)
 
void unit_list_sort_ord_map (struct unit_list *punitlist)
 
void unit_list_sort_ord_city (struct unit_list *punitlist)
 
bool can_units_do (const struct unit_list *punits, bool(can_fn)(const struct unit *punit))
 
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))
 
bool can_units_do_activity (const struct civ_map *nmap, const struct unit_list *punits, enum unit_activity activity)
 
bool can_units_do_activity_targeted (const struct civ_map *nmap, const struct unit_list *punits, enum unit_activity activity, struct extra_type *pextra)
 
bool can_units_do_any_road (const struct civ_map *nmap, const struct unit_list *punits)
 
bool can_units_do_base_gui (const struct unit_list *punits, enum base_gui_type base_gui)
 
bool units_have_type_flag (const struct unit_list *punits, enum unit_type_flag_id flag, bool has_flag)
 
bool units_contain_cityfounder (const struct unit_list *punits)
 
bool units_can_do_action (const struct unit_list *punits, action_id act_id, bool can_do)
 
bool units_can_do_action_with_result (const struct unit_list *punits, enum action_result result, bool can_do)
 
bool units_are_occupied (const struct unit_list *punits)
 
bool units_can_load (const struct unit_list *punits)
 
bool units_can_unload (const struct unit_list *punits)
 
bool units_have_activity_on_tile (const struct unit_list *punits, enum unit_activity activity)
 
bool units_can_upgrade (const struct civ_map *nmap, const struct unit_list *punits)
 
bool units_can_convert (const struct civ_map *nmap, const struct unit_list *punits)
 

Macro Definition Documentation

◆ SPECLIST_TAG

#define SPECLIST_TAG   unit

Definition at line 27 of file unitlist.h.

◆ SPECLIST_TYPE

#define SPECLIST_TYPE   struct unit

Definition at line 28 of file unitlist.h.

◆ unit_list_both_iterate

#define unit_list_both_iterate (   unitlist,
  plink,
  punit 
)
Value:
plink, punit)
char * incite_cost
Definition comments.c:75
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
#define TYPED_LIST_BOTH_ITERATE(TYPE_link, TYPE_data, ARG_list, NAME_link, NAME_data)
Definition speclist.h:698
Definition unit.h:138

Definition at line 34 of file unitlist.h.

◆ unit_list_both_iterate_end

#define unit_list_both_iterate_end   LIST_BOTH_ITERATE_END

Definition at line 37 of file unitlist.h.

◆ unit_list_iterate

#define unit_list_iterate (   unitlist,
  punit 
)     TYPED_LIST_ITERATE(struct unit, unitlist, punit)

Definition at line 31 of file unitlist.h.

◆ unit_list_iterate_end

#define unit_list_iterate_end   LIST_ITERATE_END

Definition at line 33 of file unitlist.h.

◆ unit_list_iterate_safe

#define unit_list_iterate_safe (   unitlist,
  _unit 
)
Value:
{ \
struct unit_list *_unit##_ul = unitlist; \
if (_unit##_size > 0) { \
int _unit##_index; \
\
_unit##_size = 0; \
_unit##_numbers[_unit##_size++] = _unit->id; \
for (_unit##_index = 0; \
_unit##_index++) { \
struct unit *_unit = \
if (NULL != _unit) {
#define unit_list_iterate_end
Definition unitlist.h:33

Definition at line 39 of file unitlist.h.

◆ unit_list_iterate_safe_end

#define unit_list_iterate_safe_end
Value:
} \
} \
} \
}

Definition at line 61 of file unitlist.h.

Function Documentation

◆ can_units_do()

bool can_units_do ( const struct unit_list *  punits,
bool(can_fn)(const struct unit *punit  
)

Return TRUE if the function returns true for any of the units.

Definition at line 95 of file unitlist.c.

Referenced by mr_menu::menus_sensitive(), and real_menus_update().

◆ can_units_do_activity()

bool can_units_do_activity ( const struct civ_map nmap,
const struct unit_list *  punits,
enum unit_activity  activity 
)

Returns TRUE if any of the units can do the activity.

Definition at line 128 of file unitlist.c.

◆ 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 
)

Returns TRUE if any of the units can do the targeted activity.

Definition at line 144 of file unitlist.c.

◆ can_units_do_any_road()

bool can_units_do_any_road ( const struct civ_map nmap,
const struct unit_list *  punits 
)

Returns TRUE if any of the units can build any road.

Definition at line 161 of file unitlist.c.

Referenced by mr_menu::menus_sensitive(), and real_menus_update().

◆ can_units_do_base_gui()

bool can_units_do_base_gui ( const struct unit_list *  punits,
enum base_gui_type  base_gui 
)

Returns TRUE if any of the units can build base with given gui_type.

Definition at line 180 of file unitlist.c.

Referenced by mr_menu::menus_sensitive(), and real_menus_update().

◆ 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  
)

Return TRUE if the function returns true for any of the units, on specific map.

Definition at line 111 of file unitlist.c.

Referenced by mr_menu::menus_sensitive(), and real_menus_update().

◆ unit_list_find()

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. Returns NULL if none is found.

Definition at line 30 of file unitlist.c.

Referenced by dai_manage_military(), mr_menu::find_last_unit_pos(), sha_unit_change(), sha_unit_recall(), sha_unit_remove(), and mr_menu::slot_execute_orders().

◆ unit_list_sort_ord_city()

void unit_list_sort_ord_city ( struct unit_list *  punitlist)

Sorts the unit list by punit->server.ord_city values.

Only used in server/savegame/savegame[23].c.

Definition at line 85 of file unitlist.c.

Referenced by unit_ordering_apply(), and unit_ordering_apply().

◆ unit_list_sort_ord_map()

void unit_list_sort_ord_map ( struct unit_list *  punitlist)

Sorts the unit list by punit->server.ord_map values.

Only used in server/savegame/savegame[23].c.

Definition at line 73 of file unitlist.c.

Referenced by unit_ordering_apply(), and unit_ordering_apply().

◆ units_are_occupied()

bool units_are_occupied ( const struct unit_list *  punits)

Return TRUE iff any of the units is a transporter that is occupied.

Definition at line 273 of file unitlist.c.

Referenced by unit_item::create_actions(), mr_menu::menus_sensitive(), and real_menus_update().

◆ units_can_convert()

bool units_can_convert ( const struct civ_map nmap,
const struct unit_list *  punits 
)

Return TRUE iff any of the units can convert to another unit type

Definition at line 349 of file unitlist.c.

Referenced by mr_menu::menus_sensitive(), and real_menus_update().

◆ units_can_do_action()

bool units_can_do_action ( const struct unit_list *  punits,
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.

If has_flag is false, returns true iff any of the units are unable do the specified action.

Definition at line 239 of file unitlist.c.

Referenced by mr_menu::menus_sensitive(), real_menus_update(), and go_act_menu::update().

◆ 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 
)

If has_flag is true, returns true iff any of the units are able to do any action with the specified result.

If has_flag is false, returns true iff any of the units are unable do any action with the specified result.

Definition at line 258 of file unitlist.c.

◆ units_can_load()

bool units_can_load ( const struct unit_list *  punits)

Returns TRUE iff any of these units can load.

Definition at line 287 of file unitlist.c.

Referenced by unit_item::create_actions(), mr_menu::menus_sensitive(), and real_menus_update().

◆ units_can_unload()

bool units_can_unload ( const struct unit_list *  punits)

Return TRUE iff any of these units can unload.

Definition at line 301 of file unitlist.c.

Referenced by unit_item::create_actions(), mr_menu::menus_sensitive(), and real_menus_update().

◆ units_can_upgrade()

bool units_can_upgrade ( const struct civ_map nmap,
const struct unit_list *  punits 
)

Return TRUE iff any of the units can be upgraded to another unit type (for money)

Definition at line 334 of file unitlist.c.

Referenced by unit_item::create_actions(), mr_menu::menus_sensitive(), and real_menus_update().

◆ units_contain_cityfounder()

bool units_contain_cityfounder ( const struct unit_list *  punits)

Does the list contain any cityfounder units

Definition at line 217 of file unitlist.c.

Referenced by mr_menu::menus_sensitive().

◆ units_have_activity_on_tile()

bool units_have_activity_on_tile ( const struct unit_list *  punits,
enum unit_activity  activity 
)

Return TRUE iff any of the units' tiles have the activity running on them.

Definition at line 318 of file unitlist.c.

Referenced by mr_menu::menus_sensitive(), and real_menus_update().

◆ units_have_type_flag()

bool units_have_type_flag ( const struct unit_list *  punits,
enum unit_type_flag_id  flag,
bool  has_flag 
)

If has_flag is true, returns true iff any of the units have the flag.

If has_flag is false, returns true iff any of the units don't have the flag.

Definition at line 202 of file unitlist.c.

Referenced by mr_menu::menus_sensitive(), and real_menus_update().