From eaf1c0f447d591efc9baa2fe4785521bc73b61c5 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 26 Nov 2005 00:58:27 +0000 Subject: [PATCH] mapper: choose_terrain didn't work with only 2 terrains. --- src/mapper/map_modify.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/mapper/map_modify.c b/src/mapper/map_modify.c index 580483203..8a6bc0009 100644 --- a/src/mapper/map_modify.c +++ b/src/mapper/map_modify.c @@ -1028,11 +1028,12 @@ static terrain_t choose_terrain(terrain_t t) { int q; - if(rand()%100 < 50) return t; - if(rand()%100 < 10) return T_OCEAN; + if (rand()%100 < 50) return t; + if (rand()%100 < 10) return T_OCEAN; - q=rand()%100; - switch(t) { + q = rand()%100; + + switch (t) { case T_OCEAN: if(rand()%100 < 60) return T_OCEAN; switch(rand()%6) { @@ -1242,10 +1243,14 @@ create_island(region *r, int n, const struct terrain_type * terrain) } r2 = findregion(x,y); if (r2 && fval(r2->terrain, SEA_REGION)) { - terrain_t t = choose_terrain(oldterrain(r2->terrain)); + const terrain_type * terrain = NULL; + do { + terrain_t t = choose_terrain(oldterrain(r2->terrain)); + terrain = newterrain(t); + } while (terrain==NULL); r2->msgs = (void *)d; push(r2); - abbruch = Create_Island(r2, &n, newterrain(t), sx, sy); + abbruch = Create_Island(r2, &n, terrain, sx, sy); } if (abbruch) break; }