Bug #1699 » 1699.v2.patch
server/advisors/autoworkers.c | ||
---|---|---|
* autowork with a unit under orders even for an AI player - these come
|
||
* from the human player and take precedence. */
|
||
unit_list_iterate_safe(pplayer->units, punit) {
|
||
UNIT_LOG(LOG_DEBUG, punit, "\x1b[94m%s:\x1b[92m%s\x1b[0m \x1b[36m%s\x1b[0m",
|
||
gen_action_name(punit->action),
|
||
server_side_agent_name(punit->ssa_controller),
|
||
punit->activity_target != nullptr ?
|
||
extra_name_translation(punit->activity_target) : "-" );
|
||
if (punit->activity == ACTIVITY_IDLE && punit->goto_tile != nullptr) {
|
||
struct pf_path *path = nullptr;
|
||
struct pf_map *pfm = NULL;
|
||
struct pf_parameter parameter;
|
||
pft_fill_unit_parameter(¶meter, nmap, punit);
|
||
parameter.omniscience = !has_handicap(pplayer, H_MAP);
|
||
parameter.get_TB = autoworker_tile_behavior;
|
||
pfm = pf_map_new(¶meter);
|
||
path = pf_map_path(pfm, punit->goto_tile);
|
||
|
||
if (path) {
|
||
bool alive;
|
||
unit_activity_handling(punit, ACTIVITY_GOTO, ACTION_NONE);
|
||
alive = adv_follow_path(punit, path, punit->goto_tile);
|
||
if (alive && punit->goto_tile != nullptr
|
||
&& same_pos(unit_tile(punit), punit->goto_tile)) {
|
||
unit_activity_handling(punit, ACTIVITY_IDLE, ACTION_NONE);
|
||
punit->goto_tile = nullptr;
|
||
}
|
||
send_unit_info(NULL, punit);
|
||
pf_path_destroy(path);
|
||
} else {
|
||
punit->goto_tile = nullptr;
|
||
}
|
||
pf_map_destroy(pfm);
|
||
} else if (punit->activity == ACTIVITY_GOTO && punit->goto_tile == nullptr) {
|
||
unit_activity_handling(punit, ACTIVITY_IDLE, ACTION_NONE);
|
||
send_unit_info(NULL, punit);
|
||
}
|
||
if ((punit->ssa_controller == SSA_AUTOWORKER || is_ai(pplayer))
|
||
&& (unit_type_get(punit)->adv.worker
|
||
|| unit_is_cityfounder(punit))
|
- « Previous
- 1
- 2
- Next »