Complete.Org: Mailing Lists: Archives: freeciv-dev: June 2006:
[Freeciv-Dev] (PR#17617) unsafe terrains and continents
Home

[Freeciv-Dev] (PR#17617) unsafe terrains and continents

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#17617) unsafe terrains and continents
From: "Jason Dorje Short" <jdorje@xxxxxxxxx>
Date: Sat, 3 Jun 2006 20:50:51 -0700
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=17617 >


   /* Unsafe terrains separate continents, otherwise small areas of green
    * near the poles could be populated by a civilization if that pole
    * was part of a larger continent. */
   assign_continent_numbers(TRUE);

The unsafe terrains that used to be glacier/arctic tiles would separate 
continents, so a small patch of green next to the pole would count as a 
1-tile continent instead of a part of a larger continent.  Now that 
arctic is no longer unsafe, this no longer works and polar placements 
are much more common.

To fix this, we need to have real detection of polar locations.  The 
whole mapgen code could use some cleanup, but this fix is needed for 2.1.

The attached patch should do a passable job of preventing this.  It just 
sets a fixed distance from the pole that starting positions have to be. 
  In a few tests I ran this looks fine.  However it obviously needs some 
extensive testing.

-jason

Index: server/generator/startpos.c
===================================================================
--- server/generator/startpos.c (revision 12004)
+++ server/generator/startpos.c (working copy)
@@ -24,6 +24,7 @@
 
 #include "mapgen_topology.h"
 #include "startpos.h"
+#include "temperature_map.h"
 #include "utilities.h"
 
 struct islands_data_type {
@@ -118,6 +119,14 @@
     return FALSE;
   }
 
+  /* A longstanding bug allowed starting positions to exist on poles,
+   * sometimes.  This hack prevents it by setting a fixed distance from
+   * the pole (dependent on map temperature) that a start pos must be.
+   * Cold and frozen tiles are not allowed for start pos placement. */
+  if (tmap_is(ptile, TT_NHOT)) {
+    return FALSE;
+  }
+
   /* Don't start too close to someone else. */
   cont_size = get_continent_size(cont);
   island = islands + islands_index[cont];
@@ -195,7 +204,17 @@
   /* this is factor is used to maximize land used in extreme little maps */
   float efactor =  game.info.nplayers / map.size / 4; 
   bool failure = FALSE;
+  bool is_tmap = temperature_is_initialized();
 
+  if (!is_tmap) {
+    /* The temperature map has already been destroyed by the time start
+     * positions have been placed.  We check for this and then create a
+     * false temperature map. This is used in the tmap_is() call above.
+     * We don't create a "real" map here because that requires the height
+     * map and other information which has already been destroyed. */
+    create_tmap(FALSE);
+  }
+
   /* Unsafe terrains separate continents, otherwise small areas of green
    * near the poles could be populated by a civilization if that pole
    * was part of a larger continent. */
@@ -374,6 +393,10 @@
   free(islands_index);
   islands = NULL;
   islands_index = NULL;
-  
+
+  if (!is_tmap) {
+    destroy_tmap();
+  }
+
   return !failure;
 }

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#17617) unsafe terrains and continents, Jason Dorje Short <=