forked from github/server
fix demand in broken regions, after load.
This commit is contained in:
parent
cd69936922
commit
e5dc754c25
|
@ -1009,6 +1009,20 @@ void setluxuries(region * r, const luxury_type * sale)
|
|||
}
|
||||
}
|
||||
|
||||
int fix_demand(region * rd) {
|
||||
luxury_type * ltype;
|
||||
int maxluxuries = get_maxluxuries();
|
||||
if (maxluxuries > 0) {
|
||||
int sale = rng_int() % maxluxuries;
|
||||
for (ltype = luxurytypes; sale != 0 && ltype; ltype = ltype->next) {
|
||||
--sale;
|
||||
}
|
||||
setluxuries(rd, ltype);
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void terraform_region(region * r, const terrain_type * terrain)
|
||||
{
|
||||
/* Resourcen, die nicht mehr vorkommen können, löschen */
|
||||
|
|
|
@ -160,6 +160,7 @@ extern "C" {
|
|||
|
||||
#define reg_hashkey(r) (r->index)
|
||||
|
||||
extern int fix_demand(struct region *r);
|
||||
int distance(const struct region *, const struct region *);
|
||||
int koor_distance(int ax, int ay, int bx, int by);
|
||||
struct region *findregion(int x, int y);
|
||||
|
|
|
@ -1096,6 +1096,9 @@ static region *readregion(struct gamedata *data, int x, int y)
|
|||
READ_INT(data->store, &n);
|
||||
r_setdemand(r, rtype->ltype, n);
|
||||
}
|
||||
if (!r->land->demands) {
|
||||
fix_demand(r);
|
||||
}
|
||||
read_items(data->store, &r->land->items);
|
||||
if (data->version >= REGIONOWNER_VERSION) {
|
||||
READ_INT(data->store, &n);
|
||||
|
|
|
@ -132,20 +132,6 @@ static bool f_nolux(const region * r)
|
|||
return (r->land && count_demand(r) != get_maxluxuries());
|
||||
}
|
||||
|
||||
int fix_demand(region * rd) {
|
||||
luxury_type * ltype;
|
||||
int maxluxuries = get_maxluxuries();
|
||||
if (maxluxuries > 0) {
|
||||
int sale = rng_int() % maxluxuries;
|
||||
for (ltype = luxurytypes; sale != 0 && ltype; ltype = ltype->next) {
|
||||
--sale;
|
||||
}
|
||||
setluxuries(rd, ltype);
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int fix_all_demand(region *rd) {
|
||||
region_list *rl, *rlist = NULL;
|
||||
recurse_regions(rd, &rlist, f_nolux);
|
||||
|
|
|
@ -35,7 +35,6 @@ extern "C" {
|
|||
|
||||
extern int autoseed(newfaction ** players, int nsize, int max_agediff);
|
||||
extern newfaction *read_newfactions(const char *filename);
|
||||
extern int fix_demand(struct region *r);
|
||||
extern const struct terrain_type *random_terrain(const struct terrain_type
|
||||
*terrains[], int distribution[], int size);
|
||||
|
||||
|
|
Loading…
Reference in New Issue