forked from github/server
BUG 2459 Regionen recycling macht ein Reset der Rohstoffe.
This commit is contained in:
parent
de7248fb5a
commit
ced21cc336
3 changed files with 62 additions and 41 deletions
29
src/gmtool.c
29
src/gmtool.c
|
@ -531,17 +531,32 @@ static void statusline(WINDOW * win, const char *str)
|
|||
}
|
||||
|
||||
static void reset_region(region *r) {
|
||||
unit **up = &r->units;
|
||||
bool players = false;
|
||||
|
||||
set_chaoscount(r, 0);
|
||||
r->flags = 0;
|
||||
a_removeall(&r->attribs, NULL);
|
||||
while (r->units) {
|
||||
remove_unit(&r->units, r->units);
|
||||
while (*up) {
|
||||
unit *u = *up;
|
||||
if (is_monsters(u->faction)) {
|
||||
remove_unit(up, u);
|
||||
}
|
||||
else {
|
||||
players = true;
|
||||
up = &u->next;
|
||||
}
|
||||
}
|
||||
while (r->ships) {
|
||||
remove_ship(&r->ships, r->ships);
|
||||
}
|
||||
while (r->buildings) {
|
||||
remove_building(&r->buildings, r->buildings);
|
||||
if (!players) {
|
||||
while (r->ships) {
|
||||
remove_ship(&r->ships, r->ships);
|
||||
}
|
||||
while (r->buildings) {
|
||||
remove_building(&r->buildings, r->buildings);
|
||||
}
|
||||
if (r->land) {
|
||||
init_region(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1048,6 +1048,43 @@ int fix_demand(region * rd) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
void init_region(region *r)
|
||||
{
|
||||
static int changed;
|
||||
static const terrain_type *t_plain;
|
||||
const terrain_type * terrain = r->terrain;
|
||||
int horses = 0, trees = 0;
|
||||
if (terrain_changed(&changed)) {
|
||||
t_plain = get_terrain(terrainnames[T_PLAIN]);
|
||||
}
|
||||
if (terrain->size>0) {
|
||||
horses = rng_int() % (terrain->size / 50);
|
||||
trees = terrain->size * (30 + rng_int() % 40) / 1000;
|
||||
}
|
||||
if (t_plain && terrain == t_plain) {
|
||||
rsethorses(r, horses);
|
||||
if (chance(0.4)) {
|
||||
rsettrees(r, 2, trees);
|
||||
}
|
||||
}
|
||||
else if (trees>0 && chance(0.2)) {
|
||||
rsettrees(r, 2, trees);
|
||||
}
|
||||
else {
|
||||
rsettrees(r, 2, 0);
|
||||
}
|
||||
rsettrees(r, 1, rtrees(r, 2) / 4);
|
||||
rsettrees(r, 0, rtrees(r, 2) / 8);
|
||||
|
||||
if (!fval(r, RF_CHAOTIC)) {
|
||||
int peasants;
|
||||
peasants = (region_maxworkers(r) * (20 + dice(6, 10))) / 100;
|
||||
rsetpeasants(r, MAX(100, peasants));
|
||||
rsetmoney(r, rpeasants(r) * ((wage(r, NULL, NULL,
|
||||
INT_MAX) + 1) + rng_int() % 5));
|
||||
}
|
||||
}
|
||||
|
||||
void terraform_region(region * r, const terrain_type * terrain)
|
||||
{
|
||||
/* Resourcen, die nicht mehr vorkommen können, löschen */
|
||||
|
@ -1195,40 +1232,8 @@ void terraform_region(region * r, const terrain_type * terrain)
|
|||
else
|
||||
freset(r, RF_MALLORN);
|
||||
}
|
||||
}
|
||||
|
||||
if (oldterrain == NULL || terrain->size != oldterrain->size) {
|
||||
static int changed;
|
||||
static const terrain_type *t_plain;
|
||||
int horses = 0, trees = 0;
|
||||
if (terrain_changed(&changed)) {
|
||||
t_plain = get_terrain(terrainnames[T_PLAIN]);
|
||||
}
|
||||
if (terrain->size>0) {
|
||||
horses = rng_int() % (terrain->size / 50);
|
||||
trees = terrain->size * (30 + rng_int() % 40) / 1000;
|
||||
}
|
||||
if (t_plain && terrain == t_plain) {
|
||||
rsethorses(r, horses);
|
||||
if (chance(0.4)) {
|
||||
rsettrees(r, 2, trees);
|
||||
}
|
||||
}
|
||||
else if (trees>0 && chance(0.2)) {
|
||||
rsettrees(r, 2, trees);
|
||||
}
|
||||
else {
|
||||
rsettrees(r, 2, 0);
|
||||
}
|
||||
rsettrees(r, 1, rtrees(r, 2) / 4);
|
||||
rsettrees(r, 0, rtrees(r, 2) / 8);
|
||||
|
||||
if (!fval(r, RF_CHAOTIC)) {
|
||||
int peasants;
|
||||
peasants = (region_maxworkers(r) * (20 + dice(6, 10))) / 100;
|
||||
rsetpeasants(r, MAX(100, peasants));
|
||||
rsetmoney(r, rpeasants(r) * ((wage(r, NULL, NULL,
|
||||
INT_MAX) + 1) + rng_int() % 5));
|
||||
if (oldterrain == NULL || terrain->size != oldterrain->size) {
|
||||
init_region(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -228,6 +228,7 @@ extern "C" {
|
|||
struct region *new_region(int x, int y, struct plane *pl, int uid);
|
||||
void remove_region(region ** rlist, region * r);
|
||||
void terraform_region(struct region *r, const struct terrain_type *terrain);
|
||||
void init_region(struct region *r);
|
||||
bool pnormalize(int *x, int *y, const struct plane *pl);
|
||||
|
||||
extern const int delta_x[MAXDIRECTIONS];
|
||||
|
|
Loading…
Reference in a new issue