avoid an annoying division by zero when terrains are not fully initialized (size=0)

This commit is contained in:
Enno Rehling 2015-09-11 21:31:59 +02:00
parent db4cb2618b
commit 7c4d18ec2d
1 changed files with 10 additions and 5 deletions

View File

@ -1119,14 +1119,19 @@ void terraform_region(region * r, const terrain_type * terrain)
}
if (oldterrain == NULL || terrain->size != oldterrain->size) {
int horses = 0, trees = 0;
if (terrain->size>0) {
horses = rng_int() % (terrain->size / 50);
trees = terrain->size * (30 + rng_int() % 40) / 1000;
}
if (terrain == newterrain(T_PLAIN)) {
rsethorses(r, rng_int() % (terrain->size / 50));
if (rng_int() % 100 < 40) {
rsettrees(r, 2, terrain->size * (30 + rng_int() % 40) / 1000);
rsethorses(r, horses);
if (chance(0.4)) {
rsettrees(r, 2, trees);
}
}
else if (chance(0.2)) {
rsettrees(r, 2, terrain->size * (30 + rng_int() % 40) / 1000);
else if (trees>0 && chance(0.2)) {
rsettrees(r, 2, trees);
}
else {
rsettrees(r, 2, 0);