Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2004:
[Freeciv-Dev] (PR#10437) Another assert failure for "punit->transported_
Home

[Freeciv-Dev] (PR#10437) Another assert failure for "punit->transported_

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: edearl@xxxxxxxxxxx, marko.lindqvist@xxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#10437) Another assert failure for "punit->transported_by > 0"
From: "Gregory Berkolaiko" <Gregory.Berkolaiko@xxxxxxxxxxxxx>
Date: Sat, 27 Nov 2004 21:26:18 -0800
Reply-to: rt@xxxxxxxxxxx

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

I could not reproduce the bug.

Anyway, I think one bug is quite clear -- when we look for a boss to put
in charge of the boat, we shouldn't consider other players' units.  A
patch is attached.

I put in an assert to stop similar bugs from happening.

>   Problem seems to originate from ai_manage_unit(pplayer, boss) call in 
> ai_manage_ferryboat(), where 'boss' is not our unit. Once pplayer's 
> ferry passes control to 'boss', it tries to load itself to another ferry 
> (boss->owner == ferry->owner)
> 
>   But then I'm a bit loss with no proper knowledge about ai(ferry) code. 
> Attached (totally untested patch) is my best shot, but I'm not at all 
> surprised if it breaks more than fixes.

This patch was dangerously wrong.  Your research into the causes of the
crash was excellent, on the other hand.  Thanks for your help and sorry
about the bug!

Gr.

Index: ai/aiferry.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aiferry.c,v
retrieving revision 1.11
diff -u -r1.11 aiferry.c
--- ai/aiferry.c        17 Nov 2004 16:26:48 -0000      1.11
+++ ai/aiferry.c        28 Nov 2004 05:26:07 -0000
@@ -153,6 +153,8 @@
 **************************************************************************/
 static void aiferry_psngr_meet_boat(struct unit *punit, struct unit *pferry)
 {
+  assert(punit->owner == pferry->owner);
+
   /* First delete the unit from the list of passengers and 
    * release its previous ferry */
   aiferry_clear_boat(punit);
@@ -764,8 +766,9 @@
     
       /* Try to select passanger-in-charge from among our passengers */
       unit_list_iterate(ptile->units, aunit) {
-        if (aunit->ai.ferryboat != punit->id 
-            && aunit->ai.ferryboat != FERRY_WANTED) {
+        if (unit_owner(aunit) != pplayer 
+            || (aunit->ai.ferryboat != punit->id 
+                && aunit->ai.ferryboat != FERRY_WANTED)) {
           continue;
         }
       

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