- new and improved seeding (use oceans)

This commit is contained in:
Enno Rehling 2009-06-26 05:29:25 +00:00
parent bb2397e141
commit a21dbbbadf
4 changed files with 88 additions and 58 deletions

View File

@ -59,7 +59,6 @@ extern void init_potions(void);
extern int get_effect(const struct unit * u, const struct potion_type * effect); extern int get_effect(const struct unit * u, const struct potion_type * effect);
extern int change_effect(struct unit * u, const struct potion_type * effect, int value); extern int change_effect(struct unit * u, const struct potion_type * effect, int value);
extern struct attrib_type at_effect; extern struct attrib_type at_effect;
extern struct attrib_type at_potiondelay;
/* rausnehmen, sobald man attribute splitten kann: */ /* rausnehmen, sobald man attribute splitten kann: */
typedef struct effect_data { typedef struct effect_data {

View File

@ -2955,7 +2955,6 @@ attrib_init(void)
/* neue UNIT-Attribute */ /* neue UNIT-Attribute */
at_register(&at_siege); at_register(&at_siege);
at_register(&at_effect); at_register(&at_effect);
at_register(&at_potiondelay);
at_register(&at_private); at_register(&at_private);
at_register(&at_icastle); at_register(&at_icastle);

View File

@ -810,8 +810,8 @@ random_neighbours(region * r, region_list ** rlist, const terrain_type *(*terraf
const terrain_type * terrain = terraformer(dir); const terrain_type * terrain = terraformer(dir);
rn = new_region(r->x+delta_x[dir], r->y+delta_y[dir], 0); rn = new_region(r->x+delta_x[dir], r->y+delta_y[dir], 0);
terraform_region(rn, terrain); terraform_region(rn, terrain);
regionqueue_push(rlist, rn);
if (rn->land) { if (rn->land) {
regionqueue_push(rlist, rn);
++nsize; ++nsize;
} }
} }
@ -824,11 +824,10 @@ const terrain_type * get_ocean(direction_t dir)
return newterrain(T_OCEAN); return newterrain(T_OCEAN);
} }
int region_quality(const region * r) int region_quality(const region * r, region * rn[])
{ {
region * rn[MAXDIRECTIONS];
int n, result = 0; int n, result = 0;
get_neighbours(r, rn);
for (n=0;n!=MAXDIRECTIONS;++n) { for (n=0;n!=MAXDIRECTIONS;++n) {
if (rn[n] && rn[n]->land) { if (rn[n] && rn[n]->land) {
if (rn[n]->terrain==newterrain(T_VOLCANO)) { if (rn[n]->terrain==newterrain(T_VOLCANO)) {
@ -841,7 +840,22 @@ int region_quality(const region * r)
return result; return result;
} }
static void smooth_island(region_list * island) static void
oceans_around(region * r, region * rn[])
{
int n;
for (n=0;n!=MAXDIRECTIONS;++n) {
region * rx = rn[n];
if (rx==NULL) {
rx = new_region(r->x+delta_x[n], r->y+delta_y[n], 0);
terraform_region(rx, newterrain(T_OCEAN));
rn[n] = rx;
}
}
}
static void
smooth_island(region_list * island)
{ {
region * rn[MAXDIRECTIONS]; region * rn[MAXDIRECTIONS];
region_list * rlist = NULL; region_list * rlist = NULL;
@ -849,47 +863,59 @@ static void smooth_island(region_list * island)
region * r = rlist->data; region * r = rlist->data;
int n, nland = 0; int n, nland = 0;
assert(r->land); if (r->land) {
get_neighbours(r, rn);
for (n=0;n!=MAXDIRECTIONS && nland<=1;++n) {
if (rn[n]->land) {
++nland;
r = rn[n];
}
}
if (nland==1) {
get_neighbours(r, rn); get_neighbours(r, rn);
for (n=0;n!=MAXDIRECTIONS;++n) { for (n=0;n!=MAXDIRECTIONS && nland<=1;++n) {
int n1 = (n+1)%MAXDIRECTIONS; if (rn[n]->land) {
int n2 = (n+1+MAXDIRECTIONS)%MAXDIRECTIONS; ++nland;
if (!rn[n]->land && rn[n1]!=r && rn[n2]!=r) { r = rn[n];
r = rlist->data; }
runhash(r); }
runhash(rn[n]);
SWAP(short, r->x, rn[n]->x); if (nland==1) {
SWAP(short, r->y, rn[n]->y); get_neighbours(r, rn);
rhash(r); for (n=0;n!=MAXDIRECTIONS;++n) {
rhash(rn[n]); int n1 = (n+1)%MAXDIRECTIONS;
rlist->data = r; int n2 = (n+1+MAXDIRECTIONS)%MAXDIRECTIONS;
for (n=0;n!=MAXDIRECTIONS;++n) { if (!rn[n]->land && rn[n1]!=r && rn[n2]!=r) {
region * rx = rconnect(r, n); r = rlist->data;
if (rx==NULL) { runhash(r);
rx = new_region(r->x+delta_x[n], r->y+delta_y[n], 0); runhash(rn[n]);
terraform_region(rx, newterrain(T_OCEAN)); SWAP(short, r->x, rn[n]->x);
} SWAP(short, r->y, rn[n]->y);
rhash(r);
rhash(rn[n]);
rlist->data = r;
oceans_around(r, rn);
break;
} }
break;
} }
} }
} }
} }
} }
static void
starting_region(region * r, region * rn[])
{
unit * u;
int n;
freset(r, RF_MARK);
for (n=0;n!=MAXDIRECTIONS;++n) {
freset(rn[n], RF_MARK);
}
terraform_region(r, newterrain(T_PLAIN));
prepare_starting_region(r);
r->land->money = 50 * 1000; /* 2% = 1000 silver */
u = addplayer(r, addfaction("enno@eressea.de", itoa36(rng_int()), races,
default_locale, 0));
}
/* E3A island generation */ /* E3A island generation */
int int
build_island_e3(short x, short y, int numfactions, int minsize) build_island_e3(short x, short y, int numfactions, int minsize)
{ {
#define MIN_QUALITY 1000
int nfactions = 0; int nfactions = 0;
region_list * rlist = NULL; region_list * rlist = NULL;
region_list * island = NULL; region_list * island = NULL;
@ -900,15 +926,15 @@ build_island_e3(short x, short y, int numfactions, int minsize)
terraform_region(r, random_terrain_e3(NODIRECTION)); terraform_region(r, random_terrain_e3(NODIRECTION));
while (r) { while (r) {
fset(r, RF_MARK);
if (r->land) { if (r->land) {
fset(r, RF_MARK); if (nsize<minsize) {
regionqueue_push(&island, r); nsize += random_neighbours(r, &rlist, &random_terrain_e3);
} } else {
if (nsize<minsize) { nsize += random_neighbours(r, &rlist, &get_ocean);
nsize += random_neighbours(r, &rlist, &random_terrain_e3); }
} else {
nsize += random_neighbours(r, &rlist, &get_ocean);
} }
regionqueue_push(&island, r);
r = regionqueue_pop(&rlist); r = regionqueue_pop(&rlist);
} }
@ -916,25 +942,31 @@ build_island_e3(short x, short y, int numfactions, int minsize)
for (rlist=island;rlist;rlist=rlist->next) { for (rlist=island;rlist;rlist=rlist->next) {
r = rlist->data; r = rlist->data;
if (fval(r, RF_MARK)) { if (r->land && fval(r, RF_MARK)) {
region *rn[MAXDIRECTIONS]; region *rn[MAXDIRECTIONS];
int n;
unit * u;
freset(r, RF_MARK);
get_neighbours(r, rn); get_neighbours(r, rn);
for (n=0;n!=MAXDIRECTIONS;++n) { q = region_quality(r,rn);
freset(rn[n], RF_MARK); if (q>=MIN_QUALITY && nfactions<numfactions) {
} starting_region(r, rn);
q = region_quality(r); minq = MIN(minq, q);
if (q>=1000 && nfactions<numfactions) { maxq = MAX(maxq, q);
terraform_region(r, newterrain(T_PLAIN)); ++nfactions;
}
}
}
for (rlist=island;rlist && nfactions<numfactions;rlist=rlist->next) {
r = rlist->data;
if (!r->land && fval(r, RF_MARK)) {
region *rn[MAXDIRECTIONS];
get_neighbours(r, rn);
q = region_quality(r, rn);
if (q>=MIN_QUALITY*4/3 && nfactions<numfactions) {
oceans_around(r, rn);
starting_region(r, rn);
minq = MIN(minq, q); minq = MIN(minq, q);
maxq = MAX(maxq, q); maxq = MAX(maxq, q);
prepare_starting_region(r);
r->land->money = 50 * 1000; /* 2% = 1000 silver */
u = addplayer(r, addfaction("enno@eressea.de", itoa36(rng_int()), races,
default_locale, 0));
++nfactions; ++nfactions;
} }
} }

View File

@ -44,7 +44,7 @@
<resource name="p2" appearance="vial"> <resource name="p2" appearance="vial">
<!-- Wasser des Lebens --> <!-- Wasser des Lebens -->
<item weight="0" score="30"> <item weight="0" score="30">
<function name="use" value="usepotion"/> <function name="use" value="usepotion_delayed"/>
<potion level="1"/> <potion level="1"/>
</item> </item>
</resource> </resource>