Project

General

Profile

Feature #1701 » 1701.v2.patch

John Robertson, 10/11/2025 07:57 AM

View differences:

ai/default/daisettler.c
cityresult_destroy(result);
/*** Go back to and found a city ***/
pf_path_destroy(path);
if (path != NULL) {
pf_path_destroy(path);
}
path = NULL;
goto BUILD_CITY;
} else if (best_impr > 0) {
......
}
if (best_tile != NULL
&& auto_worker_setup_work(nmap, pplayer, punit, state, 0, path,
&& auto_worker_setup_work(nmap, pplayer, punit, state, 0, &path,
best_tile, best_act, &best_target,
completion_time)) {
if (pcity != NULL) {
server/advisors/autoworkers.c
enum unit_activity *best_act,
struct extra_type **best_target,
struct tile **best_tile,
struct pf_path **path,
struct pf_path **ppath,
struct workermap *state)
{
const struct player *pplayer = unit_owner(punit);
......
*best_tile = NULL;
}
if (path) {
*path = *best_tile ? pf_map_path(pfm, *best_tile) : NULL;
if (ppath) {
if (*ppath != nullptr) {
pf_path_destroy(*ppath);
}
*ppath = *best_tile ? pf_map_path(pfm, *best_tile) : NULL;
}
pf_map_destroy(pfm);
......
**************************************************************************/
struct city *worker_evaluate_city_requests(struct unit *punit,
struct worker_task **best_task,
struct pf_path **path,
struct pf_path **ppath,
struct workermap *state)
{
const struct player *pplayer = unit_owner(punit);
......
*best_task = best;
if (path != NULL) {
*path = best ? pf_map_path(pfm, best->ptile) : NULL;
if (ppath != NULL) {
if (*ppath != NULL) {
pf_path_destroy(*ppath);
}
*ppath = best ? pf_map_path(pfm, best->ptile) : NULL;
}
pf_map_destroy(pfm);
......
best_target = best_task->tgt;
if (auto_worker_setup_work(nmap, pplayer, punit, state, recursion,
path, best_task->ptile, best_task->act,
&path, best_task->ptile, best_task->act,
&best_target, completion_time)) {
clear_worker_task(taskcity, best_task);
}
......
adv_unit_new_task(punit, AUT_AUTO_WORKER, best_tile);
auto_worker_setup_work(nmap, pplayer, punit, state, recursion, path,
auto_worker_setup_work(nmap, pplayer, punit, state, recursion, &path,
best_tile, best_act, &best_target,
completion_time);
......
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 pf_path **ppath,
struct tile *best_tile,
enum unit_activity best_act,
struct extra_type **best_target,
......
best_target && *best_target ? extra_rule_name(*best_target) : "-",
TILE_XY(best_tile));
if (!path) {
if (ppath != nullptr && *ppath == nullptr) {
pft_fill_unit_parameter(&parameter, nmap, punit);
parameter.omniscience = !has_handicap(pplayer, H_MAP);
parameter.get_TB = autoworker_tile_behavior;
pfm = pf_map_new(&parameter);
path = pf_map_path(pfm, best_tile);
*ppath = pf_map_path(pfm, best_tile);
}
if (path) {
if (ppath != nullptr && *ppath != nullptr) {
bool alive;
alive = adv_follow_path(punit, path, best_tile);
alive = adv_follow_path(punit, *ppath, best_tile);
if (alive && same_pos(unit_tile(punit), best_tile)
&& punit->moves_left > 0) {
......
}
send_unit_info(NULL, punit);
pf_path_destroy(path);
path = nullptr;
} else {
punit->goto_tile = nullptr;
}
server/advisors/autoworkers.h
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 pf_path **ppath,
struct tile *best_tile,
enum unit_activity best_act,
struct extra_type **best_target,
......
enum unit_activity *best_act,
struct extra_type **best_target,
struct tile **best_tile,
struct pf_path **path,
struct pf_path **ppath,
struct workermap *state);
struct city *worker_evaluate_city_requests(struct unit *punit,
struct worker_task **best_task,
struct pf_path **path,
struct pf_path **ppath,
struct workermap *state);
void adv_unit_new_task(struct unit *punit, enum adv_unit_task task,
(2-2/3)