Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2003:
[Freeciv-Dev] Re: (PR#2748) 3 mapgen patches now through rt (sorry about
Home

[Freeciv-Dev] Re: (PR#2748) 3 mapgen patches now through rt (sorry about

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: kayeats@xxxxxxxxxxxx
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#2748) 3 mapgen patches now through rt (sorry about that) --- 1 of 3
From: "kayeats@xxxxxxxxxxxxxxxxxxxxxxxxx via RT" <rt@xxxxxxxxxxxxxx>
Date: Thu, 9 Jan 2003 09:45:02 -0800
Reply-to: rt@xxxxxxxxxxxxxx

>    Mapgenerators 2-4 already
>    treat rivers as percent.

Really?  I just looked at the code and all they seem to do in gens 2-4 is
divide by 10 everwhere.  Maybe I'm not looking closely enough.

Anyway, once I saw all the dividing by 10 that was already there I was
convinced that my initial instinct to change the maximum of
map.riverlength to be 100 like all the other terrain parameters was the
right solution.  Attached is the new version of the patch.  I also
followed your polar suggestion (sort-of, it isn't quite so simple as
simply replacing everywhere because you have to compute differently with
fixed values, so the only use of it is for clarity and hence I only used
it local to adjust_terrain_param).  Hopefully my third patch will go
in as well and it won't matter one bit.

If I'm misunderstanding how this will interact with gens 2-4 please
correct me.

Karen


Index: common/map.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/map.h,v
retrieving revision 1.134
diff -u -r1.134 map.h
--- common/map.h        2003/01/05 15:34:06     1.134
+++ common/map.h        2003/01/09 17:43:55
@@ -614,9 +614,9 @@
 #define MAP_MIN_DESERTS          0
 #define MAP_MAX_DESERTS          100
 
-#define MAP_DEFAULT_RIVERS       50
+#define MAP_DEFAULT_RIVERS       5
 #define MAP_MIN_RIVERS           0
-#define MAP_MAX_RIVERS           1000
+#define MAP_MAX_RIVERS           100
 
 #define MAP_DEFAULT_FORESTS      20
 #define MAP_MIN_FORESTS          0
Index: server/mapgen.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/mapgen.c,v
retrieving revision 1.105
diff -u -r1.105 mapgen.c
--- server/mapgen.c     2003/01/05 23:24:52     1.105
+++ server/mapgen.c     2003/01/09 17:44:01
@@ -647,13 +647,17 @@
      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() - 2 * map.xsize) *
     /* 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 1000'. */
+       settings and as many rivers as possible with 'set rivers 100'. */
     0xD000;
 
   /* The number of river tiles that have been set. */
@@ -1166,65 +1170,34 @@
 }
 
 /**************************************************************************
- readjust terrain counts so that it makes sense for mapgen 1, 2, 3 and 4
- idea: input is the number of terrain
- mapgen 1 needs custom parameters, 
- mapgen 2 and 3 and 4 use percents, currently.
- Ultimately, I hope all parameters below will be weights,
- with the defaults set to a percentage;
- Placing deserts and swamps may cause some problems.
+ Convert terrain parameters from the server into percents for the generators
 
  This function needs to be called from the server everytime a
- a parameter changes.
- It will be called again at game start, too.
+ a parameter changes. It will be called again at game start, too.
 **************************************************************************/
 void adjust_terrain_param(void)
 {
   int total;
+  int polar = 5; /* hopefully this will soon be a server option too */
 
-  /*!PS: I don't have the time to have several test runs */
-  /* to find a mapping from percents to generator 1 settings. */
+  total = map.mountains + map.deserts + map.forestsize + map.swampsize 
+    + map.grasssize;
 
-  if(map.generator==1){
-    /*map.riverlength*= 10; */
-    /*I leave this out, people will get too upset 
-      if they have to change all their scripts */
-    return;
-  }
-
-  map.riverlength/= 10;/* left in */
-
-    total = map.riverlength + map.mountains + map.deserts 
-    + map.forestsize + map.swampsize + map.grasssize;
-
-  if(total>100){
-    total = map.riverlength + map.mountains + map.deserts 
-    + map.forestsize + map.swampsize + map.grasssize;
-    map.forestsize= map.forestsize*100/total;
-
-    total = map.riverlength + map.mountains + map.deserts 
-    + map.forestsize + map.swampsize + map.grasssize;
-    map.riverlength= map.riverlength*100/total;
+  if (terrain_control.river_style == R_AS_TERRAIN)
+    total += map.riverlength;
 
-    total = map.riverlength + map.mountains + map.deserts 
-    + map.forestsize + map.swampsize + map.grasssize;
-    map.swampsize= map.swampsize*100/total;
-
-    total = map.riverlength + map.mountains + map.deserts 
-    + map.forestsize + map.swampsize + map.grasssize;
-    map.mountains= map.mountains*100/total;
-
-    total = map.riverlength + map.mountains + map.deserts 
-    + map.forestsize + map.swampsize + map.grasssize;
-    map.deserts= map.deserts*100/total;
-
-    total = map.riverlength + map.mountains + map.deserts 
-    + map.forestsize + map.swampsize + 0;
-    map.grasssize= 100 - total;
+  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;
+    if (terrain_control.river_style == R_AS_TERRAIN){
+      map.riverlength = map.riverlength * (100 - polar) / total;
+      map.grasssize -= map.riverlength;
+    }
   }
-  /* if smaller than 100, rest goes implicitly to grass */
-
-  map.riverlength*= 10;
 }
 
 /**************************************************************************
@@ -1661,7 +1634,7 @@
     if (pstate->totalmass > 3000)
       freelog(LOG_NORMAL, _("High landmass - this may take a few seconds."));
 
-    i = (map.riverlength / 10) + map.mountains
+    i = map.riverlength + map.mountains
                + map.deserts + map.forestsize + map.swampsize;
     i = i <= 90 ? 100 : i * 11 / 10;
     tilefactor = pstate->totalmass / i;
@@ -1712,14 +1685,14 @@
 
     i *= tilefactor;
     if (terrain_control.river_style==R_AS_TERRAIN) {
-      riverbuck += map.riverlength / 10 * i;
+      riverbuck += map.riverlength * i;
       fill_island(1, &riverbuck,
                  1,1,1,1,
                  T_RIVER, T_RIVER, T_RIVER, T_RIVER, 
                  pstate);
     }
     if (terrain_control.river_style==R_AS_SPECIAL) {
-      riverbuck += map.riverlength / 10 * i;
+      riverbuck += map.riverlength * i;
       fill_island_rivers(1, &riverbuck, pstate);
     }
     mountbuck += map.mountains * i;

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