Complete.Org: Mailing Lists: Archives: freeciv-dev: May 2004:
[Freeciv-Dev] (PR#8870) moving some code in adjust_map().
Home

[Freeciv-Dev] (PR#8870) moving some code in adjust_map().

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#8870) moving some code in adjust_map().
From: "Marcelo Burda" <mburda@xxxxxxxxx>
Date: Sat, 29 May 2004 14:50:51 -0700
Reply-to: rt@xxxxxxxxxxx

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

Hi
This litle patch move some code in adjust map. this avoid to see 2 times
the some thinck. adjust map is called directyl by make_land()
Marcelo
diff -ruN -Xfreeciv/diff_ignore freeciv/server/mapgen.c freeciv_/server/mapgen.c
--- freeciv/server/mapgen.c     2004-05-21 10:54:02.000000000 +0200
+++ freeciv_/server/mapgen.c    2004-05-30 01:44:23.000000000 +0200
@@ -62,7 +62,7 @@
 static void mapgenerator4(void);
 static void mapgenerator5(void);
 static void smooth_map(void);
-static void adjust_map(int minval);
+static void adjust_map(void);
 static void adjust_terrain_param(void);
 
 #define RIVERS_MAXTRIES 32767
@@ -879,10 +879,14 @@
 **************************************************************************/
 static void make_land(void)
 {
-  int tres=(maxval*map.landpercent)/100;
+  int tres;
   int count=0;
   int total = (map_num_tiles() * map.landpercent) / 100;
   int forever=0;
+
+  adjust_map(); 
+  tres = (maxval * map.landpercent ) / 100;
+
   do {
     forever++;
     if (forever>50) break; /* loop elimination */
@@ -1360,8 +1364,19 @@
   i reduce the height so the lowest height is zero, this makes calculations
   easier
 **************************************************************************/
-static void adjust_map(int minval)
+static void adjust_map(void)
 {
+  int minval = 60000;
+
+  maxval = 0;
+  whole_map_iterate(x, y) {
+    if (hmap(x, y) > maxval)
+      maxval = hmap(x, y);
+    if (hmap(x, y) < minval)
+      minval = hmap(x, y);
+  } whole_map_iterate_end;
+
+  maxval-=minval;
   whole_map_iterate(x, y) {
     hmap(x, y) -= minval;
   } whole_map_iterate_end;
@@ -1394,16 +1409,6 @@
   smooth_map(); 
   smooth_map(); 
 
-  whole_map_iterate(x, y) {
-    if (hmap(x, y) > maxval)
-      maxval = hmap(x, y);
-    if (hmap(x, y) < minval)
-      minval = hmap(x, y);
-  } whole_map_iterate_end;
-
-  maxval-=minval;
-  adjust_map(minval);
-
   make_land();
   free(height_map);
   height_map = NULL;
@@ -2374,7 +2379,7 @@
 
   int xmax = map.xsize - (xnowrap ? 1 : 0);
   int ymax = map.ysize - (ynowrap ? 1 : 0);
-  int xn, yn, minval;
+  int xn, yn;
   /* just need something > log(max(xsize, ysize)) for the recursion */
   int step = map.xsize + map.ysize; 
   /* edges are avoided more strongly as this increases */
@@ -2436,16 +2441,6 @@
     hmap(x, y) = 8 * hmap(x, y) + myrand(4) - 2;
   } whole_map_iterate_end;
 
-  /* and calibrate maxval and minval */
-  maxval = hnat(0, 0);
-  minval = hnat(0, 0);
-  whole_map_iterate(x, y) {
-    maxval = MAX(maxval, hmap(x, y));
-    minval = MIN(minval, hmap(x, y));
-  } whole_map_iterate_end;
-  maxval -= minval;
-  adjust_map(minval);
-  
   make_land();
   free(height_map);
   height_map = NULL;

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