2001-01-25 10:37:55 +01:00
|
|
|
|
/* vi: set ts=2:
|
|
|
|
|
*
|
2001-04-14 13:39:14 +02:00
|
|
|
|
*
|
2003-07-29 11:48:03 +02:00
|
|
|
|
* Eressea PB(E)M host Copyright (C) 1998-2003
|
2001-01-25 10:37:55 +01:00
|
|
|
|
* 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 <config.h>
|
|
|
|
|
#include <curses.h>
|
2001-09-05 21:40:40 +02:00
|
|
|
|
#include <ctype.h>
|
2001-01-25 10:37:55 +01:00
|
|
|
|
#include <eressea.h>
|
|
|
|
|
#include "mapper.h"
|
|
|
|
|
|
|
|
|
|
/* kernel includes */
|
2004-06-27 18:56:01 +02:00
|
|
|
|
#include <kernel/alliance.h>
|
|
|
|
|
#include <kernel/building.h>
|
|
|
|
|
#include <kernel/curse.h>
|
|
|
|
|
#include <kernel/faction.h>
|
|
|
|
|
#include <kernel/item.h>
|
|
|
|
|
#include <kernel/plane.h>
|
|
|
|
|
#include <kernel/race.h>
|
|
|
|
|
#include <kernel/region.h>
|
|
|
|
|
#include <kernel/resources.h>
|
|
|
|
|
#include <kernel/ship.h>
|
|
|
|
|
#include <kernel/unit.h>
|
2001-01-25 10:37:55 +01:00
|
|
|
|
|
2002-11-17 09:36:06 +01:00
|
|
|
|
/* modules includes */
|
|
|
|
|
|
2001-01-25 10:37:55 +01:00
|
|
|
|
/* util includes */
|
|
|
|
|
#include <base36.h>
|
|
|
|
|
|
|
|
|
|
/* libc includes */
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
void
|
2001-12-10 01:13:39 +01:00
|
|
|
|
incat(char *buf, const int n, const size_t bufsize)
|
2001-01-25 10:37:55 +01:00
|
|
|
|
{
|
2001-12-10 01:13:39 +01:00
|
|
|
|
char s[10];
|
|
|
|
|
snprintf(s, 9, "%d", n);
|
|
|
|
|
sncat(buf, s, bufsize);
|
2001-01-25 10:37:55 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int rbottom;
|
|
|
|
|
dbllist *reglist = NULL;
|
|
|
|
|
static dbllist *runten = NULL, *roben = NULL;
|
2002-03-17 13:31:54 +01:00
|
|
|
|
#define LASTLINE SY-3
|
2001-01-25 10:37:55 +01:00
|
|
|
|
/* Letzte Zeile, in der Regionsinfo bei der Karte kommt */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2001-02-03 14:45:35 +01:00
|
|
|
|
ClearRegion(void)
|
2001-01-25 10:37:55 +01:00
|
|
|
|
{
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
2001-09-05 21:40:40 +02:00
|
|
|
|
void
|
|
|
|
|
SpecialFunction(region *r)
|
|
|
|
|
{
|
|
|
|
|
WINDOW *win;
|
|
|
|
|
|
|
|
|
|
win = openwin(60, 5, "< Specials Regions >");
|
|
|
|
|
wmove(win, 1, 2);
|
2002-02-23 11:34:55 +01:00
|
|
|
|
wAddstr("1 - set Godcurse (n.imm), 2 - set Peace-Curse (imm)");
|
2001-09-05 21:40:40 +02:00
|
|
|
|
wmove(win, 2, 2);
|
|
|
|
|
wrefresh(win);
|
|
|
|
|
switch(getch()) {
|
|
|
|
|
case '1':
|
2002-05-01 22:06:32 +02:00
|
|
|
|
if (get_curse(r->attribs, ct_find("godcursezone"))==NULL) {
|
|
|
|
|
curse * c = create_curse(NULL, &r->attribs, ct_find("godcursezone"),
|
2001-09-05 21:40:40 +02:00
|
|
|
|
100, 100, 0, 0);
|
2002-05-01 22:06:32 +02:00
|
|
|
|
curse_setflag(c, CURSE_ISNEW|CURSE_IMMUNE);
|
2001-09-05 21:40:40 +02:00
|
|
|
|
modified = 1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2002-02-23 11:34:55 +01:00
|
|
|
|
case '2':
|
2002-05-01 22:06:32 +02:00
|
|
|
|
if(!is_cursed_internal(r->attribs, ct_find("peacezone"))) {
|
|
|
|
|
curse * c = create_curse(NULL, &r->attribs, ct_find("peacezone"), 100, 2, 0, 0);
|
|
|
|
|
curse_setflag(c, CURSE_IMMUNE);
|
2002-02-23 11:34:55 +01:00
|
|
|
|
modified = 1;
|
|
|
|
|
}
|
2001-09-05 21:40:40 +02:00
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
delwin(win);
|
|
|
|
|
}
|
|
|
|
|
|
2001-01-25 10:37:55 +01:00
|
|
|
|
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];
|
2001-12-15 13:26:04 +01:00
|
|
|
|
#if NEW_RESOURCEGROWTH
|
2001-12-10 01:13:39 +01:00
|
|
|
|
int iron = -1, ironlevel = -1,
|
|
|
|
|
laen = -1, laenlevel = -1,
|
|
|
|
|
stone = -1, stonelevel = -1;
|
|
|
|
|
struct rawmaterial *res;
|
|
|
|
|
#endif
|
2001-01-25 10:37:55 +01:00
|
|
|
|
|
|
|
|
|
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,'<EFBFBD>',strlen(buf)+1);
|
|
|
|
|
str[strlen(buf)+1] = 0;
|
|
|
|
|
adddbllist(®list, str);
|
|
|
|
|
|
2003-07-29 12:04:55 +02:00
|
|
|
|
sprintf(buf, " %hd turns old:", r->age);
|
|
|
|
|
adddbllist(®list, buf);
|
2001-01-25 10:37:55 +01:00
|
|
|
|
if (r->terrain != T_OCEAN && r->terrain!=T_FIREWALL) {
|
2001-12-10 01:13:39 +01:00
|
|
|
|
sprintf(buf, " %d peasants, %d(%d) silver", rpeasants(r), rmoney(r), count_all_money(r));
|
2001-01-25 10:37:55 +01:00
|
|
|
|
adddbllist(®list, buf);
|
2001-12-15 13:26:04 +01:00
|
|
|
|
#if GROWING_TREES
|
2001-12-10 01:13:39 +01:00
|
|
|
|
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);
|
|
|
|
|
#else
|
2001-01-25 10:37:55 +01:00
|
|
|
|
sprintf(buf, " %d Pferde, %d ", rhorses(r), rtrees(r));
|
|
|
|
|
if (fval(r,RF_MALLORN))
|
2001-12-10 01:13:39 +01:00
|
|
|
|
sncat(buf, "mallorn", BUFSIZE);
|
2001-01-25 10:37:55 +01:00
|
|
|
|
else
|
2001-12-10 01:13:39 +01:00
|
|
|
|
sncat(buf, "trees", BUFSIZE);
|
|
|
|
|
#endif
|
2001-01-25 10:37:55 +01:00
|
|
|
|
adddbllist(®list, buf);
|
|
|
|
|
|
2001-12-15 13:26:04 +01:00
|
|
|
|
#if NEW_RESOURCEGROWTH
|
2001-12-10 01:13:39 +01:00
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
#else
|
2001-09-05 21:40:40 +02:00
|
|
|
|
if (riron(r) > 0 || rlaen(r) > 0) {
|
2001-01-25 10:37:55 +01:00
|
|
|
|
sprintf(buf, " %d Eisen, %d Laen", riron(r), rlaen(r));
|
|
|
|
|
adddbllist(®list, buf);
|
|
|
|
|
}
|
2001-12-10 01:13:39 +01:00
|
|
|
|
#endif
|
2001-01-25 10:37:55 +01:00
|
|
|
|
}
|
|
|
|
|
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 (r->terrain != T_OCEAN) {
|
2001-12-10 01:13:39 +01:00
|
|
|
|
strcpy(buf, "buildings:");
|
2001-01-25 10:37:55 +01:00
|
|
|
|
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)
|
2003-07-29 11:48:03 +02:00
|
|
|
|
if (u->building == b && fval(u, UFL_OWNER)) {
|
2001-01-25 10:37:55 +01:00
|
|
|
|
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++;
|
2001-12-10 01:13:39 +01:00
|
|
|
|
sncat(buf, " ", BUFSIZE);
|
|
|
|
|
incat(buf, d, BUFSIZE);
|
2001-01-25 10:37:55 +01:00
|
|
|
|
adddbllist(®list, buf);
|
|
|
|
|
}
|
|
|
|
|
NL(reglist);
|
|
|
|
|
}
|
2001-12-10 01:13:39 +01:00
|
|
|
|
strcpy(buf, "ships:");
|
2001-01-25 10:37:55 +01:00
|
|
|
|
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)
|
2003-07-29 11:48:03 +02:00
|
|
|
|
if (u->ship == sh && fval(u, UFL_OWNER)) {
|
2001-01-25 10:37:55 +01:00
|
|
|
|
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++;
|
2001-12-10 01:13:39 +01:00
|
|
|
|
sncat(buf, " ", BUFSIZE);
|
|
|
|
|
incat(buf, d, BUFSIZE);
|
2001-01-25 10:37:55 +01:00
|
|
|
|
adddbllist(®list, buf);
|
|
|
|
|
}
|
|
|
|
|
NL(reglist);
|
|
|
|
|
|
|
|
|
|
if (!factions)
|
|
|
|
|
return;
|
|
|
|
|
|
2001-12-10 01:13:39 +01:00
|
|
|
|
strcpy(buf, "factions:");
|
2001-01-25 10:37:55 +01:00
|
|
|
|
|
|
|
|
|
if (!r->units) {
|
|
|
|
|
sncat(buf, " keine", BUFSIZE);
|
|
|
|
|
adddbllist(®list, buf);
|
|
|
|
|
} else {
|
|
|
|
|
adddbllist(®list, buf);
|
|
|
|
|
|
|
|
|
|
for (f = factions; f; f = f->next)
|
2002-03-31 10:46:36 +02:00
|
|
|
|
f->num_people = f->no_units = 0;
|
2001-01-25 10:37:55 +01:00
|
|
|
|
for (u = r->units; u; u = u->next) {
|
|
|
|
|
if (u->faction) {
|
2002-03-31 10:46:36 +02:00
|
|
|
|
u->faction->no_units++;
|
2001-01-25 10:37:55 +01:00
|
|
|
|
u->faction->num_people += u->number;
|
|
|
|
|
} else
|
|
|
|
|
fprintf(stderr,"Unit %s hat keine faction!\n",unitid(u));
|
|
|
|
|
}
|
|
|
|
|
for (f = factions; f; f = f->next)
|
2002-03-31 10:46:36 +02:00
|
|
|
|
if (f->no_units) {
|
2004-06-27 18:56:01 +02:00
|
|
|
|
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));
|
|
|
|
|
}
|
2001-01-25 10:37:55 +01:00
|
|
|
|
adddbllist(®list, buf);
|
|
|
|
|
sprintf(buf, " Einheiten: %d; Leute: %d %c",
|
2002-03-31 10:46:36 +02:00
|
|
|
|
f->no_units, f->num_people, Tchar[old_race(f->race)]);
|
2001-01-25 10:37:55 +01:00
|
|
|
|
adddbllist(®list, buf);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (d = RC_UNDEAD; d < MAXRACES; d++)
|
|
|
|
|
ecount[d] = count[d] = 0;
|
|
|
|
|
for (u = r->units; u; u = u->next) {
|
2001-12-10 01:13:39 +01:00
|
|
|
|
if (u->race >= new_race[RC_UNDEAD])
|
2001-01-25 10:37:55 +01:00
|
|
|
|
pp=1;
|
2001-12-10 01:13:39 +01:00
|
|
|
|
ecount[old_race(u->race)]++;
|
|
|
|
|
count[old_race(u->race)] += u->number;
|
2001-01-25 10:37:55 +01:00
|
|
|
|
}
|
|
|
|
|
if (pp) {
|
|
|
|
|
NL(reglist);
|
|
|
|
|
adddbllist(®list, "Monster, Zauber usw.:");
|
|
|
|
|
for (d = RC_UNDEAD; d < MAXRACES; d++) {
|
|
|
|
|
if (count[d]) {
|
2001-12-10 01:13:39 +01:00
|
|
|
|
sprintf(buf, " %s: %d in %d", new_race[d]->_name[0], count[d], ecount[d]);
|
2001-01-25 10:37:55 +01:00
|
|
|
|
adddbllist(®list, buf);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
NL(reglist);
|
|
|
|
|
}
|