Author: cazfi Date: Sat Dec 20 03:24:13 2014 New Revision: 27351 URL: http://svn.gna.org/viewcvs/freeciv?rev=27351&view=rev Log: Made default AI settlers to handle worker tasks.
See bug #23079 Modified: branches/S2_5/ai/default/aisettler.c branches/S2_5/server/advisors/autosettlers.c branches/S2_5/server/advisors/autosettlers.h Modified: branches/S2_5/ai/default/aisettler.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_5/ai/default/aisettler.c?rev=27351&r1=27350&r2=27351&view=diff ============================================================================== --- branches/S2_5/ai/default/aisettler.c (original) +++ branches/S2_5/ai/default/aisettler.c Sat Dec 20 03:24:13 2014 @@ -1077,12 +1077,27 @@ if (unit_has_type_flag(punit, UTYF_SETTLERS)) { TIMING_LOG(AIT_WORKERS, TIMER_START); - best_impr = settler_evaluate_improvements(punit, &best_act, &best_target, - &best_tile, &path, state); + + /* Have nearby cities requests? */ + best_impr = settler_evaluate_city_requests(punit, &best_act, &best_target, + &best_tile, &path, state); + + if (best_impr > 0) { + if (path != NULL) { + completion_time = pf_path_last_position(path)->turn; + } else { + best_impr = 0; + } + } + + if (best_impr <= 0) { + best_impr = settler_evaluate_improvements(punit, &best_act, &best_target, + &best_tile, &path, state); + if (path) { + completion_time = pf_path_last_position(path)->turn; + } + } UNIT_LOG(LOG_DEBUG, punit, "impr want %d", best_impr); - if (path) { - completion_time = pf_path_last_position(path)->turn; - } TIMING_LOG(AIT_WORKERS, TIMER_STOP); } Modified: branches/S2_5/server/advisors/autosettlers.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_5/server/advisors/autosettlers.c?rev=27351&r1=27350&r2=27351&view=diff ============================================================================== --- branches/S2_5/server/advisors/autosettlers.c (original) +++ branches/S2_5/server/advisors/autosettlers.c Sat Dec 20 03:24:13 2014 @@ -572,12 +572,12 @@ /**************************************************************************** Return best city request to fulfill. ****************************************************************************/ -static int settler_evaluate_city_requests(struct unit *punit, - enum unit_activity *best_act, - struct act_tgt *best_target, - struct tile **best_tile, - struct pf_path **path, - struct settlermap *state) +int settler_evaluate_city_requests(struct unit *punit, + enum unit_activity *best_act, + struct act_tgt *best_target, + struct tile **best_tile, + struct pf_path **path, + struct settlermap *state) { const struct player *pplayer = unit_owner(punit); struct pf_parameter parameter; Modified: branches/S2_5/server/advisors/autosettlers.h URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_5/server/advisors/autosettlers.h?rev=27351&r1=27350&r2=27351&view=diff ============================================================================== --- branches/S2_5/server/advisors/autosettlers.h (original) +++ branches/S2_5/server/advisors/autosettlers.h Sat Dec 20 03:24:13 2014 @@ -41,6 +41,12 @@ struct tile **best_tile, struct pf_path **path, struct settlermap *state); +int settler_evaluate_city_requests(struct unit *punit, + enum unit_activity *best_act, + struct act_tgt *best_target, + struct tile **best_tile, + struct pf_path **path, + struct settlermap *state); void adv_unit_new_task(struct unit *punit, enum adv_unit_task task, struct tile *ptile); _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits