diff --git a/src/common/kernel/save.c b/src/common/kernel/save.c index e343eff36..ef7b26d4a 100644 --- a/src/common/kernel/save.c +++ b/src/common/kernel/save.c @@ -466,10 +466,10 @@ unitorders(FILE * F, struct faction * f) if (u && u->faction == f) { order ** ordp; - if (!quiet) { - printf(",_%4s_", itoa36(u->no)); - fflush(stdout); - } + if (quiet==0) { + printf(",_%4s_", itoa36(u->no)); + fflush(stdout); + } if (!fval(u, UFL_ORDERS)) { /* alle wiederholbaren, langen befehle werden gesichert: */ @@ -533,32 +533,32 @@ unitorders(FILE * F, struct faction * f) static faction * factionorders(void) { - char b[16]; - char * fid = strnzcpy(b, getstrtoken(), 15); - const char * pass = getstrtoken(); - faction *f; - - f = findfaction(atoi36(fid)); - - if (f!=NULL) { - /* Kontrolliere, ob das Passwort richtig eingegeben wurde. Es - * muß in "Gänsefüßchen" stehen!! */ - - /* War vorher in main.c:getgarbage() */ - if (!quiet) { - printf(" %4s;", factionid(f)); - fflush(stdout); - } - - if (checkpasswd(f, pass, true) == false) { - log_warning(("Invalid password for faction %s\n", fid)); + char b[16]; + char * fid = strnzcpy(b, getstrtoken(), 15); + const char * pass = getstrtoken(); + faction *f; + + f = findfaction(atoi36(fid)); + + if (f!=NULL) { + /* Kontrolliere, ob das Passwort richtig eingegeben wurde. Es + * muß in "Gänsefüßchen" stehen!! */ + + /* War vorher in main.c:getgarbage() */ + if (quiet==0) { + printf(" %4s;", factionid(f)); + fflush(stdout); + } + + if (checkpasswd(f, pass, true) == false) { + log_warning(("Invalid password for faction %s\n", fid)); ADDMSG(&f->msgs, msg_message("msg_errors", "string", - "Das Passwort wurde falsch eingegeben")); - return 0; - } - /* Die Partei hat sich zumindest gemeldet, so daß sie noch - * nicht als untätig gilt */ - + "Das Passwort wurde falsch eingegeben")); + return 0; + } + /* Die Partei hat sich zumindest gemeldet, so daß sie noch + * nicht als untätig gilt */ + /* TODO: +1 ist ein Workaround, weil turn erst in process_orders * incrementiert wird. */ f->lastorders = global.data_turn+1; @@ -1495,7 +1495,7 @@ readfaction(FILE * F) if (strlen(f->banner)>=DISPLAYSIZE) f->banner[DISPLAYSIZE] = 0; #endif - if (!quiet) printf(" - Lese Partei %s (%s)\n", f->name, factionid(f)); + if (quiet==0) printf(" - Lese Partei %s (%s)\n", f->name, factionid(f)); rds(F, &email); if (set_email(&f->email, email)!=0) { @@ -1758,7 +1758,7 @@ readgame(const char * filename, int backup) read_alliances(F); } n = ri(F); - printf(" - Einzulesende Parteien: %d\n", n); + if (quiet<2) printf(" - Einzulesende Parteien: %d\n", n); fp = &factions; while (*fp) fp=&(*fp)->next; @@ -1784,7 +1784,7 @@ readgame(const char * filename, int backup) n = ri(F); if (rmax<0) rmax = n; - printf(" - Einzulesende Regionen: %d/%d\r", rmax, n); + if (quiet<2) printf(" - Einzulesende Regionen: %d/%d\r", rmax, n); if (loadplane || dirtyload || firstx || firsty || maxregions>=0) { incomplete_data = true; } @@ -1809,7 +1809,7 @@ readgame(const char * filename, int backup) if (dirtyload) break; skip = true; } - if ((n & 0x3FF) == 0) { /* das spart extrem Zeit */ + if (quiet<2 && (n & 0x3FF) == 0) { /* das spart extrem Zeit */ printf(" - Einzulesende Regionen: %d/%d ", rmax, n); printf("* %d,%d \r", x, y); } @@ -1910,7 +1910,7 @@ readgame(const char * filename, int backup) } } } - printf("\n"); + if (quiet<2) printf("\n"); if (!dirtyload) { read_borders(F); } @@ -1918,10 +1918,10 @@ readgame(const char * filename, int backup) fclose(F); /* Unaufgeloeste Zeiger initialisieren */ - printf("\n - Referenzen initialisieren...\n"); + if (quiet<2) printf("\n - Referenzen initialisieren...\n"); resolve(); - printf("\n - Leere Gruppen löschen...\n"); + if (quiet<2) printf("\n - Leere Gruppen löschen...\n"); for (f=factions; f; f=f->next) { group ** gp = &f->groups; while (*gp) { @@ -1938,7 +1938,7 @@ readgame(const char * filename, int backup) building * b; for (b=r->buildings;b;b=b->next) update_lighthouse(b); } - printf(" - Regionen initialisieren & verbinden...\n"); + if (quiet < 2) printf(" - Regionen initialisieren & verbinden...\n"); for (f = factions; f; f = f->next) { for (u = f->units; u; u = u->nextF) { if (u->number>0) { @@ -2047,7 +2047,7 @@ writegame(const char *filename, int quiet) wi(F, n); wnl(F); - printf(" - Schreibe %d Parteien...\n",n); + if (quiet < 2) printf(" - Schreibe %d Parteien...\n",n); for (f = factions; f; f = f->next) { writefaction(F, f); } @@ -2060,11 +2060,11 @@ writegame(const char *filename, int quiet) n=listlen(regions); wi(F, n); wnl(F); - printf(" - Schreibe Regionen: %d \r", n); + if (quiet<2) printf(" - Schreibe Regionen: %d \r", n); for (r = regions; r; r = r->next, --n) { /* plus leerzeile */ - if ((n%1024)==0) { /* das spart extrem Zeit */ + if (quiet<2 && (n%1024)==0) { /* das spart extrem Zeit */ printf(" - Schreibe Regionen: %d \r", n); fflush(stdout); } @@ -2112,7 +2112,7 @@ writegame(const char *filename, int quiet) write_borders(F); wnl(F); fclose(F); - printf("\nOk.\n"); + if (quiet<2) printf("\nOk.\n"); return 0; } diff --git a/src/common/triggers/triggers.c b/src/common/triggers/triggers.c index a5136a3c3..c1e3f1fe6 100644 --- a/src/common/triggers/triggers.c +++ b/src/common/triggers/triggers.c @@ -44,7 +44,7 @@ void init_triggers(void) { - fprintf(stdout, "- registering triggers\n"); + if (quiet<2) printf("- registering triggers\n"); tt_register(&tt_changefaction); tt_register(&tt_changerace); tt_register(&tt_createcurse); diff --git a/src/eressea/curses/listbox.c b/src/eressea/curses/listbox.c index 31e183220..9490068a7 100644 --- a/src/eressea/curses/listbox.c +++ b/src/eressea/curses/listbox.c @@ -88,11 +88,11 @@ do_selection(list_selection * sel, const char * title, void (*perform)(list_sele for (;;) { int input; if (update) { - /* wclear(wn); */ for (s=top;s!=NULL && top->index+height!=s->index;s=s->next) { i = s->index-top->index; wmove(wn, i + 1, 4); waddnstr(wn, s->str, -1); + wclrtoeol(wn); } wborder(wn, 0, 0, 0, 0, 0, 0, 0, 0); mvwprintw(wn, 0, 2, "[ %s ]", title); @@ -103,7 +103,7 @@ do_selection(list_selection * sel, const char * title, void (*perform)(list_sele wmove(wn, i + 1, 2); waddstr(wn, "->"); wmove(wn, i + 1, 4); - waddnstr(wn, current->str, width); + waddnstr(wn, current->str, -1); wattroff(wn, A_BOLD | COLOR_PAIR(COLOR_YELLOW)); wrefresh(wn); @@ -116,6 +116,29 @@ do_selection(list_selection * sel, const char * title, void (*perform)(list_sele waddnstr(wn, current->str, width); switch (input) { + case KEY_NPAGE: + for (i=0;i!=height/2;++i) { + if (current->next) { + current = current->next; + if (current->index-height>=top->index) { + top=current; + update = true; + } + } + } + break; + case KEY_PPAGE: + for (i=0;i!=height/2;++i) { + if (current->prev) { + if (current==top) { + top = sel; + while (top->index+heightindex) top=top->next; + update = true; + } + current = current->prev; + } + } + break; case KEY_DOWN: if (current->next) { current = current->next; @@ -159,6 +182,10 @@ do_selection(list_selection * sel, const char * title, void (*perform)(list_sele if (s==NULL) s = top; } } + if (current->index-height>=top->index) { + top=current; + update = true; + } } } } diff --git a/src/eressea/editing.c b/src/eressea/editing.c index fcde1366e..b2410b035 100644 --- a/src/eressea/editing.c +++ b/src/eressea/editing.c @@ -13,6 +13,28 @@ #include "editing.h" #include +#include +#include + +#define ISLANDSIZE 20 +#define TURNS_PER_ISLAND 4 +void +seed_players(const char * filename, boolean new_island) +{ + newfaction * players = read_newfactions(filename); + if (players!=NULL) { + rng_init(players->subscription); + while (players) { + int n = listlen(players); + int k = (n+ISLANDSIZE-1)/ISLANDSIZE; + k = n / k; + n = autoseed(&players, k, new_island || (turn % TURNS_PER_ISLAND)==0); + if (n==0) { + break; + } + } + } +} void make_block(short x, short y, short radius, const struct terrain_type * terrain) diff --git a/src/eressea/editing.h b/src/eressea/editing.h index 7cd936947..31475a26e 100644 --- a/src/eressea/editing.h +++ b/src/eressea/editing.h @@ -13,5 +13,6 @@ extern void make_block(short x, short y, short radius, const struct terrain_type * terrain); extern void make_island(short x, short y, int size); +extern void seed_players(const char * filename, boolean new_island); #endif /* GM_EDITING */ diff --git a/src/eressea/gmtool.c b/src/eressea/gmtool.c index 15b1c3761..58dc0f54a 100644 --- a/src/eressea/gmtool.c +++ b/src/eressea/gmtool.c @@ -17,7 +17,6 @@ #include "editing.h" #include "curses/listbox.h" -#include #include #include #ifdef MUSEUM_MODULE @@ -99,7 +98,7 @@ read_args(int argc, char **argv) { int i; - quiet = 1; + quiet = 0xFF; /* no printing whatsoever */ turn = first_turn; for (i=1;i!=argc;++i) { @@ -227,9 +226,12 @@ init_curses(void) if (has_colors() || force_color) { short bcol = COLOR_BLACK; start_color(); +#ifdef WIN32 + /* looks crap on putty with TERM=linux */ if (can_change_color()) { init_color(COLOR_YELLOW, 1000, 1000, 0); } +#endif init_pair(COLOR_BLACK, COLOR_BLACK, bcol); init_pair(COLOR_GREEN, COLOR_GREEN, bcol); init_pair(COLOR_GREEN, COLOR_GREEN, bcol); @@ -248,12 +250,12 @@ init_curses(void) } keypad(stdscr, TRUE); /* enable keyboard mapping */ + meta(stdscr, TRUE); nonl(); /* tell curses not to do NL->CR/NL on output */ cbreak(); /* take input chars one at a time, no wait for \n */ noecho(); /* don't echo input */ scrollok(stdscr, FALSE); refresh(); -/* wclear(stdscr); */ } static map_region * @@ -680,6 +682,7 @@ handlekey(state * st, int c) region *r; boolean invert = false; char sbuffer[80]; + static char kbuffer[80]; switch(c) { case FAST_RIGHT: @@ -951,6 +954,11 @@ handlekey(state * st, int c) if (tagged_region(st->selected, cursor)) untag_region(st->selected, cursor); else tag_region(st->selected, cursor); break; + case 'A': + sprintf(sbuffer, "%s/newfactions", basepath()); + seed_players(sbuffer, false); + st->wnd_map->update |= 1; + break; case '/': statusline(st->wnd_status->handle, "find-"); doupdate(); @@ -1033,8 +1041,13 @@ handlekey(state * st, int c) } } if (wnd==NULL) { - sprintf(sbuffer, "getch: 0x%x", c); - statusline(st->wnd_status->handle, sbuffer); + if (kbuffer[0]==0) { + strcpy(kbuffer, "getch:"); + } + sprintf(sbuffer, " 0x%x", c); + strncat(kbuffer, sbuffer, sizeof(kbuffer)); + statusline(st->wnd_status->handle, kbuffer); + if (strlen(kbuffer)>70) kbuffer[0]=0; } break; }