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:32:50 -0800
Reply-to: rt@xxxxxxxxxxx

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

> [glip - Tue Jan 27 23:27:00 2004]:
> 
> On Mon, 26 Jan 2004, Guest wrote:
> 
> > <URL: http://rt.freeciv.org/Ticket/Display.html?id=7324 >
> > 
> > Here's another possible (but as of yet, untested) patch. 
> 
> From debugging perspective I would prefer that human has precedence.  But 
> it has to be done cleanly via ai_new_role or what is this function's 
> name...

I don't understand this.  When the unit is given the orders it must have
no AI role.  So all we have to do is make sure it doesn't get a new role
until the orders are complete.

Hmm, looks like another assertion would help here.

jason

Index: ai/aitools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aitools.c,v
retrieving revision 1.96
diff -u -r1.96 aitools.c
--- ai/aitools.c        2003/11/28 17:37:18     1.96
+++ ai/aitools.c        2004/01/28 06:30:05
@@ -429,6 +429,8 @@
   struct unit *charge = find_unit_by_id(punit->ai.charge);
   struct unit *bodyguard = find_unit_by_id(punit->ai.bodyguard);
 
+  assert(!unit_has_orders(punit));
+
   /* Free our ferry.  Most likely it has been done already. */
   if (task == AIUNIT_NONE || task == AIUNIT_DEFEND_HOME) {
     ai_clear_ferry(punit);
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:30:06
@@ -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:30:07
@@ -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]