forked from github/server
luxusgut-korrektur in neu erschaffenen Inseln.
This commit is contained in:
parent
192a52a4b6
commit
61e63eed3c
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
/* kernel includes */
|
/* kernel includes */
|
||||||
#include <kernel/alliance.h>
|
#include <kernel/alliance.h>
|
||||||
|
#include <kernel/item.h>
|
||||||
#include <kernel/region.h>
|
#include <kernel/region.h>
|
||||||
#include <kernel/plane.h>
|
#include <kernel/plane.h>
|
||||||
#include <kernel/faction.h>
|
#include <kernel/faction.h>
|
||||||
|
@ -32,6 +33,126 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
count_demand(const region *r)
|
||||||
|
{
|
||||||
|
struct demand *dmd;
|
||||||
|
int c = 0;
|
||||||
|
if (r->land) {
|
||||||
|
for (dmd=r->land->demands;dmd;dmd=dmd->next) c++;
|
||||||
|
}
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
recurse_regions(region *r, region_list **rlist, boolean(*fun)(const region *r))
|
||||||
|
{
|
||||||
|
if (!fun(r)) return 0;
|
||||||
|
else {
|
||||||
|
int len = 0;
|
||||||
|
direction_t d;
|
||||||
|
region_list * rl = calloc(sizeof(region_list), 1);
|
||||||
|
rl->next = *rlist;
|
||||||
|
rl->data = r;
|
||||||
|
(*rlist) = rl;
|
||||||
|
fset(r, FL_MARK);
|
||||||
|
for (d=0;d!=MAXDIRECTIONS;++d) {
|
||||||
|
region * nr = rconnect(r, d);
|
||||||
|
if (nr && !fval(nr, FL_MARK)) len += recurse_regions(nr, rlist, fun);
|
||||||
|
}
|
||||||
|
return len+1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int maxluxuries = 0;
|
||||||
|
|
||||||
|
static boolean
|
||||||
|
f_nolux(const region * r)
|
||||||
|
{
|
||||||
|
if (r->land && count_demand(r) != maxluxuries) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
fix_demand(region *r)
|
||||||
|
{
|
||||||
|
region_list *rl, *rlist = NULL;
|
||||||
|
static const struct luxury_type **mlux = 0, ** ltypes;
|
||||||
|
const luxury_type *sale = NULL;
|
||||||
|
int maxlux = 0;
|
||||||
|
|
||||||
|
if (maxluxuries==0) for (sale=luxurytypes;sale;sale=sale->next) {
|
||||||
|
++maxluxuries;
|
||||||
|
}
|
||||||
|
recurse_regions(r, &rlist, f_nolux);
|
||||||
|
if (mlux==0) {
|
||||||
|
int i = 0;
|
||||||
|
mlux = (const luxury_type **)gc_add(calloc(maxluxuries, sizeof(const luxury_type *)));
|
||||||
|
ltypes = (const luxury_type **)gc_add(calloc(maxluxuries, sizeof(const luxury_type *)));
|
||||||
|
for (sale=luxurytypes;sale;sale=sale->next) {
|
||||||
|
ltypes[i++] = sale;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
int i;
|
||||||
|
for (i=0;i!=maxluxuries;++i) mlux[i] = 0;
|
||||||
|
}
|
||||||
|
for (rl=rlist;rl;rl=rl->next) {
|
||||||
|
region * r = rl->data;
|
||||||
|
direction_t d;
|
||||||
|
for (d=0;d!=MAXDIRECTIONS;++d) {
|
||||||
|
region * nr = rconnect(r, d);
|
||||||
|
if (nr && nr->land && nr->land->demands) {
|
||||||
|
struct demand * dmd;
|
||||||
|
for (dmd = nr->land->demands;dmd;dmd=dmd->next) {
|
||||||
|
if (dmd->value == 0) {
|
||||||
|
int i;
|
||||||
|
for (i=0;i!=maxluxuries;++i) {
|
||||||
|
if (mlux[i]==NULL) {
|
||||||
|
maxlux = i;
|
||||||
|
mlux[i] = dmd->type;
|
||||||
|
break;
|
||||||
|
} else if (mlux[i]==dmd->type) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
freset(r, FL_MARK); /* undo recursive marker */
|
||||||
|
}
|
||||||
|
if (maxlux<2) {
|
||||||
|
int i;
|
||||||
|
for (i=maxlux;i!=2;++i) {
|
||||||
|
int j;
|
||||||
|
do {
|
||||||
|
int k = rand() % maxluxuries;
|
||||||
|
mlux[i] = ltypes[k];
|
||||||
|
for (j=0;j!=i;++j) {
|
||||||
|
if (mlux[j]==mlux[i]) break;
|
||||||
|
}
|
||||||
|
} while (j!=i);
|
||||||
|
}
|
||||||
|
maxlux=2;
|
||||||
|
}
|
||||||
|
for (rl=rlist;rl;rl=rl->next) {
|
||||||
|
region * r = rl->data;
|
||||||
|
if (!fval(r, RF_CHAOTIC)) {
|
||||||
|
log_warning(("fixing demand in %s\n", regionname(r, NULL)));
|
||||||
|
}
|
||||||
|
setluxuries(r, mlux[rand() % maxlux]);
|
||||||
|
}
|
||||||
|
while (rlist) {
|
||||||
|
rl = rlist->next;
|
||||||
|
free(rlist);
|
||||||
|
rlist = rl;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
newfaction *
|
newfaction *
|
||||||
read_newfactions(const char * filename)
|
read_newfactions(const char * filename)
|
||||||
{
|
{
|
||||||
|
@ -47,10 +168,12 @@ read_newfactions(const char * filename)
|
||||||
|
|
||||||
if (alliances!=NULL) {
|
if (alliances!=NULL) {
|
||||||
/* email;race;locale;startbonus;subscription;alliance */
|
/* email;race;locale;startbonus;subscription;alliance */
|
||||||
if (fscanf(F, "%s %s %s %d %d %s %d", email, race, lang, &bonus, &subscription, password, &alliance)<=0) break;
|
if (fscanf(F, "%s %s %s %d %d %s %d", email, race, lang, &bonus,
|
||||||
|
&subscription, password, &alliance)<=0) break;
|
||||||
} else {
|
} else {
|
||||||
/* email;race;locale;startbonus;subscription */
|
/* email;race;locale;startbonus;subscription */
|
||||||
if (fscanf(F, "%s %s %s %d %d %s", email, race, lang, &bonus, &subscription, password)<=0) break;
|
if (fscanf(F, "%s %s %s %d %d %s", email, race, lang, &bonus,
|
||||||
|
&subscription, password)<=0) break;
|
||||||
}
|
}
|
||||||
for (f=factions;f;f=f->next) {
|
for (f=factions;f;f=f->next) {
|
||||||
if (strcmp(f->email, email)==0 && f->subscription) break;
|
if (strcmp(f->email, email)==0 && f->subscription) break;
|
||||||
|
@ -62,7 +185,8 @@ read_newfactions(const char * filename)
|
||||||
if (nf) continue;
|
if (nf) continue;
|
||||||
nf = calloc(sizeof(newfaction), 1);
|
nf = calloc(sizeof(newfaction), 1);
|
||||||
if (set_email(&nf->email, email)!=0) {
|
if (set_email(&nf->email, email)!=0) {
|
||||||
log_error(("Invalid email address for subscription %s: %s\n", itoa36(subscription), email));
|
log_error(("Invalid email address for subscription %s: %s\n",
|
||||||
|
itoa36(subscription), email));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
nf->password = strdup(password);
|
nf->password = strdup(password);
|
||||||
|
@ -346,7 +470,7 @@ autoseed(newfaction ** players, int nsize)
|
||||||
*/
|
*/
|
||||||
for (r=regions;r;r=r->next) {
|
for (r=regions;r;r=r->next) {
|
||||||
struct plane * p = rplane(r);
|
struct plane * p = rplane(r);
|
||||||
if (r->terrain==T_OCEAN && p==NULL && (rmin==NULL || r->age<=MAXAGEDIFF)) {
|
if (r->terrain==T_OCEAN && p==0 && (rmin==NULL || r->age<=MAXAGEDIFF)) {
|
||||||
direction_t d;
|
direction_t d;
|
||||||
for (d=0;d!=MAXDIRECTIONS;++d) {
|
for (d=0;d!=MAXDIRECTIONS;++d) {
|
||||||
if (rconnect(r, d)==NULL) break;
|
if (rconnect(r, d)==NULL) break;
|
||||||
|
@ -374,82 +498,87 @@ autoseed(newfaction ** players, int nsize)
|
||||||
rsize = 1;
|
rsize = 1;
|
||||||
|
|
||||||
while (rsize && (nsize || isize>=REGIONS_PER_FACTION)) {
|
while (rsize && (nsize || isize>=REGIONS_PER_FACTION)) {
|
||||||
int i = rand() % rsize;
|
int i = rand() % rsize;
|
||||||
region_list ** rnext = &rlist;
|
region_list ** rnext = &rlist;
|
||||||
direction_t d;
|
direction_t d;
|
||||||
while (i--) rnext=&(*rnext)->next;
|
while (i--) rnext=&(*rnext)->next;
|
||||||
r = (*rnext)->data;
|
r = (*rnext)->data;
|
||||||
*rnext = (*rnext)->next;
|
*rnext = (*rnext)->next;
|
||||||
--rsize;
|
--rsize;
|
||||||
for (d=0;d!=MAXDIRECTIONS;++d) {
|
for (d=0;d!=MAXDIRECTIONS;++d) {
|
||||||
region * rn = rconnect(r, d);
|
region * rn = rconnect(r, d);
|
||||||
if (virgin_region(rn)) {
|
if (virgin_region(rn)) {
|
||||||
if (rn==NULL) {
|
if (rn==NULL) {
|
||||||
rn = new_region(r->x + delta_x[d], r->y + delta_y[d]);
|
rn = new_region(r->x + delta_x[d], r->y + delta_y[d]);
|
||||||
terraform(rn, T_OCEAN);
|
terraform(rn, T_OCEAN);
|
||||||
}
|
}
|
||||||
add_regionlist(&rlist, rn);
|
add_regionlist(&rlist, rn);
|
||||||
++rsize;
|
++rsize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (rand() % VOLCANO_CHANCE == 0) {
|
if (rand() % VOLCANO_CHANCE == 0) {
|
||||||
terraform(r, T_VOLCANO);
|
terraform(r, T_VOLCANO);
|
||||||
} else if (nsize && (rand() % isize == 0 || rsize==0)) {
|
} else if (nsize && (rand() % isize == 0 || rsize==0)) {
|
||||||
newfaction ** nfp, * nextf = *players;
|
newfaction ** nfp, * nextf = *players;
|
||||||
unit * u;
|
unit * u;
|
||||||
|
|
||||||
isize += REGIONS_PER_FACTION;
|
isize += REGIONS_PER_FACTION;
|
||||||
terraform(r, preferred_terrain(nextf->race));
|
terraform(r, preferred_terrain(nextf->race));
|
||||||
++tsize;
|
++tsize;
|
||||||
u = addplayer(r, addfaction(nextf->email, nextf->password, nextf->race, nextf->lang,
|
u = addplayer(r, addfaction(nextf->email, nextf->password, nextf->race,
|
||||||
nextf->subscription));
|
nextf->lang, nextf->subscription));
|
||||||
u->faction->alliance = nextf->allies;
|
u->faction->alliance = nextf->allies;
|
||||||
|
|
||||||
/* remove duplicate email addresses */
|
/* remove duplicate email addresses */
|
||||||
nfp = players;
|
nfp = players;
|
||||||
while (*nfp) {
|
while (*nfp) {
|
||||||
newfaction * nf = *nfp;
|
newfaction * nf = *nfp;
|
||||||
if (strcmp(nextf->email, nf->email)==0) {
|
if (strcmp(nextf->email, nf->email)==0) {
|
||||||
*nfp = nf->next;
|
*nfp = nf->next;
|
||||||
if (nextf!=nf) free(nf);
|
if (nextf!=nf) free(nf);
|
||||||
}
|
}
|
||||||
else nfp = &nf->next;
|
else nfp = &nf->next;
|
||||||
}
|
}
|
||||||
++psize;
|
++psize;
|
||||||
--nsize;
|
--nsize;
|
||||||
--isize;
|
--isize;
|
||||||
if (psize>=PLAYERS_PER_ISLAND) break;
|
if (psize>=PLAYERS_PER_ISLAND) break;
|
||||||
} else {
|
} else {
|
||||||
terraform(r, (terrain_t)((rand() % T_GLACIER)+1));
|
terraform(r, (terrain_t)((rand() % T_GLACIER)+1));
|
||||||
--isize;
|
--isize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (r!=NULL) {
|
||||||
|
/* reicht das? */
|
||||||
|
fix_demand(r);
|
||||||
|
}
|
||||||
|
|
||||||
if (nsize!=0) {
|
if (nsize!=0) {
|
||||||
log_error(("Could not place all factions on the same island as requested\n"));
|
log_error(("Could not place all factions on the same island as requested\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (rlist) {
|
if (rlist) {
|
||||||
#define MINOCEANDIST 3
|
#define MINOCEANDIST 3
|
||||||
#define MAXFILLDIST 10
|
#define MAXFILLDIST 10
|
||||||
#define SPECIALCHANCE 80
|
#define SPECIALCHANCE 80
|
||||||
region_list ** rbegin = &rlist;
|
region_list ** rbegin = &rlist;
|
||||||
int i;
|
int i;
|
||||||
int special = 1;
|
int special = 1;
|
||||||
|
|
||||||
for (i=0;i!=MINOCEANDIST;++i) {
|
for (i=0;i!=MINOCEANDIST;++i) {
|
||||||
region_list ** rend = rbegin;
|
region_list ** rend = rbegin;
|
||||||
while (*rend) rend=&(*rend)->next;
|
while (*rend) rend=&(*rend)->next;
|
||||||
while (rbegin!=rend) {
|
while (rbegin!=rend) {
|
||||||
direction_t d;
|
direction_t d;
|
||||||
region * r = (*rbegin)->data;
|
region * r = (*rbegin)->data;
|
||||||
rbegin=&(*rbegin)->next;
|
rbegin=&(*rbegin)->next;
|
||||||
for (d=0;d!=MAXDIRECTIONS;++d) {
|
for (d=0;d!=MAXDIRECTIONS;++d) {
|
||||||
region * rn = rconnect(r, d);
|
region * rn = rconnect(r, d);
|
||||||
if (rn==NULL) {
|
if (rn==NULL) {
|
||||||
terrain_t terrain = T_OCEAN;
|
terrain_t terrain = T_OCEAN;
|
||||||
rn = new_region(r->x + delta_x[d], r->y + delta_y[d]);
|
rn = new_region(r->x + delta_x[d], r->y + delta_y[d]);
|
||||||
if (rand() % SPECIALCHANCE < special) {
|
if (rand() % SPECIALCHANCE < special) {
|
||||||
terrain = (terrain_t)(1 + rand() % T_GLACIER);
|
terrain = (terrain_t)(1 + rand() % T_GLACIER);
|
||||||
special = SPECIALCHANCE / 3; /* 33% chance auf noch eines */
|
special = SPECIALCHANCE / 3; /* 33% chance auf noch eines */
|
||||||
|
@ -461,31 +590,31 @@ autoseed(newfaction ** players, int nsize)
|
||||||
if (rand() % 100 < 15) rsetlaen(r, 5 + rand() % 5);
|
if (rand() % 100 < 15) rsetlaen(r, 5 + rand() % 5);
|
||||||
/* the new region has an extra 20% chance to have mallorn */
|
/* the new region has an extra 20% chance to have mallorn */
|
||||||
if (rand() % 100 < 20) fset(r, RF_MALLORN);
|
if (rand() % 100 < 20) fset(r, RF_MALLORN);
|
||||||
add_regionlist(rend, rn);
|
add_regionlist(rend, rn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
while (*rbegin) {
|
while (*rbegin) {
|
||||||
region * r = (*rbegin)->data;
|
region * r = (*rbegin)->data;
|
||||||
direction_t d;
|
direction_t d;
|
||||||
rbegin=&(*rbegin)->next;
|
rbegin=&(*rbegin)->next;
|
||||||
for (d=0;d!=MAXDIRECTIONS;++d) if (rconnect(r, d)==NULL) {
|
for (d=0;d!=MAXDIRECTIONS;++d) if (rconnect(r, d)==NULL) {
|
||||||
int i;
|
int i;
|
||||||
for (i=1;i!=MAXFILLDIST;++i) {
|
for (i=1;i!=MAXFILLDIST;++i) {
|
||||||
if (findregion(r->x + i*delta_x[d], r->y + i*delta_y[d]))
|
if (findregion(r->x + i*delta_x[d], r->y + i*delta_y[d]))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
if (i!=MAXFILLDIST) {
|
if (i!=MAXFILLDIST) {
|
||||||
while (--i) {
|
while (--i) {
|
||||||
region * rn = new_region(r->x + i*delta_x[d], r->y + i*delta_y[d]);
|
region * rn = new_region(r->x + i*delta_x[d], r->y + i*delta_y[d]);
|
||||||
terraform(rn, T_OCEAN);
|
terraform(rn, T_OCEAN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return tsize;
|
return tsize;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,20 +21,21 @@ struct region_list;
|
||||||
struct newfaction;
|
struct newfaction;
|
||||||
|
|
||||||
typedef struct newfaction {
|
typedef struct newfaction {
|
||||||
struct newfaction * next;
|
struct newfaction * next;
|
||||||
char * email;
|
char * email;
|
||||||
char * password;
|
char * password;
|
||||||
const struct locale * lang;
|
const struct locale * lang;
|
||||||
const struct race * race;
|
const struct race * race;
|
||||||
int bonus;
|
int bonus;
|
||||||
int subscription;
|
int subscription;
|
||||||
boolean oldregions;
|
boolean oldregions;
|
||||||
struct alliance * allies;
|
struct alliance * allies;
|
||||||
} newfaction;
|
} newfaction;
|
||||||
|
|
||||||
extern int autoseed(newfaction ** players, int nsize);
|
extern int autoseed(newfaction ** players, int nsize);
|
||||||
extern newfaction * read_newfactions(const char * filename);
|
extern newfaction * read_newfactions(const char * filename);
|
||||||
extern void get_island(struct region * root, struct region_list ** rlist);
|
extern void get_island(struct region * root, struct region_list ** rlist);
|
||||||
|
extern int fix_demand(struct region *r);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include <attributes/key.h>
|
#include <attributes/key.h>
|
||||||
#include <attributes/otherfaction.h>
|
#include <attributes/otherfaction.h>
|
||||||
#include <modules/xecmd.h>
|
#include <modules/xecmd.h>
|
||||||
|
#include <modules/autoseed.h>
|
||||||
|
|
||||||
/* gamecode includes */
|
/* gamecode includes */
|
||||||
#include <gamecode/economy.h>
|
#include <gamecode/economy.h>
|
||||||
|
@ -330,127 +331,6 @@ fix_age(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 1
|
|
||||||
static int
|
|
||||||
count_demand(const region *r)
|
|
||||||
{
|
|
||||||
struct demand *dmd;
|
|
||||||
int c = 0;
|
|
||||||
if (r->land) {
|
|
||||||
for (dmd=r->land->demands;dmd;dmd=dmd->next) c++;
|
|
||||||
}
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static int
|
|
||||||
recurse_regions(region * r, region_list **rlist, boolean(*fun)(const region * r))
|
|
||||||
{
|
|
||||||
if (!fun(r)) return 0;
|
|
||||||
else {
|
|
||||||
int len = 0;
|
|
||||||
direction_t d;
|
|
||||||
region_list * rl = calloc(sizeof(region_list), 1);
|
|
||||||
rl->next = *rlist;
|
|
||||||
rl->data = r;
|
|
||||||
(*rlist) = rl;
|
|
||||||
fset(r, FL_MARK);
|
|
||||||
for (d=0;d!=MAXDIRECTIONS;++d) {
|
|
||||||
region * nr = rconnect(r, d);
|
|
||||||
if (nr && !fval(nr, FL_MARK)) len += recurse_regions(nr, rlist, fun);
|
|
||||||
}
|
|
||||||
return len+1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#if 1
|
|
||||||
static int maxluxuries = 0;
|
|
||||||
|
|
||||||
static boolean
|
|
||||||
f_nolux(const region * r)
|
|
||||||
{
|
|
||||||
if (r->land && count_demand(r) != maxluxuries) return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
fix_demand_region(region *r)
|
|
||||||
{
|
|
||||||
region_list *rl, *rlist = NULL;
|
|
||||||
static const luxury_type **mlux = 0, ** ltypes;
|
|
||||||
const luxury_type *sale = NULL;
|
|
||||||
int maxlux = 0;
|
|
||||||
|
|
||||||
recurse_regions(r, &rlist, f_nolux);
|
|
||||||
if (mlux==0) {
|
|
||||||
int i = 0;
|
|
||||||
if (maxluxuries==0) for (sale=luxurytypes;sale;sale=sale->next) {
|
|
||||||
maxluxuries++;
|
|
||||||
}
|
|
||||||
mlux = (const luxury_type **)gc_add(calloc(maxluxuries, sizeof(const luxury_type *)));
|
|
||||||
ltypes = (const luxury_type **)gc_add(calloc(maxluxuries, sizeof(const luxury_type *)));
|
|
||||||
for (sale=luxurytypes;sale;sale=sale->next) {
|
|
||||||
ltypes[i++] = sale;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
int i;
|
|
||||||
for (i=0;i!=maxluxuries;++i) mlux[i] = 0;
|
|
||||||
}
|
|
||||||
for (rl=rlist;rl;rl=rl->next) {
|
|
||||||
region * r = rl->data;
|
|
||||||
direction_t d;
|
|
||||||
for (d=0;d!=MAXDIRECTIONS;++d) {
|
|
||||||
region * nr = rconnect(r, d);
|
|
||||||
if (nr && nr->land && nr->land->demands) {
|
|
||||||
struct demand * dmd;
|
|
||||||
for (dmd = nr->land->demands;dmd;dmd=dmd->next) {
|
|
||||||
if (dmd->value == 0) {
|
|
||||||
int i;
|
|
||||||
for (i=0;i!=maxluxuries;++i) {
|
|
||||||
if (mlux[i]==NULL) {
|
|
||||||
maxlux = i;
|
|
||||||
mlux[i] = dmd->type;
|
|
||||||
break;
|
|
||||||
} else if (mlux[i]==dmd->type) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
freset(r, FL_MARK); /* undo recursive marker */
|
|
||||||
}
|
|
||||||
if (maxlux<2) {
|
|
||||||
int i;
|
|
||||||
for (i=maxlux;i!=2;++i) {
|
|
||||||
int j;
|
|
||||||
do {
|
|
||||||
int k = rand() % maxluxuries;
|
|
||||||
mlux[i] = ltypes[k];
|
|
||||||
for (j=0;j!=i;++j) {
|
|
||||||
if (mlux[j]==mlux[i]) break;
|
|
||||||
}
|
|
||||||
} while (j!=i);
|
|
||||||
}
|
|
||||||
maxlux=2;
|
|
||||||
}
|
|
||||||
for (rl=rlist;rl;rl=rl->next) {
|
|
||||||
region * r = rl->data;
|
|
||||||
if (!fval(r, RF_CHAOTIC)) log_warning(("fixing demand in %s\n", regionname(r, NULL)));
|
|
||||||
setluxuries(r, mlux[rand() % maxlux]);
|
|
||||||
}
|
|
||||||
while (rlist) {
|
|
||||||
rl = rlist->next;
|
|
||||||
free(rlist);
|
|
||||||
rlist = rl;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
fix_firewalls(void)
|
fix_firewalls(void)
|
||||||
|
@ -532,23 +412,25 @@ update_gms(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 1
|
static int maxluxuries = 0;
|
||||||
|
|
||||||
static int
|
static int
|
||||||
fix_demand(void)
|
fix_demands(void)
|
||||||
{
|
{
|
||||||
region *r;
|
region *r;
|
||||||
const luxury_type *sale = NULL;
|
const luxury_type *sale = NULL;
|
||||||
|
|
||||||
if (maxluxuries==0) for (sale=luxurytypes;sale;sale=sale->next) ++maxluxuries;
|
if (maxluxuries==0) for (sale=luxurytypes;sale;sale=sale->next) ++maxluxuries;
|
||||||
|
|
||||||
for (r=regions; r; r=r->next) {
|
for (r=regions; r; r=r->next) {
|
||||||
if (r->land!=NULL && r->land->peasants>=100 && count_demand(r) != maxluxuries) {
|
if (r->land!=NULL && r->land->peasants>=100) {
|
||||||
fix_demand_region(r);
|
if (count_demand(r) != maxluxuries) {
|
||||||
}
|
fix_demand(r);
|
||||||
}
|
}
|
||||||
return 0;
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "group.h"
|
#include "group.h"
|
||||||
static void
|
static void
|
||||||
|
@ -1105,27 +987,27 @@ korrektur(void)
|
||||||
if (!ExpensiveMigrants()) {
|
if (!ExpensiveMigrants()) {
|
||||||
no_teurefremde(true);
|
no_teurefremde(true);
|
||||||
}
|
}
|
||||||
fix_allies();
|
fix_allies();
|
||||||
update_gmquests(); /* test gm quests */
|
update_gmquests(); /* test gm quests */
|
||||||
/* fix_unitrefs(); */
|
/* fix_unitrefs(); */
|
||||||
warn_password();
|
warn_password();
|
||||||
fix_road_borders();
|
fix_road_borders();
|
||||||
if (turn>1000) curse_emptiness(); /*** disabled ***/
|
if (turn>1000) curse_emptiness(); /*** disabled ***/
|
||||||
/* seems something fishy is going on, do this just
|
/* seems something fishy is going on, do this just
|
||||||
* to be on the safe side:
|
* to be on the safe side:
|
||||||
*/
|
*/
|
||||||
fix_demand();
|
fix_demands();
|
||||||
fix_otherfaction();
|
fix_otherfaction();
|
||||||
/* trade_orders(); */
|
/* trade_orders(); */
|
||||||
|
|
||||||
/* immer ausführen, wenn neue Sprüche dazugekommen sind, oder sich
|
/* immer ausführen, wenn neue Sprüche dazugekommen sind, oder sich
|
||||||
* Beschreibungen geändert haben */
|
* Beschreibungen geändert haben */
|
||||||
show_newspells();
|
show_newspells();
|
||||||
fix_age();
|
fix_age();
|
||||||
|
|
||||||
/* Immer ausführen! Erschafft neue Teleport-Regionen, wenn nötig */
|
/* Immer ausführen! Erschafft neue Teleport-Regionen, wenn nötig */
|
||||||
create_teleport_plane();
|
create_teleport_plane();
|
||||||
|
|
||||||
#ifdef WDW_PHOENIX
|
#ifdef WDW_PHOENIX
|
||||||
check_phoenix();
|
check_phoenix();
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue