[Freeciv-Dev] Opps! My last patch did not fully re-initialize maps
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
The last patch which I just posted here did not currectly fully
initialize the maps. I have corrected this; I have also verified what
I am doing is correct by running a given map both as a retry and as the
first try; then diffing the two saved games. The two saved games were
identical.
Here is a corrected version of the patch which ensures that each player
gets their own island with gen 1 or with gen 5.
My next project: Making sure the humans get the better islands than the
computer players (this is what Alpha Centauri does).
- Sam
--- freeciv-1.14.0/server/mapgen.h Tue Feb 5 11:05:51 2002
+++ freeciv-1.14.0-hacked/server/mapgen.h Mon Mar 10 02:23:20 2003
@@ -15,7 +15,7 @@
void assign_continent_numbers(void);
void map_fractal_generate(void);
-void create_start_positions(void);
+int create_start_positions(void);
void adjust_terrain_param(void);
#endif /* FC__MAPGEN_H */
--- freeciv-1.14.0/server/mapgen.c Fri Oct 11 16:35:50 2002
+++ freeciv-1.14.0-hacked/server/mapgen.c Mon Mar 10 03:51:42 2003
@@ -941,8 +941,9 @@
Allocate islands array and fill in values.
Note this is only use for map.generator<=1, since others
setups islands and starters explicitly.
+ Output: The number of good islands that this map has
**************************************************************************/
-static void setup_isledata(void)
+int setup_isledata(void)
{
int x;
int good, mingood, maxgood;
@@ -1104,6 +1105,7 @@
}
freelog(LOG_DEBUG, "The map has %i starting positions on %i isles.",
starters, goodisles);
+ return goodisles;
}
/**************************************************************************
@@ -1113,17 +1115,47 @@
FIXME: MAXTRIES used to be 1.000.000, but has been raised to 10.000.000
because a set of values hit the limit. At some point we want to
make a better solution.
+ Output: Whether this is a good map; 1 if yes, 0 if no
**************************************************************************/
#define MAXTRIES 10000000
-void create_start_positions(void)
+int create_start_positions(void)
{
int nr=0;
int dist=40;
int x, y, j=0, k, sum;
int counter = 0;
+ int isles;
+
+ isles = 10000; /* Big number so this passes the "own island" test */
if (!islands) /* already setup for generators 2,3, and 4 */
- setup_isledata();
+ isles = setup_isledata();
+
+ if(isles < game.nplayers) { /* Each player gets their own island */
+ printf("Seed %d does not create enough islands for %d players.\n",
+ map.seed,game.nplayers);
+ map.seed++;
+ free(islands);
+ free(height_map);
+ free(river_map);
+ islands = NULL;
+ height_map = NULL;
+ river_map = NULL;
+ maxval = 0;
+ forests = 0;
+ free(map.tiles);
+ map.tiles = NULL;
+ map.num_continents = 0;
+ map.num_start_positions = 0;
+ map.have_specials = FALSE;
+ map.have_huts = FALSE;
+ /* Initializing the next two may not be necessary */
+ map.fixed_start_positions = FALSE;
+ map.have_rivers_overlay = FALSE;
+ return 0;
+ }
+
+ printf("Using seed %d\n",map.seed);
if(dist>= map.xsize/2)
dist= map.xsize/2;
@@ -1169,6 +1201,7 @@
free(islands);
islands = NULL;
+ return 1; /* Good map */
}
/**************************************************************************
@@ -1204,7 +1237,7 @@
mapgenerator3();
if( map.generator == 2 )
mapgenerator2();
- if( map.generator == 1 )
+ if( map.generator == 1 )
mapgenerator1();
if (!map.tinyisles) {
remove_tiny_islands();
--- freeciv-1.14.0/server/srv_main.c Fri Oct 11 16:35:50 2002
+++ freeciv-1.14.0-hacked/server/srv_main.c Mon Mar 10 02:22:56 2003
@@ -1798,6 +1798,7 @@
void srv_main(void)
{
int i;
+ int is_good_map;
/* make sure it's initialized */
if (!has_been_srv_init) {
@@ -1943,7 +1944,11 @@
if(game.is_new_game)
generate_ai_players();
-
+
+ /* This is a loop which will recreate the map in case the map
+ generator decides the generated map is not good enough */
+ do {
+
/* if we have a tile map, and map.generator==0, call map_fractal_generate
anyway, to make the specials and huts */
if(map_is_empty() || (map.generator == 0 && game.is_new_game))
@@ -1972,13 +1977,16 @@
} players_iterate_end;
game.max_players=game.nplayers;
+ is_good_map = 1;
/* we don't want random start positions in a scenario which already
provides them. -- Gudy */
if(map.num_start_positions==0) {
- create_start_positions();
+ is_good_map = create_start_positions();
}
}
+ } while(is_good_map == 0);
+
initialize_move_costs(); /* this may be the wrong place to do this */
generate_minimap(); /* for city_desire; saves a lot of calculations */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] Opps! My last patch did not fully re-initialize maps,
sam+civ <=
|
|