seed a single faction from newplayers file.

This commit is contained in:
Enno Rehling 2017-07-23 09:15:23 +02:00
parent 12222c6562
commit a5d350fe3a
2 changed files with 39 additions and 26 deletions

View File

@ -814,7 +814,7 @@ static void select_regions(state * st, int selectmode)
st->wnd_map->update |= 3;
}
void loaddata(state *st) {
static void loaddata(state *st) {
char datafile[MAX_PATH];
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];
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)
{
window *wnd;
@ -897,10 +911,6 @@ static void handlekey(state * st, int c)
loaddata(st);
break;
case 'B':
if (!new_players) {
join_path(basepath(), "newfactions", sbuffer, sizeof(sbuffer));
new_players = read_newfactions(sbuffer);
}
cnormalize(&st->cursor, &nx, &ny);
minpop = config_get_int("editor.population.min", 8);
maxpop = config_get_int("editor.population.max", minpop);
@ -1111,13 +1121,15 @@ static void handlekey(state * st, int c)
else
tag_region(st->selected, nx, ny);
break;
case 'A':
if (!new_players) {
join_path(basepath(), "newfactions", sbuffer, sizeof(sbuffer));
new_players = read_newfactions(sbuffer);
case 's': /* seed */
if (new_players) {
newfaction * next = new_players->next;
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;
case '/':
statusline(st->wnd_status->handle, "find-");
@ -1289,13 +1301,15 @@ void run_mapper(void)
int split = 20;
state *st;
point tl;
/* FIXME: dsiable logging
int old_flags = log_flags;
log_flags &= ~(LOG_CPERROR | LOG_CPWARNING);
*/
char sbuffer[512];
if (!new_players) {
join_path(basepath(), "newfactions", sbuffer, sizeof(sbuffer));
new_players = read_newfactions(sbuffer);
}
init_curses();
curs_set(1);
set_readline(curses_readline);
assert(stdscr);
getbegyx(stdscr, x, y);

View File

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