forked from github/server
Merge branch 'master' into develop
Conflicts: src/gmtool.c
This commit is contained in:
commit
0cb085378d
|
@ -1,10 +1,7 @@
|
||||||
Freust Du Dich, dass es diese Woche wieder einen Eressea-Report gibt?
|
|
||||||
Möchtest Du dazu beitragen, dass das auch nächste Woche wieder passiert?
|
|
||||||
Eressea ist ein freiwilliges gratis-Angebot, und die Spielleitung bezahlt
|
|
||||||
seit Jahren die Entwicklung und das Hosting aus eigener Tasche. Wenn Dir
|
|
||||||
das etwas wert ist, kannst Du das auf
|
|
||||||
https://flattr.com/thing/681354/Eressea zum Ausdruck bringen.
|
|
||||||
|
|
||||||
Diese Mail enthält ein Attachment mit Deinem Eressea-Report in
|
Diese Mail enthält ein Attachment mit Deinem Eressea-Report in
|
||||||
komprimierter Form. Um ihn zu entpacken benötigst Du ein Programm,
|
komprimierter Form. Um ihn zu entpacken benötigst Du ein Programm,
|
||||||
das ZIP-Archive öffnen kann, wie z.B. 7-Zip (http://www.7-zip.org/)
|
das ZIP-Archive öffnen kann, wie z.B. 7-Zip (http://www.7-zip.org/)
|
||||||
|
|
||||||
|
Eressea ist ein kostenloses Angebot von Freiwilligen, und die Spielleitung bezahlt
|
||||||
|
seit Jahren die Entwicklung und den Betrieb aus eigener Tasche. Wenn Dir
|
||||||
|
das etwas wert ist, kannst Du das Spiel auf https://www.patreon.com/enno unterstützen.
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
13
src/chaos.c
13
src/chaos.c
|
@ -53,6 +53,19 @@ attrib_type at_chaoscount = {
|
||||||
ATF_UNIQUE
|
ATF_UNIQUE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void set_chaoscount(struct region *r, int deaths)
|
||||||
|
{
|
||||||
|
if (deaths==0) {
|
||||||
|
a_removeall(&r->attribs, &at_chaoscount);
|
||||||
|
} else {
|
||||||
|
attrib *a = a_find(r->attribs, &at_chaoscount);
|
||||||
|
if (!a) {
|
||||||
|
a = a_add(&r->attribs, a_new(&at_chaoscount));
|
||||||
|
}
|
||||||
|
a->data.i = deaths;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int get_chaoscount(const region * r)
|
int get_chaoscount(const region * r)
|
||||||
{
|
{
|
||||||
attrib *a = a_find(r->attribs, &at_chaoscount);
|
attrib *a = a_find(r->attribs, &at_chaoscount);
|
||||||
|
|
|
@ -29,6 +29,7 @@ extern "C" {
|
||||||
void chaos_register(void);
|
void chaos_register(void);
|
||||||
void chaos_update(void);
|
void chaos_update(void);
|
||||||
|
|
||||||
|
void set_chaoscount(struct region *r, int deaths);
|
||||||
int get_chaoscount(const struct region * r);
|
int get_chaoscount(const struct region * r);
|
||||||
void add_chaoscount(struct region * r, int deaths);
|
void add_chaoscount(struct region * r, int deaths);
|
||||||
|
|
||||||
|
|
71
src/gmtool.c
71
src/gmtool.c
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
#include "gmtool.h"
|
#include "gmtool.h"
|
||||||
#include "gmtool_structs.h"
|
#include "gmtool_structs.h"
|
||||||
|
#include "chaos.h"
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "listbox.h"
|
#include "listbox.h"
|
||||||
#include "wormhole.h"
|
#include "wormhole.h"
|
||||||
|
@ -45,6 +46,7 @@
|
||||||
#include <attributes/attributes.h>
|
#include <attributes/attributes.h>
|
||||||
#include <triggers/triggers.h>
|
#include <triggers/triggers.h>
|
||||||
|
|
||||||
|
#include <util/attrib.h>
|
||||||
#include <util/log.h>
|
#include <util/log.h>
|
||||||
#include <util/unicode.h>
|
#include <util/unicode.h>
|
||||||
#include <util/lists.h>
|
#include <util/lists.h>
|
||||||
|
@ -515,6 +517,46 @@ static void statusline(WINDOW * win, const char *str)
|
||||||
wnoutrefresh(win);
|
wnoutrefresh(win);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void reset_region(region *r) {
|
||||||
|
set_chaoscount(r, 0);
|
||||||
|
r->flags = 0;
|
||||||
|
a_removeall(&r->attribs, NULL);
|
||||||
|
while (r->units) {
|
||||||
|
remove_unit(&r->units, r->units);
|
||||||
|
}
|
||||||
|
while (r->ships) {
|
||||||
|
remove_ship(&r->ships, r->ships);
|
||||||
|
}
|
||||||
|
while (r->buildings) {
|
||||||
|
remove_building(&r->buildings, r->buildings);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void reset_cursor(state *st) {
|
||||||
|
int nx = st->cursor.x;
|
||||||
|
int ny = st->cursor.y;
|
||||||
|
region *r;
|
||||||
|
pnormalize(&nx, &ny, st->cursor.pl);
|
||||||
|
if ((r = findregion(nx, ny)) != NULL) {
|
||||||
|
reset_region(r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void reset_rect(state *st) {
|
||||||
|
int x, y, bs = 3;
|
||||||
|
for (x=0;x!=bs;++x) {
|
||||||
|
for (y = 0; y != bs; ++y) {
|
||||||
|
region *r;
|
||||||
|
int nx = st->cursor.x + x;
|
||||||
|
int ny = st->cursor.y + y;
|
||||||
|
pnormalize(&nx, &ny, st->cursor.pl);
|
||||||
|
if ((r = findregion(nx, ny)) != NULL) {
|
||||||
|
reset_region(r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void terraform_at(coordinate * c, const terrain_type * terrain)
|
static void terraform_at(coordinate * c, const terrain_type * terrain)
|
||||||
{
|
{
|
||||||
if (terrain != NULL) {
|
if (terrain != NULL) {
|
||||||
|
@ -844,11 +886,24 @@ static void seed_player(state *st, const newfaction *player) {
|
||||||
pnormalize(&nx, &ny, st->cursor.pl);
|
pnormalize(&nx, &ny, st->cursor.pl);
|
||||||
r = findregion(nx, ny);
|
r = findregion(nx, ny);
|
||||||
if (r) {
|
if (r) {
|
||||||
addplayer(r, addfaction(player->email, player->password, player->race,
|
const char *at = strchr(player->email, '@');
|
||||||
player->lang, player->subscription));
|
faction *f;
|
||||||
|
addplayer(r, f = addfaction(player->email, player->password,
|
||||||
|
player->race, player->lang,
|
||||||
|
player->subscription));
|
||||||
|
if (at) {
|
||||||
|
char fname[64];
|
||||||
|
size_t len = at - player->email;
|
||||||
|
if (len>4 && len<sizeof(fname)) {
|
||||||
|
memcpy(fname, player->email, len);
|
||||||
|
fname[len]=0;
|
||||||
|
faction_setname(f, fname);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handlekey(state * st, int c)
|
static void handlekey(state * st, int c)
|
||||||
{
|
{
|
||||||
window *wnd;
|
window *wnd;
|
||||||
|
@ -912,15 +967,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;
|
||||||
|
@ -934,6 +989,12 @@ static void handlekey(state * st, int c)
|
||||||
st->wnd_status->update |= 1;
|
st->wnd_status->update |= 1;
|
||||||
st->wnd_map->update |= 1;
|
st->wnd_map->update |= 1;
|
||||||
break;
|
break;
|
||||||
|
case 'c': /* clear/reset */
|
||||||
|
reset_cursor(st);
|
||||||
|
break;
|
||||||
|
case 'C': /* clear/reset */
|
||||||
|
reset_rect(st);
|
||||||
|
break;
|
||||||
case 0x09: /* tab = next selected */
|
case 0x09: /* tab = next selected */
|
||||||
if (regions != NULL) {
|
if (regions != NULL) {
|
||||||
map_region *mr = cursor_region(&st->display, cursor);
|
map_region *mr = cursor_region(&st->display, cursor);
|
||||||
|
|
|
@ -286,12 +286,14 @@ faction *addfaction(const char *email, const char *password,
|
||||||
unit *addplayer(region * r, faction * f)
|
unit *addplayer(region * r, faction * f)
|
||||||
{
|
{
|
||||||
unit *u;
|
unit *u;
|
||||||
|
const char * name;
|
||||||
const struct equipment* eq;
|
const struct equipment* eq;
|
||||||
|
|
||||||
assert(f->units == NULL);
|
assert(f->units == NULL);
|
||||||
faction_setorigin(f, 0, r->x, r->y);
|
faction_setorigin(f, 0, r->x, r->y);
|
||||||
u = create_unit(r, f, 1, f->race, 0, NULL, NULL);
|
u = create_unit(r, f, 1, f->race, 0, NULL, NULL);
|
||||||
eq = get_equipment("first_unit");
|
name = config_get("rules.equip_first");
|
||||||
|
eq = get_equipment(name ? name : "first_unit");
|
||||||
if (eq) {
|
if (eq) {
|
||||||
equip_items(&u->items, eq);
|
equip_items(&u->items, eq);
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,9 +157,13 @@ newfaction *read_newfactions(const char *filename)
|
||||||
password[0] = '\0';
|
password[0] = '\0';
|
||||||
|
|
||||||
if (sscanf(buf, "%54s %20s %8s %d %d %16s %d", email, race, lang, &bonus,
|
if (sscanf(buf, "%54s %20s %8s %d %d %16s %d", email, race, lang, &bonus,
|
||||||
&subscription, password, &alliance) < 3)
|
&subscription, password, &alliance) < 3) {
|
||||||
break;
|
break;
|
||||||
if (email[0] == '\0')
|
}
|
||||||
|
if (email[0] == '#') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (email[0] == '\0')
|
||||||
break;
|
break;
|
||||||
if (email[0] == '#')
|
if (email[0] == '#')
|
||||||
break;
|
break;
|
||||||
|
@ -778,25 +782,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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -906,7 +914,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;
|
||||||
|
@ -917,9 +925,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);
|
||||||
|
@ -928,10 +937,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);
|
||||||
|
@ -948,7 +957,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);
|
||||||
|
@ -963,7 +972,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