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: Wed, 1 Sep 2004 01:24:04 -0700
Reply-to: RT_CorrespondAddressNotSet@xxxxxxxxxxxxxx

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

This patch depend on 9876(map.temperature parameter)

there i delete the map.grasssize, map.swampsize, map.desserts,
map.mountains and map.forestsize

and create map.steepnes and map.wetness 

with this 2 new parameters and map.temperature we has a way to define
maps is no more dependent of terrains ruleset, these 2 patchs are the
begin on a work to extend and improve generator to load terrains rules-set.

steepnes, wetness, and temperature has to be handled in best way in near
future patchs.

map.riverlenght are not touched but maybe this can be calculate from
these 3 parameters, what you think?

Marcelo
diff -ruN -Xfreeciv/diff_ignore freeciv_improved/common/map.c 
freeciv_/common/map.c
--- freeciv_improved/common/map.c       2004-08-31 21:29:40.000000000 +0200
+++ freeciv_/common/map.c       2004-08-31 14:13:42.000000000 +0200
@@ -197,12 +197,9 @@
   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.wetness               = MAP_DEFAULT_WETNESS;
+  map.steepness             = MAP_DEFAULT_STEEPNESS;
   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;
diff -ruN -Xfreeciv/diff_ignore freeciv_improved/common/map.h 
freeciv_/common/map.h
--- freeciv_improved/common/map.h       2004-08-31 21:29:40.000000000 +0200
+++ freeciv_/common/map.h       2004-08-31 14:12:36.000000000 +0200
@@ -163,17 +163,14 @@
   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;
@@ -638,30 +635,18 @@
 #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_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_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_GENERATOR    1
 #define MAP_MIN_GENERATOR        1
 #define MAP_MAX_GENERATOR        5
diff -ruN -Xfreeciv/diff_ignore freeciv_improved/server/mapgen.c 
freeciv_/server/mapgen.c
--- freeciv_improved/server/mapgen.c    2004-08-31 21:29:40.000000000 +0200
+++ freeciv_/server/mapgen.c    2004-09-01 08:04:56.272868456 +0200
@@ -92,6 +92,11 @@
 static int plains_to_be_placed = 0;
 static int swamps_to_be_placed = 0;
 
+/* 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;
+ 
 struct isledata {
   int goodies;
   int starters;
@@ -385,12 +390,12 @@
 /**************************************************************************
   make_relief() will convert all squares that are higher than thill to
   mountains and hills. Notice that thill will be adjusted according to
-  the map.mountains value, so increase map.mountains and you'll get more 
+  the map.steepness value, so increase map.steepness and you'll get more 
   hills and mountains (and vice versa).
 **************************************************************************/
 static void make_relief()
 {
-  reliefval = ((maxval - seaval)* (100 - map.mountains)) / 100 + seaval;
+  reliefval = ((maxval - seaval)* (100 - map.steepness)) / 100 + seaval;
   whole_map_iterate(x, y) {
     if (not_placed(x,y) 
        && ((reliefval < hmap(x, y) && (myrand(10) > 5 
@@ -633,12 +638,9 @@
     }
   } whole_map_iterate_end;
 
-  forests_to_be_placed = total * map.forestsize
-       / ( map.forestsize + map.deserts + map.grasssize +  map.swampsize );
-  deserts_to_be_placed = total * map.deserts
-       / ( map.forestsize + map.deserts + map.grasssize +  map.swampsize);
-  swamps_to_be_placed = total * map.swampsize
-       / ( map.forestsize + map.deserts + map.grasssize +  map.swampsize);
+  forests_to_be_placed = total * forest_pct / (100 - mountain_pct);
+  deserts_to_be_placed = total * desert_pct / (100 - mountain_pct);
+  swamps_to_be_placed  = total * swamp_pct  / (100 - mountain_pct);
 
   /* grassland, tundra and plains is counted in map.grasssize */
   plains_to_be_placed = total - forests_to_be_placed - deserts_to_be_placed
@@ -1073,7 +1075,7 @@
     10 *
     /* The size of the map (poles don't count). */
     map_num_tiles() 
-      * (map.alltemperate ? 1.0 : 2.0 * ICE_BASE_LEVEL/MAX_TEMP) *
+      * (map.alltemperate ? 1.0 : (1.0 - 2.0 * ICE_BASE_LEVEL/MAX_TEMP)) *
     /* Rivers need to be on land only. */
     map.landpercent /
     /* Adjustment value. Tested by me. Gives no rivers with 'set
@@ -1696,24 +1698,22 @@
 }
 
 /**************************************************************************
- 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_TEMP;
+  int polar = 2 * ICE_BASE_LEVEL * map.landpercent / MAX_TEMP ;
+  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) ; 
+  /* 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) ;
+  
 }
 
 /**************************************************************************
@@ -2282,8 +2282,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 = map.riverlength + 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);
@@ -2349,24 +2349,24 @@
     riverbuck += map.riverlength * 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_improved/server/savegame.c 
freeciv_/server/savegame.c
--- freeciv_improved/server/savegame.c  2004-08-31 21:29:40.000000000 +0200
+++ freeciv_/server/savegame.c  2004-08-31 14:22:50.000000000 +0200
@@ -3095,13 +3095,9 @@
       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.wetness = secfile_lookup_int(file, "map.wetness");
       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.steepness = secfile_lookup_int(file, "map.steepness");
       map.have_huts = secfile_lookup_bool_default(file, TRUE,
                                                  "map.have_huts");
       map.temperature =
@@ -3471,11 +3467,9 @@
     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.wetness, "map.wetness");
     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.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_improved/server/stdinhand_info.h 
freeciv_/server/stdinhand_info.h
--- freeciv_improved/server/stdinhand_info.h    2004-08-31 21:29:40.000000000 
+0200
+++ freeciv_/server/stdinhand_info.h    2004-08-31 20:48:53.000000000 +0200
@@ -265,37 +265,22 @@
          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/plains and tundra 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]