Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2004:
[Freeciv-Dev] (PR#7231) Bug: Goto gets on ally's' boats
Home

[Freeciv-Dev] (PR#7231) Bug: Goto gets on ally's' boats

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: vanevery@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#7231) Bug: Goto gets on ally's' boats
From: "Gregory Berkolaiko" <Gregory.Berkolaiko@xxxxxxxxxxxxx>
Date: Wed, 4 Aug 2004 09:14:08 -0700
Reply-to: rt@xxxxxxxxxxx

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

I think that passing through boats requires much organization and can
not be trusted to GOTO function at all.  Even more so because the PF
callbacks cannot tell what turn it will be on.

Thus I decided to outlaw passing through any boats, whether allied or
your own.

I think the attached is an acceptable fix.

Compiled but not tested.

G.
? log.txt
? log1.txt
? ttt.gz
Index: client/goto.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/goto.c,v
retrieving revision 1.70
diff -u -r1.70 goto.c
--- client/goto.c       21 Jun 2004 15:14:43 -0000      1.70
+++ client/goto.c       4 Aug 2004 16:08:45 -0000
@@ -333,7 +333,7 @@
 
 /********************************************************************** 
   PF callback to prohibit going into the unknown.  Also makes sure we 
-  don't plan our route through enemy city/tile.
+  don't plan our route through enemy city/tile or through a transport.
 ***********************************************************************/
 static enum tile_behavior get_TB_aggr(int x, int y, enum known_type known,
                                       struct pf_parameter *param)
@@ -348,12 +348,21 @@
     /* Can attack but can't count on going through */
     return TB_DONT_LEAVE;
   }
+
+  if (*(enum unit_move_type *)param->data == LAND_MOVING 
+      && is_ocean(map_get_terrain(x, y))) {
+    /* Passing through ships is disallowed */
+    return TB_DONT_LEAVE;
+  }
+
   return TB_NORMAL;
 }
 
 /********************************************************************** 
   PF callback for caravans. Caravans doesn't go into the unknown and
   don't attack enemy units but enter enemy cities.
+
+  Like other land units caravans don't go through transports.
 ***********************************************************************/
 static enum tile_behavior get_TB_caravan(int x, int y, enum known_type known,
                                         struct pf_parameter *param)
@@ -371,6 +380,12 @@
     return TB_IGNORE;
   }
 
+  if (is_ocean(map_get_terrain(x, y))
+      && *(enum unit_move_type *)param->data == LAND_MOVING) {
+    /* Passing through ships is disallowed */
+    return TB_DONT_LEAVE;
+  }
+
   /* Includes empty, allied, or allied-city tiles. */
   return TB_NORMAL;
 }
@@ -402,6 +417,8 @@
 
   /* May be overwritten by the caller. */
   parameter->moves_left_initially = punit->moves_left;
+
+  parameter->data = &(unit_type(punit)->move_type);
 }
 
 /********************************************************************** 

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#7231) Bug: Goto gets on ally's' boats, Gregory Berkolaiko <=