Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2004:
[Freeciv-Dev] (PR#7324) orders and AI goto conflict
Home

[Freeciv-Dev] (PR#7324) orders and AI goto conflict

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: matusik_s@xxxxx
Subject: [Freeciv-Dev] (PR#7324) orders and AI goto conflict
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 27 Jan 2004 22:27:53 -0800
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=7324 >

Looks like the fix is easy.  Auto-settlers are handled separately from
other AI units.

jason

Index: ai/aiunit.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aiunit.c,v
retrieving revision 1.306
diff -u -r1.306 aiunit.c
--- ai/aiunit.c 2004/01/11 17:45:02     1.306
+++ ai/aiunit.c 2004/01/28 06:26:54
@@ -2586,6 +2586,13 @@
 
   CHECK_UNIT(punit);
 
+  /* Make sure the unit doesn't have orders - human control always has
+   * precedence. */
+  if (unit_has_orders(punit)) {
+    punit->ai.ai_role = AIUNIT_NONE;
+    return;
+  }
+
   /* retire useless barbarian units here, before calling the management
      function */
   if( is_barbarian(pplayer) ) {
Index: server/settlers.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/settlers.c,v
retrieving revision 1.177
diff -u -r1.177 settlers.c
--- server/settlers.c   2004/01/11 17:45:06     1.177
+++ server/settlers.c   2004/01/28 06:26:55
@@ -1312,10 +1312,16 @@
 
   freelog(LOG_DEBUG, "Warmth = %d, game.globalwarming=%d",
          pplayer->ai.warmth, game.globalwarming);
+
+  /* Auto-settle with a settler unit if it's under AI control (e.g. human
+   * player auto-settler mode) or if the player is an AI.  But don't
+   * auto-settle with a unit under orders even for an AI player - these come
+   * from the human player and take precedence. */
   unit_list_iterate(pplayer->units, punit) {
     if ((punit->ai.control || pplayer->ai.control)
        && (unit_flag(punit, F_SETTLERS)
-           || unit_flag(punit, F_CITIES))) {
+           || unit_flag(punit, F_CITIES))
+       && !unit_has_orders(punit)) {
       freelog(LOG_DEBUG, "%s's settler at (%d, %d) is ai controlled.",
              pplayer->name, punit->x, punit->y); 
       if (punit->activity == ACTIVITY_SENTRY) {

[Prev in Thread] Current Thread [Next in Thread]