terraforming changes herbs

https://bugs.eressea.de/view.php?id=2730
This commit is contained in:
Enno Rehling 2021-03-18 18:35:25 +01:00
parent 738ddfc2e5
commit 316188531e
2 changed files with 28 additions and 23 deletions

View File

@ -1102,6 +1102,31 @@ void init_region(region *r)
} }
} }
static void reset_herbs(region *r) {
const item_type *itype = NULL;
if (r->terrain->herbs) {
int len = 0;
while (r->terrain->herbs[len])
++len;
if (len)
itype = r->terrain->herbs[rng_int() % len];
}
if (itype != NULL) {
rsetherbtype(r, itype);
rsetherbs(r, 50 + rng_int() % 31);
}
else {
rsetherbtype(r, NULL);
}
if (rng_int() % 100 < 3) {
fset(r, RF_MALLORN);
}
else {
freset(r, RF_MALLORN);
}
}
/* Resourcen loeschen, die im aktuellen terrain nicht (mehr) vorkommen koennen */ /* Resourcen loeschen, die im aktuellen terrain nicht (mehr) vorkommen koennen */
static void reset_rawmaterials(region *r) { static void reset_rawmaterials(region *r) {
const terrain_type * terrain = r->terrain; const terrain_type * terrain = r->terrain;
@ -1208,28 +1233,7 @@ static void create_land(region *r) {
nb = NULL; nb = NULL;
} }
const item_type *itype = NULL; reset_herbs(r);
if (r->terrain->herbs) {
int len = 0;
while (r->terrain->herbs[len])
++len;
if (len)
itype = r->terrain->herbs[rng_int() % len];
}
if (itype != NULL) {
rsetherbtype(r, itype);
rsetherbs(r, 50 + rng_int() % 31);
}
else {
rsetherbtype(r, NULL);
}
if (rng_int() % 100 < 3) {
fset(r, RF_MALLORN);
}
else {
freset(r, RF_MALLORN);
}
} }
void terraform_region(region * r, const terrain_type * terrain) void terraform_region(region * r, const terrain_type * terrain)
@ -1238,6 +1242,7 @@ void terraform_region(region * r, const terrain_type * terrain)
assert(terrain); assert(terrain);
r->terrain = terrain; r->terrain = terrain;
reset_herbs(r);
reset_rawmaterials(r); reset_rawmaterials(r);
terraform_resources(r); terraform_resources(r);

View File

@ -188,7 +188,7 @@ extern "C" {
#define rbuildings(r) ((r)->buildings) #define rbuildings(r) ((r)->buildings)
#define rherbtype(r) ((r)->land?(r)->land->herbtype:0) #define rherbtype(r) ((r)->land?(r)->land->herbtype:NULL)
bool r_isforest(const struct region *r); bool r_isforest(const struct region *r);