Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2004:
[Freeciv-Dev] (PR#7209) deserts in a no-poles game
Home

[Freeciv-Dev] (PR#7209) deserts in a no-poles game

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#7209) deserts in a no-poles game
From: "Jason Short" <jshort@xxxxxxxxxxxxxx>
Date: Tue, 6 Jan 2004 09:25:36 -0800
Reply-to: rt@xxxxxxxxxxx

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

This patch prevents removes the lattitude restriction from deserts on a 
map without poles.

jason

Index: server/mapgen.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/mapgen.c,v
retrieving revision 1.122
diff -u -r1.122 mapgen.c
--- server/mapgen.c     2003/11/18 23:11:14     1.122
+++ server/mapgen.c     2004/01/06 17:25:16
@@ -247,29 +247,32 @@
 }
 
 /*************************************************************************
-  make_deserts calls make_desert until we have enough deserts actually
-  there is no map setting for how many we want, what happends is that
-  we choose a random coordinate between 20 and 30 degrees north and south 
-  (deserts tend to be between 15 and 35, make_desert will expand them) and 
-  if it's a grassland square we call make_desert with this coordinate, we 
-  try this 500 times for each region: north and south.
+  Make deserts until we have enough of them.
 **************************************************************************/
 static void make_deserts(void)
 {
   int x,y,i,j;
   i=map.deserts;
   j=0;
-  while (i > 0 && j < 500) {
+  while (i > 0 && j < 100 * map.deserts) {
     j++;
 
-    y=myrand(map.ysize*10/180)+map.ysize*110/180;
-    x=myrand(map.xsize);
-    if (map_get_terrain(x, y)==T_GRASSLAND) {
-      make_desert(x,y, hmap(x, y), 50);
-      i--;
+    if (has_poles) {
+      /* Choose a random coordinate between 20 and 30 degrees north/south
+       * (deserts tend to be between 15 and 35; make_desert will expand
+       * them). */
+      y = myrand(map.ysize * 10 / 180) + map.ysize * 60 / 180;
+      x = myrand(map.xsize);
+      if (myrand(2) != 0) {
+       y = map.ysize - 1 - y;
+      }
+    } else {
+      /* If there are no poles we can pick any location to be a desert. */
+      rand_map_pos(&x, &y);
     }
-    y=myrand(map.ysize*10/180)+map.ysize*60/180;
-    x=myrand(map.xsize);
+
+    /* If it's a grassland square call make_desert here.  We loop repeatedly
+     * since we may not always find grassland. */
     if (map_get_terrain(x, y)==T_GRASSLAND) {
       make_desert(x,y, hmap(x, y), 50);
       i--;

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#7209) deserts in a no-poles game, Jason Short <=