Freeciv-3.3: /fast/freeciv/nightly/main/server/advisors/autoworkers.h File Reference

Freeciv-3.3

Loading...
Searching...
No Matches
Macros | Functions | Variables
autoworkers.h File Reference
`#include "fc_types.h"`

Go to the source code of this file.

## Macros

#define | aw_transform_action_iterate(_act_)
#define | aw_transform_action_iterate_end
#define | aw_extra_action_iterate(_act_)
#define | aw_extra_action_iterate_end
#define | aw_rmextra_action_iterate(_act_)
#define | aw_rmextra_action_iterate_end

## Functions

void | auto_workers_ruleset_init (void)
void | adv_workers_free (void)
void | auto_workers_player (struct player *pplayer)
void | auto_worker_findwork (const struct civ_map *nmap, struct player *pplayer, struct unit *punit, struct workermap *state, int recursion)
bool | auto_worker_setup_work (const struct civ_map *nmap, struct player *pplayer, struct unit *punit, struct workermap *state, int recursion, struct pf_path *path, struct tile *best_tile, enum unit_activity best_act, struct extra_type **best_target, int completion_time)
adv_want | worker_evaluate_improvements (const struct civ_map *nmap, struct unit *punit, enum unit_activity *best_act, struct extra_type **best_target, struct tile **best_tile, struct pf_path **path, struct workermap *state)
struct city * | worker_evaluate_city_requests (struct unit *punit, struct worker_task **best_task, struct pf_path **path, struct workermap *state)
void | adv_unit_new_task (struct unit *punit, enum adv_unit_task task, struct tile *ptile)
bool | adv_worker_safe_tile (const struct civ_map *nmap, const struct player *pplayer, struct unit *punit, struct tile *ptile)
adv_want | adv_workers_road_bonus (const struct civ_map *nmap, struct tile *ptile, struct road_type *proad)
bool | auto_workers_speculate_can_act_at (const struct unit *punit, enum unit_activity activity, bool omniscient_cheat, struct extra_type *target, const struct tile *ptile)

## Variables

action_id | aw_actions_transform [MAX_NUM_ACTIONS]
action_id | aw_actions_extra [MAX_NUM_ACTIONS]
action_id | aw_actions_rmextra [MAX_NUM_ACTIONS]

## Macro Definition Documentation

## ◆ aw_extra_action_iterate

#define aw_extra_action_iterate | ( |  | _act_ | ) |

Value:
{ \
action_array_iterate(aw_actions_extra, _act_)
aw_actions_extra
action_id aw_actions_extra[MAX_NUM_ACTIONS]
Definition autoworkers.c:78
incite_cost
char * incite_cost
Definition comments.c:74

Definition at line 84 of file autoworkers.h.

## ◆ aw_extra_action_iterate_end

#define aw_extra_action_iterate_end

Value:
action_array_iterate_end \
}
action_array_iterate_end
#define action_array_iterate_end
Definition actions.h:264

Definition at line 88 of file autoworkers.h.

## ◆ aw_rmextra_action_iterate

#define aw_rmextra_action_iterate | ( |  | _act_ | ) |

Value:
{ \
action_array_iterate(aw_actions_rmextra, _act_)
aw_actions_rmextra
action_id aw_actions_rmextra[MAX_NUM_ACTIONS]
Definition autoworkers.c:79

Definition at line 94 of file autoworkers.h.

## ◆ aw_rmextra_action_iterate_end

#define aw_rmextra_action_iterate_end

Value:
action_array_iterate_end \
}

Definition at line 98 of file autoworkers.h.

## ◆ aw_transform_action_iterate

#define aw_transform_action_iterate | ( |  | _act_ | ) |

Value:
{ \
action_array_iterate(aw_actions_transform, _act_)
aw_actions_transform
action_id aw_actions_transform[MAX_NUM_ACTIONS]
Definition autoworkers.c:77

Definition at line 74 of file autoworkers.h.

## ◆ aw_transform_action_iterate_end

#define aw_transform_action_iterate_end

Value:
action_array_iterate_end \
}

Definition at line 78 of file autoworkers.h.

## Function Documentation

## ◆ adv_unit_new_task()

void adv_unit_new_task | ( | struct unit * | punit,
|  | enum adv_unit_task | task,
|  | struct tile * | ptile
| ) |  |

Change unit's advisor task.

Definition at line 1276 of file autoworkers.c.

Referenced by auto_worker_findwork(), dai_auto_settler_run(), dai_manage_settler(), handle_unit_change_activity_real(), handle_unit_orders(), player_restore_units(), server_remove_unit_full(), and unit_plans_clear().

## ◆ adv_worker_safe_tile()

bool adv_worker_safe_tile | ( | const struct civ_map * | nmap,
|  | const struct player * | pplayer,
|  | struct unit * | punit,
|  | struct tile * | ptile
| ) |  |

Do we consider tile safe for autoworker to work?

Definition at line 1150 of file autoworkers.c.

Referenced by auto_workers_player(), dai_auto_settler_cont(), and worker_evaluate_improvements().

## ◆ adv_workers_free()

void adv_workers_free | ( | void |  | ) |

Free resources allocated for autoworkers system

Definition at line 86 of file autoworkers.c.

Referenced by server_quit().

## ◆ adv_workers_road_bonus()

adv_want adv_workers_road_bonus | ( | const struct civ_map * | nmap,
|  | struct tile * | ptile,
|  | struct road_type * | proad
| ) |  |

Calculate the attractiveness of building a road/rail at the given tile.

This calculates the overall benefit of connecting the civilization; this is independent from the local tile (trade) bonus granted by the road.

Definition at line 132 of file autoworkers.c.

Referenced by texai_tile_worker_task_select(), and worker_evaluate_improvements().

## ◆ auto_worker_findwork()

void auto_worker_findwork | ( | const struct civ_map * | nmap,
|  | struct player * | pplayer,
|  | struct unit * | punit,
|  | struct workermap * | state,
|  | int | recursion
| ) |  |

Definition at line 926 of file autoworkers.c.

Referenced by auto_worker_setup_work(), and auto_workers_player().

## ◆ auto_worker_setup_work()

bool auto_worker_setup_work | ( | const struct civ_map * | nmap,
|  | struct player * | pplayer,
|  | struct unit * | punit,
|  | struct workermap * | state,
|  | int | recursion,
|  | struct pf_path * | path,
|  | struct tile * | best_tile,
|  | enum unit_activity | best_act,
|  | struct extra_type ** | best_target,
|  | int | completion_time
| ) |  |

Setup our worker to do the work it has found. Returns TRUE if started actual work.

Definition at line 1015 of file autoworkers.c.

Referenced by auto_worker_findwork(), and dai_auto_settler_run().

## ◆ auto_workers_player()

void auto_workers_player | ( | struct player * | pplayer | ) |

Run through all the players workers and let those on ai.control work automagically.

Definition at line 1172 of file autoworkers.c.

Referenced by end_phase().

## ◆ auto_workers_ruleset_init()

void auto_workers_ruleset_init | ( | void |  | ) |

Initialize autoworkers based on the ruleset.

Definition at line 95 of file autoworkers.c.

Referenced by adv_units_ruleset_init().

## ◆ auto_workers_speculate_can_act_at()

bool auto_workers_speculate_can_act_at | ( | const struct unit * | punit,
|  | enum unit_activity | activity,
|  | bool | omniscient_cheat,
|  | struct extra_type * | target,
|  | const struct tile * | ptile
| ) |  |

Returns TRUE iff the unit can do the targeted activity at the given location.

Definition at line 1293 of file autoworkers.c.

Referenced by worker_evaluate_city_requests().

## ◆ worker_evaluate_city_requests()

struct city * worker_evaluate_city_requests | ( | struct unit * | punit,
|  | struct worker_task ** | best_task,
|  | struct pf_path ** | path,
|  | struct workermap * | state
| ) |  |

Return best city request to fulfill.

Definition at line 835 of file autoworkers.c.

Referenced by auto_worker_findwork(), and dai_auto_settler_run().

## ◆ worker_evaluate_improvements()

adv_want worker_evaluate_improvements | ( | const struct civ_map * | nmap,
|  | struct unit * | punit,
|  | enum unit_activity * | best_act,
|  | struct extra_type ** | best_target,
|  | struct tile ** | best_tile,
|  | struct pf_path ** | path,
|  | struct workermap * | state
| ) |  |

Finds tiles to improve, using punit.

The returned value is the goodness of the best tile and action found. If this return value is > 0, then best_tile indicates the tile chosen, bestact indicates the activity it wants to do, and path (if not NULL) indicates the path to follow for the unit. If 0 is returned then there are no worthwhile activities available.

completion_time is the time that would be taken by punit to travel to and complete work at best_tile

state contains, for each tile, the unit id of the worker en route, and the eta of this worker (if any). This information is used to possibly displace this previously assigned worker. if this array is NULL, workers are never displaced.

Definition at line 442 of file autoworkers.c.

Referenced by auto_worker_findwork(), contemplate_terrain_improvements(), and dai_auto_settler_run().

## Variable Documentation

## ◆ aw_actions_extra

action_id aw_actions_extra[MAX_NUM_ACTIONS]

extern

Definition at line 78 of file autoworkers.c.

Referenced by auto_workers_ruleset_init().

## ◆ aw_actions_rmextra

action_id aw_actions_rmextra[MAX_NUM_ACTIONS]

extern

Definition at line 79 of file autoworkers.c.

Referenced by auto_workers_ruleset_init().

## ◆ aw_actions_transform

action_id aw_actions_transform[MAX_NUM_ACTIONS]

extern

Definition at line 77 of file autoworkers.c.

Referenced by auto_workers_ruleset_init().