diff --git a/src/common/kernel/region.c b/src/common/kernel/region.c index 0e85c43c4..eb71e3373 100644 --- a/src/common/kernel/region.c +++ b/src/common/kernel/region.c @@ -913,9 +913,11 @@ terraform(region * r, terrain_t t) if (landregion(t)) { const char *name = NULL; - - if (terrain[r->terrain].herbs) name = terrain[r->terrain].herbs[rand()%3]; - + if (terrain[r->terrain].herbs) { + int len=0; + while (terrain[r->terrain].herbs[len]) ++len; + if (len) name = terrain[r->terrain].herbs[rand()%len]; + } if (name != NULL) { const item_type * itype = finditemtype(name, locale_de); const herb_type * htype = resource2herb(itype->rtype); diff --git a/src/eressea/korrektur.c b/src/eressea/korrektur.c index a3aa8186a..7e24d1583 100644 --- a/src/eressea/korrektur.c +++ b/src/eressea/korrektur.c @@ -1334,6 +1334,33 @@ fix_herbtypes(void) } #endif +static int +fix_plainherbs(void) +{ + region *r, *lastr; + for (r=regions;r;r=r->next) { + int i; + const char * name; + terrain_t t = rterrain(r); + if (t!=T_PLAIN) continue; + name = LOC(default_locale, rherbtype(r)->itype->rtype->_name[0]); + for (i=0;i!=3;++i) if (strcmp(terrain[t].herbs[i], name)==0) break; + if (i!=3) lastr=r->next; + r=r->next; + } + for (r=lastr;r;r=r->next) { + terrain_t t = rterrain(r); + if (t!=T_PLAIN) continue; + if (rand()%2) { + const char * name = terrain[t].herbs[3+rand()%3]; + const item_type * itype = finditemtype(name, default_locale); + const herb_type * htype = resource2herb(itype->rtype); + rsetherbtype(r, htype); + } + } + return 0; +} + #ifdef SKILLFIX_SAVE typedef struct skillfix_data { unit * u; @@ -2685,6 +2712,7 @@ korrektur(void) stats(); do_once("sql2", dump_sql()); do_once("fw01", fix_watchers()); + do_once("fixh", fix_plainherbs()); #if NEW_RESOURCEGROWTH /* do not remove do_once calls - old datafiles need them! */ do_once("rgrw", convert_resources()); diff --git a/src/mapper/logging.c b/src/mapper/logging.c index 022f86790..deb620927 100644 --- a/src/mapper/logging.c +++ b/src/mapper/logging.c @@ -46,7 +46,10 @@ log_read(const char * filename) fscanf(log, "%s %d %d", buf, &x, &y); u = readunit(log); r = findregion(x, y); - assert(r); + if (r==NULL) { + r = new_region(x, y); + terraform(r, T_PLAIN); + } if (u->region!=r) move_unit(u, r, NULL); } else if (strcmp(buf, "REGION")==0) { int x, y;