Complete.Org: Mailing Lists: Archives: freeciv-ai: October 2003:
[freeciv-ai] (PR#6450) AI Passengers counting reported false positive 1
Home

[freeciv-ai] (PR#6450) AI Passengers counting reported false positive 1

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [freeciv-ai] (PR#6450) AI Passengers counting reported false positive 1
From: "Gregory Berkolaiko" <Gregory.Berkolaiko@xxxxxxxxxxxx>
Date: Sat, 18 Oct 2003 10:10:09 -0700
Reply-to: rt@xxxxxxxxxxxxxx

On Sun, 12 Oct 2003, Jason Short wrote:

> Gregory Berkolaiko wrote:
> > On Thu, 9 Oct 2003, Jason Short wrote:
> > 
> > 
> >>I get this message all the time.
> >>
> >>   AI Passengers counting reported false positive 1

The bug was quite funny actually: these passengers that the boat couldn't 
find were in the same square as the boat.  The attached simple fix helps.
Also improves reporting of the mistake.

It is quite likely that this mistake will surface again at some point, 
because ferry handling at the moment assumes that all water bodies are 
connected.

G.

Index: ai/aiunit.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aiunit.c,v
retrieving revision 1.299
diff -u -r1.299 aiunit.c
--- ai/aiunit.c 2003/10/13 07:37:05     1.299
+++ ai/aiunit.c 2003/10/18 17:05:43
@@ -2295,8 +2295,8 @@
     } unit_list_iterate_end;
   }
 
-  freelog(LOG_ERROR, "AI Passengers counting reported false positive %d",
-          passengers);
+  UNIT_LOG(LOG_ERROR, punit,
+           "AI Passengers counting reported false positive %d", passengers);
   pf_destroy_map(map);
   return FALSE;
 }
@@ -2342,31 +2342,32 @@
   }
 
   if (punit->ai.passenger <= 0) {
-    struct unit *bodyguard = NULL;
+    struct unit *candidate = NULL;
     
-    /* Try to select passanger-in-charge from among their passengers */
+    /* Try to select passanger-in-charge from among our passengers */
     unit_list_iterate(ptile->units, aunit) {
-      if (aunit->ai.ferryboat != punit->id) {
+      if (aunit->ai.ferryboat != punit->id 
+          && aunit->ai.ferryboat != FERRY_WANTED) {
         continue;
       }
       
       if (aunit->ai.ai_role != AIUNIT_ESCORT) {
-        /* Bodyguards shouldn't be in charge of boats... */
-        UNIT_LOG(LOGLEVEL_FERRY, punit, 
-                 "appointed %s[%d] our passenger-in-charge",
-                 unit_type(aunit)->name, aunit->id);
-        punit->ai.passenger = aunit->id;
+        candidate = aunit;
         break;
       } else {
-        bodyguard = aunit;
+        /* Bodyguards shouldn't be in charge of boats so continue looking */
+        candidate = aunit;
       }
     } unit_list_iterate_end;
     
-    if (punit->ai.passenger <= 0 && bodyguard) {
+    if (candidate) {
       UNIT_LOG(LOGLEVEL_FERRY, punit, 
-               "has to take %s[%d] as our passenger-in-charge",
-               unit_type(bodyguard)->name, bodyguard->id);
-      punit->ai.passenger = bodyguard->id;
+               "appointed %s[%d] our passenger-in-charge",
+               unit_type(candidate)->name, candidate->id);
+      if (candidate->ai.ferryboat == FERRY_WANTED) {
+        ai_set_ferry(candidate, punit);
+      }
+      ai_set_passenger(punit, candidate);
     }
   }
 

[Prev in Thread] Current Thread [Next in Thread]
  • [freeciv-ai] (PR#6450) AI Passengers counting reported false positive 1, Gregory Berkolaiko <=