Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2004:
[Freeciv-Dev] (PR#9858) PATCH delete_tiny_islands -> grown_tiny_islands
Home

[Freeciv-Dev] (PR#9858) PATCH delete_tiny_islands -> grown_tiny_islands

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#9858) PATCH delete_tiny_islands -> grown_tiny_islands (and clean ups)
From: "Marcelo Burda" <mburda@xxxxxxxxx>
Date: Sun, 29 Aug 2004 02:29:11 -0700
Reply-to: rt@xxxxxxxxxxx

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

I rm hard dependecies of T_ARTIC and spetials in tiny island code and
change it to delete_tiny_islands -> grown_tiny_islands
has tiny islands no more exist option is deleted too.

this is done at land cration time, befor placing terrains.

all generators

Marcelo
diff -ruN -Xfreeciv/diff_ignore freeciv/common/map.c freeciv_/common/map.c
--- freeciv/common/map.c        2004-08-25 20:24:19.000000000 +0200
+++ freeciv_/common/map.c       2004-08-29 09:16:18.632136272 +0200
@@ -204,7 +204,6 @@
   map.riverlength           = MAP_DEFAULT_RIVERS;
   map.forestsize            = MAP_DEFAULT_FORESTS;
   map.generator             = MAP_DEFAULT_GENERATOR;
-  map.tinyisles             = MAP_DEFAULT_TINYISLES;
   map.separatepoles         = MAP_DEFAULT_SEPARATE_POLES;
   map.alltemperate          = MAP_DEFAULT_ALLTEMPERATE;
   map.tiles                 = NULL;
diff -ruN -Xfreeciv/diff_ignore freeciv/common/map.h freeciv_/common/map.h
--- freeciv/common/map.h        2004-08-26 20:37:52.000000000 +0200
+++ freeciv_/common/map.h       2004-08-29 09:15:55.330678632 +0200
@@ -170,7 +170,6 @@
   int riverlength;
   int forestsize;
   int generator;
-  bool tinyisles;
   bool separatepoles;
   bool alltemperate;
   int num_start_positions;
@@ -665,10 +664,6 @@
 #define MAP_MIN_GENERATOR        1
 #define MAP_MAX_GENERATOR        5
 
-#define MAP_DEFAULT_TINYISLES    FALSE
-#define MAP_MIN_TINYISLES        FALSE
-#define MAP_MAX_TINYISLES        TRUE
-
 #define MAP_DEFAULT_SEPARATE_POLES   TRUE
 #define MAP_MIN_SEPARATE_POLES       FALSE
 #define MAP_MAX_SEPARATE_POLES       TRUE
diff -ruN -Xfreeciv/diff_ignore freeciv/server/mapgen.c freeciv_/server/mapgen.c
--- freeciv/server/mapgen.c     2004-08-28 18:50:49.000000000 +0200
+++ freeciv_/server/mapgen.c    2004-08-29 09:09:02.299468920 +0200
@@ -1129,6 +1129,35 @@
 }
 
 /**************************************************************************
+  Returns if this is a 1x1 island
+**************************************************************************/
+#define is_tiny_island(x, y) \
+  (not_placed(x, y) && \
+   count_ocean_near_tile(x,y) == map.num_valid_dirs )
+
+/**************************************************************************
+  Removes all 1x1 islands (sets them to ocean).
+**************************************************************************/
+static void grown_tiny_islands(void)
+{
+  whole_map_iterate(x, y) {
+    if (is_tiny_island(x, y)) {
+      cardinal_adjc_iterate(x, y, x1, y1) {
+       if(count_ocean_near_tile(x1,y1) == map.num_valid_dirs - 1) {
+         map_set_terrain(x1, y1, T_NOT_PLACED);
+         map_set_continent(x1, y1, map_get_continent(x,y));
+         break;
+       }
+      } cardinal_adjc_iterate_end;
+      if (is_tiny_island(x, y)) {
+       map_set_terrain(x, y, T_OCEAN);
+       map_set_continent(x, y, 0);
+      }
+    }
+  } whole_map_iterate_end;
+}
+
+/**************************************************************************
   make land simply does it all based on a generated heightmap
   1) with map.landpercent it generates a ocean/grassland map 
   2) it then calls the above functions to generate the different terrains
@@ -1165,6 +1194,7 @@
 
   renormalize_hmap_poles();
   make_polar_land(); /* make extra land at poles*/
+  grown_tiny_islands();
   make_mountains(maxval*8/10);
   make_arctic();
   make_tundra();
@@ -1178,42 +1208,6 @@
   assign_continent_numbers();
 }
 
-/**************************************************************************
-  Returns if this is a 1x1 island
-**************************************************************************/
-static bool is_tiny_island(int x, int y) 
-{
-  Terrain_type_id t = map_get_terrain(x, y);
-
-  if (is_ocean(t) || t == T_ARCTIC) {
-    /* The arctic check is needed for iso-maps: the poles may not have
-     * any cardinally adjacent land tiles, but that's okay. */
-    return FALSE;
-  }
-
-  cardinal_adjc_iterate(x, y, x1, y1) {
-    if (!is_ocean(map_get_terrain(x1, y1))) {
-      return FALSE;
-    }
-  } cardinal_adjc_iterate_end;
-
-  return TRUE;
-}
-
-/**************************************************************************
-  Removes all 1x1 islands (sets them to ocean).
-**************************************************************************/
-static void remove_tiny_islands(void)
-{
-  whole_map_iterate(x, y) {
-    if (is_tiny_island(x, y)) {
-      map_set_terrain(x, y, T_OCEAN);
-      map_clear_special(x, y, S_RIVER);
-      map_set_continent(x, y, 0);
-    }
-  } whole_map_iterate_end;
-}
-
 /****************************************************************************
   Return an approximation of the goodness of a tile to a civilization.
 ****************************************************************************/
@@ -1568,12 +1562,6 @@
 
 /**************************************************************************
   See stdinhand.c for information on map generation methods.
-
-FIXME: Some continent numbers are unused at the end of this function, fx
-       removed completely by remove_tiny_islands.
-       When this function is finished various data is written to "islands",
-       indexed by continent numbers, so a simple renumbering would not
-       work...
 **************************************************************************/
 void map_fractal_generate(void)
 {
@@ -1603,9 +1591,6 @@
       mapgenerator2();
     if( map.generator == 1 )
       mapgenerator1();
-    if (!map.tinyisles) {
-      remove_tiny_islands();
-    }
   } else {
       assign_continent_numbers();
   }
@@ -2076,6 +2061,7 @@
   pstate->e += xon - pstate->w;
   pstate->n = yon;
   pstate->w = xon;
+  grown_tiny_islands();
   return i != 0;
 }
 
diff -ruN -Xfreeciv/diff_ignore freeciv/server/savegame.c 
freeciv_/server/savegame.c
--- freeciv/server/savegame.c   2004-08-27 19:36:53.000000000 +0200
+++ freeciv_/server/savegame.c  2004-08-29 09:18:45.216852008 +0200
@@ -3108,9 +3108,6 @@
       map.alltemperate
        = secfile_lookup_bool_default(file, MAP_DEFAULT_ALLTEMPERATE,
                                      "map.alltemperate");
-      map.tinyisles
-       = secfile_lookup_bool_default(file, MAP_DEFAULT_TINYISLES,
-                                     "map.tinyisles");
       map.separatepoles
        = secfile_lookup_bool_default(file, MAP_DEFAULT_SEPARATE_POLES,
                                      "map.separatepoles");
@@ -3478,7 +3475,6 @@
     secfile_insert_int(file, map.generator, "map.generator");
     secfile_insert_bool(file, map.have_huts, "map.have_huts");
     secfile_insert_bool(file, map.alltemperate, "map.alltemperate");
-    secfile_insert_bool(file, map.tinyisles, "map.tinyisles");
     secfile_insert_bool(file, map.separatepoles, "map.separatepoles");
   } 
 
diff -ruN -Xfreeciv/diff_ignore freeciv/server/stdinhand.c 
freeciv_/server/stdinhand.c
--- freeciv/server/stdinhand.c  2004-08-24 23:23:12.000000000 +0200
+++ freeciv_/server/stdinhand.c 2004-08-29 09:15:03.195604368 +0200
@@ -332,12 +332,6 @@
             "(Zero indicates a scenario map.)"), NULL,
          MAP_MIN_GENERATOR, MAP_MAX_GENERATOR, MAP_DEFAULT_GENERATOR)
 
-  GEN_BOOL("tinyisles", map.tinyisles,
-          SSET_MAP_GEN, SSET_GEOLOGY, SSET_RARE, SSET_TO_CLIENT,
-          N_("Presence of 1x1 islands"),
-          N_("0 = no 1x1 islands; 1 = some 1x1 islands"), NULL,
-          MAP_DEFAULT_TINYISLES)
-
   GEN_BOOL("separatepoles", map.separatepoles,
           SSET_MAP_GEN, SSET_GEOLOGY, SSET_SITUATIONAL, SSET_TO_CLIENT,
           N_("Whether the poles are separate continents"),

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#9858) PATCH delete_tiny_islands -> grown_tiny_islands (and clean ups), Marcelo Burda <=