forked from github/server
bugfix terraforming in regionen ohne production
This commit is contained in:
parent
e8746177bc
commit
76976a970e
|
@ -62,34 +62,35 @@ update_resource(struct rawmaterial * res, double modifier)
|
||||||
void
|
void
|
||||||
terraform_resources(region * r)
|
terraform_resources(region * r)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
const terrain_type * terrain = r->terrain;
|
const terrain_type * terrain = r->terrain;
|
||||||
|
|
||||||
for (i=0;terrain->production[i].type; ++i) {
|
if (terrain->production==NULL) return;
|
||||||
rawmaterial *rm;
|
for (i=0;terrain->production[i].type; ++i) {
|
||||||
|
rawmaterial *rm;
|
||||||
const terrain_production * production = terrain->production+i;
|
const terrain_production * production = terrain->production+i;
|
||||||
const resource_type * rtype = production->type;
|
const resource_type * rtype = production->type;
|
||||||
|
|
||||||
for (rm=r->resources; rm; rm=rm->next) {
|
for (rm=r->resources; rm; rm=rm->next) {
|
||||||
if (rm->type->rtype == rtype) break;
|
if (rm->type->rtype == rtype) break;
|
||||||
}
|
}
|
||||||
if (rm) continue;
|
if (rm) continue;
|
||||||
|
|
||||||
if (chance(production->chance)) {
|
if (chance(production->chance)) {
|
||||||
rm = calloc(sizeof(struct rawmaterial), 1);
|
rm = calloc(sizeof(struct rawmaterial), 1);
|
||||||
|
|
||||||
rm->next = r->resources;
|
rm->next = r->resources;
|
||||||
r->resources = rm;
|
r->resources = rm;
|
||||||
rm->level = dice_rand(production->startlevel);
|
rm->level = dice_rand(production->startlevel);
|
||||||
rm->startlevel = rm->level;
|
rm->startlevel = rm->level;
|
||||||
rm->base = dice_rand(production->base);
|
rm->base = dice_rand(production->base);
|
||||||
rm->divisor = dice_rand(production->divisor);
|
rm->divisor = dice_rand(production->divisor);
|
||||||
rm->flags = 0;
|
rm->flags = 0;
|
||||||
rm->type = rmt_get(production->type);
|
rm->type = rmt_get(production->type);
|
||||||
update_resource(rm, 1.0);
|
update_resource(rm, 1.0);
|
||||||
rm->type->terraform(rm, r);
|
rm->type->terraform(rm, r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in New Issue