Author: cazfi
Date: Sat Dec 20 03:24:06 2014
New Revision: 27350

URL: http://svn.gna.org/viewcvs/freeciv?rev=27350&view=rev
Log:
Made default AI settlers to handle worker tasks.

See bug #23079

Modified:
    trunk/ai/default/aisettler.c
    trunk/server/advisors/autosettlers.c
    trunk/server/advisors/autosettlers.h

Modified: trunk/ai/default/aisettler.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/aisettler.c?rev=27350&r1=27349&r2=27350&view=diff
==============================================================================
--- trunk/ai/default/aisettler.c        (original)
+++ trunk/ai/default/aisettler.c        Sat Dec 20 03:24:06 2014
@@ -1070,12 +1070,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: trunk/server/advisors/autosettlers.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/advisors/autosettlers.c?rev=27350&r1=27349&r2=27350&view=diff
==============================================================================
--- trunk/server/advisors/autosettlers.c        (original)
+++ trunk/server/advisors/autosettlers.c        Sat Dec 20 03:24:06 2014
@@ -683,12 +683,12 @@
 /****************************************************************************
   Return best city request to fulfill.
 ****************************************************************************/
-static int settler_evaluate_city_requests(struct unit *punit,
-                                          enum unit_activity *best_act,
-                                          struct extra_type **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 extra_type **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: trunk/server/advisors/autosettlers.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/advisors/autosettlers.h?rev=27350&r1=27349&r2=27350&view=diff
==============================================================================
--- trunk/server/advisors/autosettlers.h        (original)
+++ trunk/server/advisors/autosettlers.h        Sat Dec 20 03:24:06 2014
@@ -42,6 +42,13 @@
                                   struct pf_path **path,
                                   struct settlermap *state);
 
+int settler_evaluate_city_requests(struct unit *punit,
+                                   enum unit_activity *best_act,
+                                   struct extra_type **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

Reply via email to