Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2004:
[Freeciv-Dev] (PR#9894) PATCH steepness and wetness new parameters for g
Home

[Freeciv-Dev] (PR#9894) PATCH steepness and wetness new parameters for g

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#9894) PATCH steepness and wetness new parameters for generators
From: "Marcelo Burda via RT" <mburda@xxxxxxxxx>
Date: Mon, 13 Sep 2004 08:54:00 -0700
Reply-to: RT_CorrespondAddressNotSet@xxxxxxxxxxxxxx

<URL: http://RT::WebBaseURL.not.configured:80/Ticket/Display.html?id=9894 >

Update 
diff -ruN -Xfreeciv/diff_ignore freeciv_/common/map.c freeciv__/common/map.c
--- freeciv_/common/map.c       2004-09-13 09:20:48.390291832 +0200
+++ freeciv__/common/map.c      2004-09-13 18:19:08.556920128 +0200
@@ -197,12 +197,8 @@
   map.riches                = MAP_DEFAULT_RICHES;
   map.huts                  = MAP_DEFAULT_HUTS;
   map.landpercent           = MAP_DEFAULT_LANDMASS;
-  map.grasssize             = MAP_DEFAULT_GRASS;
-  map.swampsize             = MAP_DEFAULT_SWAMPS;
-  map.deserts               = MAP_DEFAULT_DESERTS;
-  map.mountains             = MAP_DEFAULT_MOUNTAINS;
-  map.riverlength           = MAP_DEFAULT_RIVERS;
-  map.forestsize            = MAP_DEFAULT_FORESTS;
+  map.wetness               = MAP_DEFAULT_WETNESS;
+  map.steepness             = MAP_DEFAULT_STEEPNESS;
   map.generator             = MAP_DEFAULT_GENERATOR;
   map.tinyisles             = MAP_DEFAULT_TINYISLES;
   map.separatepoles         = MAP_DEFAULT_SEPARATE_POLES;
diff -ruN -Xfreeciv/diff_ignore freeciv_/common/map.h freeciv__/common/map.h
--- freeciv_/common/map.h       2004-09-13 09:20:48.398290616 +0200
+++ freeciv__/common/map.h      2004-09-13 18:19:08.565918760 +0200
@@ -163,17 +163,13 @@
   int riches;
   int huts;
   int landpercent;
-  int grasssize;
-  int swampsize;
-  int deserts;
-  int mountains;
-  int riverlength;
-  int forestsize;
   int generator;
   bool tinyisles;
   bool separatepoles;
   bool alltemperate;
   int temperature;
+  int wetness;
+  int steepness;
   int num_start_positions;
   bool have_specials;
   bool have_huts;
@@ -636,29 +632,13 @@
 #define MAP_MIN_RICHES           0
 #define MAP_MAX_RICHES           1000
 
-#define MAP_DEFAULT_MOUNTAINS    30
-#define MAP_MIN_MOUNTAINS        10
-#define MAP_MAX_MOUNTAINS        100
-
-#define MAP_DEFAULT_GRASS       35
-#define MAP_MIN_GRASS           20
-#define MAP_MAX_GRASS           100
-
-#define MAP_DEFAULT_SWAMPS       5
-#define MAP_MIN_SWAMPS           0
-#define MAP_MAX_SWAMPS           100
-
-#define MAP_DEFAULT_DESERTS      5
-#define MAP_MIN_DESERTS          0
-#define MAP_MAX_DESERTS          100
-
-#define MAP_DEFAULT_RIVERS       5
-#define MAP_MIN_RIVERS           0
-#define MAP_MAX_RIVERS           100
-
-#define MAP_DEFAULT_FORESTS      20
-#define MAP_MIN_FORESTS          0
-#define MAP_MAX_FORESTS          100
+#define MAP_DEFAULT_STEEPNESS    30
+#define MAP_MIN_STEEPNESS        0
+#define MAP_MAX_STEEPNESS        100
+
+#define MAP_DEFAULT_WETNESS      50
+#define MAP_MIN_WETNESS          0
+#define MAP_MAX_WETNESS          100
 
 #define MAP_DEFAULT_GENERATOR    1
 #define MAP_MIN_GENERATOR        1
Les fichiers freeciv_/manual/civmanual et freeciv__/manual/civmanual sont 
différents.
diff -ruN -Xfreeciv/diff_ignore freeciv_/server/generator/mapgen.c 
freeciv__/server/generator/mapgen.c
--- freeciv_/server/generator/mapgen.c  2004-09-13 17:21:31.876415440 +0200
+++ freeciv__/server/generator/mapgen.c 2004-09-13 18:39:51.743926976 +0200
@@ -67,6 +67,12 @@
    A value of 2 means river.                            -Erik Sigra */
 static int *river_map;
 
+/* these are the old parameters of terrains types do in %
+   TODO: this deppend of the hardcoded terrains
+   this has to work from a terrains rules-set */
+static int forest_pct = 0, desert_pct = 0, swamp_pct = 0, mountain_pct = 0,
+    jungle_pct = 0, river_pct = 0;
+ 
 struct isledata {
   int goodies;
   int starters;
@@ -93,7 +99,7 @@
 static int hmap_low_level = 0;
 #define ini_hmap_low_level() \
 { \
-hmap_low_level = (2 * map.swampsize  * \
+hmap_low_level = (2 * swamp_pct * \
      (hmap_max_level - hmap_shore_level)) / 100 + hmap_shore_level; \
 }
 /* should be used after having hmap_low_level initialized */
@@ -229,7 +235,7 @@
 /**************************************************************************
   make_relief() will convert all squares that are higher than thill to
   mountains and hills. Note that thill will be adjusted according to
-  the map.mountains value, so increasing map.mountains will result in
+  the map.steepness value, so increasing map.mountains will result in
   more hills and mountains.
 **************************************************************************/
 static void make_relief(void)
@@ -237,7 +243,7 @@
   /* Calculate the mountain level.  map.mountains specifies the percentage
    * of land that is turned into hills and mountains. */
   hmap_mountain_level = ((hmap_max_level - hmap_shore_level)
-                        * (100 - map.mountains)) / 100 + hmap_shore_level;
+                        * (100 - map.steepness)) / 100 + hmap_shore_level;
 
   whole_map_iterate(x, y) {
     if (not_placed(x,y) &&
@@ -420,18 +426,13 @@
     }
   } whole_map_iterate_end;
 
-  forests_count = total * map.forestsize
-       / ( map.forestsize + map.deserts + map.grasssize +  map.swampsize );
-  jungles_count = (MAX_COLATITUDE - TROPICAL_LEVEL) * forests_count 
-      /  (MAX_COLATITUDE * 2);
-  forests_count -= jungles_count;
-
-  deserts_count = total * map.deserts
-       / ( map.forestsize + map.deserts + map.grasssize +  map.swampsize);
-  swamps_count = total * map.swampsize
-       / ( map.forestsize + map.deserts + map.grasssize +  map.swampsize);
+  forests_count = total * forest_pct / (100 - mountain_pct);
+  jungles_count = total * jungle_pct / (100 - mountain_pct);
+ 
+  deserts_count = total * desert_pct / (100 - mountain_pct); 
+  swamps_count = total * swamp_pct  / (100 - mountain_pct);
 
-  /* grassland, tundra and plains is counted in map.grasssize */
+  /* grassland, tundra,arctic and plains is counted in plains_count */
   plains_count = total - forests_count - deserts_count
       - swamps_count - jungles_count;
 
@@ -794,20 +795,15 @@
   /* Formula to make the river density similar om different sized maps. Avoids
      too few rivers on large maps and too many rivers on small maps. */
   int desirable_riverlength =
-    map.riverlength *
-    /* This 10 is a conversion factor to take into account the fact that this
-     * river code was written when map.riverlength had a maximum value of 
-     * 1000 rather than the current 100 */
-    10 *
-    /* The size of the map (poles don't count). */
-    map_num_tiles() 
-      * (map.alltemperate ? 1.0 : 1.0 - 2.0 * ICE_BASE_LEVEL / MAX_COLATITUDE) 
*
-    /* Rivers need to be on land only. */
-    map.landpercent /
-    /* Adjustment value. Tested by me. Gives no rivers with 'set
-       rivers 0', gives a reasonable amount of rivers with default
-       settings and as many rivers as possible with 'set rivers 100'. */
-    0xD000; /* (= 53248 in decimal) */
+    river_pct *
+      /* The size of the map (poles counted in river_pct). */
+      map_num_tiles() *
+      /* Rivers need to be on land only. */
+      map.landpercent /
+      /* Adjustment value. Tested by me. Gives no rivers with 'set
+        rivers 0', gives a reasonable amount of rivers with default
+        settings and as many rivers as possible with 'set rivers 100'. */
+      5325;
 
   /* The number of river tiles that have been set. */
   int current_riverlength = 0;
@@ -1359,24 +1355,27 @@
 }
 
 /**************************************************************************
- Convert terrain parameters from the server into percents for the generators
+ Convert parameters from the server into terrains percents parameters for
+ the generators
 **************************************************************************/
 static void adjust_terrain_param(void)
 {
-  int total;
-  int polar = ICE_BASE_LEVEL * 100 / MAX_COLATITUDE;
+  int polar = 2 * ICE_BASE_LEVEL * map.landpercent / MAX_COLATITUDE ;
+  float factor =(100.0 - polar - map.steepness * 0.8 ) / 10000;
 
-  total = map.mountains + map.deserts + map.forestsize + map.swampsize
-    + map.grasssize;
 
-  if (total != 100 - polar) {
-    map.forestsize = map.forestsize * (100 - polar) / total;
-    map.swampsize = map.swampsize * (100 - polar) / total;
-    map.mountains = map.mountains * (100 - polar) / total;
-    map.deserts = map.deserts * (100 - polar) / total;
-    map.grasssize = 100 - map.forestsize - map.swampsize - map.mountains 
-      - polar - map.deserts;
-  }
+  mountain_pct = factor *  map.steepness * 0.8;
+  /* 40 % if wetness == 50 & */
+  forest_pct = factor * (map.wetness * 60 + 1000) ; 
+  jungle_pct = forest_pct * (MAX_COLATITUDE - TROPICAL_LEVEL)
+     /  (MAX_COLATITUDE * 2);
+  forest_pct -= jungle_pct;
+  /* 3 - 11 % */
+  river_pct = (100 - polar) * (3 + map.wetness / 12) / 100;
+  /* 6 %  if wetness == 50 && temperature == 50 */
+  swamp_pct = factor * (map.wetness * 6 + map.temperature * 6);
+  desert_pct =factor * (map.temperature * 10 + (100 - map.wetness) * 10) ;
+  
 }
 
 /**************************************************************************
@@ -1894,8 +1893,8 @@
     if (pstate->totalmass > 3000)
       freelog(LOG_NORMAL, _("High landmass - this may take a few seconds."));
 
-    i = map.riverlength + map.mountains
-               + map.deserts + map.forestsize + map.swampsize;
+    i = river_pct + mountain_pct
+               + desert_pct + forest_pct + swamp_pct;
     i = i <= 90 ? 100 : i * 11 / 10;
     tilefactor = pstate->totalmass / i;
     riverbuck = -(long int) myrand(pstate->totalmass);
@@ -1958,27 +1957,27 @@
 
     i *= tilefactor;
 
-    riverbuck += map.riverlength * i;
+    riverbuck += river_pct * i;
     fill_island_rivers(1, &riverbuck, pstate);
 
-    mountbuck += map.mountains * i;
+    mountbuck += mountain_pct * i;
     fill_island(20, &mountbuck,
                3,1, 3,1,
                T_HILLS, T_MOUNTAINS, T_HILLS, T_MOUNTAINS,
                pstate);
-    desertbuck += map.deserts * i;
+    desertbuck += desert_pct * i;
     fill_island(40, &desertbuck,
-               map.deserts, map.deserts, map.deserts, map.deserts,
+               desert_pct, desert_pct, desert_pct, desert_pct,
                T_DESERT, T_DESERT, T_DESERT, T_TUNDRA,
                pstate);
-    forestbuck += map.forestsize * i;
+    forestbuck += forest_pct * i;
     fill_island(60, &forestbuck,
-               map.forestsize, map.swampsize, map.forestsize, map.swampsize,
+               forest_pct, swamp_pct, forest_pct, swamp_pct,
                T_FOREST, T_JUNGLE, T_FOREST, T_TUNDRA,
                pstate);
-    swampbuck += map.swampsize * i;
+    swampbuck += swamp_pct * i;
     fill_island(80, &swampbuck,
-               map.swampsize, map.swampsize, map.swampsize, map.swampsize,
+               swamp_pct, swamp_pct, swamp_pct, swamp_pct,
                T_SWAMP, T_SWAMP, T_SWAMP, T_SWAMP,
                pstate);
 
diff -ruN -Xfreeciv/diff_ignore freeciv_/server/savegame.c 
freeciv__/server/savegame.c
--- freeciv_/server/savegame.c  2004-09-13 09:22:31.595602240 +0200
+++ freeciv__/server/savegame.c 2004-09-13 18:20:08.421819280 +0200
@@ -3095,13 +3095,8 @@
       map.generator = secfile_lookup_int(file, "map.generator");
       map.seed = secfile_lookup_int(file, "map.seed");
       map.landpercent = secfile_lookup_int(file, "map.landpercent");
-      map.grasssize =
-       secfile_lookup_int_default(file, MAP_DEFAULT_GRASS, "map.grasssize");
-      map.swampsize = secfile_lookup_int(file, "map.swampsize");
-      map.deserts = secfile_lookup_int(file, "map.deserts");
-      map.riverlength = secfile_lookup_int(file, "map.riverlength");
-      map.mountains = secfile_lookup_int(file, "map.mountains");
-      map.forestsize = secfile_lookup_int(file, "map.forestsize");
+      map.wetness = secfile_lookup_int(file, "map.wetness");
+      map.steepness = secfile_lookup_int(file, "map.steepness");
       map.have_huts = secfile_lookup_bool_default(file, TRUE,
                                                  "map.have_huts");
       map.temperature =
@@ -3478,11 +3473,8 @@
     secfile_insert_int(file, map.seed, "map.seed");
     secfile_insert_int(file, map.landpercent, "map.landpercent");
     secfile_insert_int(file, map.riches, "map.riches");
-    secfile_insert_int(file, map.swampsize, "map.swampsize");
-    secfile_insert_int(file, map.deserts, "map.deserts");
-    secfile_insert_int(file, map.riverlength, "map.riverlength");
-    secfile_insert_int(file, map.mountains, "map.mountains");
-    secfile_insert_int(file, map.forestsize, "map.forestsize");
+    secfile_insert_int(file, map.wetness, "map.wetness");
+    secfile_insert_int(file, map.steepness, "map.steepness");
     secfile_insert_int(file, map.huts, "map.huts");
     secfile_insert_int(file, map.generator, "map.generator");
     secfile_insert_bool(file, map.have_huts, "map.have_huts");
diff -ruN -Xfreeciv/diff_ignore freeciv_/server/settings.c 
freeciv__/server/settings.c
--- freeciv_/server/settings.c  2004-09-13 09:22:31.630596920 +0200
+++ freeciv__/server/settings.c 2004-09-13 18:20:08.426818520 +0200
@@ -309,37 +309,17 @@
          N_("Amount of land vs ocean"), "", NULL,
          MAP_MIN_LANDMASS, MAP_MAX_LANDMASS, MAP_DEFAULT_LANDMASS)
 
-  GEN_INT("mountains", map.mountains,
+  GEN_INT("steepness", map.steepness,
          SSET_MAP_GEN, SSET_GEOLOGY, SSET_SITUATIONAL, SSET_TO_CLIENT,
          N_("Amount of hills/mountains"),
          N_("Small values give flat maps, higher values give more "
             "hills and mountains."), NULL,
-         MAP_MIN_MOUNTAINS, MAP_MAX_MOUNTAINS, MAP_DEFAULT_MOUNTAINS)
+         MAP_MIN_STEEPNESS, MAP_MAX_STEEPNESS, MAP_DEFAULT_STEEPNESS)
 
-  GEN_INT("rivers", map.riverlength,
-         SSET_MAP_GEN, SSET_GEOLOGY, SSET_SITUATIONAL, SSET_TO_CLIENT,
-         N_("Amount of river squares"), "", NULL,
-         MAP_MIN_RIVERS, MAP_MAX_RIVERS, MAP_DEFAULT_RIVERS)
-
-  GEN_INT("grass", map.grasssize,
-         SSET_MAP_GEN, SSET_ECOLOGY, SSET_SITUATIONAL, SSET_TO_CLIENT,
-         N_("Amount of grass squares"), "", NULL,
-         MAP_MIN_GRASS, MAP_MAX_GRASS, MAP_DEFAULT_GRASS)
-
-  GEN_INT("forests", map.forestsize,
-         SSET_MAP_GEN, SSET_ECOLOGY, SSET_SITUATIONAL, SSET_TO_CLIENT,
-         N_("Amount of forest squares"), "", NULL, 
-         MAP_MIN_FORESTS, MAP_MAX_FORESTS, MAP_DEFAULT_FORESTS)
-
-  GEN_INT("swamps", map.swampsize,
-         SSET_MAP_GEN, SSET_ECOLOGY, SSET_SITUATIONAL, SSET_TO_CLIENT,
-         N_("Amount of swamp squares"), "", NULL, 
-         MAP_MIN_SWAMPS, MAP_MAX_SWAMPS, MAP_DEFAULT_SWAMPS)
-
-  GEN_INT("deserts", map.deserts,
-         SSET_MAP_GEN, SSET_ECOLOGY, SSET_SITUATIONAL, SSET_TO_CLIENT,
-         N_("Amount of desert squares"), "", NULL, 
-         MAP_MIN_DESERTS, MAP_MAX_DESERTS, MAP_DEFAULT_DESERTS)
+  GEN_INT("wetness", map.wetness,
+         SSET_MAP_GEN, SSET_GEOLOGY, SSET_SITUATIONAL, SSET_TO_CLIENT,
+         N_("Amount of water on lands"), "", NULL, 
+         MAP_MIN_WETNESS, MAP_MAX_WETNESS, MAP_DEFAULT_WETNESS)
 
   GEN_INT("seed", map.seed,
          SSET_MAP_GEN, SSET_INTERNAL, SSET_RARE, SSET_SERVER_ONLY,

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