Index: mapgen.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/mapgen.c,v retrieving revision 1.78 diff -u -r1.78 mapgen.c --- mapgen.c 2001/11/27 10:05:13 1.78 +++ mapgen.c 2001/11/27 10:15:44 @@ -1433,6 +1433,30 @@ return ( y * 5 < map.ysize || y * 5 > map.ysize * 4 ); } +static void get_position_from_state(int *x, int *y, + const struct gen234_state *const + pstate) +{ + int is_real; + + *x = pstate->w; + *y = pstate->n; + + is_real = normalize_map_pos(x, y); + assert(is_real); + + assert((pstate->e - pstate->w) > 0); + assert((pstate->e - pstate->w) < map.xsize); + assert((pstate->s - pstate->n) > 0); + assert((pstate->s - pstate->n) < map.ysize); + + *x += myrand(pstate->e - pstate->w); + *y += myrand(pstate->s - pstate->n); + + is_real = normalize_map_pos(x, y); + assert(is_real); +} + /************************************************************************** fill an island with up four types of terrains, rivers have extra code **************************************************************************/ @@ -1462,8 +1486,8 @@ i= 0; while (i && failsafe--) { - x = myrand(pstate->e - pstate->w) + pstate->w; - y = myrand(pstate->s - pstate->n) + pstate->n; + get_position_from_state(&x, &y, pstate); + if (map_get_continent(x, y) == pstate->isleindex && map_get_terrain(x, y) == T_GRASSLAND) { @@ -1516,8 +1540,7 @@ if(failsafe<0){ failsafe= -failsafe; } while (i && failsafe--) { - x = myrand(pstate->e - pstate->w) + pstate->w; - y = myrand(pstate->s - pstate->n) + pstate->n; + get_position_from_state(&x, &y, pstate); if (map_get_continent(x, y) == pstate->isleindex && map_get_terrain(x, y) == T_GRASSLAND) { @@ -1622,8 +1645,7 @@ pstate->e = x + 2; i = islemass - 1; while (i && tries-->0) { - x = myrand(pstate->e - pstate->w) + pstate->w; - y = myrand(pstate->s - pstate->n) + pstate->n; + get_position_from_state(&x, &y, pstate); if ((!hmap(x, y)) && ( hmap(x+1, y) || hmap(x-1, y) || hmap(x, y+1) || hmap(x, y-1) )) {