Merge pull request #712 from ennorehling/master

GM tool improvement
This commit is contained in:
Enno Rehling 2017-07-23 09:21:37 +02:00 committed by GitHub
commit daca7b084d
3 changed files with 44 additions and 26 deletions

View File

@ -20,6 +20,11 @@
<xi:include href="config://game/spells.xml"/> <xi:include href="config://game/spells.xml"/>
<xi:include href="config://default/adamantium.xml"/> <xi:include href="config://default/adamantium.xml"/>
<equipment> <equipment>
<set name="first_unit">
<item name="money" amount="2500"/>
<item name="log" amount="10"/>
<item name="stone" amount="4"/>
</set>
<set name="autoseed_unit"> <set name="autoseed_unit">
<item name="log" amount="50"/> <item name="log" amount="50"/>
<item name="stone" amount="50"/> <item name="stone" amount="50"/>

View File

@ -814,7 +814,7 @@ static void select_regions(state * st, int selectmode)
st->wnd_map->update |= 3; st->wnd_map->update |= 3;
} }
void loaddata(state *st) { static void loaddata(state *st) {
char datafile[MAX_PATH]; char datafile[MAX_PATH];
askstring(st->wnd_status->handle, "save as:", datafile, sizeof(datafile)); askstring(st->wnd_status->handle, "save as:", datafile, sizeof(datafile));
@ -824,7 +824,7 @@ void loaddata(state *st) {
} }
} }
void savedata(state *st) { static void savedata(state *st) {
char datafile[MAX_PATH]; char datafile[MAX_PATH];
askstring(st->wnd_status->handle, "save as:", datafile, sizeof(datafile)); askstring(st->wnd_status->handle, "save as:", datafile, sizeof(datafile));
@ -835,6 +835,20 @@ void savedata(state *st) {
} }
} }
static void seed_player(state *st, const newfaction *player) {
if (player) {
region *r;
int nx = st->cursor.x;
int ny = st->cursor.y;
pnormalize(&nx, &ny, st->cursor.pl);
r = findregion(nx, ny);
if (r) {
addplayer(r, addfaction(player->email, player->password, player->race,
player->lang, player->subscription));
}
}
}
static void handlekey(state * st, int c) static void handlekey(state * st, int c)
{ {
window *wnd; window *wnd;
@ -897,10 +911,6 @@ static void handlekey(state * st, int c)
loaddata(st); loaddata(st);
break; break;
case 'B': case 'B':
if (!new_players) {
join_path(basepath(), "newfactions", sbuffer, sizeof(sbuffer));
new_players = read_newfactions(sbuffer);
}
cnormalize(&st->cursor, &nx, &ny); cnormalize(&st->cursor, &nx, &ny);
minpop = config_get_int("editor.population.min", 8); minpop = config_get_int("editor.population.min", 8);
maxpop = config_get_int("editor.population.max", minpop); maxpop = config_get_int("editor.population.max", minpop);
@ -1111,13 +1121,15 @@ static void handlekey(state * st, int c)
else else
tag_region(st->selected, nx, ny); tag_region(st->selected, nx, ny);
break; break;
case 'A': case 's': /* seed */
if (!new_players) { if (new_players) {
join_path(basepath(), "newfactions", sbuffer, sizeof(sbuffer)); newfaction * next = new_players->next;
new_players = read_newfactions(sbuffer); seed_player(st, new_players);
free(new_players->email);
free(new_players->password);
free(new_players);
new_players = next;
} }
seed_players(&new_players, false);
st->wnd_map->update |= 1;
break; break;
case '/': case '/':
statusline(st->wnd_status->handle, "find-"); statusline(st->wnd_status->handle, "find-");
@ -1289,13 +1301,15 @@ void run_mapper(void)
int split = 20; int split = 20;
state *st; state *st;
point tl; point tl;
/* FIXME: dsiable logging char sbuffer[512];
int old_flags = log_flags;
log_flags &= ~(LOG_CPERROR | LOG_CPWARNING); if (!new_players) {
*/ join_path(basepath(), "newfactions", sbuffer, sizeof(sbuffer));
new_players = read_newfactions(sbuffer);
}
init_curses(); init_curses();
curs_set(1); curs_set(1);
set_readline(curses_readline); set_readline(curses_readline);
assert(stdscr); assert(stdscr);
getbegyx(stdscr, x, y); getbegyx(stdscr, x, y);

View File

@ -22,7 +22,6 @@ extern "C" {
struct terrain_type; struct terrain_type;
struct newfaction; struct newfaction;
int gmmain(int argc, char *argv[]);
int curses_readline(struct lua_State *L, char *buffer, size_t size, int curses_readline(struct lua_State *L, char *buffer, size_t size,
const char *prompt); const char *prompt);