Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2003:
[Freeciv-Dev] Re: (PR#4588) goto moves directly from ship into city
Home

[Freeciv-Dev] Re: (PR#4588) goto moves directly from ship into city

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jdorje@xxxxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#4588) goto moves directly from ship into city
From: "Gregory Berkolaiko" <Gregory.Berkolaiko@xxxxxxxxxxxx>
Date: Thu, 17 Jul 2003 16:31:28 -0700
Reply-to: rt@xxxxxxxxxxxxxx

On Thu, 17 Jul 2003, Jason Short wrote:

> Client goto from a ship onto an adjacent city will try to move the unit
> directly into the city, even if this isn't possible.  It should disallow
> this move and find the shortest legal route.  Useful for horsemen...

The attached patch should fix this bug and 4572 in one sweep.  Check, 
test.  Will apply tomorrow.

G.


Index: common/aicore/path_finding.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/aicore/path_finding.h,v
retrieving revision 1.3
diff -u -r1.3 path_finding.h
--- common/aicore/path_finding.h        2003/07/17 22:33:34     1.3
+++ common/aicore/path_finding.h        2003/07/17 23:29:11
@@ -299,6 +299,7 @@
 
   struct player *owner;
 
+  bv_flags unit_flags;          /* Like F_MARINE and F_TRIREME */
   bool omniscience;            /* Do we care if the tile is visible? */
 
   enum turn_mode turn_mode;    /* See definitions. */
Index: common/aicore/pf_tools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/aicore/pf_tools.c,v
retrieving revision 1.3
diff -u -r1.3 pf_tools.c
--- common/aicore/pf_tools.c    2003/07/17 22:33:34     1.3
+++ common/aicore/pf_tools.c    2003/07/17 23:29:11
@@ -77,7 +77,15 @@
       move_cost = PF_IMPOSSIBLE_MC;
     }
   } else if (ptile->terrain == T_OCEAN) {
-    move_cost = get_tile_type(terrain1)->movement_cost * SINGLE_MOVE;
+    struct tile *ptile1 = map_get_tile(x1, y1);
+
+    if (!BV_ISSET(param->unit_flags, F_MARINES)
+        && (is_non_allied_unit_tile(ptile1, param->owner) 
+            || is_non_allied_city_tile(ptile1, param->owner))) {
+      move_cost = PF_IMPOSSIBLE_MC;
+    } else {
+      move_cost = get_tile_type(terrain1)->movement_cost * SINGLE_MOVE;
+    }
   } else {
     move_cost = ptile->move_cost[dir];
   }
@@ -91,7 +99,7 @@
   recommended to use dont_cross_ocean TB callback with this 
   one, so we don't venture too far into the ocean ;)
 
-  Alternatively,we can change the flow to
+  Alternatively, we can change the flow to
   if (ptile->terrain == T_OCEAN) {
     move_cost = PF_IMPOSSIBLE_MC;
   } else if (terrain1 == T_OCEAN) {
@@ -99,7 +107,7 @@
   } else {
     move_cost = ptile->move_cost[dir];
   }
-  which will achieve thesame without call-back.
+  which will achieve the same without call-back.
 ************************************************************/
 static int land_overlap_move(int x, int y, enum direction8 dir,
                             int x1, int y1, struct pf_parameter *param)
@@ -267,6 +275,8 @@
   parameter->moves_left_initially = punit->moves_left;
   parameter->move_rate = unit_move_rate(punit);
   parameter->owner = unit_owner(punit);
+  parameter->unit_flags = unit_type(punit)->flags;
+  parameter->omniscience = !ai_handicap(unit_owner(punit), H_MAP);
 
   switch (unit_type(punit)->move_type) {
   case LAND_MOVING:
@@ -315,6 +325,8 @@
   parameter->moves_left_initially = punit->moves_left;
   parameter->move_rate = unit_move_rate(punit);
   parameter->owner = unit_owner(punit);
+  parameter->unit_flags = unit_type(punit)->flags;
+  parameter->omniscience = !ai_handicap(unit_owner(punit), H_MAP);
 
   switch (unit_type(punit)->move_type) {
   case LAND_MOVING:
@@ -345,6 +357,8 @@
   parameter->turn_mode = TM_CAPPED;
   parameter->get_TB = NULL;
   parameter->get_EC = NULL;
+  BV_CLR_ALL(parameter->unit_flags);
+  parameter->omniscience = TRUE;
 }
 
 /**********************************************************************

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