diff --git a/src/mapper/Jamfile b/src/mapper/Jamfile deleted file mode 100644 index c84846f9e..000000000 --- a/src/mapper/Jamfile +++ /dev/null @@ -1,35 +0,0 @@ -SubDir TOP mapper ; - -TargetDirectory ; -SubDirHdrs $(SUBDIR)/../common/gamecode ; -SubDirHdrs $(SUBDIR)/../common/kernel ; -SubDirHdrs $(SUBDIR)/../common/util ; -SubDirHdrs $(SUBDIR)/../common ; -SubDirHdrs $(SUBDIR)/.. ; - -SubDirHdrs $(XMLHDRS) ; - -SOURCES = - logging.c - map_modify.c - map_partei.c - mapper.c - map_region.c - map_tools.c - map_units.c - ; - -Main mapper : $(SOURCES) ; -LinkLibraries mapper : - gamecode - items - spells - kernel - modules - attributes - races - triggers - util ; - -libxml2 mapper ; -LINKLIBS on mapper += -L$(LUABIND_ROOT)/lib -lm -lncurses ; diff --git a/src/mapper/logging.c b/src/mapper/logging.c deleted file mode 100644 index c1eae62bc..000000000 --- a/src/mapper/logging.c +++ /dev/null @@ -1,107 +0,0 @@ -/* vi: set ts=2: - +-------------------+ Christian Schlittchen - | | Enno Rehling - | Eressea PBEM host | Katja Zedel - | (c) 1998 - 2003 | Henning Peters - | | Ingo Wilken - +-------------------+ Stefan Reich - - This program may not be used, modified or distributed - without prior permission by the authors of Eressea. -*/ - -#include -#include - -/* kernel includes */ -#include -#include -#include -#include -#include -#include - -/* util includes */ -#include - -/* libc includes */ -#include -#include - -static FILE * log; - -void -log_read(const char * filename) -{ - FILE * log = fopen(filename, "r"); - faction **fp = &factions; - char buf[64]; - - while (*fp) fp=&(*fp)->next; - fscanf(log, "LOGVERSION %u\n", &global.data_version); - while (!feof(log)) { - if(fscanf(log, "%s", buf) == EOF) break; - if (strcmp(buf, "UNIT")==0) { - short x, y; - unit * u; - region * r; - fscanf(log, "%s %hd %hd", buf, &x, &y); - u = readunit(log); - r = findregion(x, y); - if (r==NULL) { - r = new_region(x, y); - terraform(r, T_PLAIN); - } - if (u->region!=r) move_unit(u, r, NULL); - } else if (strcmp(buf, "REGION")==0) { - short x, y; - fscanf(log, "%hd %hd", &x, &y); - readregion(log, x, y); - } else if (strcmp(buf, "FACTION")==0) { - faction * f; - fscanf(log, "%s", buf); - f = findfaction(atoi36(buf)); - if (f) { - readfaction(log); - } else { - *fp = readfaction(log); - fp=&(*fp)->next; - } - } else assert(0); - } -} - -void -log_faction(const struct faction * f) -{ - fprintf(log, "FACTION %s\n", factionid(f)); - writefaction(log, f); -} - -void -log_unit(const struct unit * u) -{ - fprintf(log, "UNIT %s %d %d\n", unitid(u), u->region->x, u->region->y); - writeunit(log, u); -} - -void -log_region(const struct region * r) -{ - fprintf(log, "REGION %d %d\n", r->x, r->y); - writeregion(log, r); -} - -void -log_start(const char * filename) -{ - log = fopen(filename, "w+"); - fprintf(log, "LOGVERSION %d\n", RELEASE_VERSION); -} - -void -log_stop(void) -{ - fclose(log); - log = NULL; -} diff --git a/src/mapper/logging.h b/src/mapper/logging.h deleted file mode 100644 index 92129a4d3..000000000 --- a/src/mapper/logging.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef _LOGGING_H -#define _LOGGING_H - -/* vi: set ts=2: - +-------------------+ Christian Schlittchen - | | Enno Rehling - | Eressea PBEM host | Katja Zedel - | (c) 1998 - 2003 | Henning Peters - | | Ingo Wilken - +-------------------+ Stefan Reich - - This program may not be used, modified or distributed - without prior permission by the authors of Eressea. -*/ - -extern void log_read(const char * logname); -extern void log_region(const struct region * r); -extern void log_unit(const struct unit * r); -extern void log_faction(const struct faction * f); -extern void log_start(const char * filename); -extern void log_stop(void); - -#endif /* _LOGGING_H */ diff --git a/src/mapper/map_modify.c b/src/mapper/map_modify.c deleted file mode 100644 index e2143fded..000000000 --- a/src/mapper/map_modify.c +++ /dev/null @@ -1,1258 +0,0 @@ -/* vi: set ts=2: - * - * Eressea PB(E)M host Copyright (C) 1998-2003 - * Christian Schlittchen (corwin@amber.kn-bremen.de) - * Katja Zedel (katze@felidae.kn-bremen.de) - * Henning Peters (faroul@beyond.kn-bremen.de) - * Enno Rehling (enno@eressea-pbem.de) - * Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de) - * - * This program may not be used, modified or distributed without - * prior permission by the authors of Eressea. - */ - -/* wenn config.h nicht vor curses included wird, kompiliert es unter windows nicht */ -/* wenn curses.h nicht vor mapper included wird, kennt es die structs nicht. TODO: curses-teil separieren (map_tools.h) */ -#include -#include -#include -#include "mapper.h" - -/* kernel includes */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* util includes */ -#include -#include - -/* libc includes */ -#include - -typedef struct menulist { - struct menulist *next, *prev; - int *val; - char *text; -} menulist; - -enum { - C_COOL, - C_TEMPERATE, - C_DRY, - C_TROPIC, - MAXCLIMATES -}; - -static int -climate(int y) -{ - if (y < -BLOCKSIZE) - return C_COOL; - if (y > 2 * BLOCKSIZE) - return C_TROPIC; - if (y > BLOCKSIZE) - return C_DRY; - return C_TEMPERATE; -} - -#define MAXSEEDSIZE 17 -static char maxseeds[MAXCLIMATES][8] = -{ - {0, 1, 3, 3, 0, 3, 3, 4,}, /* Summe muß MAXSEEDSIZE sein */ - {0, 5, 4, 2, 0, 2, 3, 1,}, - {0, 6, 1, 0, 6, 2, 2, 0,}, - {0, 4, 5, 4, 0, 2, 2, 0,}, -}; - -static terrain_t -terrain_create(int climate) -{ - int i = rng_int() % MAXSEEDSIZE; - terrain_t terrain = T_OCEAN; - - while (i > maxseeds[climate][terrain]) - i -= maxseeds[climate][terrain++]; - return terrain; -} - -static terrain_t newblock[BLOCKSIZE][BLOCKSIZE]; - -void -block_create(short x1, short y1, int size, char chaotisch, int special, const terrain_type * terrain) -{ - int local_climate, k; - short x, y; - vset fringe; - - vset_init(&fringe); - -/* x1 = blockcoord(x1); - y1 = blockcoord(y1); -*/ local_climate = climate(y1); - - memset(newblock, T_OCEAN, sizeof newblock); - x = BLOCKSIZE / 2; - y = BLOCKSIZE / 2; - - vset_add(&fringe, (void *) (((short) (x) << 16) + - ((short) (y) & 0xFFFF))); - for (x=0;x!=BLOCKSIZE;++x) { - for (y=0;y!=BLOCKSIZE;++y) { - /* add the borders of the block taht have a - * non-ocean region in them to the fringe - * */ - int i; - direction_t d; - int nb[4][3]; - - memset(nb, 0, sizeof(nb)); - - for (d=0;d!=MAXDIRECTIONS;++d) { - region * r = findregion(x1 + delta_x[d] + x, y1 + delta_y[d]); - if (r && rterrain(r)!=T_OCEAN) { - nb[0][0] = x; - nb[0][1] = 0; - nb[0][2] = 1; - } - r = findregion(x1 + delta_x[d] + x, y1 + BLOCKSIZE - 1 + delta_y[d]); - if (r && rterrain(r)!=T_OCEAN) { - nb[1][0] = x; - nb[1][1] = BLOCKSIZE - 1; - nb[1][2] = 1; - } - r = findregion(x1 + delta_x[d] + BLOCKSIZE - 1, y1 + y + delta_y[d]); - if (r && rterrain(r)!=T_OCEAN) { - nb[2][0] = BLOCKSIZE - 1; - nb[2][1] = y; - nb[2][2] = 1; - } - r = findregion(x1 + delta_x[d], y1 + y + delta_y[d]); - if (r && rterrain(r)!=T_OCEAN) { - nb[3][0] = 0; - nb[3][1] = y; - nb[3][2] = 1; - } - } - - for (i=0;i!=3;++i) if (nb[i][2]) { - vset_add(&fringe, (void *) (((short) nb[i][0] << 16) + - ((short) nb[i][1] & 0xFFFF))); - } - } - } - for (k = 0; k != size; ++k) { - int c = (int) fringe.data[rng_int() % fringe.size]; - direction_t d; - - x = (short)(c >> 16); - y = (short)(c & 0xFFFF); - assert(newblock[x][y] == T_OCEAN); - newblock[x][y] = terrain_create(local_climate); - vset_erase(&fringe, (void *) c); - for (d = 0; d != MAXDIRECTIONS; ++d) { - short dx = x+delta_x[d]; - short dy = y+delta_y[d]; - if (dx >= 0 && dx < BLOCKSIZE && dy >= 0 && dy < BLOCKSIZE && newblock[dx][dy] == T_OCEAN) - vset_add(&fringe, (void *) (((short) (dx) << 16) + - ((short) (dy) & 0xFFFF))); - } - } - { - /* newblock wird innerhalb der Rahmen in die Karte kopiert, die - * Landstriche werden benannt und bevoelkert, und die produkte - * p1 und p2 des Kontinentes werden gesetzt. */ - region *r; - int i, i1 = -1, i2 = -1; - const luxury_type *ltype, *p1 = NULL, *p2=NULL; - int maxlux = get_maxluxuries(); - if (maxlux>0) { - i1 = (item_t)(rng_int() % maxlux); - do { - i2 = (item_t)(rng_int() % maxlux); - } - while (i2 == i1); - } - ltype = luxurytypes; - for (i=0;!p1 || !p2;++i) { - if (i==i1) p1=ltype; - else if (i==i2) p2=ltype; - ltype=ltype->next; - } - for (x = 0; x != BLOCKSIZE; x++) { - for (y = 0; y != BLOCKSIZE; y++) { - const luxury_type * sale = (rng_int()%2)?p1:p2; - r = findregion(x1 + x - BLOCKSIZE/2, y1 + y - BLOCKSIZE/2); - if (r && !fval(r->terrain, SEA_REGION)) continue; - if (r==NULL) r = new_region(x1 + x - BLOCKSIZE/2, y1 + y - BLOCKSIZE/2); - if (chaotisch) fset(r, RF_CHAOTIC); - if (special == 1) { - terraform_region(r, terrain); - } else if (special == 2) { - if (newblock[x][y] != T_OCEAN) - terraform_region(r, terrain); - else - terraform(r, T_OCEAN); - } else { - terraform(r, newblock[x][y]); - } - if (r->land && sale) setluxuries(r, sale); - } - } - } - vset_destroy(&fringe); -} - -static void -addmenulist(menulist ** SP, const char *s, int *val) -{ - menulist *S, *X; - S = calloc(1, sizeof(menulist)); - S->text = strdup(s); - S->val = val; - S->next = 0; - - if (*SP) { - for (X = *SP; X->next; X = X->next); - X->next = S; - S->prev = X; - } else { - S->prev = 0; - *SP = S; - } -} - -/* Wilder Hack: Zur Übergabe an addmenulist() brauchen wir Adressen, - * die die r*-Funktionen natürlich nicht mehr liefern. Also diese - * Variablen als Zwischenpuffer. */ - -static int peasants, money, trees, horses, iron, laen, chaotisch; - -static int saplings, seeds; - -static int ironlevel, laenlevel, stone, stonelevel; - -static void -get_region(region *r) { - struct rawmaterial *res; - - peasants = rpeasants(r); - money = rmoney(r); - trees = rtrees(r,2); - saplings = rtrees(r,1); - seeds = rtrees(r,0); - horses = rhorses(r); - iron = -1; - ironlevel = -1; - laen = -1; - laenlevel = -1; - stone = -1; - stonelevel = -1; - for (res=r->resources;res;res=res->next) { - const item_type * itype = resource2item(res->type->rtype); - if(itype == olditemtype[I_IRON]) { - iron = res->amount; - ironlevel = res->level + itype->construction->minskill - 1; - } else if(itype == olditemtype[I_LAEN]) { - laen = res->amount; - laenlevel = res->level + itype->construction->minskill - 1; - } else if(itype == olditemtype[I_STONE]) { - stone = res->amount; - stonelevel = res->level + itype->construction->minskill - 1; - } - } - chaotisch = fval(r, RF_CHAOTIC); -} - -static void -put_region(region *r) { - struct rawmaterial *res; - - rsetpeasants(r, peasants); - rsetmoney(r,money); - rsettrees(r,2,trees); - rsettrees(r,1,saplings); - rsettrees(r,0,seeds); - rsethorses(r, horses); - - for (res=r->resources;res;res=res->next) { - const item_type * itype = resource2item(res->type->rtype); - if(itype == olditemtype[I_IRON]) { - res->amount = iron; - res->level = ironlevel - itype->construction->minskill + 1; - } else if(itype == olditemtype[I_LAEN]) { - res->amount = laen; - res->level = laenlevel - itype->construction->minskill + 1; - } else if(itype == olditemtype[I_STONE]) { - res->amount = stone; - res->level = stonelevel - itype->construction->minskill + 1; - } - } - if (chaotisch) fset(r, RF_CHAOTIC); else freset(r, RF_CHAOTIC); -} - -static void -create_region_menu(menulist ** menu, region * r) -{ - char str[80]; - unit *u; - building *b; - ship *sh; - faction *f; - - get_region(r); - - addmenulist(menu, "Peasants", &peasants); - addmenulist(menu, "Silver", &money); - if (fval(r, RF_MALLORN)) { - addmenulist(menu, "Mallorntrees", &trees); - addmenulist(menu, "Mallornsaplings", &saplings); - addmenulist(menu, "Mallornseeds", &seeds); - } else { - addmenulist(menu, "Trees", &trees); - addmenulist(menu, "Saplings", &saplings); - addmenulist(menu, "Seeds", &seeds); - } - addmenulist(menu, "Horses", &horses); - -/* if(iron != -1) { */ - addmenulist(menu, "Iron", &iron); - addmenulist(menu, "Ironlevel", &ironlevel); -/* } */ -/* if(laen != -1) { */ - addmenulist(menu, "Laen", &laen); - addmenulist(menu, "Laenlevel", &laenlevel); -/* } */ -/* if(stone != -1) { */ - addmenulist(menu, "Stone", &stone); - addmenulist(menu, "Stonelevel", &stonelevel); -/* } */ - addmenulist(menu, "Chaos-Factor", &chaotisch); - - if (r->planep) { - strcpy(buf,"Plane: "); - strncpy(str, r->planep->name, 30); - str[30] = 0; - sncat(buf, str, BUFSIZE); - sncat(buf, " (", BUFSIZE); - sncat(buf, r->planep->name, BUFSIZE); - sncat(buf, ")", BUFSIZE); - addmenulist(menu, buf, 0); - } - strcpy(buf, "Buildings:"); - if (!r->buildings) { - sncat(buf, " keine", BUFSIZE); - addmenulist(menu, buf, 0); - } else { - addmenulist(menu, buf, 0); - for (b = r->buildings; b; b = b->next) { - sprintf(buf, " %s: ", Buildingid(b)); - for (u = r->units; u; u = u->next) - if (u->building == b && fval(u, UFL_OWNER)) { - strncpy(str, u->name, 28); - str[28] = 0; - sncat(buf, str, BUFSIZE); - sprintf(str, " (%s), Partei %s", unitid(u), factionid(u->faction)); - sncat(buf, str, BUFSIZE); - break; - } - if (!u) - sncat(buf, "steht leer", BUFSIZE); - addmenulist(menu, buf, 0); - } - } - - strcpy(buf, "Ships:"); - if (!r->ships) { - sncat(buf, " keine", BUFSIZE); - addmenulist(menu, buf, 0); - } else { - addmenulist(menu, buf, 0); - for (sh = r->ships; sh; sh = sh->next) { - sprintf(buf, " %s: ", shipname(sh)); - if (sh->size!=sh->type->construction->maxsize) - sncat(buf, "(im Bau) ", BUFSIZE); - for (u = r->units; u; u = u->next) - if (u->ship == sh && fval(u, UFL_OWNER)) { - strncpy(str, u->name, 28); - str[28] = 0; - sncat(buf, str, BUFSIZE); - sprintf(str, " (%s), Partei %s", unitid(u), factionid(u->faction)); - sncat(buf, str, BUFSIZE); - break; - } - if (!u) - sncat(buf, "ohne Besitzer", BUFSIZE); - addmenulist(menu, buf, 0); - } - } - - strcpy(buf, "Parteien:"); - - if (!r->units) { - sncat(buf, " keine", BUFSIZE); - addmenulist(menu, buf, 0); - } else { - for (f = factions; f; f = f->next) - f->num_people = f->no_units = 0; - for (u = r->units; u; u = u->next) { - u->faction->no_units++; - u->faction->num_people += u->number; - } - addmenulist(menu, buf, 0); - - for (f = factions; f; f = f->next) { - if (f->no_units) { - sprintf(buf, " %s: ", factionname(f)); - sprintf(str, "Einheiten: %d; Leute: %d", f->no_units, f->num_people); - sncat(buf, str, BUFSIZE); - addmenulist(menu, buf, 0); - } - } - } -} - -char modified = 0; - -WINDOW *mywin; -int pline; - -#define Printw(x,l) \ - { \ - wmove(mywin,l,4); \ - Addstr(x->text); \ - if (x->val) wprintw(mywin, (NCURSES_CONST char*)": %d",(char*)*(x->val)); \ - } \ - -static void -modify_value(menulist * v) -{ - int vl; - vl = map_input(mywin, 40, pline, "Neuer Wert", -1, 999999, *(v->val)); - Movexy(4, pline); - wclrtoeol(mywin); - Printw(v, pline); - if (vl != *(v->val)) { - modified = 1; - *(v->val) = vl; - } -} - -void -NeuesSchiff(region * r) -{ - ship_type *stype[40]; /* Maximal 40 Schiffe */ - ship_typelist *st; - ship *s; - WINDOW *win; - int i, q, y, maxtype; - - for(st = shiptypes, maxtype=0; st; st=st->next, maxtype++) { - stype[maxtype] = (ship_type *)st->type; - } - - win = openwin(SX - 10, 6, "< Neues Schiff erschaffen >"); - - q = 0; - y = 2; - wmove(win, y, 4); - for (i = 0; i < maxtype; i++) { - sprintf(buf, "%d=%s; ", i, stype[i]->name[0]); - q += strlen(buf); - if (q > SX - 20) { - q = strlen(buf); - y++; - wmove(win, y, 4); - } - waddnstr(win, buf, -1); - } - wrefresh(win); - q = map_input(win, 2, 1, "Schiffstyp", -1, maxtype, 0); - - if (q < 0) { - delwin(win); - return; - } - for (; y > 0; y--) { - wmove(win, y, 2); - wclrtoeol(win); - wrefresh(win); - wmove(win, y, win->_maxx); - waddch(win, '|'); - wrefresh(win); - } - wmove(win, 1, 2); - wAddstr(stype[q]->name[0]); - wrefresh(win); - - s = new_ship(stype[q], default_locale, r); - s->region = r; - - strcpy(buf, my_input(win, 2, 2, "Name: ", NULL)); - if (strlen(buf) > 0) - set_string(&s->name, buf); - if (clipunit) { - wmove(win, 3, 2); - wAddstr("Einheit im Clip: "); - wAddstr(Unitid(clipunit)); - wmove(win, 4, 2); - if (yes_no(win, "Clipunit als Besitzer?", 'n')) { - leave(clipregion, clipunit); - if (r != clipregion) - translist(&clipregion->units, &r->units, clipunit); - clipunit->ship = s; - fset(clipunit, UFL_OWNER); - } - } - delwin(win); - modified = 1; -} - -static const char * oldbuildings[] = { - "castle", - "lighthouse", - "mine", - "quarry", - "harbour", - "academy", - "magictower", - "smithy", - "sawmill", - "stables", - "monument", - "dam", - "caravan", - "tunnel", - "inn", - "stonecircle", - "blessedstonecircle", - "illusion", - NULL -}; - -void -NeueBurg(region * r) -{ - building *b; - WINDOW *win; - int i, q, y; - win = openwin(SX - 10, 10, "< Neues Gebäude erschaffen >"); - - q = 0; - y = 2; - wmove(win, y, 4); - for (i = 0; oldbuildings[i]; i++) { - sprintf(buf, "%d=%s; ", i, oldbuildings[i]); - q += strlen(buf); - if (q > SX - 20) { - q = strlen(buf); - y++; - wmove(win, y, 4); - } - waddnstr(win, buf, -1); - } - wrefresh(win); - q = map_input(win, 2, 1, "Gebäudetyp", -1, i, 0); - - if (q < 0) { - delwin(win); - return; - } - for (; y > 0; y--) { - wmove(win, y, 4); - wclrtoeol(win); - wrefresh(win); - wmove(win, y, win->_maxx); - waddch(win, '|'); - } - wmove(win, 1, 2); - wAddstr((char*)oldbuildings[q]); - wrefresh(win); - - b = new_building(bt_find(oldbuildings[q]), r, NULL); - - b->size = map_input(win, 2, 2, "Grösse", 1, 99999, 1); - - strcpy(buf, my_input(win, 2, 3, "Name: ", NULL)); - if (strlen(buf) > 0) - set_string(&b->name, buf); - if (clipunit) { - wmove(win, 4, 2); - wAddstr("Einheit im Clip: "); - wAddstr(Unitid(clipunit)); - wmove(win, 5, 2); - if (yes_no(win, "Clipunit als Besitzer?", 'n')) { - leave(clipregion, clipunit); - if (r != clipregion) - translist(&clipregion->units, &r->units, clipunit); - clipunit->building = b; - fset(clipunit, UFL_OWNER); - } - } - delwin(win); - modified = 1; -} - -int -modify_region(region * r) -{ - menulist *eh = NULL, *unten, *oben, *hlp = NULL, *such = NULL, *mpoint; - int line, ch, bottom, bot; - size_t lt; - char *s = NULL, *txt, *suchtext = NULL; - - create_region_menu(&eh, r); - - clear(); - strncpy(buf, rname(r, NULL), 65); - buf[65] = 0; - movexy(0, 0); - printw((char*)"%s (%d,%d):", buf, r->x, r->y); - for (line = 0; line <= SX; line++) - buf[line] = '-'; - movexy(0, SY - 1); - addstr(buf); - movexy(0, 1); - addstr(buf); - movexy(0, SY); - addstr(": Neuer Wert; T: neuer Text; u: Units; B: neue Burg; S: neues Schiff"); - refresh(); - - mywin = newwin(SY - 3, SX, 2, 0); - wclear(mywin); - bot = mywin->_maxy + 1; - for (line = 0, unten = eh; line < bot && unten->next; line++, unten = unten->next) { - Printw(unten, line); - wrefresh(mywin); - } - Printw(unten, line); - wrefresh(mywin); - - bottom = line - 1; - mpoint = oben = eh; /* unten=unten->prev; */ - scrollok(mywin, TRUE); - pline = 0; - - for (;;) { - Movexy(1, pline); - if (mpoint->val) { - wattron(mywin, A_BOLD); - Addstr("=>"); - wattroff(mywin, A_BOLD); - move(SY, 0); - clrtoeol(); - addstr(": Neuer Wert; T: neuer Text; u: Units; B: neue Burg; S: neues Schiff"); - refresh(); - } else { - Addstr("->"); - move(SY, 0); - clrtoeol(); - addstr("u: Units; T: neuer Text; B: neue Burg; S: neues Schiff"); - refresh(); - } - wrefresh(mywin); - ch = getch(); - Movexy(1, pline); - Addstr(" "); - switch (ch) { - case KEY_DOWN: - if (mpoint->next) { - mpoint = mpoint->next; - if (pline > bottom) { - pline--; - if (unten->next) { - wscrl(mywin, 1); - Printw(unten, bottom); - unten = unten->next; - oben = oben->next; - } - } - pline++; - } else - beep(); - break; - case KEY_UP: - if (mpoint->prev) { - mpoint = mpoint->prev; - pline--; - if (pline < 0) { - pline++; - if (oben->prev) { - unten = unten->prev; - oben = oben->prev; - wscrl(mywin, -1); - Printw(oben, 0); - } - } - } else - beep(); - break; - case KEY_RIGHT: - case KEY_NPAGE: - for (line = 0; line < 20 && unten->next; line++) { - oben = oben->next; - unten = unten->next; - if (mpoint->next) - mpoint = mpoint->next; - else - pline--; - } - wclear(mywin); - for (line = 0, hlp = oben; line < bot && hlp->next; line++, hlp = hlp->next) { - Printw(hlp, line); - wrefresh(mywin); - } - Printw(hlp, line); - wrefresh(mywin); - bottom = line - 1; - if (pline < 0) - pline = 0; - break; - case KEY_PPAGE: - case KEY_LEFT: - for (line = 0; line < 20 && oben->prev; line++) { - oben = oben->prev; - unten = unten->prev; - if (mpoint->prev) - mpoint = mpoint->prev; - else - pline++; - } - wclear(mywin); - for (line = 0, hlp = oben; line < bot && hlp->next; line++, hlp = hlp->next) { - Printw(hlp, line); - wrefresh(mywin); - } - Printw(hlp, line); - wrefresh(mywin); - bottom = line - 1; - if (pline > bottom) - pline = bottom; - break; - case 12: /* ^L -> redraw */ - wclear(mywin); - for (line = 0, hlp = oben; line < bot && hlp->next; line++, hlp = hlp->next) { - Printw(hlp, line); - wrefresh(mywin); - } - Printw(hlp, line); - wrefresh(mywin); - bottom = line - 1; - break; - case '/': - suchtext = my_input(0, 0, 0, (char*)"Suchtext: ", NULL); - such = eh; - case 'n': - line = 0; - lt = strlen(suchtext); - while (such->next && !line) { - s = such->text; - while (strlen(s) >= lt && !line) { - if (strncasecmp(s, suchtext, lt) == 0) - line = 1; - s++; - } - such = such->next; - } - if (line) { - wclear(mywin); - Movexy(4, 0); - txt = such->prev->text; - s--; - ch = *s; - *s = 0; - Addstr(txt); - wattron(mywin, A_REVERSE); - *s = (char)ch; - txt = s; - ch = txt[lt]; - txt[lt] = 0; - Addstr(txt); - wattroff(mywin, A_REVERSE); - txt[lt] = (char)ch; - txt += lt; - Addstr(txt); - if (such->prev->val) { - sprintf(buf, ": %d", *(such->prev->val)); - Addstr(buf); - } - for (line = 0, hlp = oben; line < bot && hlp->next; line++, hlp = hlp->next) { - Printw(hlp, line); - wrefresh(mywin); - } - Printw(hlp, line); - wrefresh(mywin); - bottom = line - 1; - oben = such->prev ? such->prev : such; - unten = hlp->prev; - mpoint = oben; - pline = 0; - } else { - movexy(0, SY); - beep(); - clrtoeol(); - printw((char*)"'%s' nicht gefunden.", suchtext); - refresh(); - } - break; - case KEY_HELP: - case '?': - case 'h': - movexy(0, SY); - clrtoeol(); - addstr(": Neuer Wert; u: Einheitenliste; B: neue Burg; S: neues Schiff"); - refresh(); - break; - case '>': - wclear(mywin); - do { - unten = unten->next; - oben = oben->next; - } while (unten->next); - for (line = 0, hlp = oben; line < bot && hlp; line++, hlp = hlp->next) { - Printw(hlp, line); - wrefresh(mywin); - } - Printw(hlp, line); - wrefresh(mywin); - bottom = line - 1; - mpoint = unten; - pline = bottom; - break; - case '<': - wclear(mywin); - for (line = 0, unten = eh; line < bot && unten->next; line++, unten = unten->next) { - Printw(unten, line); - wrefresh(mywin); - } - Printw(hlp, line); - wrefresh(mywin); - bottom = line - 1; - mpoint = such = oben = eh; - unten = unten->prev; - pline = 0; - break; - case 10: - case 13: - if (mpoint->val) { - modify_value(mpoint); - for (line = 0, unten = eh; line < bot && unten->next; line++, unten = unten->next) { - Printw(unten, line); - wrefresh(mywin); - } - Printw(unten, line); - wrefresh(mywin); - } else - beep(); - break; - case 'T': - - case 'B': - if (fval(r->terrain, LAND_REGION)) { - NeueBurg(r); - return 1; - } else - beep(); - case 'S': - NeuesSchiff(r); - return 1; - case 'u': - while (showunits(r)); - wclear(mywin); - for (line = 0, hlp = oben; line < bot && hlp->next; line++, hlp = hlp->next) { - Printw(hlp, line); - wrefresh(mywin); - } - Printw(hlp, line); - wrefresh(mywin); - bottom = line - 1; - break; - case 27: /* Esc */ - case 'q': - put_region(r); - delwin(mywin); - freelist(eh); - return 0; - } - } -} - -void -make_new_region(short x, short y) -{ - WINDOW *win; - region *r; - const terrain_type * terrain = NULL; - - win = openwin(SX - 10, 10, "< Region erzeugen >"); - - x = (short)map_input(win, 2, 1, "X-Koordinate", -999, 999, x); - y = (short)map_input(win, 2, 2, "Y-Koordinate", -999, 999, y); - wmove(win, 3, 2); - if ((r=findregion(x, y))!=NULL) { - if (!yes_no(win, "Dort ist schon etwas! Überschreiben?", 'n')) - return; - else { - wmove(win, 3, 2); - wclrtoeol(win); - wmove(win, 3, win->_maxx); - waddch(win, '|'); - } - } else - r=new_region(x,y); - - terrain = select_terrain(NULL); - terraform_region(r, terrain); - - wrefresh(win); - wmove(win, 4, 3); - if(yes_no(win, "Chaotische Region?", 'n')) { - fset(r, RF_CHAOTIC); - } else { - freset(r, RF_CHAOTIC); - } - modified=1; -} - -#define BLOCK_RADIUS 6 - -void -make_ocean_block(short x, short y) -{ - short cx, cy; - region *r; - - for(cx = x - BLOCK_RADIUS; cx < x+BLOCK_RADIUS; cx++) { - for(cy = y - BLOCK_RADIUS; cy < y+BLOCK_RADIUS; cy++) { - if(koor_distance(cx, cy, x, y) < BLOCK_RADIUS) { - if (!findregion(cx, cy)) { - r = new_region(cx, cy); - terraform(r, T_OCEAN); - } - } - } - } -} - -const terrain_type * -select_terrain(const terrain_type * default_terrain) -{ - selection *prev, *ilist = NULL, **iinsert; - selection *selected = NULL; - const terrain_type * terrain = terrains(); - - if (!terrain) return NULL; - iinsert = &ilist; - prev = ilist; - - while (terrain) { - push_selection(iinsert, terrain->_name, (void*)terrain); - terrain = terrain->next; - } - selected = do_selection(ilist, "Terrain", NULL, NULL); - if (selected==NULL) return NULL; - return (const terrain_type*)selected->data; -} - -void -make_new_block(int x, int y) -{ - WINDOW *win; - int z, special = 0; - char chaos; - const terrain_type * terrain = NULL; - - win = openwin(SX - 10, 10, "< Block erzeugen >"); - - x = map_input(win, 2, 1, "X-Koordinate innerhalb des Blocks", -999, 999, x); - y = map_input(win, 2, 2, "Y-Koordinate innerhalb des Blocks", -999, 999, y); - wmove(win, 3, 2); - if (findregion(x, y)) { - if (!yes_no(win, "Dort ist schon etwas! Überschreiben?", 'n')) - return; - else { - wmove(win, 3, 2); - wclrtoeol(win); - wmove(win, 3, win->_maxx); - waddch(win, '|'); - } - } - z = 2; - wmove(win, ++z, 2); - if (yes_no(win, "Mini-Insel?", 'n')) - special = 4; - else { - wmove(win, ++z, 2); - if (yes_no(win, "Nur Wasser?", 'n')) { - special = 1; - terrain = newterrain(T_OCEAN); - } - else { - wmove(win, ++z, 2); - if (yes_no(win, "1-Terrain-Insel?", 'n')) { - terrain = select_terrain(NULL); - } - } - } - wmove(win, ++z, 2); - if (special != 1) - chaos = (char)(yes_no(win, "Chaotischer Block?", 'n') ? 1 : 0); - else - chaos = 0; - - block_create(x, y, ISLANDSIZE, chaos, special, terrain); - - if (y < MINY) - MINY -= 9; - else if (y > MAXY) - MAXY += 9; - if (x < MINX) - MINX -= 9; - else if (x > MAXX) - MAXX += 9; - modified = 1; -} - -static terrain_t -choose_terrain(terrain_t t) { - int q; - - if (rng_int()%100 < 50) return t; - if (rng_int()%100 < 10) return T_OCEAN; - - q = rng_int()%100; - - switch (t) { - case T_OCEAN: - if(rng_int()%100 < 60) return T_OCEAN; - switch(rng_int()%6) { - case 0: - return T_SWAMP; - case 1: - return T_PLAIN; - case 2: - return T_GLACIER; - case 3: - return T_DESERT; - case 4: - return T_HIGHLAND; - case 5: - return T_MOUNTAIN; - } - break; - case T_PLAIN: - if (q<20) - return T_SWAMP; - if (q<40) - return T_MOUNTAIN; - if (q<50) - return T_HIGHLAND; - if (q<80) - return T_DESERT; - if (q<90) - return T_GLACIER; - break; - case T_SWAMP: - if (q<40) - return T_PLAIN; - if (q<65) - return T_HIGHLAND; - if (q<80) - return T_MOUNTAIN; - if (q<90) - return T_GLACIER; - if (q<95) - return T_DESERT; - break; - case T_HIGHLAND: - if (q<35) - return T_PLAIN; - if (q<50) - return T_MOUNTAIN; - if (q<70) - return T_GLACIER; - if (q<80) - return T_SWAMP; - if (q<90) - return T_DESERT; - break; - case T_DESERT: - if (q<35) - return T_PLAIN; - if (q<45) - return T_MOUNTAIN; - if (q<50) - return T_GLACIER; - if (q<55) - return T_SWAMP; - if (q<70) - return T_HIGHLAND; - break; - case T_MOUNTAIN: - if (q<35) - return T_PLAIN; - if (q<65) - return T_HIGHLAND; - if (q<80) - return T_GLACIER; - if (q<90) - return T_SWAMP; - if (q<95) - return T_DESERT; - break; - case T_GLACIER: - if (q<35) - return T_PLAIN; - if (q<50) - return T_MOUNTAIN; - if (q<70) - return T_HIGHLAND; - if (q<90) - return T_SWAMP; - if (q<95) - return T_DESERT; - break; - } - return t; -} - -region *t_queue[10000]; -int t_queue_len = 0; - -void -push(region *r) { - t_queue[t_queue_len] = r; - t_queue_len++; -} - -static region * -shift(void) -{ - int p; - region *r; - - if(t_queue_len == 0) return NULL; - - p = rng_int()%t_queue_len; - r = t_queue[p]; - - memmove(&t_queue[p], &t_queue[p+1], (10000-p)*sizeof(region *)); - t_queue_len--; - return r; -} - -static const luxury_type * tradegood = NULL; - -void -settg(region *r) -{ - const luxury_type * ltype; - int g = get_maxluxuries(); - if (tradegood==NULL) tradegood = luxurytypes; - - for (ltype=luxurytypes; ltype; ltype=ltype->next) { - if (ltype!=tradegood) r_setdemand(r, ltype, 1 + rng_int() % 5); - } - r_setdemand(r, tradegood, 0); - if (g>0 && (rng_int()%10)<2) { - int t = rng_int() % g; - - for (tradegood = luxurytypes;t;--t) { - tradegood = tradegood->next; - } - } -} - -boolean -Create_Island(region *r, int * n, const terrain_type * terrain, int x, int y) { - terrain_t t = oldterrain(terrain); - if (!r) return false; - if (*n == 0) return true; - - if((t == T_MOUNTAIN || t == T_GLACIER) && rng_int()%100 < 5) { - terraform(r,T_VOLCANO); - } else { - terraform_region(r, terrain); - } - if (r->land) settg(r); - (*n)--; - - return false; -} - -void -create_island(region *r, int n, const struct terrain_type * terrain) -{ - short sx=r->x, sy=r->y, i, x = 0, y = 0; - direction_t d; - boolean abbruch=false; - region *r2; - - for(r2=regions; r2; r2=r2->next) { - r2->msgs = (void *)0; - } - tradegood = NULL; - terraform_region(r, terrain); - if(r->land) settg(r); - r->msgs = (void *)(rng_int()%6); - - push(r); - for(d=0; dmsgs = (void *)(int)d; - } - } - - while (n>0 && (r=shift())!=NULL) { - for(i = -1; i <= 1; i++) { - int d = ((int)r->msgs + i + 6)%6; - - switch(d) { - case 0: - x=r->x-1; y=r->y; /* Westen */ - break; - case 1: - x=r->x-1; y=r->y+1; /* Nordwesten */ - break; - case 2: - x=r->x; y=r->y+1; /* Nordosten */ - break; - case 3: - x=r->x+1; y=r->y; /* Osten */ - break; - case 4: - x=r->x+1; y=r->y-1; /* Südosten */ - break; - case 5: - x=r->x; y=r->y-1; /* Südwesten */ - break; - } - r2 = findregion(x,y); - if (r2 && fval(r2->terrain, SEA_REGION)) { - const terrain_type * terrain = NULL; - do { - terrain_t t = choose_terrain(oldterrain(r2->terrain)); - terrain = newterrain(t); - } while (terrain==NULL); - r2->msgs = (void *)d; - push(r2); - abbruch = Create_Island(r2, &n, terrain, sx, sy); - } - if (abbruch) break; - } - } - - t_queue_len = 0; -} - diff --git a/src/mapper/map_partei.c b/src/mapper/map_partei.c deleted file mode 100644 index be9fefbc4..000000000 --- a/src/mapper/map_partei.c +++ /dev/null @@ -1,555 +0,0 @@ -/* vi: set ts=2: - * - * Eressea PB(E)M host Copyright (C) 1998-2003 - * Christian Schlittchen (corwin@amber.kn-bremen.de) - * Katja Zedel (katze@felidae.kn-bremen.de) - * Henning Peters (faroul@beyond.kn-bremen.de) - * Enno Rehling (enno@eressea-pbem.de) - * Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de) - * - * This program may not be used, modified or distributed without - * prior permission by the authors of Eressea. - */ - -#include -#include -#include -#include "mapper.h" - -#include - -/* kernel includes */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* util includes */ -#include -#include -#include - -/* libc includes */ -#include -#include -#include - -#ifdef __USE_POSIX -#include -#include -#include -#endif - -const char * orderfile = NULL; - -void -RemovePartei(void) { - faction *f, *F; - ally *a, *anext; - WINDOW *win; - char *fac_nr36; - int x; - unit *u; - region *r; - win = openwin(SX - 20, 5, "< Partei löschen >"); - - fac_nr36 = my_input(win, 2, 1, "Partei Nummer: ", NULL); - - x = atoi36(fac_nr36); - - if (fac_nr36 && *fac_nr36 && x > 0) { - wmove(win, 1, 2); - wclrtoeol(win); - wrefresh(win); - wmove(win, 1, win->_maxx); - waddch(win, '|'); - wrefresh(win); - F = findfaction(x); - wmove(win, 1, 2); - if (F) { - wAddstr(factionname(F)); - wrefresh(win); - wmove(win, 3, 4); - wattron(win, A_BOLD); - wAddstr("Alle Einheiten gehen verloren!"); - wattroff(win, A_BOLD); - wmove(win, 3, 4); - beep(); - if (yes_no(win, "Diese Partei wirklich löschen?", 'n')) { - for (f = factions; f; f = f->next) - if (f != F) - for (a = f->allies; a; a = anext) { - anext = a->next; - if (a->faction->no == F->no) - removelist(&f->allies, a); - } - for (r = firstregion(F); r != lastregion(F); r = r->next) - for (u = r->units; u; u = u->next) - if (u->faction == F) - set_number(u, 0); - modified = 1; - remove_empty_units(); - removelist(&factions, F); - findfaction(-1); /* static lastfaction auf NULL setzen */ - } - } else { - wprintw(win, (NCURSES_CONST char*)"Partei %d gibt es nicht.", x); - wmove(win, 3, 6); - wAddstr(""); - wrefresh(win); - getch(); - } - } - delwin(win); -} - -extern int left, top, breit, hoch; - -typedef struct island { - vmap factions; - int maxage; - int x; - int y; - unsigned int land; - int age; -} island; - -newfaction * -select_newfaction(const struct race * rc) -{ - selection *prev, *ilist = NULL, **iinsert; - selection *selected = NULL; - newfaction *player = newfactions; - - if (!player) return NULL; - insert_selection(&ilist, NULL, "new player", NULL); - iinsert=&ilist->next; - prev = ilist; - - while (player) { - if (rc==NULL || player->race==rc) { - char str[80]; - if (alliances!=NULL) { - snprintf(str, 70, "%s %d %s %s", player->bonus?"!":" ", player->allies?player->allies->id:0, locale_string(default_locale, rc_name(player->race, 0)), player->email); - } else { - snprintf(str, 70, "%s %s %s", player->bonus?"!":" ", locale_string(default_locale, rc_name(player->race, 0)), player->email); - } - insert_selection(iinsert, prev, str, (void*)player); - prev = *iinsert; - iinsert = &prev->next; - } - player=player->next; - } - selected = do_selection(ilist, "Partei", NULL, NULL); - if (selected==NULL) return NULL; - return (newfaction*)selected->data; -} - -void -NeuePartei(region * r) -{ - int i, q, y; - char email[INPUT_BUFSIZE+1]; - newfaction * nf, **nfp; - const struct locale * lang; - const struct race * frace; - int late, subscription = 0; - unit *u; - const char * passwd = NULL; - int locale_nr; - faction * f; - - if (!r->land) { - warnung(0, "Ungeeignete Region! "); - return; - } - - nf = select_newfaction(NULL); - - if (nf!=NULL) { - frace = nf->race; - subscription = nf->subscription; - late = nf->bonus; - lang = nf->lang; - passwd = nf->password; - strcpy(email, nf->email); - if (late) { - WINDOW *win = openwin(SX - 10, 3, "< Neue Partei einfügen >"); - if(r->age >= 5) - late = (int) map_input(win, 2, 1, "Startbonus", -1, 99, r->age/2); - else - late = (int) map_input(win, 2, 1, "Startbonus", -1, 99, 0); - delwin(win); - } - } else { - WINDOW *win = openwin(SX - 10, 12, "< Neue Partei einfügen >"); - - strcpy(buf, my_input(win, 2, 1, "EMail-Adresse (Leer->Ende): ", NULL)); - if (!buf[0]) { - delwin(win); - return; - } - - strcpy(email, buf); - for (f=factions;f;f=f->next) { - if (strcmp(email, f->email)==0 && f->age==0) { - warnung(0, "Neue Partei mit dieser Adresse existiert bereits."); - delwin(win); - return; - } - } - - y = 3; - q = 0; - wmove(win, y, 4); - for (i = 0; i < MAXRACES; i++) if(playerrace(new_race[i])) { - sprintf(buf, "%d=%s; ", i, new_race[i]->_name[0]); - q += strlen(buf); - if (q > SX - 20) { - q = strlen(buf); - y++; - wmove(win, y, 4); - } - wAddstr(buf); - } - wrefresh(win); - - y++; - do { - int nrace = (char) map_input(win, 2, y, "Rasse", -1, MAXRACES-1, 0); - if (nrace == -1) { - delwin(win); - return; - } - frace = new_race[nrace]; - } while(!playerrace(frace)); - - y++; - late = (int) map_input(win, 2, y, "Startbonus", -1, 99, 0); - if(late == -1) { - delwin(win); - return; - } - i = 0; q = 0; y++; - wmove(win, y, 4); - while(localenames[i] != NULL) { - sprintf(buf, "%d=%s; ", i, localenames[i]); - q += strlen(buf); - if (q > SX - 20) { - q = strlen(buf); - y++; - wmove(win, y, 4); - } - wAddstr(buf); - i++; - } - wrefresh(win); - - y++; - locale_nr = map_input(win, 2, 8, "Locale", -1, i-1, 0); - if(locale_nr == -1) { - delwin(win); - return; - } - lang = find_locale(localenames[locale_nr]); - - delwin(win); - } - - /* remove duplicate email addresses */ - nfp=&newfactions; - while (*nfp) { - newfaction * nf = *nfp; - if (strcmp(email, nf->email)==0) { - *nfp = nf->next; - free(nf); - } - else nfp = &nf->next; - } - modified = 1; - u = addplayer(r, addfaction(email, passwd, frace, lang, subscription)); - ++numnewbies; - - sprintf(buf, "newuser %s", email); - system(buf); -} - -static void -ModifyPartei(faction * f) -{ - int c, i, q, y; - int fmag = count_skill(f, SK_MAGIC); - int falch = count_skill(f, SK_ALCHEMY); - WINDOW *win; - unit *u; - sprintf(buf, "<%s >", factionname(f)); - win = openwin(SX - 6, 12, buf); - wmove(win, 1, 2); - wprintw(win, (NCURSES_CONST char*)"Rasse: %s", f->race->_name[1]); - wmove(win, 2, 2); - wprintw(win, (NCURSES_CONST char*)"Einheiten: %d", f->no_units); - wmove(win, 3, 2); - wprintw(win, (NCURSES_CONST char*)"Personen: %d", f->num_people); - wmove(win, 4, 2); - wprintw(win, (NCURSES_CONST char*)"Silber: %d", f->money); - wmove(win, 5, 2); - wprintw(win, (NCURSES_CONST char*)"Magier: %d", fmag); - if (fmag) { - region *r; - freset(f, FL_DH); - waddnstr(win, " (", -1); - for (r = firstregion(f); r != lastregion(f); r = r->next) - for (u = r->units; u; u = u->next) - if (u->faction == f && has_skill(u, SK_MAGIC)) { - if (fval(f, FL_DH)) - waddnstr(win, ", ", -1); - wprintw(win, (NCURSES_CONST char*)"%s(%d): %d", unitid(u), u->number, get_level(u, SK_MAGIC)); - fset(f, FL_DH); - } - waddch(win, ')'); - } - wmove(win, 6, 2); - wprintw(win, (NCURSES_CONST char*)"Alchemisten: %d", falch); - if (falch) { - region *r; - waddnstr(win, " (", -1); - freset(f, FL_DH); - for (r = firstregion(f); r != lastregion(f); r = r->next) - for (u = r->units; u; u = u->next) - if (u->faction == f && has_skill(u, SK_ALCHEMY)) { - if (fval(f, FL_DH)) - waddnstr(win, ", ", -1); - wprintw(win, (NCURSES_CONST char*)"%s(%d): %d", unitid(u), u->number, get_level(u, SK_ALCHEMY)); - fset(f, FL_DH); - } - waddch(win, ')'); - } - wmove(win, 7, 2); - wprintw(win, (NCURSES_CONST char*)"Regionen: %d", f->nregions); - wmove(win, 8, 2); - wprintw(win, (NCURSES_CONST char*)"eMail: %s", f->email); - wmove(win, 10, 2); - wprintw(win, (NCURSES_CONST char*)"Neue (R)asse oder (e)Mail, (q)uit"); - wrefresh(win); - - for(;;) { - c = getch(); - switch (tolower(c)) { - case 'q': - case 27: - delwin(win); - touchwin(stdscr); - return; - case 'r': - mywin = newwin(5, SX - 20, (SY - 5) / 2, (SX - 20) / 2); - wclear(mywin); - /*wborder(mywin, '|', '|', '-', '-', '.', '.', '`', '\'');*/ - wborder(mywin, 0, 0, 0, 0, 0, 0, 0, 0); - Movexy(3, 0); - Addstr("< Rasse wählen >"); - wrefresh(mywin); - y = 2; - q = 0; - wmove(mywin, y, 4); - for (i = 1; i < MAXRACES; i++) { - sprintf(buf, "%d=%s; ", i, new_race[i]->_name[0]); - q += strlen(buf); - if (q > SX - 25) { - q = strlen(buf); - y++; - wmove(mywin, y, 4); - } - wAddstr(buf); - } - q = map_input(mywin, 2, 1, "Rasse", 1, MAXRACES-1, old_race(f->race)); - delwin(mywin); - touchwin(stdscr); - touchwin(win); - if (new_race[q] != f->race) { - modified = 1; - f->race = new_race[q]; - wmove(win, 1, 2); - wprintw(win, (NCURSES_CONST char*)"Rasse: %s", f->race->_name[1]); - } - refresh(); - wrefresh(win); - break; - case 'e': - strcpy(buf, my_input(0, 0, 0, "Neue eMail: ", NULL)); - touchwin(stdscr); - touchwin(win); - if (strlen(buf)) { - strcpy(f->email, buf); - wmove(win, 8, 2); - wprintw(win, (NCURSES_CONST char*)"eMail: %s", f->email); - modified = 1; - } - refresh(); - wrefresh(win); - break; - } - } -} - - -int -ParteiListe(void) -{ - dbllist *P = NULL, *oben, *unten, *tmp; - faction *f; - char *s; - int x; - - clear(); - move(1, 1); - addstr("generiere Liste..."); - refresh(); - - for (f = factions; f; f = f->next) { - if (SX > 104) - sprintf(buf, "%4s: %-30.30s %-12.12s %-24.24s", factionid(f), - f->name, f->race->_name[1], f->email); - else - sprintf(buf, "%4s: %-30.30s %-12.12s", factionid(f), - f->name, f->race->_name[1]); - adddbllist(&P, buf); - } - - oben = unten = pointer = P; - pline = 0; - x = -1; - clear(); - - movexy(0, SY - 1); - hline('-', SX + 1); - movexy(0, SY); - addstr(" Daten; /: suchen; D: Löschen; q,Esc: Ende"); - - for (;;) { - if (x == -1) { - clear(); - if(oben) { - for (unten = oben, x = 0; x < SY - 1 && unten->next; x++) { - movexy(3, x); - addstr(unten->s); - unten = unten->next; - } - } - if (x < SY - 1 && unten) { /* extra, weil sonst - * unten=NULL nach for() */ - movexy(3, x); - addstr(unten->s); - } - movexy(0, SY - 1); - hline('-', SX + 1); - movexy(0, SY); - addstr(" Daten; /: suchen; D: Löschen; q,Esc: Ende"); - } - movexy(0, pline); - addstr("->"); - refresh(); - x = getch(); - movexy(0, pline); - addstr(" "); - switch (x) { - case 'q': - case 27: - return 0; - case 13: - case 10: - { - char fno[5]; - strncpy(fno, pointer->s, 4); - fno[4]=0; - ModifyPartei(findfaction(atoi36(fno))); - } - break; - case 'D': - RemovePartei(); - return 1; - case KEY_DOWN: - if (pointer->next) { - pline++; - pointer = pointer->next; - if (pline == SY - 1) { - x = 20; - do { - oben = oben->next; - unten = unten->next; - x--; - pline--; - } while (x && unten /*->next*/ ); - x = -1; - } - } else - beep(); - break; - case KEY_UP: - if (pointer->prev) { - pline--; - pointer = pointer->prev; - if (pline < 0) { - x = 20; - do { - oben = oben->prev; - unten = unten->prev; - x--; - pline++; - } while (x && oben->prev); - x = -1; - } - } else - beep(); - break; - case KEY_NPAGE: - case KEY_RIGHT: - for (x = 20; x && unten; x--) { - oben = oben->next; - pointer = pointer->next; - unten = unten->next; - } - x = -1; - break; - case KEY_PPAGE: - case KEY_LEFT: - for (x = 20; x && oben->prev; x--) { - oben = oben->prev; - pointer = pointer->prev; - unten = unten->prev; - } - x = -1; - break; - case '/': - strcpy(buf, my_input(0, 0, 0, "Partei Nr. oder Name: ", NULL)); - touchwin(stdscr); /* redraw erzwingen */ - for (tmp = P; tmp; tmp = tmp->next) { - s = tmp->s; - while (s && strncasecmp(buf, s, strlen(buf))) { - s = strchr(s, ' '); - if (s) - s++; - } - if (s) - break; - } - if (tmp) { - pointer = tmp; - pline = 0; - if (tmp->prev) { - tmp = tmp->prev; - pline++; - } - oben = tmp; - x = -1; - } else - beep(); - break; - } - } -} diff --git a/src/mapper/map_region.c b/src/mapper/map_region.c deleted file mode 100644 index 6e2417a73..000000000 --- a/src/mapper/map_region.c +++ /dev/null @@ -1,402 +0,0 @@ -/* vi: set ts=2: - * - * - * Eressea PB(E)M host Copyright (C) 1998-2003 - * Christian Schlittchen (corwin@amber.kn-bremen.de) - * Katja Zedel (katze@felidae.kn-bremen.de) - * Henning Peters (faroul@beyond.kn-bremen.de) - * Enno Rehling (enno@eressea-pbem.de) - * Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de) - * - * This program may not be used, modified or distributed without - * prior permission by the authors of Eressea. - */ - -#include -#include -#include -#include -#include "mapper.h" - -/* kernel includes */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* modules includes */ - -/* util includes */ -#include - -/* libc includes */ -#include -#include - -void -incat(char *buf, const int n, const size_t bufsize) -{ - char s[10]; - snprintf(s, 9, "%d", n); - sncat(buf, s, bufsize); -} - -int rbottom; -dbllist *reglist = NULL; -static dbllist *runten = NULL, *roben = NULL; -#define LASTLINE SY-3 -/* Letzte Zeile, in der Regionsinfo bei der Karte kommt */ - - -static void -ClearRegion(void) -{ - int line; - refresh(); - for (line = 0; line < LASTLINE; line++) { - movexy(SX - 38, line); - clrtoeol(); - } -} - -void -ScrollRegList(int dir) -{ - dbllist *hlp; - int line; - if ((dir == -1 && !runten->next) || (dir == 1 && !roben->prev)) - return; - - switch (dir) { - case -1: - for (line = 0; line < SY - 4 && runten->next; line++) { - roben = roben->next; - runten = runten->next; - } - ClearRegion(); - for (line = 0, hlp = roben; line < LASTLINE && hlp; line++, hlp = hlp->next) { - movexy(SX - 37, line); - addstr(hlp->s); - } - rbottom = line; - break; - case 1: - for (line = 0; line < SY - 4 && roben->prev; line++) { - roben = roben->prev; - runten = runten->prev; - } - ClearRegion(); - for (line = 0, hlp = roben; line < LASTLINE && hlp; line++, hlp = hlp->next) { - movexy(SX - 37, line); - addstr(hlp->s); - } - rbottom = line; - break; - } -} - -void -saddstr(char *s) -{ - if (s[0] < ' ') - s++; - addstr(s); -} - -void -DisplayRegList(int neu) -{ - int line; - dbllist *hlp; - ClearRegion(); - - if (!reglist) { - movexy(SX - 30, 0); - addstr("undefiniert"); - refresh(); - return; - } - if (neu) - runten = reglist; - else - runten = roben; - - for (line = 0, hlp = runten; line < LASTLINE && hlp; line++, hlp = hlp->next) { - movexy(SX - 37, line); - saddstr(hlp->s); - if (runten->next) - runten = runten->next; - } - rbottom = line; - if (neu) - roben = reglist; - refresh(); -} - -void -SpecialFunction(region *r) -{ - WINDOW *win; - variant zero_effect; - zero_effect.i = 0; - - win = openwin(60, 5, "< Specials Regions >"); - wmove(win, 1, 2); - wAddstr("1 - set Godcurse (n.imm), 2 - set Peace-Curse (imm)"); - wmove(win, 2, 2); - wrefresh(win); - switch(getch()) { - case '1': - if (get_curse(r->attribs, ct_find("godcursezone"))==NULL) { - curse * c = create_curse(NULL, &r->attribs, ct_find("godcursezone"), - 100, 100, zero_effect, 0); - curse_setflag(c, CURSE_ISNEW|CURSE_IMMUNE); - modified = 1; - break; - } - case '2': - if(!is_cursed_internal(r->attribs, ct_find("peacezone"))) { - curse * c = create_curse(NULL, &r->attribs, ct_find("peacezone"), 100, 2, zero_effect, 0); - curse_setflag(c, CURSE_IMMUNE); - modified = 1; - } - default: - break; - } - delwin(win); -} - -static int -count_all_money(const region * r) -{ - const unit *u; - int m = rmoney(r); - - for (u = r->units; u; u = u->next) - m += get_money(u); - - return m; -} - -char Tchar[MAXRACES] = "ZEOGMTDIHK~uifdwtbrsz"; - -void -showregion(region * r, char full) -{ - unit *u; - building *b; - ship *sh; - faction *f; - int d,pp=0, ecount[MAXRACES], count[MAXRACES]; - char str[256]; - int iron = -1, ironlevel = -1, - laen = -1, laenlevel = -1, - stone = -1, stonelevel = -1; - struct rawmaterial *res; - - if (reglist) { - freelist(reglist); - reglist = NULL; - } - if (!r) return; - - memset(ecount, 0, sizeof(ecount)); - strncpy(str, rname(r, NULL), 24); - str[24] = 0; - sprintf(buf, "%s (%d,%d)", str, r->x, r->y); - adddbllist(®list, buf); - memset(str,'¯',strlen(buf)+1); - str[strlen(buf)+1] = 0; - adddbllist(®list, str); - - sprintf(buf, " %hd turns old:", r->age); - adddbllist(®list, buf); - if (rterrain(r) != T_OCEAN && rterrain(r)!=T_FIREWALL) { - sprintf(buf, " %d peasants, %d(%d) silver", rpeasants(r), rmoney(r), count_all_money(r)); - adddbllist(®list, buf); - sprintf(buf, " %d horses, %d/%d/%d ", - rhorses(r), rtrees(r,2), rtrees(r,1), rtrees(r,0)); - if (fval(r,RF_MALLORN)) - sncat(buf, "mallorn", BUFSIZE); - else - sncat(buf, "trees", BUFSIZE); - adddbllist(®list, buf); - - for(res=r->resources;res;res=res->next) { - const item_type * itype = resource2item(res->type->rtype); - if(itype == olditemtype[I_IRON]) { - iron = res->amount; - ironlevel = res->level + itype->construction->minskill - 1; - } else if(itype == olditemtype[I_LAEN]) { - laen = res->amount; - laenlevel = res->level + itype->construction->minskill - 1; - } else if(itype == olditemtype[I_STONE]) { - stone = res->amount; - stonelevel = res->level + itype->construction->minskill - 1; - } - } - strcpy(buf, " "); - if(iron != -1) { - incat(buf, iron, BUFSIZE); - sncat(buf, " iron/", BUFSIZE); - incat(buf, ironlevel, BUFSIZE); - } - if(laen != -1) { - if(iron != -1) { - sncat(buf, ", ", BUFSIZE); - } - incat(buf, laen, BUFSIZE); - sncat(buf, " laen/", BUFSIZE); - incat(buf, laenlevel, BUFSIZE); - } - if(iron != -1 || laen != -1) { - adddbllist(®list, buf); - } - if(stone != -1) { - snprintf(buf, BUFSIZE, " %d stone/%d", stone, stonelevel); - adddbllist(®list, buf); - } - } - if (fval(r, RF_CHAOTIC)) { - adddbllist(®list, "chaotisch"); - } - if (r->planep) { - strcpy(buf,"Plane: "); - strncpy(str, r->planep->name, 30); - str[30] = 0; sncat(buf, str, BUFSIZE); - sncat(buf, " (", BUFSIZE); - sncat(buf, r->planep->name, BUFSIZE); - sncat(buf, ")", BUFSIZE); - adddbllist(®list, buf); - } - NL(reglist); - - if (rterrain(r) != T_OCEAN) { - strcpy(buf, "buildings:"); - if (!r->buildings) { - sncat(buf, " keine", BUFSIZE); - adddbllist(®list, buf); - } else if (full) { - adddbllist(®list, buf); - for (b = r->buildings; b; b = b->next) { - adddbllist(®list, Buildingid(b)); - for (u = r->units; u; u = u->next) - if (u->building == b && fval(u, UFL_OWNER)) { - strncpy(str, u->name, 27); - str[27] = 0; - sprintf(buf, " %s (%s)", str, unitid(u)); - adddbllist(®list, buf); - strncpy(str, factionname(u->faction), 34); - str[34] = 0; - sprintf(buf, " %s", str); - adddbllist(®list, buf); - break; - } - if (!u) - adddbllist(®list, " steht leer"); - } - } else { - d = 0; - for (b = r->buildings; b; b = b->next) - d++; - sncat(buf, " ", BUFSIZE); - incat(buf, d, BUFSIZE); - adddbllist(®list, buf); - } - NL(reglist); - } - strcpy(buf, "ships:"); - if (!r->ships) { - sncat(buf, " keine", BUFSIZE); - adddbllist(®list, buf); - } else if (full) { - adddbllist(®list, buf); - for (sh = r->ships; sh; sh = sh->next) { - adddbllist(®list, Shipid(sh)); - for (u = r->units; u; u = u->next) - if (u->ship == sh && fval(u, UFL_OWNER)) { - strncpy(str, u->name, 28); - str[28] = 0; - sprintf(buf, " %s (%s)", str, unitid(u)); - adddbllist(®list, buf); - sprintf(buf, " %s", factionname(u->faction)); - adddbllist(®list, buf); - break; - } - if (!u) - adddbllist(®list, " ohne Besitzer"); - } - } else { - d = 0; - for (sh = r->ships; sh; sh = sh->next) - d++; - sncat(buf, " ", BUFSIZE); - incat(buf, d, BUFSIZE); - adddbllist(®list, buf); - } - NL(reglist); - - if (!factions) - return; - - strcpy(buf, "factions:"); - - if (!r->units) { - sncat(buf, " keine", BUFSIZE); - adddbllist(®list, buf); - } else { - adddbllist(®list, buf); - - for (f = factions; f; f = f->next) - f->num_people = f->no_units = 0; - for (u = r->units; u; u = u->next) { - if (u->faction) { - u->faction->no_units++; - u->faction->num_people += u->number; - } else - fprintf(stderr,"Unit %s hat keine faction!\n",unitid(u)); - } - for (f = factions; f; f = f->next) - if (f->no_units) { - if (alliances==NULL) { - sprintf(buf, " %-29.29s (%s)", f->name, factionid(f)); - } else if (f->alliance != NULL) { - sprintf(buf, " %-26.26s (%s/%d)", f->name, factionid(f), f->alliance->id); - } else { - sprintf(buf, " %-26.26s (%s/-)", f->name, factionid(f)); - } - adddbllist(®list, buf); - sprintf(buf, " Einheiten: %d; Leute: %d %c", - f->no_units, f->num_people, Tchar[old_race(f->race)]); - adddbllist(®list, buf); - } - - for (d = RC_UNDEAD; d < MAXRACES; d++) - ecount[d] = count[d] = 0; - for (u = r->units; u; u = u->next) { - if (u->race >= new_race[RC_UNDEAD]) - pp=1; - ecount[old_race(u->race)]++; - count[old_race(u->race)] += u->number; - } - if (pp) { - NL(reglist); - adddbllist(®list, "Monster, Zauber usw.:"); - for (d = RC_UNDEAD; d < MAXRACES; d++) { - if (count[d]) { - sprintf(buf, " %s: %d in %d", new_race[d]->_name[0], count[d], ecount[d]); - adddbllist(®list, buf); - } - } - } - } - NL(reglist); -} diff --git a/src/mapper/map_tools.c b/src/mapper/map_tools.c deleted file mode 100644 index 761245a5f..000000000 --- a/src/mapper/map_tools.c +++ /dev/null @@ -1,405 +0,0 @@ -/* vi: set ts=2: - * - * - * Eressea PB(E)M host Copyright (C) 1998-2003 - * Christian Schlittchen (corwin@amber.kn-bremen.de) - * Katja Zedel (katze@felidae.kn-bremen.de) - * Henning Peters (faroul@beyond.kn-bremen.de) - * Enno Rehling (enno@eressea-pbem.de) - * Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de) - * - * This program may not be used, modified or distributed without - * prior permission by the authors of Eressea. - */ - -#include -#include -#include -#include "mapper.h" - -/* kernel includes */ -#include -#include -#include -#include - -/* util includes */ -#include - -/* libc includes */ -#include -#include -#include -#include -#include - -void -adddbllist(dbllist ** SP, const char *s) -{ - dbllist *S, *X; - - S = calloc(1, sizeof(dbllist) + strlen(s)); - strcpy(S->s, s); - - S->next = 0; - - if (*SP) { - for (X = *SP; X->next; X = X->next); - X->next = S; - S->prev = X; - } else { - S->prev = 0; - *SP = S; - } -} - -char * -Unitid(unit * u) -{ - static char buf[NAMESIZE]; - static char un[30]; - strncpy(un, u->name, 25); - un[25] = 0; - sprintf(buf, "%s (%s)", un, unitid(u)); - return buf; -} - -char * -Buildingid(building * b) -{ - static char buf[35]; - sprintf(buf, "\002%s (%s), Größe %d", - buildingtype(b->type, b, b->size /*, NULL */), - buildingid(b), b->size); - return buf; -} - -char * -Shipid(ship * sh) -{ - static char buf[30]; - sprintf(buf, "\023%s (%s)", sh->type->name[0], shipid(sh)); - return buf; -} - -char * -BuildingName(building * b) -{ - static char buf[35]; - sprintf(buf, "%s (%s)", - buildingtype(b->type, b, b->size /*, NULL*/), buildingid(b)); - return buf; -} - -int -map_input(WINDOW * win, int x, int y, const char *text, int mn, int mx, int pre) -{ - char lbuf[10]; - int val, ch, cx, nw = 0; - if (!win) { - win = openwin(50, 3, 0); - nw = y = 1; - x = 2; - } else - wrefresh(win); - do { - char zText[160]; - sprintf(lbuf, "%d", pre); - wmove(win, y, x); - curs_set(1); - sprintf(zText, "%s (%d..%d): %d", text, mn, mx, pre); - wprintw(win, (NCURSES_CONST char*)zText); - wrefresh(win); -/* getyx(win, y, x); */ - cx = x + strlen(zText)/* getcurx(win) */- strlen(lbuf); - val = strlen(lbuf); - do { - ch = getch(); - if (ch==8 || ch == KEY_BACKSPACE || ch == KEY_LEFT) { - if (val == 0) - beep(); - else { - val--; - wmove(win, y, val + cx); - waddch(win, ' '); - wmove(win, y, val + cx); - wrefresh(win); - } - } else if (ch == 10 || ch == 13) { - curs_set(0); - } else if ((ch == '-' && val == 0) || (ch >= '0' && ch <= '9' && val < 10)) { - waddch(win, ch); - lbuf[val] = (char) ch; - val++; - } else - beep(); - wrefresh(win); - } while (!(ch == 10 || ch == 13)); - lbuf[val] = 0; - val = atoi(lbuf); - if (val < mn || val > mx) - beep(); - } while (val < mn || val > mx); - if (nw) - delwin(win); - return val; -} - -void -warnung(WINDOW * win, const char *text) -{ - if (!win) { - win = openwin(strlen(text) + 4, 3, "< WARNING >"); - wmove(win, 1, 2); - } - wprintw(win, (NCURSES_CONST char*)"%s", text); - beep(); - wrefresh(win); - getch(); - delwin(win); -} - -boolean -yes_no(WINDOW * win, const char *text, const char def) -{ - int ch; - boolean mywin = false; - if (!win) { - win = openwin(strlen(text) + 10, 3, 0); - wmove(win, 1, 2); - mywin = true; - } - wprintw(win, (NCURSES_CONST char*)"%s (%c/%c)", text, def == 'j' ? 'J' : 'j', def == 'n' ? 'N' : 'n'); - wrefresh(win); - ch = getch(); - if (mywin) { - delwin(win); - } - if (ch == 10 || ch == 13) - ch = def; - return (boolean)((ch == 'j' || ch == 'J' || ch == 'y' || ch == 'Y')?true:false); -} - -char * -my_input(WINDOW * win, int x, int y, const char *text, const char *def) -{ - static char lbuf[INPUT_BUFSIZE+1]; - int val, ch, p, nw = 0; - - if (!win) { - win = openwin(SX - 10, 3, 0); - nw = 1; - y = 1; - x = 2; - } - - wmove(win, y, x); - wAddstr(text); - if(def) { - strcpy(lbuf, def); - wAddstr(lbuf); - p = x + strlen(text); - val = strlen(lbuf); - wmove(win, y, p + val); - } else { - p = x + strlen(text); - wmove(win, y, p); - val = 0; - } - wrefresh(win); - curs_set(1); - wcursyncup(win); - - do { - ch = getch(); - if (ch == KEY_BACKSPACE || ch == KEY_LEFT) { - if (val == 0) - beep(); - else { - val--; - wmove(win, y, val + p); - waddch(win, ' '); - wmove(win, y, val + p); - wrefresh(win); - } - } else if (ch == '\n') { - curs_set(0); - } if(val >= INPUT_BUFSIZE) { - beep(); - } else if (isprint(ch)) { - waddch(win, ch); - lbuf[val] = (char) ch; - val++; - } else - beep(); - wrefresh(win); - } while (!(ch == '\n')); - if (nw) { - wclear(win); - delwin(win); - } - curs_set(0); - lbuf[val] = 0; - return lbuf; -} - -void -insert_selection(selection ** p_sel, selection * prev, const char * str, void * payload) -{ - selection * sel = calloc(sizeof(selection), 1); - sel->str = strdup(str); - sel->data = payload; - if (*p_sel) { - selection * s; - sel->next = *p_sel; - sel->prev = sel->next->prev; - sel->next->prev=sel; - if (sel->prev) { - sel->prev->next = sel; - sel->index=sel->prev->index+1; - } - for (s=sel->next;s;s=s->next) { - s->index = s->prev->index+1; - } - } else { - *p_sel = sel; - sel->prev = prev; - if (prev) sel->index=prev->index+1; - } -} - -selection ** -push_selection(selection ** p_sel, char * str, void * payload) -{ - selection * sel = calloc(sizeof(selection), 1); - selection * prev = NULL; - sel->str = str; - sel->data = payload; - while (*p_sel) { - prev = *p_sel; - p_sel=&prev->next; - } - *p_sel = sel; - if (prev) { - sel->prev = prev; - sel->index = prev->index+1; - } - return p_sel; -} - -selection * -do_selection(selection * sel, const char * title, void (*perform)(selection *, void *), void * data) -{ - WINDOW * wn; - boolean update = true; - selection *s; - selection *top = sel; - selection *current = top; - int i; - int height=0, width=strlen(title)+8; - for (s=sel;s;s=s->next) { - if (strlen(s->str)>(unsigned)width) width = strlen(s->str); - ++height; - } - if (height==0 || width==0) return NULL; - if (width+3>SX) width=SX-4; - if (height+2>SY) height=SY-2; - - wn = newwin(height+2, width+4, (SY - height - 2) / 2, (SX - width - 4) / 2); - - 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); - } - /*wborder(wn, '|', '|', '-', '-', '+', '+', '+', '+');*/ - wborder(wn, 0, 0, 0, 0, 0, 0, 0, 0); - wmove(wn, 0, 2); - sprintf(buf, "[ %s ]", title); - waddnstr(wn, buf, width); - update = false; - } - i = current->index-top->index; - wmove(wn, i + 1, 2); - waddstr(wn, "->"); - wmove(wn, i + 1, 4); - wattron(wn, A_BOLD); - waddnstr(wn, current->str, width); - wattroff(wn, A_BOLD); - - wrefresh(wn); - - input = getch(); - - wmove(wn, i + 1, 2); - waddstr(wn, " "); - wmove(wn, i + 1, 4); - waddnstr(wn, current->str, width); - - switch (input) { - case KEY_DOWN: - if (current->next) { - current = current->next; - if (current->index-height>=top->index) { - top=current; - update = true; - } - } - break; - case KEY_UP: - if (current->prev) { - if (current==top) { - top = sel; - while (top->index+heightindex) top=top->next; - update = true; - } - current = current->prev; - } - break; - case 27: - case 'q': - delwin(wn); - return NULL; - case 10: - case 13: - if (perform) perform(current, data); - else { - delwin(wn); - return current; - } - break; - default: - s = current->next; - while (s && s!=current) { - if (tolower(s->str[0])==tolower(input)) { - current = s; - update = true; - } else { - s = s->next; - } - } - } - } -} - -FILE * -mapperFopen(const char *defName, const char *mode) -{ - char nameBuf[80]; - FILE *fileP; - - strncpy(nameBuf, my_input(0,0,0,"Ausgabe in File: ", defName), 79); - nameBuf[79] = 0; - - fileP = fopen(nameBuf, mode); - if(!fileP) { - warnung(NULL, "Can't open file for writing"); - } - - return fileP; -} - diff --git a/src/mapper/map_units.c b/src/mapper/map_units.c deleted file mode 100644 index bfc004fe4..000000000 --- a/src/mapper/map_units.c +++ /dev/null @@ -1,1534 +0,0 @@ -/* vi: set ts=2: - * - * - * Eressea PB(E)M host Copyright (C) 1998-2003 - * Christian Schlittchen (corwin@amber.kn-bremen.de) - * Katja Zedel (katze@felidae.kn-bremen.de) - * Henning Peters (faroul@beyond.kn-bremen.de) - * Enno Rehling (enno@eressea-pbem.de) - * Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de) - * - * This program may not be used, modified or distributed without - * prior permission by the authors of Eressea. - */ - -/* wenn config.h nicht vor curses included wird, kompiliert es unter windows nicht */ - -#include -#include -#include -#include "mapper.h" - -/* kernel includes */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -/* libc includes */ -#include -#include -#include -#include - -#define findunit(f,r) findunitg(f,r) - -static region *shipregion; - -void -SpecialFunctionUnit(unit *u) -{ - WINDOW *win; - - win = openwin(60, 5, "< Specials Units >"); - wmove(win, 1, 2); - wAddstr("B - give balloon, M - set noMovement"); - wmove(win, 2, 2); - wrefresh(win); - switch(getch()) { - case 'b': - case 'B': - { - ship *sh = new_ship(st_find("balloon"), u->faction->locale, u->region); - set_string(&sh->name, "Ballon"); - set_string(&sh->display, "Eine große leuchtendrote Werbeaufschrift " - "für den Xontormia Express prangt auf einer Seite des Luftgefährts."); - sh->size = 5; - leave(u->region, u); - u->ship = sh; - fset(u, UFL_OWNER); - } - break; - case 'm': - case 'M': - set_movement(&u->attribs, MV_CANNOTMOVE); - break; - } - delwin(win); -} - -unit * -make_new_unit(region * r) -{ - unit *u; - faction *f; - WINDOW *win; - char *fac_nr36; - int i, p, anz, q, y; - win = openwin(SX - 10, 17, "< Neue Einheit erschaffen >"); - - if (r->units) - p = r->units->faction->no; - else - p = 0; - - do { - fac_nr36 = my_input(win, 2, 1, "Parteinummer: ", itoa36(p)); - if(fac_nr36 == NULL || *fac_nr36 == 0) { - delwin(win); - return 0; - } - f = findfaction(atoi36(fac_nr36)); - } while (!f); - wmove(win, 1, 2); - wclrtoeol(win); - wmove(win, 1, win->_maxx); - waddch(win, '|'); - wmove(win, 1, 2); - wAddstr(factionname(f)); - wrefresh(win); - - anz = map_input(win, 2, 2, "Anzahl Personen", 0, 9999, 1); - if (anz > 0) { - q = 0; - y = 4; - wmove(win, y, 4); - for (i = 0; i < MAXRACES; i++) { - if(new_race[i] == NULL) continue; - sprintf(buf, "%d=%s; ", i, new_race[i]->_name[0]); - q += strlen(buf); - if (q > SX - 20) { - q = strlen(buf); - y++; - wmove(win, y, 4); - } - wAddstr(buf); - } - q = map_input(win, 2, 3, "Rasse", 0, MAXRACES-1, old_race(f->race)); - - if(new_race[q] != NULL) { - u = createunit(r, f, anz, new_race[q]); - if (p==0) - u->age = (short)map_input(win, 2, 4, "Alter", 1, 99, 1); - else - u->age = 0; - for (; y > 3; y--) { - wmove(win, y, 4); - wclrtoeol(win); - wrefresh(win); - wmove(win, y, win->_maxx); - waddch(win, '|'); - wrefresh(win); - } - - buf[0] = 0; - strcpy(buf, my_input(win, 2, 4, "Name: ", NULL)); - if (buf[0]) - set_string(&u->name, buf); - if (!strlen(u->name)) - set_string(&u->name, buf); - set_money(u, map_input(win, 2, 5, "Silber", 0, 999999, anz * 10)); - } else - u = NULL; - } else - u = NULL; - - delwin(win); - return u; -} - -void -copy_unit(unit * from, unit * to) -{ - memcpy(to, from, sizeof(unit)); -} - - -static int -input_string(const char * text, char * result, size_t len) { - WINDOW * wn; - int res; - wn = newwin(1, SX, SY-1, 0); - werase(wn); - wmove(wn, 0, 0); - wattron(wn, A_BOLD); - waddstr(wn, (char*)text); - waddstr(wn, ": "); - echo(); - curs_set(1); - res = wgetnstr(wn, result, len); - curs_set(0); - noecho(); - delwin(wn); - return res; -} - -static boolean i_modif = false; - -static void -chg_item(selection * s, void * data) { - unit * u = (unit *)data; - int i; - - i = input_string("Anzahl", buf, 80); - if (i==ERR) return; - i = atoi(buf); - if (i) { - const item_type * itype = (const item_type *)s->data; - item * itm = i_change(&u->items, itype, i); - int k = itm?itm->number:0; - sprintf(buf, "%s: %d", locale_string(NULL, resourcename(itype->rtype, GR_PLURAL)), k); - i_modif = true; - free(s->str); - s->str = strdup(buf); - } -} - -boolean -modify_items(unit * u) -{ - selection *ilist = NULL; -#if 0 - selection **ilast = &ilist; - const item_type * itype = itemtypes; - - while (itype!=NULL) { - selection * prev = NULL; - item * itm = *i_find(&u->items, itype); - int q = itm?itm->number:0; - sprintf(buf, "%s: %d", locale_string(NULL, resourcename(itype->rtype, GR_PLURAL)), q); - for (ilast = &ilist; *ilast; ilast=&(*ilast)->next) { - if (strcmp((*ilast)->str, buf)>0) break; - prev = *ilast; - } - insert_selection(ilast, prev, buf, (void*)itype); - itype=itype->next; - while (ilist->prev!=NULL) ilist=ilist->prev; - } -#endif - i_modif = false; - do_selection(ilist, "Gegenstände", chg_item, (void*)u); - while (ilist) { - selection * s = ilist; - ilist=ilist->next; - free((void*)s->str); - free(s); - } - return i_modif; -} - -#if 0 -char -modify_zauber(unit * u) -{ - int q, L; - char i, x, modif = 0; - WINDOW *wn; - char *ZL[MAXSPELLS]; - - if (SY > MAXSPELLS + 2) - L = MAXSPELLS; - else - L = 10; - - wn = newwin(L + 2, 50, (SY - L - 2) / 2, (SX - 50) / 2); - - wclear(wn); - /* wborder(wn, '|', '|', '-', '-', '.', '.', '`', '\''); */ - wborder(wn, 0, 0, 0, 0, 0, 0, 0, 0); - wmove(wn, 0, 3); - waddnstr(wn, "< Zauber >", -1); - for (i = 0; i < MAXSPELLS; i++) { - if (get_spell(u, i)) - sprintf(buf, "%s", spellnames[i]); - else - sprintf(buf, " (%s)", spellnames[i]); - ZL[i] = strdup(buf); - modif = 1; - if (L > 10) { - wmove(wn, i + 1, 4); - waddnstr(wn, ZL[i], -1); - } - } - - x = 0; - do { - if (L == 10) { - for (i = 0; i < L && i + x < MAXSPELLS; i++) { - wmove(wn, i + 1, 2); - wclrtoeol(wn); - if (i == 0) - wattron(wn, A_BOLD); - waddnstr(wn, ZL[i + x], -1); - if (i == 0) - wattroff(wn, A_BOLD); - } - if (i < L) - for (; i < L; i++) { - wmove(wn, i + 1, 2); - wclrtoeol(wn); - } - /* wborder(wn, '|', '|', '-', '-', '.', '.', '`', '\''); */ - wborder(wn, 0, 0, 0, 0, 0, 0, 0, 0); - wmove(wn, 0, 3); - waddnstr(wn, "< Zauber >", -1); - } else { - wmove(wn, x + 1, 1); - waddnstr(wn, "-> ", -1); - wattron(wn, A_BOLD); - waddnstr(wn, ZL[x], -1); - wattroff(wn, A_BOLD); - wmove(wn, x + 1, 1); - } - wrefresh(wn); - - q = getch(); - - if (L > 10) { - waddnstr(wn, " ", -1); - waddnstr(wn, ZL[x], -1); - } - switch (q) { - case KEY_DOWN: - if (x < MAXSPELLS - 1) - x++; - else - beep(); - break; - case KEY_UP: - if (x > 0) - x--; - else - beep(); - break; - case 10: - case 13: - if (get_spell(u, x)) { - sprintf(buf, " (%s)", spellnames[x]); - set_spell(u, x, false); - } else { - sprintf(buf, "%s", spellnames[x]); - set_spell(u, x, true); - } - free(ZL[x]); - ZL[x] = strdup(buf); - modif = 1; - break; - } - } while (q != 27 && q != 'q'); - delwin(wn); - return modif; -} -#endif - -char -modify_talente(unit * u, region * r) -{ - int q, L; - item_t i; - skill_t sk; - unsigned char x; - char modif=0; - WINDOW *wn; - char *TL[MAXSKILLS]; - if (SY > MAXSKILLS + 2) - L = MAXSKILLS; - else - L = 10; - - wn = newwin(L + 2, 40, (SY - L - 2) / 2, (SX - 40) / 2); - - wclear(wn); - /* wborder(wn, '|', '|', '-', '-', '.', '.', '`', '\''); */ - wborder(wn, 0, 0, 0, 0, 0, 0, 0, 0); - wmove(wn, 0, 3); - waddnstr(wn, "< Talente >", -1); - for (sk = 0; sk != MAXSKILLS; ++sk) { - sprintf(buf, "%s %d", skillname(sk, NULL), eff_skill(u, sk, r)); - TL[sk] = strdup(buf); - if (L > 10) { - wmove(wn, sk + 1, 4); - waddnstr(wn, TL[sk], -1); - } - } - - x = 0; - do { - if (L == 10) { - for (i = 0; i < L && i + x < MAXSKILLS; i++) { - wmove(wn, i + 1, 2); - wclrtoeol(wn); - if (i == 0) - wattron(wn, A_BOLD); - waddnstr(wn, TL[i + x], -1); - if (i == 0) - wattroff(wn, A_BOLD); - } - if (i < L) - for (; i < L; i++) { - wmove(wn, i + 1, 2); - wclrtoeol(wn); - } - /* wborder(wn, '|', '|', '-', '-', '.', '.', '`', '\''); */ - wborder(wn, 0, 0, 0, 0, 0, 0, 0, 0); - wmove(wn, 0, 3); - waddnstr(wn, "< Talente >", -1); - } else { - wmove(wn, x + 1, 1); - waddnstr(wn, "-> ", -1); - wattron(wn, A_BOLD); - waddnstr(wn, TL[x], -1); - wattroff(wn, A_BOLD); - wmove(wn, x + 1, 1); - } - wrefresh(wn); - - q = getch(); - - if (L > 10) { - waddnstr(wn, " ", -1); - waddnstr(wn, TL[x], -1); - } - switch (q) { - case KEY_DOWN: - if (x < MAXSKILLS - 1) - x++; - else - beep(); - break; - case KEY_UP: - if (x > 0) - x--; - else - beep(); - break; - case 10: - case 13: - if (L == 10) { - wmove(wn, x + 2, 2); - wclrtoeol(wn); - wmove(wn, x + 2, 39); - waddch(wn, '|'); - wrefresh(wn); - q = map_input(wn, 2, 2, "Talentstufe", 0, 30, get_level(u, x)); - } else { - q = map_input(0, 0, 0, "Talentstufe", 0, 30, get_level(u, x)); - touchwin(mywin); - touchwin(wn); - wrefresh(mywin); /* altes Fenster überbügeln */ - } - set_level(u, x, q); - sprintf(buf, "%s %d", skillname(x, NULL), eff_skill(u, x, r)); - free(TL[x]); - modif = 1; - TL[x] = strdup(buf); - q = 0; /* sicherheitshalber, weil 27 oder 'q' -> Ende */ - break; - } - } while (q != 27 && q != 'q'); - delwin(wn); - return modif; -} - -boolean -modify_unit(region * r, unit * modunit) -{ - WINDOW *win; - unit *u; - int q, a, x, y, zt, zg; - char modif = 0; - int at; - const item * itm; - - wclear(mywin); - sprintf(buf, "< Einheit modifizieren: %s,%s >", - Unitid(modunit), factionname(modunit->faction)); - movexy((SX - strlen(buf)) / 2, 1); - addstr(buf); - - u = calloc(1, sizeof(unit)); - copy_unit(modunit, u); - - do { - skill_t sk; - item_t i; - y = 0; - wclear(mywin); - Movexy(3, y); - wprintw(mywin, (NCURSES_CONST char*)"Rasse: %s", u->race->_name[0]); - Movexy(3, ++y); - wprintw(mywin, (NCURSES_CONST char*)"Anzahl: %d", u->number); - Movexy(3, ++y); - wprintw(mywin, (NCURSES_CONST char*)"Silber: %d", get_money(u)); - Movexy(3, ++y); - at = fval(modunit, UFL_PARTEITARNUNG); - wprintw(mywin, (NCURSES_CONST char*)"Parteitarnung: %s", at ? "an" : "aus"); - Movexy(3, ++y); - Addstr("Dämonentarnung: "); -#if 0 /* ja, wie denn? */ - if (u->race == new_race[RC_DAEMON] && u->itypus > 0 && u->typus != u->itypus) - Addstr(typusdaten[u->itypus].name[0]); - else { -#endif - Addstr("keine"); - if (u->race != new_race[RC_DAEMON]) - Addstr(" möglich"); -#if 0 - } -#endif - - Movexy(3, ++y); - zt = y; - q = 11; - x = 0; - Addstr("Talente: "); - for (sk = 0; sk != MAXSKILLS; sk++) { - if (has_skill(u, sk)) { - if (x) { - Addstr(", "); - q += 2; - } - sprintf(buf, "%s %d", skillname(sk, NULL), eff_skill(u, sk, r)); - q += strlen(buf); - if (q > SX - 8) { - q = strlen(buf); - y++; - Movexy(5, y); - } - Addstr(buf); - x = 1; - } - } - if (!x) - Addstr("keine"); - y++; - - Movexy(3, y); - q = 15; - x = false; - zg = y; - Addstr("Gegenstände: "); - for (itm=u->items;itm;itm=itm->next) { - if (x) { - Addstr(", "); - q += 2; - } - sprintf(buf, "%d %s", itm->number, locale_string(NULL, resourcename(itm->type->rtype, GR_PLURAL))); - q += strlen(buf); - if (q > SX - 8) { - q = strlen(buf); - y++; - Movexy(5, y); - } - Addstr(buf); - x = true; - } - if (!x) - Addstr("keine"); - y++; - y++; - Movexy(3, y); - Addstr("Anfangsbuchstabe, für Ende"); - wrefresh(mywin); - - q = getch(); - switch (tolower(q)) { - case 't': - modif = modify_talente(u, r); - break; - case 'g': - modif = (char)modify_items(u); - break; - case 'r': - win = openwin(SX - 10, 5, "< Rasse wählen >"); - y = 2; - q = 0; - wmove(win, y, 4); - for (i = 1; i < MAXRACES; i++) { - sprintf(buf, "%d=%s; ", i, new_race[i]->_name[0]); - q += strlen(buf); - if (q > SX - 20) { - q = strlen(buf); - y++; - wmove(win, y, 4); - } - wAddstr(buf); - } - u->race = new_race[map_input(win, 2, 1, "Rasse", 0, MAXRACES-1, old_race(modunit->faction->race))]; - modif = 1; - delwin(win); - break; - case 'd': - if (u->race == new_race[RC_DAEMON]) { - race_t rc; - win = openwin(SX - 10, 5, "< Tarnrasse wählen >"); - y = 2; - q = 0; - wmove(win, y, 4); - for (rc = 1; rc != MAXRACES; rc++) { - sprintf(buf, "%d=%s; ", rc, new_race[rc]->_name[0]); - q += strlen(buf); - if (q > SX - 20) { - q = strlen(buf); - y++; - wmove(win, y, 4); - } - wAddstr(buf); - } - u->irace = new_race[map_input(win, 2, 1, "Tarnrasse", 0, MAXRACES, old_race(modunit->irace))]; - modif = 1; - delwin(win); - } else - beep(); - break; - case 'a': - a = u->number; - scale_number(u, map_input(0, 0, 0, "Anzahl Personen", 1, 9999, u->number)); - if (a != u->number) - modif = 1; - break; - case 's': - set_money(u, map_input(0, 0, 0, "Silber", 0, 999999, get_money(u))); - modif = 1; - break; - case 'p': - q = (int) yes_no(0, "Parteitarnung?", - (char) ((fval(modunit, UFL_PARTEITARNUNG)) - ? 'j' : 'n')); - if (at && !q) { - freset(modunit, UFL_PARTEITARNUNG); - modif = 1; - } else if (!at && q) { - fset(modunit, UFL_PARTEITARNUNG); - modif = 1; - } - break; - } - } while (q != 27 && q != 'q'); - - if (modif) { - if (yes_no(0, "Änderungen übernehmen?", 'j')) { - copy_unit(u, modunit); - modified = 1; - } - } - free(u); - movexy(0, 1); - hline('-', SX + 1); - refresh(); - return i2b(modif == 1); -} - -dbllist *pointer; -boolean isunit; - -void -SetPointer(int dir) -{ - dbllist *h = pointer; - int pl = pline; - switch (dir) { - case KEY_UP: - case KEY_LEFT: - case KEY_PPAGE: - case '/': - case 'n': - case '<': - while (h) { - if (h->s[0] < ' ') { - if (h->s[0] == '\025') /* eine Einheit */ - isunit = true; - else - isunit = false; - pointer = h; - pline = pl; - return; - } - h = h->prev; - pl--; - } - break; - case KEY_DOWN: - case KEY_RIGHT: - case KEY_NPAGE: - case '>': - while (h) { - if (h->s[0] < ' ') { - if (h->s[0] == '\025') /* eine Einheit */ - isunit = true; - else - isunit = false; - pointer = h; - pline = pl; - return; - } - h = h->next; - pl++; - } - } - - /* Unten bzw. oben angekommen und nix gefunden? Dann andersrum */ - h = pointer; - pl = pline; - switch (dir) { - case KEY_DOWN: - case KEY_RIGHT: - case KEY_NPAGE: - case '>': - while (h) { - if (h->s[0] < ' ') { - if (h->s[0] == '\025') /* eine Einheit */ - isunit = true; - else - isunit = false; - pointer = h; - pline = pl; - return; - } - h = h->prev; - pl--; - } - break; - case KEY_UP: - case KEY_PPAGE: - case KEY_LEFT: - case '/': - case 'n': - case '<': - while (h) { - if (h->s[0] < ' ') { - if (h->s[0] == '\025') /* eine Einheit */ - isunit = true; - else - isunit = false; - pointer = h; - pline = pl; - return; - } - h = h->next; - pl++; - } - } - return; -} - -void -Umark(int p) -{ - Movexy(0, p); - if (isunit) - Addstr("=>"); - else - Addstr("->"); - movexy(0, 1); - hline('-', SX + 1); - if (clipship) { - sprintf(buf, "< Clipschiff: %s >", shipname(clipship)); - movexy(SX - strlen(buf) - 2, 1); - addstr(buf); - } - movexy(0, SY - 1); - hline('-', SX + 1); - if (clipunit) { - sprintf(buf, "< Clipunit:%s >", Unitid(clipunit)); - movexy(SX - strlen(buf) - 2, SY - 1); - addstr(buf); - } - Movexy(0, p); - wrefresh(mywin); -} - -void -sAddstr(char *s) -{ - if (s[0] < ' ') - s++; - Addstr(s); -} - -unit *clipunit; /* hierin kann eine Einheit gespeichert werden */ -region *clipregion; /* hierher kommt die clipunit */ - -void -dblparagraph(dbllist ** SP, char *s, int indent, char mark) -{ - int i, j, width, delta = 0; - int firstline; - static char lbuf[128]; - width = SX - 5 - indent; - firstline = 1; - - for (;;) { - i = 0; - - do { - j = i; - while (s[j] && s[j] != ' ') - j++; - if (j > width) { - if (i == 0) - i = width - 1; - break; - } - i = j + 1; - } - while (s[j]); - - j = 0; - if (firstline) { - if (*s == '\025') { /* \023 ist ^U => Unit-Kennung */ - lbuf[0] = '\025'; /* Kennung nach vorne - * holen */ - delta = 1; - } - } else - delta = 0; - - for (j = 0; j != indent; j++) - lbuf[j + delta] = ' '; - - if (firstline && mark) - lbuf[indent - 2 + delta] = mark; - - for (j = 0; j != i - 1; j++) - lbuf[indent + j + delta] = s[j + delta]; - lbuf[indent + j + delta] = 0; - - adddbllist(SP, lbuf); - - if (!s[i - 1 + delta]) - break; - - s += i; - firstline = 0; - } -} - -void -mapper_spunit(dbllist ** SP, unit * u, int indent) -{ - int i, dh; - item * itm; - char * bufp; - - strcpy(buf, "\025"); - sncat(buf, unitname(u), BUFSIZE); - sncat(buf, ", ", BUFSIZE); - sncat(buf, factionname(u->faction), BUFSIZE); - - if (fval(u, UFL_PARTEITARNUNG)) - sncat(buf, " (getarnt)", BUFSIZE); - - sncat(buf, ", ", BUFSIZE); - icat(u->number); - sncat(buf, " ", BUFSIZE); - - i = old_race(u->race); - if (u->irace != u->race) { - sncat(buf, u->irace->_name[u->number != 1], BUFSIZE); - sncat(buf, " (", BUFSIZE); - if (u->race == new_race[RC_ILLUSION]) - sncat(buf, u->faction->race->_name[u->number != 1], BUFSIZE); - else - sncat(buf, u->race->_name[u->number != 1], BUFSIZE); - sncat(buf, ")", BUFSIZE); - } else { - if (u->race == new_race[RC_ILLUSION]) - sncat(buf, u->faction->race->_name[u->number != 1], BUFSIZE); - else - sncat(buf, u->race->_name[u->number != 1], BUFSIZE); - } - - switch (u->status) { - case ST_FIGHT: - sncat(buf, ", vorne", BUFSIZE); - break; - case ST_BEHIND: - sncat(buf, ", hinten", BUFSIZE); - break; - case ST_AVOID: - sncat(buf, ", kämpft nicht", BUFSIZE); - break; - case ST_FLEE: - sncat(buf, ", flieht", BUFSIZE); - break; - default: - sncat(buf, ", unbekannt", BUFSIZE); - break; - } - - if(get_movement(&u->attribs, MV_CANNOTMOVE)) { - sncat(buf, ", cannot move", BUFSIZE); - } - - sncat(buf, " (", BUFSIZE); icat(u->hp/u->number); sncat(buf, " HP)", BUFSIZE); - - if (getguard(u)) - sncat(buf, ", bewacht die Region", BUFSIZE); - - if (usiege(u)) { - sncat(buf, ", belagert ", BUFSIZE); - sncat(buf, buildingname(usiege(u)), BUFSIZE); - } - sncat(buf, ", ", BUFSIZE); - icat(get_money(u)); - sncat(buf, " Silber", BUFSIZE); - - dh = 0; - bufp = buf + strlen(buf); - if (u->skill_size>0) { - skill * sv; - struct locale * lang = find_locale("de"); - for (sv = u->skills;sv!=u->skills+u->skill_size;++sv) { - bufp += spskill(bufp, sizeof(buf)-(bufp-buf), lang, u, sv, &dh, 1); - } - } - dh = 0; - - for (itm = u->items;itm;itm=itm->next) { - sncat(buf, ", ", BUFSIZE); - - if (!dh) { - sncat(buf, "hat: ", BUFSIZE); - dh = 1; - } - if (itm->number == 1) - sncat(buf, locale_string(NULL, resourcename(itm->type->rtype, 0)), BUFSIZE); - else { - icat(itm->number); - sncat(buf, " ", BUFSIZE); - sncat(buf, locale_string(NULL, resourcename(itm->type->rtype, GR_PLURAL)), BUFSIZE); - } - } - dh = 0; - - if (uprivate(u)) { - sncat(buf, " (Bem: ", BUFSIZE); - sncat(buf, uprivate(u), BUFSIZE); - sncat(buf, ")", BUFSIZE); - } - sncat(buf, ".", BUFSIZE); - - dblparagraph(SP, buf, indent, '-'); - adddbllist(SP, " "); -} - - -int -showunits(region * r) -{ - unit *u, *x; - building *b; - ship *sh; - dbllist *eh = NULL, *unten, *oben, *hlp = NULL, *such = NULL, *tmp; - int line, ch, bottom, bot, f; - size_t lt; - char *s = NULL, *txt, *suchtext = 0, str[45], lbuf[256]; - - clear(); - strncpy(str, rname(r, NULL), 44); - str[44] = 0; - movexy(0, 0); - printw((NCURSES_CONST char*)"Einheiten in %s (%d,%d):", str, r->x, r->y); - movexy(0, SY); - addstr("/,n: Suche; N: NewUnit; G: GetUnit; P: PutUnit; M: Modify; S: Schiff; B: Burg"); - refresh(); - - for (b = r->buildings; b; b = b->next) { - if (b->type == bt_find("castle")) { - sprintf(lbuf, "\002%s, Größe %d, %s", buildingname(b), b->size, - buildingtype(b->type, b, b->size /*, NULL */)); - } else { - sprintf(lbuf, "\002%s, Größe %d, %s", buildingname(b), - b->size, buildingtype(b->type, b, b->size /*, NULL */)); - if (b->type->maxsize > 0 && - b->size < b->type->maxsize) { - sncat(lbuf, " (im Bau)", BUFSIZE); - } - } - adddbllist(&eh, lbuf); - adddbllist(&eh, " "); - for (u = r->units; u; u = u->next) { - if (u->building == b && fval(u, UFL_OWNER)) { - mapper_spunit(&eh, u, 4); - break; - } - } - for (u = r->units; u; u = u->next) { - if (u->building == b && !fval(u, UFL_OWNER)) { - mapper_spunit(&eh, u, 4); - } - } - } - for (sh = r->ships; sh; sh = sh->next) { - int n = 0, p = 0; - getshipweight(sh, &n, &p); - n = (n+99) / 100; /* 1 Silber = 1 GE */ - sprintf(lbuf, "\023%s, %s, (%d/%d)", shipname(sh), sh->type->name[0], - n, shipcapacity(sh)/100); - if (sh->type->construction && sh->size!=sh->type->construction->maxsize) { - f = 100 * (sh->size) / sh->type->construction->maxsize; - sncat(lbuf, ", im Bau (", BUFSIZE); - icat(f); - sncat(lbuf, "%) ", BUFSIZE); - } - if (sh->damage) { - sncat(lbuf, ", ", BUFSIZE); - icat(sh->damage); - sncat(lbuf, "% beschädigt", BUFSIZE); - } - adddbllist(&eh, lbuf); - adddbllist(&eh, " "); - for (u = r->units; u; u = u->next) { - if (u->ship == sh && fval(u, UFL_OWNER)) { - mapper_spunit(&eh, u, 4); - break; - } - } - for (u = r->units; u; u = u->next) { - if (u->ship == sh && !fval(u, UFL_OWNER)) - mapper_spunit(&eh, u, 4); - } - } - - if (!r->units) { - adddbllist(&eh, "keine Einheiten"); - adddbllist(&eh, " "); - } else { - for (u = r->units; u; u = u->next) { - if (!u->ship && !u->building) - mapper_spunit(&eh, u, 2); - } - } - - mywin = newwin(SY - 3, SX, 2, 0); - wclear(mywin); - bot = mywin->_maxy + 1; - if (!pointer) - pointer = eh; - else { - pointer = eh; - for (f = 0; f < pline && pointer->next; f++) - pointer = pointer->next; - } - oben = pointer; - f = 4; - while (oben->prev && --f!=0) - oben = oben->prev; /* Wenn dies ein "Fullredraw" ist, pointer dorthin, - wo wir vorher ungefähr waren. */ - for (line=0, unten=oben; linenext; line++, unten=unten->next) { - Movexy(3, line); - sAddstr(unten->s); - } - bottom = line - 1; - tmp = oben; - pline = 0; - - while (tmp != pointer) { - pline++; - tmp = tmp->next; - } - - scrollok(mywin, TRUE); - ch = KEY_DOWN; - wrefresh(mywin); - - for (;;) { - SetPointer(ch); - if (pline < 0 || pline >= bot || !pointer) - beep(); - else - Umark(pline); - ch = getch(); - if (pointer) - Addstr(" "); - switch (ch) { - case KEY_DOWN: - if (pointer->next) { - pointer = pointer->next; - pline++; - } else - beep(); - if (pline > bot - 5 && unten->next) { - line = bot - 5; - while (line && unten->next) { - unten = unten->next; - oben = oben->next; - pline--; - line--; - } - f = -1; - } - break; - case KEY_UP: - if (pointer->prev) { - pointer = pointer->prev; - pline--; - } else - beep(); - if (pline < 5 && oben != eh) { - line = bot - 5; - while (line && oben->prev) { - unten = unten->prev; - oben = oben->prev; - pline++; - line--; - } - f = -1; - } - break; - case KEY_NPAGE: - case KEY_RIGHT: - for (line = 0; line < 20 && unten->next; line++) { - oben = oben->next; - unten = unten->next; - if (pointer->next) - pointer = pointer->next; - } - f = -1; - break; - case KEY_PPAGE: - case KEY_LEFT: - for (line = 0; line < 20 && oben->prev; line++) { - oben = oben->prev; - unten = unten->prev; - if (pointer->prev) - pointer = pointer->prev; - } - f = -1; - break; - case '/': - suchtext = my_input(0, 0, 0, "Suchtext: ", NULL); - such = eh; - case 'n': - if (suchtext) { - line = 0; - lt = strlen(suchtext); - while (such->next && !line) { - s = such->s; - while (strlen(s) >= lt && !line) { - if (strncasecmp(s, suchtext, lt) == 0) - line = 1; - s++; - } - if (!line) - such = such->next; - } - if (line) { - wclear(mywin); - oben = such->prev ? such->prev : such; - pline = 0; - /* unten = hlp->prev; */ - while (oben->prev && oben->s[0] != '\025') { /* eine Einheit */ - oben = oben->prev; - unten = unten->prev; - } - pointer = oben; - Movexy(3, 0); - for (line = 1, hlp = oben; line < bot && hlp->next; line++, hlp = hlp->next) { - Movexy(3, line); - if (hlp == such) { - txt = such->s; - s--; - ch = *s; - *s = 0; - sAddstr(txt); - wattron(mywin, A_REVERSE); - *s = (char)ch; - txt = s; - ch = txt[lt]; - txt[lt] = 0; - Addstr(txt); - wattroff(mywin, A_REVERSE); - txt[lt] = (char)ch; - txt += lt; - Addstr(txt); - } else - sAddstr(hlp->s); - } - bottom = line - 1; - } else { - movexy(0, SY); - beep(); - clrtoeol(); - printw((NCURSES_CONST char*)"'%s' nicht gefunden.", suchtext); - refresh(); - } - } else - beep(); - break; - case KEY_HELP: - case '?': - case 'h': - movexy(0, SY); - clrtoeol(); - addstr("/,n:Suche; N:New; G:Get; P:Put; M:Modify; B:Burg; S:Schiff;"); - refresh(); - break; - case '>': - while (unten->next) { - unten = unten->next; - oben = oben->next; - } - while (pointer->next) - pointer = pointer->next; - pline = bot; - f = -1; - break; - case '<': - pointer = such = oben = eh; - pline = 0; - f = -1; - break; - case 'X': - if(clipunit) { - SpecialFunctionUnit(clipunit); - modified = 1; - clipunit = 0; - clipregion = 0; - for (pline = 0, tmp = eh; tmp != pointer; tmp = tmp->next) - pline++; /* Stelle merken */ - freelist(eh); - delwin(mywin); - return 1; - } - break; - case 'N': - if ((u = make_new_unit(r))!=NULL) { - modified = 1; - if ((s = strchr(pointer->s, '('))!=NULL) { - s++; - f = atoi36(s); - switch (pointer->s[0]) { - case '\002': - b = findbuilding(f); - sprintf(lbuf, "Einheit in %s als Eigner?", BuildingName(b)); - if (yes_no(0, lbuf, 'j')) { - for (x = r->units; x; x = x->next) - if (x->building == b && fval(x, UFL_OWNER)) { - freset(x, UFL_OWNER); - break; - } - u->building = b; - fset(u, UFL_OWNER); - } - break; - case '\023': - sh = findship(f); - if (sh) { - sprintf(lbuf, "Einheit auf%s als Eigner?", shipname(sh)); - if (yes_no(0, lbuf, 'j')) { - for (x = r->units; x; x = x->next) - if (x->ship == sh && fval(x, UFL_OWNER)) { - freset(x, UFL_OWNER); - break; - } - u->ship = sh; - fset(u, UFL_OWNER); - } - } - break; - case '\025': - x = findunit(f, r); - if(x) { - if (x->building) { - sprintf(lbuf, "Einheit in %s rein?", buildingname(x->building)); - if (yes_no(0, lbuf, 'j')) - u->building = x->building; - } else if (x->ship) { - sprintf(lbuf, "Einheit auf%s rauf?", shipname(x->ship)); - if (yes_no(0, lbuf, 'j')) - u->ship = x->ship; - } - } - break; - } - } - for (pline = 0, tmp = eh; tmp != pointer; tmp = tmp->next) - pline++; /* Stelle merken */ - delwin(mywin); - freelist(eh); - return 1; - } - case 12: /* ^L */ - f = -1; - break; - case 'S': - if (!clipship) - beep(); - else { - sprintf(lbuf, "Schiff%s löschen?", shipname(clipship)); - if (yes_no(0, lbuf, 'n')) { - modified = 1; - for (x = shipregion->units; x; x = x->next) - leave(shipregion, x); - destroy_ship(clipship); - clipship = 0; - shipregion = 0; - for (pline = 0, tmp = eh; tmp != pointer; tmp = tmp->next) - pline++; /* Stelle merken */ - delwin(mywin); - freelist(eh); - return 1; - } else - wrefresh(mywin); - } - break; - case 's': - if (clipship && shipregion != r) { - unit *un; - sprintf(lbuf, "Schiff %s einfügen?", shipname(clipship)); - if (yes_no(0, lbuf, 'j')) { - boolean owner_set = false; - - for (x = shipregion->units; x;) { - un = x->next; - if (x->ship == clipship) { - f = (int) fval(x, UFL_OWNER); - leave(shipregion, x); - translist(&shipregion->units, &r->units, x); - x->ship = clipship; - if (owner_set == false && f) { - owner_set = true; - fset(x, UFL_OWNER); - } else { - freset(x, UFL_OWNER); - } - } - x = un; - } - move_ship(clipship, shipregion, r, NULL); - clipship = NULL; - shipregion = NULL; - } - } else - NeuesSchiff(r); - for (pline = 0, tmp = eh; tmp != pointer; tmp = tmp->next) - pline++; /* Stelle merken */ - freelist(eh); - delwin(mywin); - return 1; - case 'b': - NeueBurg(r); - for (pline = 0, tmp = eh; tmp != pointer; tmp = tmp->next) - pline++; /* Stelle merken */ - freelist(eh); - delwin(mywin); - return 1; - case 'B': - if (pointer) { - if ((s = strchr(pointer->s, '('))!=NULL) { - s++; - f = atoi36(s); - if (f) { - b = findbuilding(f); - if (b) { - sprintf(lbuf, "Gebäude %s löschen?", BuildingName(b)); - if (yes_no(0, lbuf, 'n')) { - modified = 1; - for (x = r->units; x; x = x->next) - if (x->building == b) - leave(r, x); - destroy_building(b); - for (pline = 0, tmp = eh; tmp != pointer; tmp = tmp->next) - pline++; /* Stelle merken */ - delwin(mywin); - freelist(eh); - return 1; - } else - wrefresh(mywin); - } - } - } - } - break; - case 'U': - f = map_input(0, 0, 0, "Einheit Nummer", 0, 99999, 0); - if (f) - clipunit = findunit(f, r); - break; - case 'M': - if (!isunit || !pointer) { - movexy(0, SY); - clrtoeol(); - movexy(0, SY); - addstr("keine Einheit hier"); - refresh(); - } else { - s = strchr(pointer->s, '('); - if (s) { - char idbuf[12]; - int i = 0; - - s++; - while(*s != ')') { - idbuf[i] = *s; - i++; s++; - assert(i<=11); - } - idbuf[i] = '\0'; - - f = atoi36(idbuf); - - x = findunit(f, r); - if (x && modify_unit(r, findunit(f, r))) { - for (pline = 0, tmp = eh; tmp != pointer; tmp = tmp->next) - pline++; /* Stelle merken */ - freelist(eh); - delwin(mywin); - clipunit = x; - clipregion = r; - return 1; - } else - f = -1; - } - } - break; - case 'P': - case 'p': - if (!clipunit) - beep(); - else { - leave(clipregion, clipunit); - if (r != clipregion) - translist(&clipregion->units, &r->units, clipunit); - modified = 1; - if (pointer && (s = strchr(pointer->s, '('))!=NULL) { - s++; - f = atoi36(s); - if (f) - switch (pointer->s[0]) { - case '\025': - f = atoi36(s); - x = findunit(f, r); - clipunit->building = x->building; - clipunit->ship = x->ship; - clipregion = r; - break; - case '\002': - f = atoi36(s); - b = findbuilding(f); - for (x = r->units; x; x = x->next) - if (x->building == b && fval(x, UFL_OWNER)) - freset(x, UFL_OWNER); - clipunit->building = b; - fset(clipunit, UFL_OWNER); - break; - case '\023': - f = atoi(s); - sh = findship(f); - for (x = r->units; x; x = x->next) - if (x->ship == sh && fval(x, UFL_OWNER)) - freset(x, UFL_OWNER); - clipunit->ship = sh; - fset(clipunit, UFL_OWNER); - break; - } - } - for (pline = 0, tmp = eh; tmp != pointer; tmp = tmp->next) - pline++; /* Stelle merken */ - delwin(mywin); - freelist(eh); - return 1; /* -> totaler Neuaufbau der - * Liste */ - } - break; - case 'E': - clipunit = 0; - clipregion = 0; - break; - case 'D': - if (!clipunit) - beep(); - else { - sprintf(lbuf, "Einheit %s löschen?", Unitid(clipunit)); - if (yes_no(0, lbuf, 'n')) { - modified = 1; - destroy_unit(clipunit); - if (clipunit->number==0) remove_unit(clipunit); - clipunit = 0; - clipregion = 0; - for (pline = 0, tmp = eh; tmp != pointer; tmp = tmp->next) - pline++; /* Stelle merken */ - freelist(eh); - delwin(mywin); - return 1; - } else - wrefresh(mywin); - - } - break; - case 'G': - case 'g': - if (!pointer) { - movexy(0, SY); - addstr("kann hier nichts aufnehmen"); - refresh(); - } else { - if ((s = strchr(pointer->s, '('))!=NULL) { - char idbuf[12]; - int i = 0; - - s++; - while(*s != ')') { - idbuf[i] = *s; - i++; s++; - assert(i<=11); - } - idbuf[i] = '\0'; - - f = atoi36(idbuf); - - if (f) - switch (pointer->s[0]) { - case '\025': - clipunit = findunit(f, r); - clipregion = r; - break; - case '\023': - clipship = findship(f); - shipregion = r; - break; - } - } - } - break; - case 27: /* Esc */ - case 'q': - delwin(mywin); - freelist(eh); - pointer = NULL; - return 0; - } - - if (f < 0) { - wclear(mywin); - for (line = 0, unten = oben; line < bot && unten->next; line++, unten = unten->next) { - Movexy(3, line); - sAddstr(unten->s); - } - bottom = line - 1; - f = 0; - } - } -} diff --git a/src/mapper/mapper.c b/src/mapper/mapper.c deleted file mode 100644 index 8a8707e72..000000000 --- a/src/mapper/mapper.c +++ /dev/null @@ -1,1733 +0,0 @@ -/* vi: set ts=2: - * - * Eressea PB(E)M host Copyright (C) 1998-2003 - * Christian Schlittchen (corwin@amber.kn-bremen.de) - * Katja Zedel (katze@felidae.kn-bremen.de) - * Henning Peters (faroul@beyond.kn-bremen.de) - * Enno Rehling (enno@eressea-pbem.de) - * Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de) - * - * This program may not be used, modified or distributed without - * prior permission by the authors of Eressea. - */ - -#define VERSION "3.3.0" -#define ISLANDSIZE 20 - -/* wenn config.h nicht vor curses included wird, kompiliert es unter windows nicht */ -#include -#include -#include -#include "mapper.h" - -#include - -#include -#include -#include -#include - -#include -#include -#ifdef MUSEUM_MODULE -#include -#endif -#ifdef ARENA_MODULE -#include -#endif -#ifdef WORMHOLE_MODULE -#include -#endif - -/* kernel includes */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* util includes */ -#include -#include -#include - -/* libc includes */ -#include -#include -#include -#include -#include -#include - -extern int maxregions; -extern boolean dirtyload; -char datafile[256]; - -/* -------------------- resizeterm ------------------------------------- */ - -short Signals = 0; -int numnewbies = 0; -unit *clipunit; -struct ship *clipship; -region *clipregion; -tagregion *Tagged; - -#undef NEW_DRAW -extern void render_init(void); - -WINDOW * openwin(int b, int h, const char* t) { - WINDOW * win = newwin(h,b,(SY-(h))/2,(SX-(b))/2); - wclear(win); - /* wborder(win, '|','|','-','-','.','.','`','\''); */ - wborder(win, 0, 0, 0, 0, 0, 0, 0, 0); - if(t) { - wmove(win,0,3); - waddnstr(win,(char*)t,-1); - } - wrefresh(win); - return win; -} - -#if !defined(WIN32) - -#ifdef SOLARIS -#define __USE_POSIX /* Sonst kein sigaction */ -#define _POSIX_C_SOURCE 1 /* dito */ -#include -#endif - -#include - -void -sighandler(int sig) -{ /* wir fangen nur das eine Signal ab */ - Signals |= S_SIGWINCH; -} - -void -signal_init(void) -{ - struct sigaction act; - memset(&act, 0, sizeof(act)); - - act.sa_handler = sighandler; - sigaction(SIGWINCH, &act, NULL); -} -#endif /* ndef Win32 */ - -short left = 0, top = 0, tx=-999, ty=-999; -int breit, hoch; -int MINX=0, MINY=0, MAXX=0, MAXY=0; -boolean minimapx=false,minimapy=false; /* Karte nicht vert./hor. scrollen */ - -/* rx,ry => Auf welcher Region steht der Cursor */ -/* hoch, breit => Breite und Höhe der Karte */ -/* x, y => ? */ -/* top, left => ? */ -/* hx, hy => ? */ - -newfaction * newfactions = NULL; - -static void -runautoseed(void) -{ - while (newfactions) { - int n = listlen(newfactions); - int k = (n+ISLANDSIZE-1)/ISLANDSIZE; - k = n / k; - autoseed(&newfactions, k, true); - } -} - -void -init_win(int x, int y) { - if (initscr() == NULL) { - puts("\07Error initializing terminal."); - exit(1); - } - keypad(stdscr, TRUE); - scrollok(stdscr,false); - curs_set(0); - cbreak(); - noecho(); - clear(); - refresh(); - - breit = (short)(SX-45)/2; hoch = (short)SY-6; - - if (breit > MAXX-MINX+(MAXY-MINY)/2) { - left = (short)(MINX-(breit-MAXX-MINX)/2+y/2); - breit = MAXX-MINX+(MAXY-MINY)/2; - minimapx=true; - } else { - left = (short)(x-breit/2+y/2); - } - - if (hoch > MAXY-MINY) { - minimapy=true; - top = (short)(MAXY+(hoch-MAXY-MINY)/2); - hoch = MAXY-MINY; - } else { - top = (short)(y+hoch/2); - } - - /* breit=(SX-45)/2; hoch=SY-6; */ /* zum Darstellen schon alles nehmen */ -} - -/* --------------------------------------------------------------------- */ - -static int hl; -static int hl_alliance; - -int politkarte = 0; - -int -RegionColor(const region *r) { - static int usecolor=0; - if (!usecolor) { - start_color(); - init_pair(T_PLAIN, COLOR_GREEN, COLOR_BLACK); - init_pair(T_SWAMP, COLOR_RED, COLOR_BLACK); - init_pair(T_OCEAN, COLOR_BLUE, COLOR_BLACK); - init_pair(T_GLACIER, COLOR_WHITE, COLOR_BLACK); - init_pair(T_HIGHLAND, COLOR_YELLOW, COLOR_BLACK); - init_pair(T_DESERT, COLOR_CYAN, COLOR_BLACK); - init_pair(T_MOUNTAIN, COLOR_WHITE, COLOR_BLACK); - usecolor=1; - } - return COLOR_PAIR(rterrain(r)); -} - -const char terrainsymbol[] = { - '.', 'P', 'S', 'D', 'H', 'M', 'G', '@', '&', 'L', '%', '*', 'v', 'V', 'i', 'I', '%', '%', '%', '#', 'X', 0 -}; - -chtype -RegionSymbol(const region *r) { - chtype rs; - int p; - - if (!r) return '?'; - - switch(politkarte) { - case 1: - { - unit *u; - faction *f; - - for (f = factions; f; f = f->next) - freset(f, FL_DH); - for (u = r->units; u; u = u->next) - fset(u->faction, FL_DH); - for (p = 0, f = factions; f; f = f->next) - if (fval(f, FL_DH)) - p++; - if (p>9) - rs = (chtype)'!'; - else if (p>0) - rs = (chtype)(p+48); - else { - rs = terrainsymbol[rterrain(r)]; - if(rs == 'P' && r_isforest(r)) rs = 'F'; - } - } - break; - case 2: - { - if(r->land == NULL || r->land->demands == NULL) { - rs = terrainsymbol[rterrain(r)]; - } else { - const luxury_type *sale=NULL; - struct demand *dmd; - - for (dmd=r->land->demands;dmd;dmd=dmd->next) { - if (dmd->value==0) sale = dmd->type; - } - - if(sale == NULL) { /* Kann nur bei einem Bug passieren */ - rs = terrainsymbol[rterrain(r)]; - } else { - rs = resourcename(sale->itype->rtype, 0)[0]; - } - } - } - break; - case 3: - { - const item_type *herb = rherbtype(r); - if (herb) { - const char *c = resourcename(herb->rtype,0); - int h = atoi(c+1); - if(h < 10) { - rs = '0'+h; - } else { - rs = 'a'+(h-10); - } - } else { - rs = terrainsymbol[rterrain(r)]; - } - } - break; - case 4: - { - if(r->land) { - struct demand *dmd; - rs = '0'; - for (dmd=r->land->demands;dmd;dmd=dmd->next) rs++; - } else { - rs = terrainsymbol[rterrain(r)]; - } - } - break; - default: - rs = terrainsymbol[rterrain(r)]; - if(rs == 'P' && r_isforest(r)) rs = 'F'; - } - return rs; -} - -boolean -is_tagged(region *r) { - tagregion *t; - - for (t=Tagged; t; t=t->next) - if (t->r == r) - return true; - return false; -} - -static boolean -factionhere(region * r, int f) -{ - unit *u; - for (u = r->units; u; u = u->next) - if (u->faction->no == f) - return true; - return false; -} - -static boolean -alliancehere(region * r, int allied) -{ - unit *u; - for (u = r->units; u; u = u->next) - if (u->faction->alliance && u->faction->alliance->id == allied) - return true; - return false; -} - -static boolean -has_laen(region *r) -{ - rawmaterial *rm; - - for(rm=r->resources; rm; rm=rm->next) { - if(rm->type == &rm_laen) return true; - } - return false; -} - -static int -crwritemap(void) -{ - FILE * F = fopen("world.cr", "w+"); - region * r; - for (r=regions;r;r=r->next) { - plane * p = rplane(r); - fprintf(F, "REGION %d %d %d\n", r->x, r->y, p?p->id:0); - fprintf(F, "\"%s\";Name\n\"%s\";Terrain\n", rname(r, default_locale), LOC(default_locale, terrain_name(r))); - } - fclose(F); - return 0; -} - -int -newbie_region(region * r) -{ - unit * u; - if (r==NULL || r->units==NULL) return 0; - for (u=r->units;u;u=u->next) { - if (u->faction->age>10) return 0; -/* if (u->faction->age==0) return 1; */ - } - return 1; -} - -static boolean -highlight_region(region *r) -{ - if ((hl == -2 && r->units) || - (hl == -3 && r->buildings) || - (hl == -4 && r->ships) || - (hl == -5 && has_laen(r)) || - (hl == -6 && fval(r, RF_MALLORN)) || - (hl == -7 && fval(r, RF_CHAOTIC)) || - (hl == -8 && get_curse(r->attribs, ct_find("godcursezone"))) || - (hl == -9 && newbie_region(r)) || - (hl == -11 && alliancehere(r, hl_alliance)) || - (hl >= 0 && factionhere(r, hl))) { - return true; - } - - return false; -} - -void -drawmap(boolean maponly) { - short x, x1, y1, y2; - int s, q; - chtype rs; - region *r; - - x1 = left; y1=top; - if(maponly == false) { - movexy(SX-36,SY-2); - sprintf(buf, "%d gesetzt, %d Rest", numnewbies, listlen(newfactions)); - addstr(buf); - movexy(SX-39, 0); - vline(ACS_VLINE, SY+1); - movexy(SX-38, SY-3); - hline(ACS_HLINE, 39); - if (hl != -1) { - movexy(SX-36,SY-3); - addstr(" High: "); - switch (hl) { - case -2: - addstr("Einheiten "); - break; - case -3: - addstr("Gebäude "); - break; - case -4: - addstr("Schiffe "); - break; - case -5: - addstr("Laen "); - break; - case -6: - addstr("Mallorn "); - break; - case -7: - addstr("Chaos "); - break; - case -8: - addstr("Godcurse "); - break; - case -9: - addstr("Anfänger "); - break; - case -10: - addstr("Dropouts "); - break; - case -11: - printw((NCURSES_CONST char*)"Allianz %d ", hl_alliance); - break; - default: - printw((NCURSES_CONST char*)"Partei %d ", hl); - } - } - switch(politkarte) { - case 0: - movexy(SX-14,SY-3); - addstr(" Geol.Karte "); - break; - case 1: - movexy(SX-14,SY-3); - addstr(" Politkarte "); - break; - case 2: - movexy(SX-14,SY-3); - addstr(" Handelskar "); - break; - case 3: - movexy(SX-14,SY-3); - addstr(" Botanik "); - break; - case 4: - movexy(SX-14,SY-3); - addstr(" Demand "); - break; - } - } - - for (s=0; sx2) { - x1-=dx; x2+=dx; - } - /* jetzt ist <1> immer unten links, <2> immer oben rechts */ - - movexy(x1-1,y1+1); hline('-', dx+2); - movexy(x1+dy,y2-1); hline('-', dx+2); - - for (; dy>=0; dy--) { - movexy(x1+dy-1,y1-dy); - addch('/'); - movexy(x1+dy+dx+1,y1-dy); - addch('/'); - } -} - -void -mark(short x, short y, short rx, short ry) { - int q; - char num[6]; - - - /* - move(0,0); - printw("hoch=%d,breit=%d,x=%d,y=%d,left=%d,top=%d,rx=%d,ry=%d ", - hoch,breit,x,y,left,top,rx,ry); - */ - - movexy(x*2+6+(y&1)+(top&1),y+6); - if (rx==tx && ry==ty) - addch('>'); - else - addch('<'); - addch(RegionSymbol(findregion(rx,ry)) | A_REVERSE); - if (rx==tx && ry==ty) - addch('<'); - else - addch('>'); - attron(A_BOLD); - sprintf(num,"%4d",rx); - for (q=0; q<5; q++) { - movexy(x*2+7+(y&1)+(top&1),q+1); - printw((NCURSES_CONST char*)"%c", num[q]); - } - movexy(1,y+6); - printw((NCURSES_CONST char*)"%4d<-",ry); - movexy(SX-39, y+6); addch('<'); - movexy(x*2+7+(y&1)+(top&1),5); addch('^'); - attroff(A_BOLD); - refresh(); -} - -static void unmark(short x, short y, short rx, short ry) { - int q; - region *r=findregion(rx,ry); - chtype rs; - - rs = RegionSymbol(r); - - movexy(x*2+6+(y&1)+(top&1),y+6); - addch(' '); - if (r) { - if (highlight_region(r) || (rx==tx && ry==ty)) { - addch(rs | A_REVERSE); - } else if (is_tagged(r)) { - addch(rs | A_BOLD); - } else { - addch(rs); - } - } else { - addch(rs); - } - addch(' '); - for (q=0; q<5; q++) { - movexy(x*2+7+(y&1)+(top&1),q+1); - addch(' '); - } - movexy(1,y+6); - printw((NCURSES_CONST char*)"%4d ",ry); - movexy(SX-39, y+6); addch('|'); - refresh(); -} - -void -modify_block(void) -{ - WINDOW *win; - int c, s = 0; - region *r; - tagregion *t; - char *name = NULL; - int div = 0; - int mal = 0; - struct rawmaterial *res; - - win = openwin(90, 4, "< Tag-Regionen modifizieren >"); - wmove(win, 1, 2); - wAddstr("Empty, Name, Peasants, Horses, Silver, Chaos, noResources, Mallorn (e/n/p/h/s/c/r/m,q)?"); - wrefresh(win); - c = getch(); - if (c == 'q') { - delwin(win); - return; - } - - switch(c) { - case 'c': - wmove(win, 2, 2); - wAddstr("Chaosstatus (s)etzen oder (l)öschen?"); - wrefresh(win); - if (getch() == 's') { - s = 1; - } else { - s = 0; - } - break; - case 'n': - name = my_input(win, 2, 2, "Name: ", NULL); - break; - case 'p': - div = atoi(my_input(win, 2, 2, "Divisor: ", "1")); - break; - case 'm': - wmove(win, 2, 2); - wAddstr("Mallorn (s)etzen oder (l)öschen?"); - wrefresh(win); - if (getch() == 's') { - mal = 1; - } else { - mal = 0; - } - break; - } - - for (t=Tagged; t; t=t->next) { - r=t->r; - if (production(r)) { - switch (c) { - case 'e': - rsetpeasants(r, 0); - rsetmoney(r, 0); - rsethorses(r, 0); - rsettrees(r,2,0); - rsettrees(r,1,0); - rsettrees(r,0,0); - - for (res=r->resources;res;res=res->next) { - const item_type * itype = resource2item(res->type->rtype); - if(itype == olditemtype[I_IRON]) { - res->amount = -1; - res->level = -1; - } else if(itype == olditemtype[I_LAEN]) { - res->amount = -1; - res->level = -1; - } else if(itype == olditemtype[I_STONE]) { - res->amount = -1; - res->level = -1; - } - } - freset(r, RF_MALLORN); - break; - case 'n': - rsetname(r, name); - break; - case 'p': - rsetpeasants(r, (production(r)*3+rng_int()%(production(r)*3))/div); - rsetmoney(r, (production(r)*10+rng_int()%(production(r)*10))/div); - break; - case 'h': - rsethorses(r, rng_int()%(production(r) / 10)); - break; - case 's': - rsetmoney(r, production(r)*10+rng_int()%(production(r)*10)); - break; - case 'r': - for (res=r->resources;res;res=res->next) { - const item_type * itype = resource2item(res->type->rtype); - if(itype == olditemtype[I_IRON]) { - res->amount = -1; - res->level = -1; - } else if(itype == olditemtype[I_LAEN]) { - res->amount = -1; - res->level = -1; - } else if(itype == olditemtype[I_STONE]) { - res->amount = -1; - res->level = -1; - } - } - break; - case 'm': - if(mal == 1) { - fset(r, RF_MALLORN); - } else { - freset(r, RF_MALLORN); - } - break; - } - } - if (c == 'c') { - if(s) { - fset(r, RF_CHAOTIC); - } else { - freset(r, RF_CHAOTIC); - } - } - } - modified = 1; - delwin(win); -} - -void -SetHighlight(void) -{ - WINDOW *win; - char *fac_nr36; - int c; - - win = openwin(60, 6, "< Highlighting >"); - wmove(win, 1, 2); - wAddstr("Regionen mit P)artei, E)inheiten, B)urgen, S)chiffen,"); - wmove(win, 2, 2); - wAddstr(" A)nfängern, L)aen, C)haos, G)odcurse"); - wmove(win, 3, 2); - wAddstr(" D)ropouts, Allian(Z) oder N)ichts?"); - wrefresh(win); - c = tolower(getch()); - switch (c) { - case 'p': - fac_nr36 = my_input(win, 2, 2, "Partei-Nummer: ", NULL); - hl = atoi36(fac_nr36); - break; - case 'z': - hl_alliance = map_input(win, 2, 2, "Allianz-Nummer: ", 0, 999, 0); - hl = -11; - break; - case 'e': - hl = -2; - break; - case 'b': - hl = -3; - break; - case 's': - hl = -4; - break; - case 'l': - hl = -5; - break; - case 'm': - hl = -6; - break; - case 'c': - hl = -7; - break; - case 'g': - hl = -8; - break; - case 'a': - hl = -9; - break; - case 'd': - hl = -10; - break; - case 'n': - default: - hl = -1; - break; - } - delwin(win); -} - -void -recalc_everything(short *x, short *y, short *rx, short *ry) -{ - int eingerueckt; - - top=(*ry)+hoch/2; (*y)=hoch/2; - (*x)=breit/2; left=(*rx)-((*y)/2)-(*x); - - /* Wenn Zeile eingerückt, left modifizieren */ - - if((top-(*ry))&1) /* Einrückung wie erste Zeile */ - eingerueckt = (hoch + (hoch&1) + (top&1))&1; - else - eingerueckt = !((hoch + (hoch&1) + (top&1))&1); - - if(eingerueckt) left++; -} - -#define restore { x=oldx; y=oldy; rx=oldrx; ry=oldry; } - -static void -movearound(short rx, short ry) { - int hx = -1, hy = -1, ch, Rand, d, a, b, p, q, oldx=0, oldy=0; - int oldrx=0, oldry=0, Hx=0, Hy=0; - short x, y; - int sel; - static int editmode=0; - char *selc; - region *c, *r = NULL, *r2; - tagregion *tag; - unit *u, *u2; - WINDOW *win; - - y=top-ry; x=rx-left; left-=y/2; - if (y&1 && !(ry&1)) left--; else left++; - if (ry&1) left--; - - r=findregion(rx,ry); - drawmap(false); - Rand=min(4, min(breit/4, hoch/4)); - showregion(r, 0); - DisplayRegList(1); - mark(x,y,rx,ry); - - for (;;) { -#ifndef WIN32 - if (Signals & S_SIGWINCH) { - do { - endwin(); - init_win(rx, ry); - Signals &= ~S_SIGWINCH; - if (SX < 50 || SY < 12) { - beep(); - move(0, 0); - addstr("Fenster zu klein!"); - refresh(); - while (!(Signals & S_SIGWINCH)) - a++; - } - } while (SX < 50 && SY < 12); - y = top - ry; x = rx - left; left-=y/2; - /* Wenn in eingerückter Zeile */ - if (y&1 && !(ry&1)) left--; else left++; - if (ry&1) left--; - ch = -9; - } else -#endif - { - int edit=0; - ch = getch(); - unmark(x, y, rx, ry); - - oldx=x; oldy=y; oldrx=rx; oldry=ry; - if (editmode) { - if (ch=='E') { - editmode=0; - edit=1; - } else { - region * r = findregion(rx, ry); - if (r) { - terrain_t t = 0; - while (terrainsymbol[t] && tolower(terrainsymbol[t])!=tolower(ch)) ++t; - if (terrainsymbol[t]) { - edit = 1; - terraform(r, t); - } - } - } - } - if (!edit) switch (ch) { - case KEY_HELP: - case '?': - if (reglist) { - freelist(reglist); - reglist = NULL; - } - adddbllist(®list, "Hilfe"); - adddbllist(®list, "¯¯¯¯¯"); - adddbllist(®list, " Cursor: Scroll"); - adddbllist(®list, " NumBlock: Move"); - adddbllist(®list, " j,m,x,y: Jump X/Y"); - adddbllist(®list, " ^L: Redraw"); - adddbllist(®list, " h: Bereich markieren"); - adddbllist(®list, " p: Parteiliste"); - adddbllist(®list, " e,u: Einheitenliste"); - adddbllist(®list, " q: Quit"); - adddbllist(®list, " r,i: Regionsinfo"); - adddbllist(®list, " t: Tag Region(en)"); - adddbllist(®list, " ^T: Untag alle Regionen"); - adddbllist(®list, " /: Suche Einheit"); - adddbllist(®list, " B: Ozean-Bereich erzeugen"); - adddbllist(®list, " ^B: neuen 9×9-Block erzeugen"); - adddbllist(®list, " C: neue Region erzeugen"); - adddbllist(®list, " D: Partei löschen"); - adddbllist(®list, " G: Jump Tagregion"); - adddbllist(®list, " H: Highlight"); - adddbllist(®list, " M: Region(en) modifizieren"); - adddbllist(®list, " P: neue Partei einfügen"); - adddbllist(®list, " T: Terraform Region"); - adddbllist(®list, " Z: Terrain Region"); - DisplayRegList(1); - ch = 999999; - break; - case 23: /* ctrl-w*/ - crwritemap(); - break; - case 'q': - if (yes_no(0, "Wirklich beenden?", 'n')) - return; - /* sonst ein redraw */ - case 12: /* ^L */ - clear(); - DisplayRegList(0); - ch = -9; /* nur ein Redraw */ - break; - case 'T': - if (r==NULL) break; - if (!Tagged) { - const terrain_type * terrain = select_terrain(r->terrain); - if (terrain!=NULL) { - if (hx>-1) { - int Rx,Ry; - Rx=rx; Ry=ry; - if (rx>Hx) { a=Hx; Hx=Rx; rx=a; } - if (ry>Hy) { a=Hy; Hy=Ry; ry=a; } - for (a=Rx; a<=Hx; a++) { - for (b=Ry; b<=Hy; b++) { - c = findregion(a,b); - if (c) terraform_region(c, terrain); - } - } - } else { - terraform_region(r, terrain); - } - } - } else { - const terrain_type * terrain = select_terrain(r->terrain); - if (terrain!=NULL) { - for (tag=Tagged; tag; tag=tag->next) { - terraform_region(tag->r, terrain); - } - } - } - ch = -9; - modified = 1; - break; - case 'Z': - if (!Tagged) { - const terrain_type * terrain = select_terrain(r->terrain); - if (terrain!=NULL) { - if (hx>-1) { - short Rx,Ry; - Rx=rx; Ry=ry; - if (rx>Hx) { a=Hx; Hx=Rx; rx=a; } - if (ry>Hy) { a=Hy; Hy=Ry; ry=a; } - for (a=Rx; a<=Hx; a++) { - for (b=Ry; b<=Hy; b++) { - c = findregion(a,b); - if (c) c->terrain = terrain; - } - } - } else { - r->terrain = terrain; - } - } - } else { - const terrain_type * terrain = select_terrain(r->terrain); - if (terrain!=NULL) { - for (tag=Tagged; tag; tag=tag->next) { - tag->r->terrain = terrain; - } - } - } - ch = -9; - modified = 1; - break; - case 't': - if (hx>-1) { - if (Hxr=c; - tag->next=Tagged; Tagged=tag; - } - } - ch=-9; - } else { - tx=rx; ty=ry; - if (is_tagged(r)) { - tag=Tagged; - while (tag->r!=r) tag=tag->next; - removelist(&Tagged,tag); - } else { - tag=calloc(1, sizeof(tagregion)); - tag->r=r; - tag->next=Tagged; Tagged=tag; - } - } - break; - case 0x14: - { - tagregion *tag_next; - tag = Tagged; - while (tag) { - tag_next = tag->next; - removelist(&Tagged, tag); - tag = tag_next; - } - ch=-9; - } break; - case 'W': - if(Tagged) { - FILE *mapFile = mapperFopen("mapper.map","w"); - const char *tname; - if(mapFile) { - tag=Tagged; - while(tag) { - fprintf(mapFile, "REGION %d %d\n", tag->r->x, tag->r->y); - tname = terrain_name(tag->r); - fprintf(mapFile, "\"%s\"; Terrain\n", locale_string(NULL, tname)); - tag = tag->next; - } - fclose(mapFile); - } - } break; - case 'G': - rx=tx; ry=ty; - recalc_everything(&x, &y, &rx, &ry); - ch=-8; - break; - case 'c': - if (clipunit) { - rx = clipregion->x; - ry = clipregion->y; - recalc_everything(&x, &y, &rx, &ry); - ch = -8; - } - break; - case '/': - win = openwin(70, 4, "< Suchen >"); - wmove(win, 1, 2); - wAddstr("Suchen nach P)artei, E)inheit, R)egionsname? "); - wrefresh(win); - sel = tolower(getch()); - switch(sel) { - case 'e': - case 'E': - q = atoi36(my_input(win, 2, 2, "Welche Einheit suchen: ", NULL)); - if (q) { - u = findunitg(q, NULL); - if (!u) { - warnung(0, "Einheit nicht gefunden."); - } else { - r = u->region; - rx=r->x; ry=r->y; - recalc_everything(&x, &y, &rx, &ry); - } - } - break; - case 'p': - case 'P': - q = atoi36(my_input(win, 2, 2, "Welche Partei suchen: ", NULL)); - if(q) { - u2 = NULL; - for(r2=regions; r2; r2=r2->next) { - for(u2=r2->units; u2; u2=u2->next) - if(u2->faction->no == q) break; - if(u2) break; - } - - if(u2) { - r = r2; - rx=r->x; ry=r->y; - recalc_everything(&x, &y, &rx, &ry); - } - } - break; - case 'r': - case 'R': - selc = my_input(win, 2, 2, "Welchen Regionsnamen suchen: ", NULL); - if(*selc) { - for(r2=regions; r2; r2=r2->next) - if(strcmp(selc, rname(r2, NULL)) == 0) break; - - if(r2) { - r = r2; - rx=r->x; ry=r->y; - recalc_everything(&x, &y, &rx, &ry); - } - } - break; - } - - delwin(win); - ch=-9; - break; - case 'H': - SetHighlight(); - ch = -9; - break; - case 'h': - if (hx < 0) { - hx = x; Hx=rx; - hy = y; Hy=ry; - } else - hx = hy = -1; - ch=-9; - break; - case 'C': - make_new_region(rx, ry); - ch = -9; - break; - case 'B': - a=map_input(0,0,0,"Start X", -999, 999, rx); - b=map_input(0,0,0,"Start Y", -999, 999, ry); - p=map_input(0,0,0,"Ende X", -999, 999, rx); - q=map_input(0,0,0,"Ende Y", -999, 999, ry); - if (a>p) { x=a; a=p; p=x; } - if (b>q) { x=b; b=q; q=x; } - for (x=a; x<=p; x++) - for (y=b; y<=q; y++) - if (!findregion(x,y)) /* keine existierenden Regionen überschreiben */ - (void)new_region(x,y); - restore; - modified=1; - ch=-9; - break; - case 'I': - if (r!=NULL) { - a = map_input(0,0,0,"Wieviele Regionen?",0,500,0); - if (a) { - const terrain_type * terrain = random_terrain(false); - create_island(r, a, terrain); - modified=1; - } - ch = -9; - } - break; - case 0x2: - make_ocean_block(rx, ry); - modified = 1; - ch = -9; - break; - case 'a': - runautoseed(); - modified = 1; - case 'S': - if (modified) - if (yes_no(0, "Daten abspeichern?", 'j')) { - remove_empty_units(); - writegame(datafile, 1); - if (yes_no(0, "Backup neu anlegen?", 'j')) { - create_backup(datafile); - } - modified = 0; - ch = -8; - } - break; - case 'D': - RemovePartei(); - ch = -9; - break; - case 'P': - if (r) NeuePartei(r); - ch = -9; - break; - case 'X': - if(Tagged) { - tag=Tagged; - while(tag) { - SpecialFunction(tag->r); - tag=tag->next; - } - } else { - SpecialFunction(r); - } - ch = -9; - break; - case 'M': - if (Tagged) - modify_block(); - else - while (modify_region(r)); /* Liste neu bei einigen Aktionen */ - ch = -9; - break; - case 'u': - case 'e': - while (r && showunits(r)); - ch = -9; - break; - case 'U': - { - unit *u, *un; - region *target_r; - static int tx = 0, ty = 0; - - tx=map_input(0,0,0,"Versetzen nach X-Koordinate", MINX, MAXX, tx); - ty=map_input(0,0,0,"Versetzen nach Y-Koordinate", MINY, MAXY, ty); - target_r = findregion(tx,ty); - if(target_r) { - for(u = r->units; u;) { - un = u->next; - leave(r, u); - move_unit(u, target_r, NULL); - u = un; - } - } - } - break; - case 'E': - editmode = !editmode; - break; - case 'i': - case 'r': - showregion(r, 1); - DisplayRegList(1); - ch = 999999; - break; - case 'p': - while (ParteiListe()); - ch = -9; - break; - case 'k': - politkarte = (politkarte+1)%5; - ch = -9; - break; - case '{': - case KEY_PPAGE: - ScrollRegList(1); - ch = 999999; - break; - case '}': - case KEY_NPAGE: - ScrollRegList(-1); - ch = 999999; - break; - case 'j': - case 'g': - if (hx<0) { - rx=map_input(0,0,0,"Neue X-Koordinate", MINX, MAXX, rx); - ry=map_input(0,0,0,"Neue Y-Koordinate", MINY, MAXY, ry); - - recalc_everything(&x, &y, &rx, &ry); - - ch=-8; - } - break; - case 'A': - { - plane *astral = getplanebyid(1); - if(!astral) break; - if(r->planep != astral) { - region *nr = r_standard_to_astral(r); - if(nr) { - r = nr; - rx = nr->x; - ry = nr->y; - recalc_everything(&x, &y, &rx, &ry); - ch = -8; - } - } else { - region *nr = r_astral_to_standard(r); - if(nr) { - r = nr; - rx = nr->x; - ry = nr->y; - recalc_everything(&x, &y, &rx, &ry); - ch = -8; - } - } - } - break; - case '1': /* left down */ - y++; ry--; - if (y&1) x--; - break; - case '7': /* left up */ - y--; ry++; - if (!(y&1)) x++; - x--; rx--; - break; - case '3': /* right down */ - rx++; - if (y&1) x++; - y++; ry--; - break; - case '9': /* right up */ - y--; ry++; - if (!(y&1)) x++; - break; - case '2': - y++; ry--; - if (y&1) rx++; - break; - case '8': - y--; ry++; - if (!(y&1)) rx--; - break; - case '4': - x--; rx--; - break; - case '6': - x++; rx++; - break; - case '5': - if (hx<0) { - top=ry+hoch/2; y=hoch/2; - x=breit/2; left=rx-(y/2)-x; if (top&1) left--; - if (!(hoch&1)) left++; - ch=-8; - } else { - ch=0; - beep(); - } - break; - case '[': - left++; - ch=-9; - break; - case ']': - left--; - ch=-9; - break; - case KEY_LEFT: /* scroll left */ - sprintf(buf, "%x", ch); - mvaddnstr(0, 0, buf, 4); - if (hx<0 && !minimapx) { - ch=-2; - rx--; left--; - } else { - ch=0; - beep(); - } - break; - case KEY_RIGHT: /* scroll right */ - if (hx<0 && !minimapx) { - ch=-3; - rx++; left++; - } else { - ch=0; - beep(); - } - break; - case KEY_DOWN: /* scroll down */ - if (hx<0 && !minimapy) { - ch=-4; - top--; - if ((top&1)) left--; else left++; - } else { - ch=0; - beep(); - } - break; - case KEY_UP: /* scroll up */ - if (hx<0 && !minimapy) { - ch=-5; - top++; - if (!(top&1)) left++; else left--; - } else { - ch=0; - beep(); - } - break; - } - } - - if (ch>0) { - if (!minimapx) { - if (x MINX) { - if (hx>-1) restore - else { - left-=(breit-2*Rand+2); - x=breit-Rand; - ch=-1; - } - } else if (x > breit-Rand && left+breit < MAXX) { - if (hx>-1) restore - else { - left+=(breit-2*Rand+1); - x=Rand; - ch=-1; - } - } - } - if (!minimapy) { - if (y < Rand-1 && top < MAXY) { - if (hx>-1) restore - else { - d=(hoch-2*Rand+2); - top+=d; - left-=d/2; - if (hoch&1) left--; - else if (ry&1) left--; else left++; - if (ry&1) left++; else left--; - y=hoch-Rand; - ch=-1; - } - } else if (y > hoch-Rand && top-hoch >= MINY) { - if (hx>-1) restore - else { - d=(hoch-2*Rand+2); - top-=d; - left+=d/2; - if (!(hoch&1)) left++; - if (ry&1) { - if (hoch&1) left++; else left--; - } else left--; - y=Rand; - ch=-1; - } - } - } - } - - if (ch < 0) { - if (ch > -9) { /* sonst sind wir an alter Position */ - ry=top-y; - } - if (ch == -9) { - clear(); - if (!r || r->x != rx || r->y != ry) - r=findregion(rx,ry); - showregion(r, 1); - DisplayRegList(1); - } - drawmap(false); - } - if (!r || r->x != rx || r->y != ry) { - r=findregion(rx,ry); - } - if (ch < 999999 && ch > -9) { /* Lange Regionsinfo nicht überschreiben */ - showregion(r, 0); - DisplayRegList(1); - } - if (hx>-1 && (x!=oldx || y!=oldy)) { - if (ch>0) drawmap(true); /* sonst war das eben schon */ - mark_region(x, y, hx, hy); - } - mark(x,y,rx,ry); - } -} - -void -Exit(int level) -{ - move(SY, 0); - deleteln(); - refresh(); - curs_set(1); - endwin(); - exit(level); -} - - -void -usage(void) -{ - fprintf(stderr, "mapper [-b basedir] [-d datadir] [-o datafile] [-c x,y]\n"); - exit(0); -} - -void -setminmax(void) -{ - region *r; - for (r = regions; r; r = r->next) { - if (r->x < MINX) - MINX = r->x; - if (r->y < MINY) - MINY = r->y; - if (r->x > MAXX) - MAXX = r->x; - if (r->y > MAXY) - MAXY = r->y; - } - MAXX += 20; - MAXY += 20; - MINX -= 20; - MINY -= 20; -} - -extern int quiet; - -extern char * g_reportdir; -extern char * g_datadir; -extern char * g_resourcedir; -extern char * g_basedir; - -static faction * -makemonsters(void) -{ - faction * f = calloc(sizeof(faction), 1); - f->next=factions; - f->race = new_race[RC_TEMPLATE]; - f->alive=1; - set_email(&f->email, ""); - f->lastorders=0; - f->locale=default_locale; - - factions=f; - f->options = want(O_REPORT); - f->no=MONSTER_FACTION; - f->subscription = 0; - f->name=strdup("Monster"); - f->passw=strdup("abc123"); - f->override = strdup(itoa36(rng_int())); - return f; -} - -#include "logging.h" - -static void -log_newstuff(void) -{ - faction * f; - region * r; - for (f=factions;f;f=f->next) { - if (f->age==0) log_faction(f); - } - for (r=regions;r;r=r->next) { - unit * u; - if (r->age==0) log_region(r); - for (u=r->units;u;u=u->next) { - if (u->age==0) log_unit(u); - } - } -} - -int -main(int argc, char *argv[]) -{ - int x = 0, y = 0, i; - char *s; - faction * f; - boolean backup = true; - boolean logging = false; - boolean readlog = false; - boolean autoseeding = false; - - sqlpatch = false; - setlocale(LC_ALL, ""); - setlocale(LC_NUMERIC, "C"); - - fprintf(stderr, " \n Mapper V" VERSION " Hex (" __DATE__ ")\n\n" - "Copyright © 1998/99 by Henning Peters - faroul@gmx.de\n" - "Copyright © 1998 by Enno Rehling - enno.rehling@gmx.de\n" - "Copyright © 2000 by Christian Schlittchen - corwin@amber.kn-bremen.de\n\n"); - - *datafile = 0; - - if (argc > 1) { - if (argv[1][0] == '?') - usage(); - - i = 1; - while (i < argc && argv[i][0] == '-') { - switch (argv[i][1]) { - case 'i': - xmlfile = argv[++i]; - break; - case 't': - if (argv[i][2]) - turn = atoi((char *)(argv[i] + 2)); - else - turn = atoi(argv[++i]); - break; - case 'f': - firstx = atoi(argv[++i]); - firsty = atoi(argv[++i]); - break; - case 'X': - dirtyload = true; - break; - case 'x': - maxregions = atoi(argv[++i]); - maxregions = (maxregions*81+80) / 81; - break; - case 'q': - quiet = 1; - break; - case 'l': - logging = true; - break; - case 'R': - readlog = true; - break; - case 'n': - switch (argv[i][2]) { - case 'b' : backup = false; break; - } - break; - case 'd': - g_datadir = argv[++i]; - break; - case 'r': - g_resourcedir = argv[++i]; - break; - case 'a': - autoseeding = true; - break; - case 'o': - strcpy(datafile, argv[++i]); - break; - case 'b': - g_basedir = argv[++i]; - break; - case 'c': - if (argv[i][2]) - s = strdup((char *) (argv[i] + 2)); - else - s = argv[++i]; - x = atoi(s); - s = strchr(s, ','); - y = atoi(++s); - break; - default: - usage(); - } - i++; - } - } - - kernel_init(); - - init_triggers(); - init_xmas(); - debug_language("locales.log"); - - register_races(); - register_resources(); - register_buildings(); - register_ships(); - register_spells(); -#ifdef MUSEUM_MODULE - register_museum(); -#endif -#ifdef ARENA_MODULE - register_arena(); -#endif -#ifdef WORMHOLE_MODULE - register_wormholes(); -#endif -/* register_dungeon(); */ - - register_itemtypes(); - register_xmlreader(); - init_data(xmlfile); - - init_locales(); - init_attributes(); - init_races(); - init_itemtypes(); - init_rawmaterials(); - - init_gmcmd(); - - if (!*datafile) sprintf(datafile, "%u", turn); - - readgame(datafile, backup); - for (f=factions;f;f=f->next) if (f->age==0) { - ++numnewbies; - } - - sprintf(buf, "%s/newfactions.%d", basepath(), turn); - newfactions = read_newfactions(buf); - if (newfactions==NULL) { - sprintf(buf, "%s/newfactions", basepath()); - newfactions = read_newfactions(buf); - } - - if (findfaction(MONSTER_FACTION)==NULL) { - makemonsters(); - } - if (readlog) { - log_read("mapper.log"); - } -#ifdef OLD_ITEMS - make_xref(); -#endif - setminmax(); - rng_init(time((time_t *) NULL)); - - if (autoseeding) { - runautoseed(); - remove_empty_units(); - writegame(datafile, 1); - } else { - if (logging) { - log_start("mapper.log"); - log_newstuff(); - } -#ifndef WIN32 - signal_init(); -#endif - init_win(x, y); - - hl=-1; - Tagged=NULL; - movearound(x, y); - if (logging) log_stop(); - if (modified) { - beep(); - if (yes_no(0, "Daten wurden modifiziert! Abspeichern?", 'j')) { - remove_empty_units(); - writegame(datafile, 1); - } - } - Exit(0); - } - return 0; -} diff --git a/src/mapper/mapper.dok b/src/mapper/mapper.dok deleted file mode 100644 index e49ca3f26..000000000 --- a/src/mapper/mapper.dok +++ /dev/null @@ -1,79 +0,0 @@ - - M A P P E R - ¯¯¯¯¯¯¯¯¯¯¯ - -Parameter: - -ddatadir -> load/save dir - -cx,y -> jumpto x,y - -t -> Testkeys - -Kurze Erklärung der Funktionen in den einzelnen Bereichen. Sind mehrere Tasten -möglich, sind diese mit , getrennt. - - - Überall - ? Kurz-Hilfe - q Beenden - <,> Springt an Anfang/Ende der Liste - Cursortasten bewegt Cursor/Zeiger; in Listen bewegt Crsr links/rechts - den Zeiger +/- 20 Zeilen. - ^L redraw - - - Karte - Shift+Cursor scrollt die Karte unter dem Cursor - T Terraform Region (mit Highlight: Terraform alle Regionen) - h Highlight Bereich (kein Scrollen möglich! m,p,j, x, y - gesperrt) - H Highlight bestimmte Merkmale (Partei, bewohnt, Burgen, - Schiffe) - C Create Block - P Neue Partei einfügen - D Partei löschen - S Daten Speichern - e,u Einheiten-Liste - p Partei-Liste - M Modify-Region (oder Regionen bei Highlight Bereich) - x neue X-Koordinate eingeben - y neue Y-Koordinate eingeben - m,j neue X- und Y-Koordinate eingeben - c springe an Position Clipunit - E Lösche Clipunit (es wird nicht die Einheit an sich - gelöscht, sondern nur Clipunit=0). - i,r ausführlichere Regionsinfos rechts - [,],PGUP,PGDN Flipt Seiten der langen Regionsinfo - q QUIT (mit Sicherheitsabfrage) - Speichert nach Abfrage, wenn Daten verändert wurden - - - Einheiten-Liste - Cursortasten bewegt Pointer; => bei Einheit, -> bei Burg/Schiff - / Sucht Text - n Sucht Text weiter - M Einheit verändern - N Neue Einheit schaffen - g,G Einheit in Clipunit bzw. Schiff in Clipschiff - P Clipunit hier einfügen - D Clipunit löschen - s Clipschiff hier einfügen oder neues Schiff - S Clipschiff löschen (Einheiten verlassen Schiff! Ozean!!) - b Neues Gebäude - B Gebäude löschen (Einheiten verlassen Gebäude) - E Lösche Clipunit (es wird nicht die Einheit an sich - gelöscht, sondern nur Clipunit=0). - U Einheits-Nummer eingeben (falls "auto-detect" nicht - klappt - q,Esc Ende Einheiten-Liste - - - Regions-Menu - Cursortasten bewegt Pointer; => Wert kann verändert werden - -> Wert kann nicht verändert werden - Return: bei => Wert neu eingeben - s Neues Schiff - S Schiff löschen - b Neues Gebäude - B Gebäude löschen - q,Esc Ende Regions-Menu - - -Ansonsten: RTFS :) - - Faroul - diff --git a/src/mapper/mapper.dsp b/src/mapper/mapper.dsp deleted file mode 100644 index 8bd2f28a4..000000000 --- a/src/mapper/mapper.dsp +++ /dev/null @@ -1,151 +0,0 @@ -# Microsoft Developer Studio Project File - Name="mapper" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -CFG=mapper - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "mapper.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "mapper.mak" CFG="mapper - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "mapper - Win32 Release" (based on "Win32 (x86) Console Application") -!MESSAGE "mapper - Win32 Debug" (based on "Win32 (x86) Console Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "mapper - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /Za /W4 /GX /Z7 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD BASE RSC /l 0x407 /d "NDEBUG" -# ADD RSC /l 0x407 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:console /debug /machine:I386 - -!ELSEIF "$(CFG)" == "mapper - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /Za /W4 /Gm /ZI /Od /I "../common/kernel" /I "../common/gamecode" /I "../common/util" /I "../common" /I ".." /D "_CONSOLE" /D "_MBCS" /D "WIN32" /D "_DEBUG" /FD /c -# SUBTRACT CPP /Fr /YX -# ADD BASE RSC /l 0x407 /d "_DEBUG" -# ADD RSC /l 0x407 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo /S (*.h ../*.h ../common/kernel/*.h ../common/attributes/*.h ../common/spells/*.h ../common/triggers/*.h ../common/items/*.h ../common/modules/*.h ../common/util/*.h) ../common/util/Debug/*.sbr ../common/items/Debug/*.sbr ../common/attributes/Debug/*.sbr ../common/kernel/Debug/*.sbr ../common/spells/Debug/*.sbr ../common/modules/Debug/*.sbr -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 curses.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "mapper - Win32 Release" -# Name "mapper - Win32 Debug" -# Begin Group "Header" - -# PROP Default_Filter "*.h" -# Begin Source File - -SOURCE=.\autoseed.h -# End Source File -# Begin Source File - -SOURCE=.\logging.h -# End Source File -# Begin Source File - -SOURCE=.\mapper.h -# End Source File -# Begin Source File - -SOURCE=..\modules\oceannames.h -# End Source File -# Begin Source File - -SOURCE=..\modules\score.h -# End Source File -# Begin Source File - -SOURCE=..\common\triggers\triggers.h -# End Source File -# Begin Source File - -SOURCE=..\modules\weather.h -# End Source File -# End Group -# Begin Source File - -SOURCE=.\autoseed.c -# End Source File -# Begin Source File - -SOURCE=.\logging.c -# End Source File -# Begin Source File - -SOURCE=.\map_modify.c -# End Source File -# Begin Source File - -SOURCE=.\map_partei.c -# End Source File -# Begin Source File - -SOURCE=.\map_region.c -# End Source File -# Begin Source File - -SOURCE=.\map_tools.c -# End Source File -# Begin Source File - -SOURCE=.\map_units.c -# End Source File -# Begin Source File - -SOURCE=.\mapper.c -# End Source File -# End Target -# End Project diff --git a/src/mapper/mapper.h b/src/mapper/mapper.h deleted file mode 100644 index b3d6cfe3a..000000000 --- a/src/mapper/mapper.h +++ /dev/null @@ -1,127 +0,0 @@ -/* vi: set ts=2: - * - * Eressea PB(E)M host Copyright (C) 1998-2003 - * Christian Schlittchen (corwin@amber.kn-bremen.de) - * Katja Zedel (katze@felidae.kn-bremen.de) - * Henning Peters (faroul@beyond.kn-bremen.de) - * Enno Rehling (enno@eressea-pbem.de) - * Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de) - * - * This program may not be used, modified or distributed without - * prior permission by the authors of Eressea. - */ - -#ifndef MAPPER_H -#define MAPPER_H - -#define INPUT_BUFSIZE 80 - -#include - -#ifndef ISLANDSIZE -# define ISLANDSIZE ((rand()%3)?(25+rand()%10):(11+rand()%14)) -#endif - -#ifndef NCURSES_CONST -#ifdef __PDCURSES__ -# define NCURSES_CONST -#else -# define NCURSES_CONST const -#endif -#endif - -struct race; - -typedef struct dbllist dbllist; -struct dbllist { - dbllist *next, *prev; - char s[1]; -}; - -typedef struct tagregion { - struct tagregion *next; - struct region *r; -} tagregion; - -extern tagregion *Tagged; - -extern const struct terrain_type * select_terrain(const struct terrain_type * default_terrain); - -void saddstr(char *s); -struct region *SeedPartei(void); -void Exit(int level); -int showunits(struct region * r); -void showregion(struct region * r, char full); -int modify_region(struct region * r); -void NeueBurg(struct region * r); -void NeuesSchiff(struct region * r); -void create_island(struct region *r, int n, const struct terrain_type * t); -void make_ocean_block(short x, short y); -void make_new_block(int x, int y); -void moveln(const int x); -char *my_input(WINDOW * win, int x, int y, const char *text, const char *def); -void make_new_region(short x, short y); -int map_input(WINDOW * win, int x, int y, const char *text, int mn, int mx, int pre); -boolean yes_no(WINDOW * win, const char *text, const char def); -void warnung(WINDOW * win, const char *text); -FILE *mapperFopen(const char *defName, const char *mode); -void adddbllist(dbllist ** S, const char *s); -void ScrollRegList(int dir); -void DisplayRegList(int neu); -void NeuePartei(struct region * r); -void RemovePartei(void); -int ParteiListe(void); -int koor_distance(int a, int b, int x, int y); -void SpecialFunction(struct region *r); - -extern WINDOW *mywin; -extern dbllist *reglist; -extern int MINX, MINY, MAXX, MAXY, pline; -extern dbllist *pointer; -extern char modified; -extern char *datadir; -extern struct unit *clipunit; -extern struct region *clipregion; -extern struct ship *clipship; -#define SX (stdscr->_maxx-1) -#define SY (stdscr->_maxy-1) - -#define NL(S) adddbllist(&S," ") - -#define wAddstr(x) waddnstr(win, (NCURSES_CONST char*)x,-1) -#define Addstr(x) waddnstr(mywin, (NCURSES_CONST char*)x,-1) -#define Movexy(x,y) wmove(mywin,y,x) -#define movexy(x,y) move(y,x) -/* move(zeile, spalte) ist "verkehrt"... */ - -extern WINDOW * openwin(int b, int h, const char* t); - -#define S_SIGWINCH 1 - -char *Unitid(struct unit * u); -char *Buildingid(struct building * b); -char *Shipid(struct ship * sh); -char *BuildingName(struct building * b); - -/* map_tools */ -typedef struct selection { - struct selection * next; - struct selection * prev; - int index; - char * str; - void * data; -} selection; - -struct selection * do_selection(struct selection * sel, const char * title, void (*perform)(struct selection *, void *), void * data); -struct selection ** push_selection(struct selection ** p_sel, char * str, void * payload); -void insert_selection(struct selection ** p_sel, struct selection * prev, const char * str, void * payload); -void block_create(short x1, short y1, int size, char chaotisch, int special, const terrain_type * terrain); - -extern void read_orders(const char * filename); -extern int numnewbies; - -#define sncat(b, s, size) strncat ((b), s, size - strlen (b)) - -extern struct newfaction * newfactions; - -#endif /* MAPPER_H */