Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2003:
[Freeciv-Dev] Re: (PR#6669) Topology and generators
Home

[Freeciv-Dev] Re: (PR#6669) Topology and generators

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: ue80@xxxxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#6669) Topology and generators
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 28 Oct 2003 13:44:23 -0800
Reply-to: rt@xxxxxxxxxxxxxx

ue80@xxxxxxxxxxxxxxxxxxxxx wrote:
> Hi,
> 
> Gen 2,3 and 4 aren't working with top 3.
> 
> And it should be possible to remove the poles in top 2 and 3.

PR#6652 provides a patch to not (always) generate poles.

The gen2/3/4 bug is closely related to that.  It happens because the 
poles are still being generated, but the code doesn't realize they're 
all one continent.

The easy fix would just be to _never_ generate poles in a N-S wrapping 
map.  That's what the gen-topology patch does; it only takes a few 
lines.  The attached patch "A" does it this way.

PR#6652 does it differently since Ross wanted this to be a server 
option.  This will make the fix harder: we actually have to figure out 
the continent numbering and do it right (e.g., more code).  I have a 
patch to do this but it doesn't work (I don't know why).

Personally, I'm in favor of completely ditching poles with the map wraps 
north-south.  I can't imagine why anyone would ever want them, and it 
makes the code significantly simpler.

jason


Index: server/mapgen.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/mapgen.c,v
retrieving revision 1.119
diff -u -r1.119 mapgen.c
--- server/mapgen.c     2003/10/21 22:04:53     1.119
+++ server/mapgen.c     2003/10/28 21:00:07
@@ -59,6 +59,7 @@
 static int *height_map;
 static int maxval=0;
 static int forests=0;
+static bool has_poles;
 
 struct isledata {
   int goodies;
@@ -854,7 +855,7 @@
       tres*=9;
     tres/=10;
   } while (abs(total-count)> maxval/40);
-  if (map.separatepoles) {
+  if (map.separatepoles && has_poles) {
     make_passable();
   }
   make_mountains(maxval*8/10);
@@ -862,7 +863,9 @@
   make_swamps();
   make_deserts();
   make_plains();
-  make_polar();
+  if (has_poles) {
+    make_polar();
+  }
   make_fair();
   make_rivers();
 }
@@ -937,7 +940,7 @@
     map_set_continent(x, y, 0);
   } whole_map_iterate_end;
 
-  if (map.generator != 0) {
+  if (map.generator != 0 && has_poles) {
     assign_continent_flood(0, 0, 1);
     assign_continent_flood(0, map.ysize-1, 2);
     isle = 3;
@@ -970,7 +973,7 @@
   islands = fc_calloc((map.num_continents + 1), sizeof(struct isledata));
   
   /* the arctic and the antarctic are continents 1 and 2 for generator > 0 */
-  if ((map.generator > 0) && map.separatepoles) {
+  if (map.generator > 0 && map.separatepoles && has_poles) {
     firstcont = 3;
   } else {
     firstcont = 1;
@@ -1155,6 +1158,8 @@
 
   mysrand(map.seed);
   
+  has_poles = !topo_has_flag(TF_WRAPY);
+
   /* don't generate tiles with mapgen==0 as we've loaded them from file */
   /* also, don't delete (the handcrafted!) tiny islands in a scenario */
   if (map.generator != 0) {
@@ -1771,21 +1776,25 @@
       map_clear_all_specials(x, y);
       map_set_owner(x, y, NULL);
     }
-  for (x = 0 ; x < map.xsize; x++) {
-    map_set_terrain(x, 0, myrand(9) > 0 ? T_ARCTIC : T_TUNDRA);
-    map_set_continent(x, 0, 1);
-    if (myrand(9) == 0) {
-      map_set_terrain(x, 1, myrand(9) > 0 ? T_TUNDRA : T_ARCTIC);
-      map_set_continent(x, 1, 1);
-    }
-    map_set_terrain(x, map.ysize-1, myrand(9) > 0 ? T_ARCTIC : T_TUNDRA);
-    map_set_continent(x, map.ysize-1, 2);
-    if (myrand(9) == 0) {
-      map_set_terrain(x, map.ysize-2, myrand(9) > 0 ? T_TUNDRA : T_ARCTIC);
-      map_set_continent(x, map.ysize-2, 2);
+  if (has_poles) {
+    for (x = 0 ; x < map.xsize; x++) {
+      map_set_terrain(x, 0, myrand(9) > 0 ? T_ARCTIC : T_TUNDRA);
+      map_set_continent(x, 0, 1);
+      if (myrand(9) == 0) {
+       map_set_terrain(x, 1, myrand(9) > 0 ? T_TUNDRA : T_ARCTIC);
+       map_set_continent(x, 1, 1);
+      }
+      map_set_terrain(x, map.ysize-1, myrand(9) > 0 ? T_ARCTIC : T_TUNDRA);
+      map_set_continent(x, map.ysize-1, 2);
+      if (myrand(9) == 0) {
+       map_set_terrain(x, map.ysize-2, myrand(9) > 0 ? T_TUNDRA : T_ARCTIC);
+       map_set_continent(x, map.ysize-2, 2);
+      }
     }
+    map.num_continents = 2;
+  } else {
+    map.num_continents = 0;
   }
-  map.num_continents = 2;
   make_island(0, 0, pstate, 0);
   islands[2].starters = 0;
   islands[1].starters = 0;
@@ -2140,7 +2149,7 @@
     for (y = 0; y < ydiv2; y++) {
       hmap(0, y * ymax / ydiv) -= avoidedge;
       hmap(xmax, y * ymax / ydiv) -= avoidedge;
-      if (map.separatepoles) {
+      if (map.separatepoles && has_poles) {
        hmap(2, y * ymax / ydiv) = hmap(0, y * ymax / ydiv) 
                                                        - myrand(3*avoidedge);
        hmap(xmax - 2, y * ymax / ydiv) 
@@ -2153,7 +2162,7 @@
     for (x = 0; x < xdiv2; x++) {
       hmap(x * xmax / xdiv, 0) -= avoidedge;
       hmap(x * xmax / xdiv, ymax) -= avoidedge;
-      if (map.separatepoles){
+      if (map.separatepoles && has_poles){
        hmap(x * xmax / xdiv, 2) = hmap(x * xmax / xdiv, 0) 
                                                        - myrand(3*avoidedge);
        hmap(x * xmax / xdiv, ymax - 2) 

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