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" <mburda@xxxxxxxxx>
Date: Sat, 18 Sep 2004 07:55:24 -0700
Reply-to: rt@xxxxxxxxxxx

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

> [mstefek - Jeu. Sep. 16 18:18:04 2004]: 
>  
> Please add default values for steepness and wetness in savegame code 
> -- 
> mateusz 
>  
Fixed, and default value for load  
? _
? freeciv.spec
? server/generator/water_map.c
? server/generator/water_map.h
Index: common/map.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/map.c,v
retrieving revision 1.196
diff -u -r1.196 map.c
--- common/map.c        16 Sep 2004 04:38:24 -0000      1.196
+++ common/map.c        18 Sep 2004 14:51:44 -0000
@@ -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;
Index: common/map.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/map.h,v
retrieving revision 1.216
diff -u -r1.216 map.h
--- common/map.h        17 Sep 2004 17:05:21 -0000      1.216
+++ common/map.h        18 Sep 2004 14:51:45 -0000
@@ -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;
@@ -640,29 +636,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
Index: server/savegame.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/savegame.c,v
retrieving revision 1.187
diff -u -r1.187 savegame.c
--- server/savegame.c   16 Sep 2004 04:38:25 -0000      1.187
+++ server/savegame.c   18 Sep 2004 14:51:47 -0000
@@ -3095,13 +3095,10 @@
       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_default(file, MAP_DEFAULT_WETNESS,
+                                              "map.wetness");
+      map.steepness = secfile_lookup_int_default(file, MAP_DEFAULT_STEEPNESS, 
+                                                "map.steepness");
       map.have_huts = secfile_lookup_bool_default(file, TRUE,
                                                  "map.have_huts");
       map.temperature =
@@ -3478,11 +3475,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");
Index: server/settings.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/settings.c,v
retrieving revision 1.4
diff -u -r1.4 settings.c
--- server/settings.c   16 Sep 2004 04:38:25 -0000      1.4
+++ server/settings.c   18 Sep 2004 14:51:48 -0000
@@ -314,37 +314,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("mapseed", map.seed,
          SSET_MAP_GEN, SSET_INTERNAL, SSET_RARE, SSET_SERVER_ONLY,
Index: server/generator/mapgen.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/generator/mapgen.c,v
retrieving revision 1.6
diff -u -r1.6 mapgen.c
--- server/generator/mapgen.c   16 Sep 2004 18:52:58 -0000      1.6
+++ server/generator/mapgen.c   18 Sep 2004 14:51:49 -0000
@@ -70,6 +70,12 @@
 
 #define HAS_POLES (map.temperature < 70 && !map.alltemperate  )
 
+/* 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;
+ 
 /****************************************************************************
  * Conditions used mainly in rand_map_pos_characteristic()
  ****************************************************************************/
@@ -88,7 +94,7 @@
 static int hmap_low_level = 0;
 #define ini_hmap_low_level() \
 { \
-hmap_low_level = (2 * map.swampsize  * \
+hmap_low_level = (4 * swamp_pct  * \
      (hmap_max_level - hmap_shore_level)) / 100 + hmap_shore_level; \
 }
 /* should be used after having hmap_low_level initialized */
@@ -224,7 +230,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)
@@ -232,7 +238,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) &&
@@ -415,18 +421,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;
 
@@ -438,7 +439,7 @@
     PLACE_ONE_TYPE(jungles_count, forests_count , T_JUNGLE,
                   WC_ALL, TT_TROPICAL, MC_NONE, 50);
     PLACE_ONE_TYPE(swamps_count, forests_count , T_SWAMP,
-                  WC_NDRY, TT_NFROZEN, MC_LOW, 50);
+                  WC_NDRY, TT_HOT, MC_LOW, 50);
     PLACE_ONE_TYPE(deserts_count, alt_deserts_count , T_DESERT,
                   WC_DRY, TT_NFROZEN, MC_NLOW, 80);
     PLACE_ONE_TYPE(alt_deserts_count, plains_count , T_DESERT,
@@ -789,20 +790,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;
@@ -1094,24 +1090,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 * 90;
+  /* 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) ;
+  
 }
 
 /**************************************************************************
@@ -1629,8 +1628,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);
@@ -1693,27 +1692,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,
+               1, 1, 1, 1,
                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,
+               1, 1, 1, 1,
                T_SWAMP, T_SWAMP, T_SWAMP, T_SWAMP,
                pstate);
 
Index: server/generator/temperature_map.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/generator/temperature_map.h,v
retrieving revision 1.1
diff -u -r1.1 temperature_map.h
--- server/generator/temperature_map.h  14 Sep 2004 08:23:00 -0000      1.1
+++ server/generator/temperature_map.h  18 Sep 2004 14:51:49 -0000
@@ -29,7 +29,7 @@
 #define TT_NFROZEN (TT_COLD | TT_TEMPERATE | TT_TROPICAL)
 #define TT_ALL (TT_FROZEN | TT_NFROZEN)
 #define TT_NHOT (TT_FROZEN | TT_COLD)
-#define TT_HOT (TT_TEMPERATE, TT_TROPICAL)
+#define TT_HOT (TT_TEMPERATE | TT_TROPICAL)
 
 bool temperature_is_initialized(void);
 bool tmap_is(int x, int y, temperature_type tt);

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