forked from github/server
more code that fails when there are no luxuries
This commit is contained in:
parent
9d1f1d77fe
commit
38062fa990
|
@ -957,7 +957,7 @@ terraform_region(region * r, const terrain_type * terrain)
|
||||||
i-=srd->value;
|
i-=srd->value;
|
||||||
srd=srd->next;
|
srd=srd->next;
|
||||||
}
|
}
|
||||||
setluxuries(r, srd->type);
|
if (srd->type) setluxuries(r, srd->type);
|
||||||
while (srd->next!=NULL) srd=srd->next;
|
while (srd->next!=NULL) srd=srd->next;
|
||||||
srd->next=trash;
|
srd->next=trash;
|
||||||
trash = nb;
|
trash = nb;
|
||||||
|
|
|
@ -91,12 +91,10 @@ recurse_regions(region *r, region_list **rlist, boolean(*fun)(const region *r))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int maxluxuries = 0;
|
|
||||||
|
|
||||||
static boolean
|
static boolean
|
||||||
f_nolux(const region * r)
|
f_nolux(const region * r)
|
||||||
{
|
{
|
||||||
if (r->land && count_demand(r) != maxluxuries) return true;
|
if (r->land && count_demand(r) != get_maxluxuries()) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,10 +105,9 @@ fix_demand(region *r)
|
||||||
static const struct luxury_type **mlux = 0, ** ltypes;
|
static const struct luxury_type **mlux = 0, ** ltypes;
|
||||||
const luxury_type *sale = NULL;
|
const luxury_type *sale = NULL;
|
||||||
int maxlux = 0;
|
int maxlux = 0;
|
||||||
|
int maxluxuries = get_maxluxuries();
|
||||||
|
|
||||||
if (maxluxuries==0) for (sale=luxurytypes;sale;sale=sale->next) {
|
if (maxluxuries==0) return 0;
|
||||||
++maxluxuries;
|
|
||||||
}
|
|
||||||
recurse_regions(r, &rlist, f_nolux);
|
recurse_regions(r, &rlist, f_nolux);
|
||||||
if (mlux==0) {
|
if (mlux==0) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@ -162,14 +159,15 @@ fix_demand(region *r)
|
||||||
}
|
}
|
||||||
} while (j!=i);
|
} while (j!=i);
|
||||||
}
|
}
|
||||||
maxlux=2;
|
maxlux = 2;
|
||||||
}
|
}
|
||||||
for (rl=rlist;rl;rl=rl->next) {
|
for (rl=rlist;rl;rl=rl->next) {
|
||||||
region * r = rl->data;
|
region * r = rl->data;
|
||||||
if (!fval(r, RF_CHAOTIC)) {
|
if (!fval(r, RF_CHAOTIC)) {
|
||||||
log_warning(("fixing demand in %s\n", regionname(r, NULL)));
|
log_warning(("fixing demand in %s\n", regionname(r, NULL)));
|
||||||
}
|
}
|
||||||
setluxuries(r, mlux[rand() % maxlux]);
|
sale = mlux[rand() % maxlux];
|
||||||
|
if (sale) setluxuries(r, sale);
|
||||||
}
|
}
|
||||||
while (rlist) {
|
while (rlist) {
|
||||||
rl = rlist->next;
|
rl = rlist->next;
|
||||||
|
|
|
@ -205,7 +205,7 @@ block_create(short x1, short y1, int size, char chaotisch, int special, const te
|
||||||
} else {
|
} else {
|
||||||
terraform(r, newblock[x][y]);
|
terraform(r, newblock[x][y]);
|
||||||
}
|
}
|
||||||
if (r->land) setluxuries(r, sale);
|
if (r->land && sale) setluxuries(r, sale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue