- Mapper, Neue-Einheiten-Dialog verbessert.

- Eine Menge 'shadows local variable'-Warnings beseitigt.
This commit is contained in:
Christian Schlittchen 2001-02-09 13:53:53 +00:00
parent 777977b975
commit c04678f0d1
20 changed files with 198 additions and 169 deletions

View File

@ -19,7 +19,7 @@ ARFLAGS = cr
CTAGSFLAGS = --langmap=c:.c.h --c-types=-m
CFLAGS = -I$(ERESSEA) -Wall -Wwrite-strings -Wstrict-prototypes \
-Wpointer-arith -Werror-implicit-function-declaration \
-Wno-char-subscripts \
-Wno-char-subscripts -Wshadow \
-march=pentiumpro -fPIC $(INCLUDES)
LDFLAGS = $(LIBS)

View File

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: alchemy.c,v 1.3 2001/02/03 13:45:30 enno Exp $
* $Id: alchemy.c,v 1.4 2001/02/09 13:53:51 corwin Exp $
* Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de)
@ -220,8 +220,8 @@ set_effect (unit * u, const potion_type * effect, int value)
a=a->nexttype;
}
if (!a && value) {
attrib * a = a_add(ap, a_new(&at_effect));
data = (effect_data*)a->data.v;
attrib * an = a_add(ap, a_new(&at_effect));
data = (effect_data*)an->data.v;
data->type = effect;
data->value = value;
} else if (a && !value) {
@ -252,8 +252,8 @@ change_effect (unit * u, const potion_type * effect, int delta)
} else if (a!=NULL) {
data->value += delta;
} else {
attrib * a = a_add(ap, a_new(&at_effect));
data = (effect_data*)a->data.v;
attrib * an = a_add(ap, a_new(&at_effect));
data = (effect_data*)an->data.v;
data->type = effect;
data->value = delta;
}

View File

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: battle.c,v 1.6 2001/02/05 16:11:57 enno Exp $
* $Id: battle.c,v 1.7 2001/02/09 13:53:51 corwin Exp $
* Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de)
@ -627,7 +627,7 @@ weapon_effskill(troop t, troop enemy, const weapon * w, boolean attacking, boole
}
if (wtype->modifiers) {
/* Pferdebonus, Lanzenbonus, usw. */
int w;
int m;
unsigned int flags = WMF_SKILL|(attacking?WMF_OFFENSIVE:WMF_DEFENSIVE);
if (riding(t)) flags |= WMF_RIDING;
@ -635,9 +635,9 @@ weapon_effskill(troop t, troop enemy, const weapon * w, boolean attacking, boole
if (riding(enemy)) flags |= WMF_AGAINST_RIDING;
else flags |= WMF_AGAINST_WALKING;
for (w=0;wtype->modifiers[w].value;++w) {
if ((wtype->modifiers[w].flags & flags) == flags) {
skill += wtype->modifiers[w].value;
for (m=0;wtype->modifiers[m].value;++m) {
if ((wtype->modifiers[m].flags & flags) == flags) {
skill += wtype->modifiers[m].value;
}
}
}
@ -2832,19 +2832,20 @@ make_fighter(battle * b, unit * u, boolean attack)
#if TACTICS_RANDOM
if (t > 0) {
int bonus = 0;
int r;
for (i = 0; i < fig->alive; i++) {
int p_bonus = 0;
int rnd;
do {
r = rand()%100;
if (r >= 40 && r <= 69)
rnd = rand()%100;
if (rnd >= 40 && rnd <= 69)
p_bonus += 1;
else if (r <= 89)
else if (rnd <= 89)
p_bonus += 2;
else
p_bonus += 3;
} while(r >= 97);
} while(rnd >= 97);
bonus = max(p_bonus, bonus);
}
t += bonus;
@ -3196,54 +3197,54 @@ do_battle(void)
for (u = r->units; u != NULL; u = u->next) {
if (fval(u, FL_HADBATTLE)) continue;
if (u->number > 0) {
strlist *s;
strlist *sl;
list_foreach(strlist, u->orders, s) {
if (igetkeyword(s->s) == K_ATTACK) {
list_foreach(strlist, u->orders, sl) {
if (igetkeyword(sl->s) == K_ATTACK) {
unit *u2;
fighter *c1, *c2;
if(r->planep && fval(r->planep, PFL_NOATTACK)) {
cmistake(u, s->s, 271, MSG_BATTLE);
list_continue(s);
cmistake(u, sl->s, 271, MSG_BATTLE);
list_continue(sl);
}
/* Fehlerbehandlung Angreifer */
if (is_spell_active(r, C_PEACE)) {
sprintf(buf, "Hier ist es so schön friedlich, %s möchte "
"hier niemanden angreifen.", unitname(u));
mistake(u, s->s, buf, MSG_BATTLE);
list_continue(s);
mistake(u, sl->s, buf, MSG_BATTLE);
list_continue(sl);
}
if (fval(u, FL_HUNGER)) {
cmistake(u, s->s, 225, MSG_BATTLE);
list_continue(s);
cmistake(u, sl->s, 225, MSG_BATTLE);
list_continue(sl);
}
if (u->status == ST_AVOID || u->status == ST_FLEE) {
cmistake(u, s->s, 226, MSG_BATTLE);
list_continue(s);
cmistake(u, sl->s, 226, MSG_BATTLE);
list_continue(sl);
}
/* ist ein Flüchtling aus einem andern Kampf */
if (fval(u, FL_MOVED)) list_continue(s);
if (fval(u, FL_MOVED)) list_continue(sl);
if (is_cursed(u->attribs, C_SLAVE, 0)) {
sprintf(buf, "%s kämpft nicht.", unitname(u));
mistake(u, s->s, buf, MSG_BATTLE);
list_continue(s);
mistake(u, sl->s, buf, MSG_BATTLE);
list_continue(sl);
}
/* Fehler: "Das Schiff muß erst verlassen werden" */
if (u->ship != NULL && rterrain(r) != T_OCEAN) {
cmistake(u, s->s, 19, MSG_BATTLE);
list_continue(s);
cmistake(u, sl->s, 19, MSG_BATTLE);
list_continue(sl);
}
if (leftship(u)) {
cmistake(u, s->s, 234, MSG_BATTLE);
list_continue(s);
cmistake(u, sl->s, 234, MSG_BATTLE);
list_continue(sl);
}
/* Ende Fehlerbehandlung Angreifer */
@ -3255,36 +3256,36 @@ do_battle(void)
/* Fehler: "Die Einheit wurde nicht gefunden" */
if (!u2 || fval(u2, FL_MOVED) || u2->number == 0
|| !cansee(u->faction, u->region, u2, 0)) {
cmistake(u, s->s, 64, MSG_BATTLE);
list_continue(s);
cmistake(u, sl->s, 64, MSG_BATTLE);
list_continue(sl);
}
/* Fehler: "Die Einheit ist eine der unsrigen" */
if (u2->faction == u->faction) {
cmistake(u, s->s, 45, MSG_BATTLE);
list_continue(s);
cmistake(u, sl->s, 45, MSG_BATTLE);
list_continue(sl);
}
/* Fehler: "Die Einheit ist mit uns alliert" */
if (allied(u, u2->faction, HELP_FIGHT)) {
cmistake(u, s->s, 47, MSG_BATTLE);
list_continue(s);
cmistake(u, sl->s, 47, MSG_BATTLE);
list_continue(sl);
}
/* xmas */
if (u2->no==atoi36("xmas") && u2->irace==RC_GNOME) {
a_add(&u->attribs, a_new(&at_key))->data.i = atoi36("coal");
sprintf(buf, "%s ist böse gewesen...", unitname(u));
mistake(u, s->s, buf, MSG_BATTLE);
list_continue(s);
mistake(u, sl->s, buf, MSG_BATTLE);
list_continue(sl);
}if (u2->faction->age < IMMUN_GEGEN_ANGRIFF) {
sprintf(buf, "Eine Partei muß mindestens %d "
"Wochen alt sein, bevor sie angegriffen werden kann",
IMMUN_GEGEN_ANGRIFF);
mistake(u, s->s, buf, MSG_BATTLE);
list_continue(s);
mistake(u, sl->s, buf, MSG_BATTLE);
list_continue(sl);
}
/* Fehler: "Die Einheit ist mit uns alliert" */
if (is_cursed(u->attribs, C_CALM, u2->faction->unique_id)) {
cmistake(u, s->s, 47, MSG_BATTLE);
list_continue(s);
cmistake(u, sl->s, 47, MSG_BATTLE);
list_continue(sl);
}
/* Ende Fehlerbehandlung */
@ -3315,7 +3316,7 @@ do_battle(void)
}
}
}
list_next(s);
list_next(sl);
}
}
if (!b)

View File

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: build.c,v 1.6 2001/02/04 10:04:51 enno Exp $
* $Id: build.c,v 1.7 2001/02/09 13:53:51 corwin Exp $
* Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de)
@ -288,7 +288,6 @@ destroy(region * r, unit * u, const char * cmd)
return;
if (getparam()==P_ROAD) {
direction_t d = getdirection();
unit * u2;
for (u2=r->units;u2;u2=u2->next) {
if (u2->faction!=u->faction && getguard(u2)&GUARD_TAX &&
!allied(u, u2->faction, HELP_GUARD)) {

View File

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: building.c,v 1.5 2001/02/03 18:46:15 enno Exp $
* $Id: building.c,v 1.6 2001/02/09 13:53:51 corwin Exp $
* Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de)
@ -827,17 +827,17 @@ bt_read(FILE * F)
if (!strcmp(semi, "name") && !bt->_name) bt->_name = strdup(s);
}
else {
int i = atoi(buf);
int j = atoi(buf);
switch (semi[0]) {
case 'c':
if (!strcmp(semi, "capacity")) bt->capacity=i;
if (!strcmp(semi, "capacity")) bt->capacity=j;
break;
case 'f':
if (!strcmp(semi, "flags")) bt->flags=i;
if (!strcmp(semi, "flags")) bt->flags=j;
break;
case 'm':
if (!strcmp(semi, "maxcapacity")) bt->maxcapacity=i;
else if (!strcmp(semi, "maxsize")) bt->maxsize=i;
if (!strcmp(semi, "maxcapacity")) bt->maxcapacity=j;
else if (!strcmp(semi, "maxsize")) bt->maxsize=j;
break;
}
}

View File

@ -1032,7 +1032,7 @@ sp_tiredsoldiers(fighter * fi, int level, int force, spell * sp)
unit *mage = fi->unit;
int n = 0;
force = force * force * 10;
force = force * force * 4;
sprintf(buf, "%s zaubert %s", unitname(mage), sp->name);
if (!count_enemies(fi->side, FS_ENEMY, FIGHT_ROW,

View File

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: magic.c,v 1.5 2001/02/04 18:50:59 corwin Exp $
* $Id: magic.c,v 1.6 2001/02/09 13:53:51 corwin Exp $
* Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de)
@ -2436,8 +2436,8 @@ set_familiar(unit * mage, unit * familiar)
a = a->nexttype;
}
if (a==NULL) {
attrib * a = a_add(&mage->attribs, a_new(&at_skillmod));
skillmod_data * smd = (skillmod_data *)a->data.v;
attrib * an = a_add(&mage->attribs, a_new(&at_skillmod));
skillmod_data * smd = (skillmod_data *)an->data.v;
smd->special = sm_familiar;
smd->skill=NOSKILL;
}

View File

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: message.c,v 1.2 2001/01/26 16:19:40 enno Exp $
* $Id: message.c,v 1.3 2001/02/09 13:53:51 corwin Exp $
* Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de)
@ -179,11 +179,11 @@ xmistake(const unit * u, const char *s, const char *comment, int mtype)
void
cmistake(const unit * u, const char *cmd, int mno, int mtype)
{
static char buf[64];
static char lbuf[64];
if (u->faction->no == MONSTER_FACTION) return;
sprintf(buf, "error%d", mno);
strcat(buf, "%s:command%i:errno%u:unit%r:region");
add_message(&u->faction->msgs, new_message(u->faction, buf, cmd, mno, u, u->region));
sprintf(lbuf, "error%d", mno);
strcat(lbuf, "%s:command%i:errno%u:unit%r:region");
add_message(&u->faction->msgs, new_message(u->faction, lbuf, cmd, mno, u, u->region));
}
void
@ -205,10 +205,11 @@ new_messagetype(const char * name, int level, const char * section)
mt->hashkey = hashstring(mt->name);
#ifndef NDEBUG
{
messagetype * mt = messagetypes;
while(mt && strcmp(mt->name, name)) mt = mt->next;
if (mt) {
fprintf(stderr, "duplicate hashkey for messagetype %s and %s", name, mt->name);
messagetype * mt2 = messagetypes;
while(mt2 && mt2->hashkey != mt->hashkey) mt2 = mt2->next;
if (mt2) {
fprintf(stderr, "duplicate hashkey for messagetype %s and %s\n",
name, mt2->name);
}
}
#endif

View File

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: movement.c,v 1.7 2001/02/07 20:42:31 corwin Exp $
* $Id: movement.c,v 1.8 2001/02/09 13:53:51 corwin Exp $
* Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de)
@ -576,16 +576,16 @@ drifting_ships(region * r)
char *
coords_or_direction(region *r, faction *f, int dir)
{
static char buf[32];
static char lbuf[32];
plane *pl = getplane(r);
if(fval(pl, PFL_NOCOORDS)) {
strcpy(buf, directions[dir]);
strcpy(lbuf, directions[dir]);
} else {
sprintf(buf, "(%d,%d)",region_x(r,f), region_y(r,f));
sprintf(lbuf, "(%d,%d)",region_x(r,f), region_y(r,f));
}
return buf;
return lbuf;
}
void
@ -941,22 +941,22 @@ travel(region * first, unit * u, region * next, int flucht)
break;
default:
{
int m = 1;
int mp = 1;
if (get_effect(u, oldpotiontype[P_FAST]) >= u->number)
m *= 2; /* Siebenmeilentee */
mp *= 2; /* Siebenmeilentee */
if (u->number <= get_item(u, I_FEENSTIEFEL))
m *= 2;
mp *= 2;
/* Im Astralraum sind Tyb und Ill-Magier doppelt so schnell.
* Nicht kumulativ mit anderen Beschleunigungen! */
if ( m == 1 && getplane(next) == astral_plane && is_mage(u)) {
if ( mp == 1 && getplane(next) == astral_plane && is_mage(u)) {
if(get_mage(u)->magietyp == M_ASTRAL
|| get_mage(u)->magietyp == M_TRAUM) {
m *= 2;
mp *= 2;
}
}
k = (int)(dk*m*BP_WALKING);
k = (int)(dk*mp*BP_WALKING);
}
break;
}
@ -986,10 +986,10 @@ travel(region * first, unit * u, region * next, int flucht)
if (b->type==&bt_wisps) {
region * rl = rconnect(current, (direction_t)((dir+MAXDIRECTIONS-1)%MAXDIRECTIONS));
region * rr = rconnect(current, (direction_t)((dir+1)%MAXDIRECTIONS));
int i = rand() % 3;
if (i==0) break;
else if (i==1 && rl && landregion(rterrain(rl))==landregion(rterrain(next))) next = rl;
else if (i==2 && rr && landregion(rterrain(rr))==landregion(rterrain(next))) next = rr;
int j = rand() % 3;
if (j==0) break;
else if (j==1 && rl && landregion(rterrain(rl))==landregion(rterrain(next))) next = rl;
else if (j==2 && rr && landregion(rterrain(rr))==landregion(rterrain(next))) next = rr;
break;
}
b = b->next;

View File

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: pool.c,v 1.2 2001/01/26 16:19:40 enno Exp $
* $Id: pool.c,v 1.3 2001/02/09 13:53:51 corwin Exp $
* Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de)
@ -330,9 +330,9 @@ change_resource(unit * u, resource_t res, int change)
}
#ifdef NEW_ITEMS
else if (itype!=NULL) {
item * i = i_change(&u->items, itype, change);
if (i==NULL) return 0;
return i->number;
item * it = i_change(&u->items, itype, change);
if (it==NULL) return 0;
return it->number;
}
#else
else if (is_item(res))

View File

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: reports.c,v 1.3 2001/01/31 07:59:42 enno Exp $
* $Id: reports.c,v 1.4 2001/02/09 13:53:52 corwin Exp $
* Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de)
@ -244,10 +244,10 @@ bufunit(const faction * f, const unit * u, int indent,
if (u->faction==f || telepath_see) {
attrib * a = a_find(u->attribs, &at_follow);
if (a) {
unit * u = (unit*)a->data.v;
if (u) {
unit * uf = (unit*)a->data.v;
if (uf) {
scat(", folgt ");
scat(itoa36(u->no));
scat(itoa36(uf->no));
}
}
}

View File

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: base36.c,v 1.2 2001/01/26 16:19:41 enno Exp $
* $Id: base36.c,v 1.3 2001/02/09 13:53:52 corwin Exp $
* Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de)
@ -60,10 +60,10 @@ itoab(int i, int base)
int neg = 0;
if (!as) {
int i;
int j;
char * x = calloc(sizeof(char), 8*4);
as = calloc(sizeof(char*), 4);
for (i=0;i!=4;++i) as[i] = x+i*8;
for (j=0;j!=4;++j) as[j] = x+j*8;
}
s = as[index];
index = (index+1) % 4;

View File

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: goodies.c,v 1.2 2001/01/26 16:19:41 enno Exp $
* $Id: goodies.c,v 1.3 2001/02/09 13:53:52 corwin Exp $
* Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de)
@ -70,6 +70,22 @@ hashstring(const char* s)
return key & 0x7fff;
}
/* Standardfunktion aus Sedgewick: Algorithmen in C++ */
#define HASH_MAX 100001
int
hashstring_new(const char* s)
{
int key = 0;
int i = strlen(s);
while (i) {
--i;
key = (256 * key + s[i])%HASH_MAX;
}
return key /* & 0x7fffffff */;
}
char *
escape_string(char * str, char replace)
{

View File

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: korrektur.c,v 1.14 2001/02/04 11:18:27 corwin Exp $
* $Id: korrektur.c,v 1.15 2001/02/09 13:53:53 corwin Exp $
* Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de)
@ -1786,7 +1786,6 @@ fix_targetregion_resolve(void)
}
}
#include <modules/gmcmd.h>
void setup_gm_faction(void);

View File

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: map_modify.c,v 1.3 2001/02/03 13:45:34 enno Exp $
* $Id: map_modify.c,v 1.4 2001/02/09 13:53:53 corwin Exp $
* Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de)
@ -492,7 +492,7 @@ NeuesSchiff(region * r)
/* Ist das richtig so, Henning? */
addlist(&r->ships, s);
strcpy(buf, my_input(win, 2, 2, "Name: "));
strcpy(buf, my_input(win, 2, 2, "Name: ", NULL));
if (strlen(buf) > 0)
set_string(&s->name, buf);
if (clipunit) {
@ -555,7 +555,7 @@ NeueBurg(region * r)
b->size = map_input(win, 2, 2, "Größe", 1, 999, 1);
strcpy(buf, my_input(win, 2, 3, "Name: "));
strcpy(buf, my_input(win, 2, 3, "Name: ", NULL));
if (strlen(buf) > 0)
set_string(&b->name, buf);
if (clipunit) {
@ -722,7 +722,7 @@ modify_region(region * r)
bottom = line - 1;
break;
case '/':
suchtext = my_input(0, 0, 0, (char*)"Suchtext: ");
suchtext = my_input(0, 0, 0, (char*)"Suchtext: ", NULL);
such = eh;
case 'n':
line = 0;

View File

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: map_partei.c,v 1.3 2001/02/03 13:45:34 enno Exp $
* $Id: map_partei.c,v 1.4 2001/02/09 13:53:53 corwin Exp $
* Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de)
@ -46,7 +46,7 @@ RemovePartei(void) {
region *r;
win = openwin(SX - 20, 5, "< Partei löschen >");
fac_nr36 = my_input(win, 2, 1, "Partei Nummer: ");
fac_nr36 = my_input(win, 2, 1, "Partei Nummer: ", NULL);
x = atoi36(fac_nr36);
@ -361,7 +361,7 @@ NeuePartei(region * r)
}
win = openwin(SX - 10, 9, "< Neue Partei einfügen >");
strcpy(buf, my_input(win, 2, 1, "EMail-Adresse (Leer->Ende): "));
strcpy(buf, my_input(win, 2, 1, "EMail-Adresse (Leer->Ende): ", NULL));
if (!buf[0]) {
delwin(win);
return;
@ -507,7 +507,7 @@ ModifyPartei(faction * f)
wrefresh(win);
break;
case 'e':
strcpy(buf, my_input(0, 0, 0, "Neue eMail: "));
strcpy(buf, my_input(0, 0, 0, "Neue eMail: ", NULL));
touchwin(stdscr);
touchwin(win);
if (strlen(buf)) {
@ -675,7 +675,7 @@ ParteiListe(void)
x = -1;
break;
case '/':
strcpy(buf, my_input(0, 0, 0, "Partei Nr. oder Name: "));
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;

View File

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: map_tools.c,v 1.3 2001/02/03 13:45:34 enno Exp $
* $Id: map_tools.c,v 1.4 2001/02/09 13:53:53 corwin Exp $
* Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de)
@ -186,23 +186,34 @@ yes_no(WINDOW * win, const char *text, const char def)
}
char *
my_input(WINDOW * win, int x, int y, const char *text)
my_input(WINDOW * win, int x, int y, const char *text, const char *def)
{
static char buf[INPUT_BUFSIZE+1];
static char lbuf[INPUT_BUFSIZE+1];
int val, ch, p, nw = 0;
if (!win) {
win = openwin(SX - 10, 3, 0);
y = nw = 1;
x = 2;
}
wmove(win, y, x);
wAddstr(text);
wmove(win, y, x + strlen(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);
p = strlen(text) + x;
val = 0;
do {
ch = getch();
if (ch == KEY_BACKSPACE || ch == KEY_LEFT) {
@ -221,7 +232,7 @@ my_input(WINDOW * win, int x, int y, const char *text)
beep();
} else if (isprint(ch)) {
waddch(win, ch);
buf[val] = (char) ch;
lbuf[val] = (char) ch;
val++;
} else
beep();
@ -230,8 +241,8 @@ my_input(WINDOW * win, int x, int y, const char *text)
if (nw)
delwin(win);
curs_set(0);
buf[val] = 0;
return buf;
lbuf[val] = 0;
return lbuf;
}
void

View File

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: map_units.c,v 1.2 2001/01/26 16:19:41 enno Exp $
* $Id: map_units.c,v 1.3 2001/02/09 13:53:53 corwin Exp $
* Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de)
@ -31,6 +31,7 @@
#include <ship.h>
#include <skill.h>
#include <unit.h>
#include <base36.h>
/* libc includes */
#include <ctype.h>
@ -47,20 +48,22 @@ make_new_unit(region * r)
unit *u;
faction *f;
WINDOW *win;
char *fac_nr36;
int i, p, anz, q, y;
win = openwin(SX - 10, 8, "< Neue Einheit erschaffen >");
if (r->units)
p = r->units->faction->no;
else
p = 0;
do {
if (r->units)
p = r->units->faction->no;
else
p = 0;
p = map_input(win, 2, 1, "Parteinummer", -1, 999, p);
if (p < 0) {
fac_nr36 = my_input(win, 2, 1, "Parteinummer: ", itoa36(p));
if(fac_nr36 == NULL || *fac_nr36 == 0) {
delwin(win);
return 0;
}
f = findfaction(p);
f = findfaction(atoi36(fac_nr36));
} while (!f);
wmove(win, 1, 2);
wclrtoeol(win);
@ -102,7 +105,7 @@ make_new_unit(region * r)
}
buf[0] = 0;
strcpy(buf, my_input(win, 2, 4, "Name: "));
strcpy(buf, my_input(win, 2, 4, "Name: ", NULL));
if (buf[0])
set_string(&u->name, buf);
if (!strlen(u->name))
@ -730,7 +733,7 @@ dblparagraph(dbllist ** SP, char *s, int indent, char mark)
{
int i, j, width, delta = 0;
int firstline;
static char buf[128];
static char lbuf[128];
width = SX - 5 - indent;
firstline = 1;
@ -753,7 +756,7 @@ dblparagraph(dbllist ** SP, char *s, int indent, char mark)
j = 0;
if (firstline) {
if (*s == '\025') { /* \023 ist ^U => Unit-Kennung */
buf[0] = '\025'; /* Kennung nach vorne
lbuf[0] = '\025'; /* Kennung nach vorne
* holen */
delta = 1;
}
@ -761,16 +764,16 @@ dblparagraph(dbllist ** SP, char *s, int indent, char mark)
delta = 0;
for (j = 0; j != indent; j++)
buf[j + delta] = ' ';
lbuf[j + delta] = ' ';
if (firstline && mark)
buf[indent - 2 + delta] = mark;
lbuf[indent - 2 + delta] = mark;
for (j = 0; j != i - 1; j++)
buf[indent + j + delta] = s[j + delta];
buf[indent + j + delta] = 0;
lbuf[indent + j + delta] = s[j + delta];
lbuf[indent + j + delta] = 0;
adddbllist(SP, buf);
adddbllist(SP, lbuf);
if (!s[i - 1 + delta])
break;
@ -849,17 +852,16 @@ mapper_spunit(dbllist ** SP, unit * u, int indent)
dh = 0;
for (itm = u->items;itm;itm=itm->next) {
int i = itm->number;
sncat(buf, ", ", BUFSIZE);
if (!dh) {
sncat(buf, "hat: ", BUFSIZE);
dh = 1;
}
if (i == 1)
if (itm->number == 1)
sncat(buf, locale_string(NULL, resourcename(itm->type->rtype, 0)), BUFSIZE);
else {
icat(i);
icat(itm->number);
sncat(buf, " ", BUFSIZE);
sncat(buf, locale_string(NULL, resourcename(itm->type->rtype, GR_PLURAL)), BUFSIZE);
}
@ -910,7 +912,7 @@ showunits(region * r)
dbllist *eh = NULL, *unten, *oben, *hlp = NULL, *such = NULL, *tmp;
int line, ch, bottom, bot, f, f2;
size_t lt;
char *s = NULL, *txt, *suchtext = 0, str[45], buf[256];
char *s = NULL, *txt, *suchtext = 0, str[45], lbuf[256];
clear();
strncpy(str, rname(r, NULL), 44);
@ -923,16 +925,16 @@ showunits(region * r)
for (b = r->buildings; b; b = b->next) {
if (b->type == &bt_castle) {
sprintf(buf, "\002%s, Größe %d, %s", buildingname(b), b->size, buildingtype(b, b->size, NULL));
sprintf(lbuf, "\002%s, Größe %d, %s", buildingname(b), b->size, buildingtype(b, b->size, NULL));
} else {
sprintf(buf, "\002%s, Größe %d, %s", buildingname(b),
sprintf(lbuf, "\002%s, Größe %d, %s", buildingname(b),
b->size, buildingtype(b, b->size, NULL));
if (b->type->maxsize > 0 &&
b->size < b->type->maxsize) {
sncat(buf, " (im Bau)", BUFSIZE);
sncat(lbuf, " (im Bau)", BUFSIZE);
}
}
adddbllist(&eh, buf);
adddbllist(&eh, lbuf);
adddbllist(&eh, " ");
for (u = r->units; u; u = u->next) {
if (u->building == b && fval(u, FL_OWNER)) {
@ -950,20 +952,20 @@ showunits(region * r)
f=0;
for (u = r->units; u; u = u->next)
if (u->ship == sh) f += weight(u);
sprintf(buf, "\023%s, %s, (%d/%d)", shipname(sh), sh->type->name[0],
sprintf(lbuf, "\023%s, %s, (%d/%d)", shipname(sh), sh->type->name[0],
(f+99)/100, shipcapacity(sh)/100);
if (sh->size!=sh->type->construction->maxsize) {
f = 100 * (sh->size) / sh->type->construction->maxsize;
sncat(buf, ", im Bau (", BUFSIZE);
sncat(lbuf, ", im Bau (", BUFSIZE);
icat(f);
sncat(buf, "%) ", BUFSIZE);
sncat(lbuf, "%) ", BUFSIZE);
}
if (sh->damage) {
sncat(buf, ", ", BUFSIZE);
sncat(lbuf, ", ", BUFSIZE);
icat(sh->damage);
sncat(buf, "% beschädigt", BUFSIZE);
sncat(lbuf, "% beschädigt", BUFSIZE);
}
adddbllist(&eh, buf);
adddbllist(&eh, lbuf);
adddbllist(&eh, " ");
for (u = r->units; u; u = u->next) {
if (u->ship == sh && fval(u, FL_OWNER)) {
@ -1084,7 +1086,7 @@ showunits(region * r)
f = -1;
break;
case '/':
suchtext = my_input(0, 0, 0, "Suchtext: ");
suchtext = my_input(0, 0, 0, "Suchtext: ", NULL);
such = eh;
case 'n':
if (suchtext) {
@ -1175,8 +1177,8 @@ showunits(region * r)
switch (pointer->s[0]) {
case '\002':
b = findbuilding(f);
sprintf(buf, "Einheit in %s als Eigner?", BuildingName(b));
if (yes_no(0, buf, 'j')) {
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, FL_OWNER)) {
freset(x, FL_OWNER);
@ -1188,8 +1190,8 @@ showunits(region * r)
break;
case '\023':
sh = findship(f);
sprintf(buf, "Einheit auf%s als Eigner?", shipname(sh));
if (yes_no(0, buf, 'j')) {
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, FL_OWNER)) {
freset(x, FL_OWNER);
@ -1203,12 +1205,12 @@ showunits(region * r)
x = findunit(f, r);
if(x) {
if (x->building) {
sprintf(buf, "Einheit in %s rein?", buildingname(x->building));
if (yes_no(0, buf, 'j'))
sprintf(lbuf, "Einheit in %s rein?", buildingname(x->building));
if (yes_no(0, lbuf, 'j'))
u->building = x->building;
} else if (x->ship) {
sprintf(buf, "Einheit auf%s rauf?", shipname(x->ship));
if (yes_no(0, buf, 'j'))
sprintf(lbuf, "Einheit auf%s rauf?", shipname(x->ship));
if (yes_no(0, lbuf, 'j'))
u->ship = x->ship;
}
}
@ -1228,8 +1230,8 @@ showunits(region * r)
if (!clipship)
beep();
else {
sprintf(buf, "Schiff%s löschen?", shipname(clipship));
if (yes_no(0, buf, 'n')) {
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);
@ -1248,8 +1250,8 @@ showunits(region * r)
case 's':
if (clipship && shipregion != r) {
unit *un;
sprintf(buf, "Schiff %s einfügen?", shipname(clipship));
if (yes_no(0, buf, 'j')) {
sprintf(lbuf, "Schiff %s einfügen?", shipname(clipship));
if (yes_no(0, lbuf, 'j')) {
boolean owner_set = false;
for (x = shipregion->units; x;) {
@ -1294,8 +1296,8 @@ showunits(region * r)
if (f) {
b = findbuilding(f);
if (b) {
sprintf(buf, "Gebäude %s löschen?", BuildingName(b));
if (yes_no(0, buf, 'n')) {
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)
@ -1401,8 +1403,8 @@ showunits(region * r)
if (!clipunit)
beep();
else {
sprintf(buf, "Einheit %s löschen?", Unitid(clipunit));
if (yes_no(0, buf, 'n')) {
sprintf(lbuf, "Einheit %s löschen?", Unitid(clipunit));
if (yes_no(0, lbuf, 'n')) {
modified = 1;
destroy_unit(clipunit);
clipunit = 0;

View File

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: mapper.c,v 1.6 2001/02/05 16:11:58 enno Exp $
* $Id: mapper.c,v 1.7 2001/02/09 13:53:53 corwin Exp $
* Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de)
@ -498,7 +498,7 @@ SetHighlight(void)
c = tolower(getch());
switch (c) {
case 'p':
fac_nr36 = my_input(win, 2, 2, "Partei-Nummer: ");
fac_nr36 = my_input(win, 2, 2, "Partei-Nummer: ", NULL);
hl = atoi36(fac_nr36);
break;
case 'e':
@ -741,7 +741,7 @@ movearound(int rx, int ry) {
switch(sel) {
case 'e':
case 'E':
q = atoi36(my_input(win, 2, 2, "Welche Einheit suchen: "));
q = atoi36(my_input(win, 2, 2, "Welche Einheit suchen: ", NULL));
if (q) {
u = findunitg(q, NULL);
if (!u) {
@ -755,7 +755,7 @@ movearound(int rx, int ry) {
break;
case 'p':
case 'P':
q = atoi36(my_input(win, 2, 2, "Welche Partei suchen: "));
q = atoi36(my_input(win, 2, 2, "Welche Partei suchen: ", NULL));
if(q) {
u2 = NULL;
for(r2=regions; r2; r2=r2->next) {
@ -773,7 +773,7 @@ movearound(int rx, int ry) {
break;
case 'r':
case 'R':
selc = my_input(win, 2, 2, "Welchen Regionsnamen suchen: ");
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;

View File

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: mapper.h,v 1.3 2001/02/03 13:45:34 enno Exp $
* $Id: mapper.h,v 1.4 2001/02/09 13:53:53 corwin Exp $
* Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de)
@ -56,7 +56,7 @@ void NeuesSchiff(struct region * r);
void create_island(struct region *r, int n, terrain_t t);
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);
char *my_input(WINDOW * win, int x, int y, const char *text, const char *def);
void make_new_region(int x, int 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);