diff --git a/src/common/kernel/terrain.h b/src/common/kernel/terrain.h index fd240db6f..31b8b6b15 100644 --- a/src/common/kernel/terrain.h +++ b/src/common/kernel/terrain.h @@ -67,6 +67,7 @@ typedef struct terrain_type { int size; /* how many peasants can work? */ unsigned int flags; short max_road; /* this many stones make a full road */ + short distribution; /* multiplier used for seeding */ struct terrain_production * production; const struct item_type ** herbs; /* zero-terminated array of herbs */ const char * (*name)(const struct region * r); diff --git a/src/common/kernel/xmlreader.c b/src/common/kernel/xmlreader.c index 6101e9cc9..308e6aa97 100644 --- a/src/common/kernel/xmlreader.c +++ b/src/common/kernel/xmlreader.c @@ -1539,13 +1539,14 @@ parse_terrains(xmlDocPtr doc) if (xml_bvalue(node, "swim", false)) terrain->flags |= SWIM_INTO; if (xml_bvalue(node, "shallow", true)) terrain->flags |= LARGE_SHIPS; if (xml_bvalue(node, "cavalry", false)) terrain->flags |= CAVALRY_REGION; - if (xml_bvalue(node, "seed", true)) terrain->flags |= AUTO_TERRAIN; } if (xml_bvalue(node, "sea", false)) terrain->flags |= SEA_REGION; if (xml_bvalue(node, "arctic", false)) terrain->flags |= ARCTIC_REGION; if (xml_bvalue(node, "land", true)) terrain->flags |= LAND_REGION; if (xml_bvalue(node, "forest", false)) terrain->flags |= FOREST_REGION; + terrain->distribution = (short)xml_ivalue(node, "seed", 0) terrain->flags |= AUTO_TERRAIN; + xpath->node = node; xpathChildren = xmlXPathEvalExpression(BAD_CAST "herb", xpath); children = xpathChildren->nodesetval; diff --git a/src/common/modules/autoseed.c b/src/common/modules/autoseed.c index 519350064..e3de3f055 100644 --- a/src/common/modules/autoseed.c +++ b/src/common/modules/autoseed.c @@ -38,23 +38,23 @@ #include const terrain_type * -random_terrain(unsigned int flags) +random_terrain(boolean distribution) { static int nterrains; + static int ndistribution; const terrain_type * terrain; int n; if (nterrains==0) { for (terrain=terrains();terrain;terrain=terrain->next) { - if (fval(terrain, flags)==flags) { - ++nterrains; - } + ndistribution += terrain->distribution; + ++nterrains; } } - n = rand() % nterrains; + + n = rand() % distribution?ndistribution:nterrains; for (terrain=terrains();terrain;terrain=terrain->next) { - if (fval(terrain, flags)==flags) { - if (n--==0) break; - } + n -= distribution?terrain->distribution:1; + if (n<0) break; } return terrain; } @@ -645,7 +645,7 @@ autoseed(newfaction ** players, int nsize, boolean new_island) --isize; if (psize>=PLAYERS_PER_ISLAND) break; } else { - terraform_region(r, random_terrain(AUTO_TERRAIN)); + terraform_region(r, random_terrain(true)); --isize; } } @@ -681,7 +681,7 @@ autoseed(newfaction ** players, int nsize, boolean new_island) const struct terrain_type * terrain = newterrain(T_OCEAN); rn = new_region(r->x + delta_x[d], r->y + delta_y[d]); if (rand() % SPECIALCHANCE < special) { - terrain = random_terrain(AUTO_TERRAIN); + terrain = random_terrain(true); special = SPECIALCHANCE / 3; /* 33% chance auf noch eines */ } else { special = 1; diff --git a/src/common/modules/autoseed.h b/src/common/modules/autoseed.h index e7d522fba..3b807d2d1 100644 --- a/src/common/modules/autoseed.h +++ b/src/common/modules/autoseed.h @@ -36,7 +36,7 @@ extern int autoseed(newfaction ** players, int nsize, boolean new_island); extern newfaction * read_newfactions(const char * filename); extern void get_island(struct region * root, struct region_list ** rlist); extern int fix_demand(struct region *r); -extern const struct terrain_type * random_terrain(unsigned int flags); +extern const struct terrain_type * random_terrain(boolean use_distribution); #ifdef __cplusplus } diff --git a/src/mapper/mapper.c b/src/mapper/mapper.c index d3edb8d2c..8c2c5161b 100644 --- a/src/mapper/mapper.c +++ b/src/mapper/mapper.c @@ -1154,7 +1154,7 @@ movearound(short rx, short ry) { if (r!=NULL) { a = map_input(0,0,0,"Wieviele Regionen?",0,500,0); if (a) { - const terrain_type * terrain = random_terrain(AUTO_TERRAIN); + const terrain_type * terrain = random_terrain(false); create_island(r, a, terrain); modified=1; } diff --git a/src/res/terrains.xml b/src/res/terrains.xml index 297b6118d..f820e9a1f 100644 --- a/src/res/terrains.xml +++ b/src/res/terrains.xml @@ -1,9 +1,9 @@ - + - + @@ -15,7 +15,7 @@ - + @@ -24,7 +24,7 @@ - + @@ -33,7 +33,7 @@ - + @@ -42,7 +42,7 @@ - + @@ -51,7 +51,7 @@ - + @@ -60,7 +60,7 @@ - + @@ -69,7 +69,7 @@ - + @@ -77,26 +77,26 @@ - + - - + + - + - + - - - + + +