forked from github/server
Merge branch 'master' of github.com:eressea/server
This commit is contained in:
commit
e59ae05729
|
@ -150,10 +150,9 @@ static int tolua_make_island(lua_State * L)
|
||||||
int x = (int)tolua_tonumber(L, 1, 0);
|
int x = (int)tolua_tonumber(L, 1, 0);
|
||||||
int y = (int)tolua_tonumber(L, 2, 0);
|
int y = (int)tolua_tonumber(L, 2, 0);
|
||||||
int s = (int)tolua_tonumber(L, 3, 0);
|
int s = (int)tolua_tonumber(L, 3, 0);
|
||||||
int n = (int)tolua_tonumber(L, 4, s / 3);
|
|
||||||
|
|
||||||
n = build_island_e3(NULL, x, y, n, s);
|
s = build_island_e3(x, y, s, NULL, 0);
|
||||||
lua_pushinteger(L, n);
|
lua_pushinteger(L, s);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -912,15 +912,15 @@ static void handlekey(state * st, int c)
|
||||||
break;
|
break;
|
||||||
case 'B':
|
case 'B':
|
||||||
cnormalize(&st->cursor, &nx, &ny);
|
cnormalize(&st->cursor, &nx, &ny);
|
||||||
minpop = config_get_int("editor.population.min", 8);
|
minpop = config_get_int("editor.island.min", 8);
|
||||||
maxpop = config_get_int("editor.population.max", minpop);
|
maxpop = config_get_int("editor.island.max", minpop);
|
||||||
if (maxpop > minpop) {
|
if (maxpop > minpop) {
|
||||||
n = rng_int() % (maxpop - minpop) + minpop;
|
n = rng_int() % (maxpop - minpop) + minpop;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
n = minpop;
|
n = minpop;
|
||||||
}
|
}
|
||||||
build_island_e3(&new_players, nx, ny, n, n * 3);
|
build_island_e3(nx, ny, n, NULL, 0);
|
||||||
st->modified = 1;
|
st->modified = 1;
|
||||||
st->wnd_info->update |= 1;
|
st->wnd_info->update |= 1;
|
||||||
st->wnd_status->update |= 1;
|
st->wnd_status->update |= 1;
|
||||||
|
|
|
@ -780,25 +780,29 @@ const terrain_type *random_terrain_e3(direction_t dir)
|
||||||
return random_terrain(terrainarr, distribution, GEOMAX);
|
return random_terrain(terrainarr, distribution, GEOMAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int
|
||||||
random_neighbours(region * r, region_list ** rlist,
|
random_neighbours(region * r, region_list ** rlist,
|
||||||
const terrain_type * (*terraformer) (direction_t))
|
const terrain_type * (*terraformer) (direction_t), int n)
|
||||||
{
|
{
|
||||||
int nsize = 0;
|
int nsize = 0;
|
||||||
direction_t dir;
|
direction_t dir;
|
||||||
for (dir = 0; dir != MAXDIRECTIONS; ++dir) {
|
for (dir = 0; dir != MAXDIRECTIONS; ++dir) {
|
||||||
region *rn = rconnect(r, dir);
|
region *rn = rconnect(r, dir);
|
||||||
if (rn == NULL) {
|
if (rn == NULL || (!rn->units && !rn->land)) {
|
||||||
const terrain_type *terrain = terraformer(dir);
|
const terrain_type *terrain = terraformer(dir);
|
||||||
plane *pl = rplane(r);
|
if (!rn) {
|
||||||
int x = r->x + delta_x[dir];
|
plane *pl = rplane(r);
|
||||||
int y = r->y + delta_y[dir];
|
int x = r->x + delta_x[dir];
|
||||||
pnormalize(&x, &y, pl);
|
int y = r->y + delta_y[dir];
|
||||||
rn = new_region(x, y, pl, 0);
|
pnormalize(&x, &y, pl);
|
||||||
|
rn = new_region(x, y, pl, 0);
|
||||||
|
}
|
||||||
terraform_region(rn, terrain);
|
terraform_region(rn, terrain);
|
||||||
regionqueue_push(rlist, rn);
|
regionqueue_push(rlist, rn);
|
||||||
if (rn->land) {
|
if (rn->land) {
|
||||||
++nsize;
|
if (++nsize >= n) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -908,7 +912,7 @@ static void starting_region(newfaction ** players, region * r, region * rn[])
|
||||||
}
|
}
|
||||||
|
|
||||||
/* E3A island generation */
|
/* E3A island generation */
|
||||||
int build_island_e3(newfaction ** players, int x, int y, int numfactions, int minsize)
|
int build_island_e3(int x, int y, int minsize, newfaction ** players, int numfactions)
|
||||||
{
|
{
|
||||||
#define MIN_QUALITY 1000
|
#define MIN_QUALITY 1000
|
||||||
int nfactions = 0;
|
int nfactions = 0;
|
||||||
|
@ -919,9 +923,10 @@ int build_island_e3(newfaction ** players, int x, int y, int numfactions, int mi
|
||||||
int nsize = 1;
|
int nsize = 1;
|
||||||
int q, maxq = INT_MIN, minq = INT_MAX;
|
int q, maxq = INT_MIN, minq = INT_MAX;
|
||||||
|
|
||||||
if (!r)
|
if (r && r->units) return 0;
|
||||||
|
if (!r) {
|
||||||
r = new_region(x, y, pl, 0);
|
r = new_region(x, y, pl, 0);
|
||||||
assert(!r->units);
|
}
|
||||||
do {
|
do {
|
||||||
terraform_region(r, random_terrain_e3(NODIRECTION));
|
terraform_region(r, random_terrain_e3(NODIRECTION));
|
||||||
} while (!r->land);
|
} while (!r->land);
|
||||||
|
@ -930,10 +935,10 @@ int build_island_e3(newfaction ** players, int x, int y, int numfactions, int mi
|
||||||
fset(r, RF_MARK);
|
fset(r, RF_MARK);
|
||||||
if (r->land) {
|
if (r->land) {
|
||||||
if (nsize < minsize) {
|
if (nsize < minsize) {
|
||||||
nsize += random_neighbours(r, &rlist, &random_terrain_e3);
|
nsize += random_neighbours(r, &rlist, &random_terrain_e3, minsize-nsize);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
nsize += random_neighbours(r, &rlist, &get_ocean);
|
nsize += random_neighbours(r, &rlist, &get_ocean, minsize - nsize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
regionqueue_push(&island, r);
|
regionqueue_push(&island, r);
|
||||||
|
@ -950,7 +955,7 @@ int build_island_e3(newfaction ** players, int x, int y, int numfactions, int mi
|
||||||
|
|
||||||
get_neighbours(r, rn);
|
get_neighbours(r, rn);
|
||||||
q = region_quality(r, rn);
|
q = region_quality(r, rn);
|
||||||
if (q >= MIN_QUALITY && nfactions < numfactions && *players) {
|
if (q >= MIN_QUALITY && nfactions < numfactions && players && *players) {
|
||||||
starting_region(players, r, rn);
|
starting_region(players, r, rn);
|
||||||
minq = MIN(minq, q);
|
minq = MIN(minq, q);
|
||||||
maxq = MAX(maxq, q);
|
maxq = MAX(maxq, q);
|
||||||
|
@ -965,7 +970,7 @@ int build_island_e3(newfaction ** players, int x, int y, int numfactions, int mi
|
||||||
region *rn[MAXDIRECTIONS];
|
region *rn[MAXDIRECTIONS];
|
||||||
get_neighbours(r, rn);
|
get_neighbours(r, rn);
|
||||||
q = region_quality(r, rn);
|
q = region_quality(r, rn);
|
||||||
if (q >= MIN_QUALITY * 4 / 3 && nfactions < numfactions && *players) {
|
if (q >= MIN_QUALITY * 4 / 3 && nfactions < numfactions && players && *players) {
|
||||||
starting_region(players, r, rn);
|
starting_region(players, r, rn);
|
||||||
minq = MIN(minq, q);
|
minq = MIN(minq, q);
|
||||||
maxq = MAX(maxq, q);
|
maxq = MAX(maxq, q);
|
||||||
|
|
|
@ -38,8 +38,7 @@ extern "C" {
|
||||||
extern const struct terrain_type *random_terrain(const struct terrain_type
|
extern const struct terrain_type *random_terrain(const struct terrain_type
|
||||||
*terrains[], int distribution[], int size);
|
*terrains[], int distribution[], int size);
|
||||||
|
|
||||||
extern int seed_adamantium(struct region *r, int base);
|
extern int build_island_e3(int x, int y, int minsize, newfaction **players, int numfactions);
|
||||||
extern int build_island_e3(newfaction **players, int x, int y, int numfactions, int minsize);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue