From 76976a970e2f9a9d7b6715176a0f4bffa9a022d6 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 21 Dec 2005 10:11:19 +0000 Subject: [PATCH] bugfix terraforming in regionen ohne production --- src/common/kernel/resources.c | 47 ++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/src/common/kernel/resources.c b/src/common/kernel/resources.c index 9c6f6fa1a..2dca79513 100644 --- a/src/common/kernel/resources.c +++ b/src/common/kernel/resources.c @@ -62,34 +62,35 @@ update_resource(struct rawmaterial * res, double modifier) void terraform_resources(region * r) { - int i; - const terrain_type * terrain = r->terrain; + int i; + const terrain_type * terrain = r->terrain; - for (i=0;terrain->production[i].type; ++i) { - rawmaterial *rm; + if (terrain->production==NULL) return; + for (i=0;terrain->production[i].type; ++i) { + rawmaterial *rm; const terrain_production * production = terrain->production+i; const resource_type * rtype = production->type; - for (rm=r->resources; rm; rm=rm->next) { - if (rm->type->rtype == rtype) break; - } - if (rm) continue; - - if (chance(production->chance)) { - rm = calloc(sizeof(struct rawmaterial), 1); - - rm->next = r->resources; - r->resources = rm; - rm->level = dice_rand(production->startlevel); - rm->startlevel = rm->level; - rm->base = dice_rand(production->base); - rm->divisor = dice_rand(production->divisor); - rm->flags = 0; - rm->type = rmt_get(production->type); + for (rm=r->resources; rm; rm=rm->next) { + if (rm->type->rtype == rtype) break; + } + if (rm) continue; + + if (chance(production->chance)) { + rm = calloc(sizeof(struct rawmaterial), 1); + + rm->next = r->resources; + r->resources = rm; + rm->level = dice_rand(production->startlevel); + rm->startlevel = rm->level; + rm->base = dice_rand(production->base); + rm->divisor = dice_rand(production->divisor); + rm->flags = 0; + rm->type = rmt_get(production->type); update_resource(rm, 1.0); - rm->type->terraform(rm, r); - } - } + rm->type->terraform(rm, r); + } + } } static void