Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2005:
[Freeciv-Dev] (PR#13478) don't dereference T_UNKNOWN in the client goto
Home

[Freeciv-Dev] (PR#13478) don't dereference T_UNKNOWN in the client goto

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#13478) don't dereference T_UNKNOWN in the client goto code
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 15 Jul 2005 10:03:59 -0700
Reply-to: bugs@xxxxxxxxxxx

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

The client goto code dereferences T_UNKNOWN terrains in several places,
because T_UNKNOWN is used for all unknown tiles in the clients and
goto-into-unknown is now possible.  This patch fixes it, more or less.

This patch would also be needed before the goto-into-unknown patch could
be backported to 2.0.

-jason

Index: common/terrain.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/terrain.h,v
retrieving revision 1.39
diff -p -u -r1.39 terrain.h
--- common/terrain.h    14 Jul 2005 19:25:45 -0000      1.39
+++ common/terrain.h    15 Jul 2005 17:02:24 -0000
@@ -211,7 +211,8 @@ enum tile_special_type get_infrastructur
 enum tile_special_type get_preferred_pillage(bv_special pset);
 
 /* Terrain-specific functions. */
-#define is_ocean(pterrain) (terrain_has_flag((pterrain), TER_OCEANIC))
+#define is_ocean(pterrain) ((pterrain) != T_UNKNOWN                        \
+                           && terrain_has_flag((pterrain), TER_OCEANIC))
 #define is_ocean_near_tile(ptile) \
   is_terrain_flag_near_tile(ptile, TER_OCEANIC)
 #define count_ocean_near_tile(ptile, cardinal_only, percentage)                
\
Index: common/aicore/path_finding.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/aicore/path_finding.c,v
retrieving revision 1.33
diff -p -u -r1.33 path_finding.c
--- common/aicore/path_finding.c        13 Jul 2005 15:41:32 -0000      1.33
+++ common/aicore/path_finding.c        15 Jul 2005 17:02:25 -0000
@@ -237,7 +237,9 @@ static void init_node(struct pf_map *pf_
   }
 
   if (params->get_zoc) {
-    bool my_zoc = (ptile->city || is_ocean(ptile->terrain)
+    bool my_zoc = (ptile->city
+                  || ptile->terrain == T_UNKNOWN
+                  || is_ocean(ptile->terrain)
                   || params->get_zoc(params->owner, ptile));
     /* ZoC rules cannot prevent us from moving into/attacking an occupied 
      * tile.  Other rules can, but we don't care about them here. */ 
Index: common/aicore/pf_tools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/aicore/pf_tools.c,v
retrieving revision 1.36
diff -p -u -r1.36 pf_tools.c
--- common/aicore/pf_tools.c    14 Jul 2005 19:25:45 -0000      1.36
+++ common/aicore/pf_tools.c    15 Jul 2005 17:02:25 -0000
@@ -574,7 +574,8 @@ static bool is_pos_dangerous(const struc
                             struct pf_parameter *param)
 {
   /* Unsafe tiles without cities are dangerous. */
-  return (terrain_has_flag(ptile->terrain, TER_UNSAFE)
+  return (ptile->terrain != T_UNKNOWN
+         && terrain_has_flag(ptile->terrain, TER_UNSAFE)
          && ptile->city == NULL);
 }
 

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