diff --git a/src/common/gamecode/laws.c b/src/common/gamecode/laws.c index 14a151e7b..a8bfb14a0 100644 --- a/src/common/gamecode/laws.c +++ b/src/common/gamecode/laws.c @@ -722,14 +722,14 @@ extern struct attrib_type at_germs; static void growing_trees_e3(region * r, const int current_season, const int last_weeks_season) { - const int transform[4][3] = { + const static int transform[4][3] = { { -1, -1, 0 }, { TREE_SEED, TREE_SAPLING, 2 }, { TREE_SAPLING, TREE_TREE, 2 }, { TREE_TREE, TREE_SEED, 2 } }; - if (current_season!=last_weeks_season && transform[current_season][2]) { + if (r->land && current_season!=last_weeks_season && transform[current_season][2]) { int src_type = transform[current_season][0]; int dst_type = transform[current_season][1]; int src = rtrees(r, src_type); @@ -737,6 +737,35 @@ growing_trees_e3(region * r, const int current_season, const int last_weeks_seas int grow = src/transform[current_season][2]; rsettrees(r, src_type, src-grow); rsettrees(r, dst_type, dst+grow); + + if (dst_type==TREE_SEED && r->terrain->size) { + region * rn[MAXDIRECTIONS]; + int d, total_size = 0; + get_neighbours(r, rn); + for (d=0;d!=MAXDIRECTIONS;++d) { + if (rn[d] && rn[d]->land) { + total_size += rn[d]->terrain->size; + } + } + if (total_size>0) { + double scale = 1.0; + if (total_sizeterrain->size) { + scale = total_size/(double)r->terrain->size; + } + for (d=0;d!=MAXDIRECTIONS;++d) { + region * rx = rn[d]; + if (rx && rx->land) { + int size = rx->terrain->size; + int d = rtrees(rx, dst_type); + double fg = grow * scale * size / MAXDIRECTIONS / total_size; + int g = (int)fg; + double ch = fg - g; + if (chance(ch)) ++g; + rsettrees(rx, dst_type, d + g); + } + } + } + } } } diff --git a/src/common/kernel/region.c b/src/common/kernel/region.c index 266660efb..53f2c079e 100644 --- a/src/common/kernel/region.c +++ b/src/common/kernel/region.c @@ -1503,6 +1503,15 @@ int region_get_morale(const region * r) void region_set_morale(region * r, int morale) { if (r->land) { - r->land->morale = morale; + r->land->morale = (short)morale; } -} \ No newline at end of file +} + +void get_neighbours(const region * r, region ** list) +{ + direction_t dir; + for (dir=0;dir!=MAXDIRECTIONS;++dir) { + list[dir] = rconnect(r, dir); + } +} + diff --git a/src/common/kernel/region.h b/src/common/kernel/region.h index ac4f020d9..a883b2432 100644 --- a/src/common/kernel/region.h +++ b/src/common/kernel/region.h @@ -276,7 +276,7 @@ int region_getresource(const struct region * r, const struct resource_type * rty void region_setresource(struct region * r, const struct resource_type * rtype, int value); extern const struct item_type * r_luxury(struct region * r); - +extern void get_neighbours(const struct region * r, struct region ** list); #ifdef __cplusplus } #endif diff --git a/src/common/modules/autoseed.c b/src/common/modules/autoseed.c index c1572de08..e007444dc 100644 --- a/src/common/modules/autoseed.c +++ b/src/common/modules/autoseed.c @@ -760,14 +760,6 @@ autoseed(newfaction ** players, int nsize, int max_agediff) return tsize; } -static void get_neighbours(const region * r, region ** list) -{ - direction_t dir; - for (dir=0;dir!=MAXDIRECTIONS;++dir) { - list[dir] = rconnect(r, dir); - } -} - region_list * regionqueue_push(region_list ** rlist, region * r) { region_list * rnew = malloc(sizeof(region_list));