Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2004:
[Freeciv-Dev] (PR#7546) move functions into mapgen
Home

[Freeciv-Dev] (PR#7546) move functions into mapgen

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#7546) move functions into mapgen
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 26 Feb 2004 12:43:52 -0800
Reply-to: rt@xxxxxxxxxxx

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

This patch moves three functions into mapgen: is_terrain_clean, 
is_hut_close, and is_special_close.  These functions are only used in 
mapgen and almost certainly will never have any use outside of it.

jason

Index: common/map.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/map.c,v
retrieving revision 1.163
diff -u -r1.163 map.c
--- common/map.c        2004/02/26 13:19:47     1.163
+++ common/map.c        2004/02/26 20:43:02
@@ -416,49 +416,6 @@
 }
 
 /***************************************************************
-...
-***************************************************************/
-bool terrain_is_clean(int x, int y)
-{
-  square_iterate(x, y, 2, x1, y1) {
-    if (map_get_terrain(x1,y1) != T_GRASSLAND
-       && map_get_terrain(x1,y1) != T_PLAINS)
-      return FALSE;
-  } square_iterate_end;
-
-  return TRUE;
-}
-
-/***************************************************************
-...
-***************************************************************/
-bool is_hut_close(int x, int y)
-{
-  square_iterate(x, y, 3, x1, y1) {
-    if (map_has_special(x1, y1, S_HUT))
-      return TRUE;
-  } square_iterate_end;
-
-  return FALSE;
-}
-
-
-/***************************************************************
-...
-***************************************************************/
-bool is_special_close(int x, int y)
-{
-  square_iterate(x, y, 1, x1, y1) {
-    if (map_has_special(x1, y1, S_SPECIAL_1)
-       || map_has_special(x1, y1, S_SPECIAL_2)) {
-      return TRUE;
-    }
-  } square_iterate_end;
-
-  return FALSE;
-}
-
-/***************************************************************
 Returns whether you can put a city on land near enough to use
 the tile.
 ***************************************************************/
Index: common/map.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/map.h,v
retrieving revision 1.177
diff -u -r1.177 map.h
--- common/map.h        2004/02/26 13:19:47     1.177
+++ common/map.h        2004/02/26 20:43:02
@@ -292,10 +292,7 @@
 bool is_special_near_tile(int x, int y, enum tile_special_type spe);
 int count_special_near_tile(int x, int y, enum tile_special_type spe);
 bool is_coastline(int x,int y);
-bool terrain_is_clean(int x, int y);
 bool is_at_coast(int x, int y);
-bool is_hut_close(int x, int y);
-bool is_special_close(int x, int y);
 bool is_sea_usable(int x, int y);
 int get_tile_food_base(struct tile * ptile);
 int get_tile_shield_base(struct tile * ptile);
Index: server/mapgen.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/mapgen.c,v
retrieving revision 1.130
diff -u -r1.130 mapgen.c
--- server/mapgen.c     2004/02/26 13:19:47     1.130
+++ server/mapgen.c     2004/02/26 20:43:03
@@ -833,6 +833,22 @@
   
 }
 
+/****************************************************************************
+  Return TRUE if the terrain is "clean".  This means that all the terrain
+  for 2 squares around us is either grassland or plains.
+****************************************************************************/
+static bool terrain_is_clean(int x, int y)
+{
+  square_iterate(x, y, 2, x1, y1) {
+    if (map_get_terrain(x1, y1) != T_GRASSLAND
+       && map_get_terrain(x1, y1) != T_PLAINS) {
+      return FALSE;
+    }
+  } square_iterate_end;
+
+  return TRUE;
+}
+
 /**************************************************************************
   we don't want huge areas of grass/plains, 
  so we put in a hill here and there, where it gets too 'clean' 
@@ -1419,6 +1435,20 @@
   free(new_hmap);
 }
 
+/****************************************************************************
+  Return TRUE iff there's already a hut within 3 tiles of us.
+****************************************************************************/
+static bool is_hut_close(int x, int y)
+{
+  square_iterate(x, y, 3, x1, y1) {
+    if (map_has_special(x1, y1, S_HUT)) {
+      return TRUE;
+    }
+  } square_iterate_end;
+
+  return FALSE;
+}
+
 /**************************************************************************
   this function spreads out huts on the map, a position can be used for a
   hut if there isn't another hut close and if it's not on the ocean.
@@ -1444,6 +1474,25 @@
   }
 }
 
+/****************************************************************************
+  Return TRUE iff there's a special (i.e., SPECIAL_1 or SPECIAL_2) within
+  1 tile of us.
+****************************************************************************/
+static bool is_special_close(int x, int y)
+{
+  square_iterate(x, y, 1, x1, y1) {
+    if (map_has_special(x1, y1, S_SPECIAL_1)
+       || map_has_special(x1, y1, S_SPECIAL_2)) {
+      return TRUE;
+    }
+  } square_iterate_end;
+
+  return FALSE;
+}
+
+/****************************************************************************
+  Add specials to the map with given probability.
+****************************************************************************/
 static void add_specials(int prob)
 {
   int xn, yn;

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#7546) move functions into mapgen, Jason Short <=