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

Timo Juhani Lindfors wrote:

> 2) Crash seems to happen since min_goodies_per_player==0 in
> 0x0813b78e in create_start_positions (mode=MT_VARIABLE) at 
> ../../../server/generator/startpos.c:320
> 3) min_goodies_per_payer seems to be zero since total_goodies==0 in
> in Breakpoint 1, create_start_positions (mode=MT_VARIABLE) at 
> ../../../server/generator/startpos.c:269

BTW I only reproduce this sometimes, it seems to happen about 80% of the
time.  I'm not positive why it wouldn't happen though.

This is easy to work around (see patch) but hard to actually fix.

The problem is the algorithm uses the number of goodies on an island as
a fixed evaluation of the goodness of the island for starting positions.
 Thus an island with 0 goodies is judged worthless.

In a randomly generated map this is not likely to be an issue.  But in a
scenario map it's possible some islands have 0 goodies but are still
good islands for starting positions.  Or even if all islands have 0
goodies, some are still better than others based on size.  If we have 3
players and 2 islands, one of which is twice as big as the other,
clearly 2 players should go on the big island and 1 on the small island.
 But without a measure of goodies there is no way for the current code
logic to know this.

I think the fundamental problem is that the 'goodies' value is intended
to be a measure of the resources of a particular island.  It just isn't
a very accurate one since only a few tiles are considered.

Anyway, for now this patch should do.  Please test it, as I'm really not
sure of the mapgen logic here.


Index: server/generator/startpos.c
--- server/generator/startpos.c	(revision 12418)
+++ server/generator/startpos.c	(working copy)
@@ -340,8 +340,16 @@
       if (mode == MT_VARIABLE && to_place > 0) {
-	islands[nr].starters = MAX(1, islands[nr].goodies 
-				   / min_goodies_per_player);
+	if (islands[nr].goodies < min_goodies_per_player) {
+	  islands[nr].starters = 1;
+	} else if (min_goodies_per_player == 0) {
+	  /* Not sure how min_goodies_per_player could be 0, except it
+	   * happens on no-goodie scenario maps. */
+	  islands[nr].starters
+	    = (game.info.nplayers - 1) / map.num_continents + 1;
+	} else {
+	  islands[nr].starters = islands[nr].goodies / min_goodies_per_player;
+	}
 	to_place -= islands[nr].total = islands[nr].starters;
Freeciv-dev mailing list

Reply via email to