Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2004:
[Freeciv-Dev] (PR#7258) replace T_OCEAN with is_ocean check
Home

[Freeciv-Dev] (PR#7258) replace T_OCEAN with is_ocean check

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#7258) replace T_OCEAN with is_ocean check
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 17 Jan 2004 10:57:47 -0800
Reply-to: rt@xxxxxxxxxxx

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

This patch replaces some rebellious T_OCEAN checks with a call to 
is_ocean().

jason

Index: common/unit.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/unit.c,v
retrieving revision 1.194
diff -u -r1.194 unit.c
--- common/unit.c       2004/01/11 17:45:04     1.194
+++ common/unit.c       2004/01/17 18:42:28
@@ -1383,7 +1383,7 @@
    * we'd need to confirm that we can exist/move at the (x, y)
    * location we are given.
    */
-  if (map_get_terrain(x, y) != T_OCEAN || is_coastline(x, y)) {
+  if (!is_ocean(map_get_terrain(x, y)) || is_coastline(x, y)) {
     return 0;
   } else {
     return base_trireme_loss_pct(pplayer, punit);
Index: common/aicore/path_finding.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/aicore/path_finding.c,v
retrieving revision 1.17
diff -u -r1.17 path_finding.c
--- common/aicore/path_finding.c        2003/11/22 14:12:32     1.17
+++ common/aicore/path_finding.c        2004/01/17 18:42:28
@@ -214,7 +214,7 @@
 
   if (params->get_zoc) {
     struct tile *tile = map_get_tile(x, y);
-    bool my_zoc = (tile->city || tile->terrain == T_OCEAN
+    bool my_zoc = (tile->city || is_ocean(tile->terrain)
                   || params->get_zoc(params->owner, x, y));
     /* 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.10
diff -u -r1.10 pf_tools.c
--- common/aicore/pf_tools.c    2004/01/11 17:45:05     1.10
+++ common/aicore/pf_tools.c    2004/01/17 18:42:29
@@ -67,10 +67,10 @@
 static int sea_overlap_move(int x, int y, enum direction8 dir,
                            int x1, int y1, struct pf_parameter *param)
 {
-  if (map_get_terrain(x, y) == T_OCEAN) {
+  if (is_ocean(map_get_terrain(x, y))) {
     return SINGLE_MOVE;
   } else if (is_allied_city_tile(map_get_tile(x, y), param->owner)
-            && map_get_terrain(x1, y1) == T_OCEAN) {
+            && is_ocean(map_get_terrain(x1, y1))) {
     return SINGLE_MOVE;
   }
 
@@ -86,13 +86,13 @@
 {
   struct tile *src_tile = map_get_tile(x, y);
 
-  if (src_tile->terrain == T_OCEAN) {
+  if (is_ocean(src_tile->terrain)) {
     if (is_non_allied_unit_tile(src_tile, param->owner)) {
       return PF_IMPOSSIBLE_MC;
     }
     return SINGLE_MOVE;
   } else if (is_allied_city_tile(map_get_tile(x, y), param->owner)
-            && map_get_terrain(x1, y1) == T_OCEAN) {
+            && is_ocean(map_get_terrain(x1, y1))) {
     return SINGLE_MOVE;
   }
 
@@ -109,13 +109,13 @@
   enum tile_terrain_type terrain1 = map_get_terrain(x1, y1);
   int move_cost;
 
-  if (terrain1 == T_OCEAN) {
+  if (is_ocean(terrain1)) {
     if (ground_unit_transporter_capacity(x1, y1, param->owner) > 0) {
       move_cost = SINGLE_MOVE;
     } else {
       move_cost = PF_IMPOSSIBLE_MC;
     }
-  } else if (ptile->terrain == T_OCEAN) {
+  } else if (is_ocean(ptile->terrain)) {
     struct tile *ptile1 = map_get_tile(x1, y1);
 
     if (!BV_ISSET(param->unit_flags, F_MARINES)
@@ -143,7 +143,7 @@
   struct tile *tgt_tile = map_get_tile(x1, y1);
   int move_cost;
 
-  if (tgt_tile->terrain == T_OCEAN) {
+  if (is_ocean(tgt_tile->terrain)) {
 
     /* Any-to-Sea */
     if (ground_unit_transporter_capacity(x1, y1, param->owner) > 0) {
@@ -151,7 +151,7 @@
     } else {
       move_cost = PF_IMPOSSIBLE_MC;
     }
-  } else if (src_tile->terrain == T_OCEAN) {
+  } else if (is_ocean(src_tile->terrain)) {
 
     /* Sea-to-Land. */
     if (!is_non_allied_unit_tile(tgt_tile, param->owner)
@@ -191,9 +191,9 @@
   one, so we don't venture too far into the ocean ;)
 
   Alternatively, we can change the flow to
-  if (ptile->terrain == T_OCEAN) {
+  if (is_ocean(ptile->terrain)) {
     move_cost = PF_IMPOSSIBLE_MC;
-  } else if (terrain1 == T_OCEAN) {
+  } else if (is_ocean(terrain1)) {
     move_cost = SINGLE_MOVE;
   } else {
     move_cost = ptile->move_cost[dir];
@@ -207,9 +207,9 @@
   enum tile_terrain_type terrain1 = map_get_terrain(x1, y1);
   int move_cost;
 
-  if (terrain1 == T_OCEAN) {
+  if (is_ocean(terrain1)) {
     move_cost = SINGLE_MOVE;
-  } else if (ptile->terrain == T_OCEAN) {
+  } else if (is_ocean(ptile->terrain)) {
     move_cost = get_tile_type(terrain1)->movement_cost * SINGLE_MOVE;
   } else {
     move_cost = ptile->move_cost[dir];
@@ -231,7 +231,7 @@
   int terrain1 = ptile->terrain;
   int move_cost = PF_IMPOSSIBLE_MC;
 
-  if (terrain1 == T_OCEAN) {
+  if (is_ocean(terrain1)) {
     if (ground_unit_transporter_capacity(x1, y1, param->owner) > 0) {
       /* Landing */
       move_cost = get_tile_type(terrain0)->movement_cost * SINGLE_MOVE;
@@ -239,7 +239,7 @@
       /* Nothing to land from */
       move_cost = PF_IMPOSSIBLE_MC;
     }
-  } else if (terrain0 == T_OCEAN) {
+  } else if (is_ocean(terrain0)) {
     /* Boarding */
     move_cost = SINGLE_MOVE;
   } else {
@@ -259,13 +259,13 @@
   struct tile *ptile = map_get_tile(x, y);
   int move_cost;
 
-  if (map_get_terrain(x1, y1) == T_OCEAN) {
+  if (is_ocean(map_get_terrain(x1, y1))) {
     if (ground_unit_transporter_capacity(x1, y1, param->owner) > 0) {
       move_cost = MOVE_COST_ROAD;
     } else {
       move_cost = PF_IMPOSSIBLE_MC;
     }
-  } else if (ptile->terrain == T_OCEAN) {
+  } else if (is_ocean(ptile->terrain)) {
     struct tile *ptile1 = map_get_tile(x1, y1);
 
     if (!BV_ISSET(param->unit_flags, F_MARINES)
@@ -293,14 +293,14 @@
   struct tile *ptile = map_get_tile(x1, y1);
   int move_cost;
 
-  if (map_get_terrain(x1, y1) == T_OCEAN) {
+  if (is_ocean(map_get_terrain(x1, y1))) {
     if (ground_unit_transporter_capacity(x1, y1, param->owner) > 0) {
       /* Landing */
       move_cost = MOVE_COST_ROAD;
     } else {
       move_cost = PF_IMPOSSIBLE_MC;
     }
-  } else if (map_get_terrain(x, y) == T_OCEAN) {
+  } else if (is_ocean(map_get_terrain(x, y))) {
     /* Boarding */
     move_cost = MOVE_COST_ROAD;
   } else {
@@ -341,7 +341,7 @@
                                           enum known_type known,
                                           struct pf_parameter *param)
 {
-  if (map_get_terrain(x, y) == T_OCEAN) {
+  if (is_ocean(map_get_terrain(x, y))) {
     return TB_DONT_LEAVE;
   }
   return TB_NORMAL;
@@ -376,7 +376,7 @@
 static bool trireme_is_pos_dangerous(int x, int y, enum known_type known,
                                     struct pf_parameter *param)
 {
-  return map_get_terrain(x, y) == T_OCEAN && !is_coastline(x, y);
+  return is_ocean(map_get_terrain(x, y)) && !is_coastline(x, y);
 }
 
 

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#7258) replace T_OCEAN with is_ocean check, Jason Short <=