Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2004:
[Freeciv-Dev] (PR#9510) is_coast_seen is wrong
Home

[Freeciv-Dev] (PR#9510) is_coast_seen is wrong

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#9510) is_coast_seen is wrong
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 2 Aug 2004 18:05:13 -0700
Reply-to: rt@xxxxxxxxxxx

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

This patch fixes is_coast_seen and makes it static inside gotohand.c.

This should fix some ai-tririemes-lost-at-see bugs.

jason

Index: server/gotohand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/gotohand.c,v
retrieving revision 1.180
diff -u -r1.180 gotohand.c
--- server/gotohand.c   28 Jul 2004 15:24:43 -0000      1.180
+++ server/gotohand.c   3 Aug 2004 01:05:04 -0000
@@ -857,6 +857,24 @@
   return TRUE;
 }
 
+/****************************************************************************
+  Can the player see that the given ocean tile is along the coastline?
+****************************************************************************/
+static bool is_coast_seen(int map_x, int map_y, struct player *pplayer)
+{
+  bool ai_always_see_map = !ai_handicap(pplayer, H_MAP);
+
+  adjc_iterate(map_x, map_y, adjc_x, adjc_y) {
+    /* Is there land here, and if so can we see it? */
+    if (!is_ocean(map_get_terrain(adjc_x, adjc_y))
+       && (ai_always_see_map || map_is_known(adjc_x, adjc_y, pplayer))) {
+      return TRUE;
+    }
+  } adjc_iterate_end;
+
+  return FALSE;
+}
+
 /**************************************************************************
 This is used to choose among the valid directions marked on the warmap
 by the find_the_shortest_path() function. Returns a direction or -1 if
Index: server/maphand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/maphand.c,v
retrieving revision 1.136
diff -u -r1.136 maphand.c
--- server/maphand.c    28 Jul 2004 15:24:43 -0000      1.136
+++ server/maphand.c    3 Aug 2004 01:05:04 -0000
@@ -1269,40 +1269,6 @@
   } players_iterate_end;
 }
 
-/***************************************************************
-Can pplayer conclude (at least by circumstantial evidence) that
-(x,y) is on coastline?  Remember, coastline ocean tiles have a 
-small stripe of land in them, even if the actual continent is 
-not seen.
-***************************************************************/
-bool is_coast_seen(int x, int y, struct player *pplayer)
-{
-  bool ai_always_see_map = !ai_handicap(pplayer, H_MAP);
-
-  square_iterate(x, y, 1, x1, y1) {
-    if (is_ocean(map_get_terrain(x1, y1))) {
-      continue;
-    }
-    /* Found land next to (x,y).  Can we see it? */
-    if (ai_always_see_map || map_is_known(x1, y1, pplayer)) {
-      /* Yes, we can see it */
-      return TRUE;
-    }
-    /* No, we cannot see it, but maybe we can see the strip of land
-     * on a tile next to it? */
-    cardinal_adjc_iterate(x1, y1, x2, y2) {
-      if (map_is_known(x2, y2, pplayer)) {
-        /* Yes, we can see (x2, y2) and it will display
-         * the strip of land.  We can conclude that (x1, y1) is land
-         * and therefore (x,y) is right next to (or on) the land */
-        return TRUE;
-      }
-    } cardinal_adjc_iterate_end; /* around x1,y1 */
-  } square_iterate_end; /* around x,y */
-
-  return FALSE;
-}
-
 /**************************************************************************
   Set the tile to be a river if required.
   It's required if one of the tiles nearby would otherwise be part of a
Index: server/maphand.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/maphand.h,v
retrieving revision 1.39
diff -u -r1.39 maphand.h
--- server/maphand.h    28 Nov 2003 17:37:22 -0000      1.39
+++ server/maphand.h    3 Aug 2004 01:05:04 -0000
@@ -89,7 +89,6 @@
 
 void enable_fog_of_war(void);
 void disable_fog_of_war(void);
-bool is_coast_seen(int x, int y, struct player *pplayer);
 
 void map_update_borders_city_destroyed(int x, int y);
 void map_update_borders_city_change(struct city *pcity);

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#9510) is_coast_seen is wrong, Jason Short <=