Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2005:
[Freeciv-Dev] (PR#11824) recursive autoexplorers cause crash
Home

[Freeciv-Dev] (PR#11824) recursive autoexplorers cause crash

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: marko.lindqvist@xxxxxxxxxxx, neil@xxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#11824) recursive autoexplorers cause crash
From: "Gregory Berkolaiko" <Gregory.Berkolaiko@xxxxxxxxxxxxx>
Date: Tue, 25 Jan 2005 20:47:39 -0800
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=11824 >

> This patch will cut off too many legitimate cases.
> I would go for comparing the move-points instead.  This will also cut
> off some legitimate cases (tried to move on a railroad but it's blocked
> -- worth a retry, unless the other path will also be blocked) which can
> be alleviated by controlling depth of the recursion.

Decided not to bother with the recursion depth.  Changed the condition
and  added a comment.  Please check whoever could reproduce the bug!

Best wishes,
GB
Index: ai/aiexplorer.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aiexplorer.c,v
retrieving revision 1.5.2.1
diff -u -r1.5.2.1 aiexplorer.c
--- ai/aiexplorer.c     15 Dec 2004 00:41:44 -0000      1.5.2.1
+++ ai/aiexplorer.c     26 Jan 2005 04:45:23 -0000
@@ -246,7 +246,7 @@
 {
   struct player *pplayer = unit_owner(punit);
   /* Loop prevention */
-  struct tile *ptile = punit->tile;
+  int init_moves = punit->moves_left;
 
   /* The log of the want of the most desirable tile, 
    * given nearby water, cities, etc. */
@@ -348,9 +348,11 @@
     }
     if (punit->moves_left > 0) {
       /* We can still move on... */
-      if (!same_pos(punit->tile, ptile)) {
-       /* At least we moved (and maybe even got to where we wnated).  
-         * Let's try again. */
+      if (punit->moves_left < init_moves) {
+       /* At least we moved (and maybe even got to where we wanted).  
+         * Let's do more exploring. 
+         * (Checking only whether our position changed is unsafe: can allow
+         * yoyoing on a RR) */
        return ai_manage_explorer(punit);          
       } else {
        /* Something went wrong. What to do but return?

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