From a02e94b8e54104ffa9635dec01d1438a6445dd22 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 13 Apr 2001 14:39:57 +0000 Subject: [PATCH] - neue Messages kleine bugfixes in einzelnen messagedefinitionen MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - graph: corwin, vertex ist ein punkt, keine kante. Du meinst edge. - graph: Fehler bei markern, ein == statt einem =. - Kampf: ST_AGGRO, ST_CHICKEN Zwei neue Kampfstati, die das Fluchtverhalten beinnflußen. --- src/common/attributes/targetregion.c | 4 +- src/common/gamecode/economy.c | 7 +- src/common/gamecode/laws.c | 101 ++----------------------- src/common/gamecode/randenc.c | 4 +- src/common/items/lmsreward.c | 2 + src/common/kernel/battle.c | 53 +++++++++++-- src/common/kernel/eressea.c | 94 +++++++++++++++++++++++ src/common/kernel/eressea.h | 18 ++--- src/common/kernel/item.c | 6 +- src/common/kernel/reports.c | 4 + src/common/kernel/save.c | 9 +++ src/common/util/goodies.c | 22 +++++- src/common/util/goodies.h | 3 +- src/common/util/graph.c | 108 +++++++++++++-------------- src/common/util/graph.h | 13 ++-- src/common/util/language.c | 15 ++-- src/common/util/translation.c | 10 +++ src/eressea/main.c | 51 +++---------- src/eressea/old/order.c | 1 + src/mapper/map_units.c | 5 +- src/res/de/messages.xml | 32 +++++--- src/res/en/messages.xml | 34 +++------ src/res/en/strings.txt | 8 ++ 23 files changed, 333 insertions(+), 271 deletions(-) diff --git a/src/common/attributes/targetregion.c b/src/common/attributes/targetregion.c index cafb89c7a..9a1db44d4 100644 --- a/src/common/attributes/targetregion.c +++ b/src/common/attributes/targetregion.c @@ -1,6 +1,6 @@ /* vi: set ts=2: * - * $Id: targetregion.c,v 1.4 2001/02/04 11:18:26 corwin Exp $ + * $Id: targetregion.c,v 1.5 2001/04/13 14:39:50 enno Exp $ * Eressea PB(E)M host Copyright (C) 1998-2000 * Christian Schlittchen (corwin@amber.kn-bremen.de) * Katja Zedel (katze@felidae.kn-bremen.de) @@ -32,7 +32,7 @@ read_targetregion(attrib * a, FILE * F) { if (global.data_version < BASE36IDS_VERSION) { a_readdefault(a, F); - /* a->data.v = findregion(a->data.sa[0], a->data.sa[1]); */ + a->data.v = findregion(a->data.sa[0], a->data.sa[1]); } else { read_region_reference((region**)&a->data.v, F); } diff --git a/src/common/gamecode/economy.c b/src/common/gamecode/economy.c index 987f08478..5253ffd6b 100644 --- a/src/common/gamecode/economy.c +++ b/src/common/gamecode/economy.c @@ -1,6 +1,6 @@ /* vi: set ts=2: * - * $Id: economy.c,v 1.11 2001/04/12 17:21:42 enno Exp $ + * $Id: economy.c,v 1.12 2001/04/13 14:39:51 enno Exp $ * Eressea PB(E)M host Copyright (C) 1998-2000 * Christian Schlittchen (corwin@amber.kn-bremen.de) * Katja Zedel (katze@felidae.kn-bremen.de) @@ -2416,9 +2416,8 @@ research(region *r, unit *u) if (rht != NULL) { add_message(&u->faction->msgs, new_message(u->faction, - "researchherb%u:unit%r:region%s:amount%s:herb", u, r, - rough_amount(rherbs(r), 100), locale_string(u->faction->locale, - resourcename(rht->itype->rtype, 1)))); + "researchherb%u:unit%r:region%s:amount%X:herb", u, r, + rough_amount(rherbs(r), 100), rht->itype->rtype)); } else { add_message(&u->faction->msgs, new_message(u->faction, "researchherb_none%u:unit%r:region", u, r)); diff --git a/src/common/gamecode/laws.c b/src/common/gamecode/laws.c index f7788f48d..a20708379 100644 --- a/src/common/gamecode/laws.c +++ b/src/common/gamecode/laws.c @@ -1963,6 +1963,14 @@ instant_orders(void) u->status = ST_FLEE; break; + case P_CHICKEN: + u->status = ST_CHICKEN; + break; + + case P_AGGRO: + u->status = ST_AGGRO; + break; + case P_VORNE: u->status = ST_FIGHT; break; @@ -2179,99 +2187,6 @@ sinkships(void) #include "eressea.h" #include "build.h" -void -reorder_owners(region * r) -{ - unit ** up=&r->units, ** useek; - building * b=NULL; - ship * sh=NULL; -#ifndef NDEBUG - size_t len = listlen(r->units); -#endif - for (b = r->buildings;b;b=b->next) { - unit ** ubegin = up; - unit ** uend = up; - - useek = up; - while (*useek) { - unit * u = *useek; - if (u->building==b) { - unit ** insert; - if (fval(u, FL_OWNER)) { - unit * nu = *ubegin; - insert=ubegin; - if (nu!=u && nu->building==u->building && fval(nu, FL_OWNER)) { - log_error(("[reorder_owners] %s hat mehrere Besitzer mit FL_OWNER.\n", buildingname(nu->building))); - freset(nu, FL_OWNER); - } - } - else insert = uend; - if (insert!=useek) { - *useek = u->next; /* raus aus der liste */ - u->next = *insert; - *insert = u; - } - if (insert==uend) uend=&u->next; - } - if (*useek==u) useek = &u->next; - } - up = uend; - } - - useek=up; - while (*useek) { - unit * u = *useek; - assert(!u->building); - if (u->ship==NULL) { - if (fval(u, FL_OWNER)) { - log_warning(("[reorder_owners] Einheit %s war Besitzer von nichts.\n", unitname(u))); - freset(u, FL_OWNER); - } - if (useek!=up) { - *useek = u->next; /* raus aus der liste */ - u->next = *up; - *up = u; - } - up = &u->next; - } - if (*useek==u) useek = &u->next; - } - - for (sh = r->ships;sh;sh=sh->next) { - unit ** ubegin = up; - unit ** uend = up; - - useek = up; - while (*useek) { - unit * u = *useek; - if (u->ship==sh) { - unit ** insert; - if (fval(u, FL_OWNER)) { - unit * nu = *ubegin; - insert = ubegin; - if (nu!=u && nu->ship==u->ship && fval(nu, FL_OWNER)) { - log_error(("[reorder_owners] %s hat mehrere Besitzer mit FL_OWNER.\n", shipname(nu->ship))); - freset(nu, FL_OWNER); - } - } - else insert = uend; - if (insert!=useek) { - *useek = u->next; /* raus aus der liste */ - u->next = *insert; - *insert = u; - } - if (insert==uend) uend=&u->next; - } - if (*useek==u) useek = &u->next; - } - up = uend; - } -#ifndef NDEBUG - assert(len==listlen(r->units)); -#endif -} - - static attrib_type at_number = { "faction_renum", NULL, NULL, NULL, NULL, NULL, diff --git a/src/common/gamecode/randenc.c b/src/common/gamecode/randenc.c index e7b08bbcb..ce4ff6cce 100644 --- a/src/common/gamecode/randenc.c +++ b/src/common/gamecode/randenc.c @@ -1137,8 +1137,8 @@ randomevents(void) } if (c) { add_message(&u->faction->msgs, new_message(u->faction, - "scunicorn%u:unit%i:amount%s:type",u,c, - locale_string(u->faction->locale, resourcename(olditemtype[I_UNICORN]->rtype, c!=1?NMF_PLURAL:0)))); + "scunicorn%u:unit%i:amount%X:type",u,c, + olditemtype[I_UNICORN]->rtype)); } } } diff --git a/src/common/items/lmsreward.c b/src/common/items/lmsreward.c index a83ec5d84..24ca609d2 100644 --- a/src/common/items/lmsreward.c +++ b/src/common/items/lmsreward.c @@ -58,6 +58,7 @@ static attrib_type at_lmsstory = { des Attributs kein curse * ist */ }; +#if 0 static int use_lmsreward(struct unit * u, const struct item_type * itype, const char * cmd) { @@ -73,6 +74,7 @@ use_lmsreward(struct unit * u, const struct item_type * itype, const char * cmd) unused(cmd); return -1; } +#endif static resource_type rt_lmsreward = { { "lmsreward", "lmsrewards" }, diff --git a/src/common/kernel/battle.c b/src/common/kernel/battle.c index 6de7fca02..ac2e27950 100644 --- a/src/common/kernel/battle.c +++ b/src/common/kernel/battle.c @@ -443,6 +443,47 @@ tactics_bonus(troop at, troop dt, boolean attacking) } #endif /* NEW_TACTICS */ +static int +statusrow(int status) +{ + switch (status) { + case ST_AGGRO: + case ST_FIGHT: + return FIGHT_ROW; + case ST_BEHIND: + case ST_CHICKEN: + return BEHIND_ROW; + case ST_AVOID: + return AVOID_ROW; + case ST_FLEE: + return FLEE_ROW; + default: + assert(!"unknown combatrow"); + } + return FIGHT_ROW; +} + +static double +hpflee(int status) + /* if hp drop below this percentage, run away */ +{ + switch (status) { + case ST_AGGRO: + return 0.0; + case ST_FIGHT: + case ST_BEHIND: + return 0.2; + case ST_CHICKEN: + case ST_AVOID: + return 0.9; + case ST_FLEE: + return 1.0; + default: + assert(!"unknown combatrow"); + } + return 0.0; +} + int get_unitrow(fighter * af) { @@ -455,7 +496,7 @@ get_unitrow(fighter * af) int line, result; int retreat = 0; int size[NUMROWS]; - int row = af->status + FIRST_ROW; + int row = statusrow(af->status); int front = 0; size_t bsize; @@ -808,11 +849,11 @@ rmtroop(troop dt) df->person[dt.index] = df->person[df->alive - df->removed]; df->person[df->alive - df->removed].hp = 0; --ds->size[SUM_ROW]; - --ds->size[df->status + FIRST_ROW]; + --ds->size[statusrow(df->status)]; /* z.B. Schattenritter */ if (race[df->unit->race].battle_flags & BF_NOBLOCK) { --ds->nonblockers[SUM_ROW]; - --ds->nonblockers[df->status + 1]; + --ds->nonblockers[statusrow(df->status)]; } } @@ -2838,10 +2879,10 @@ make_fighter(battle * b, unit * u, boolean attack) battlerecord(b, buf); } - s1->size[fig->status + FIGHT_ROW] += u->number; + s1->size[statusrow(fig->status)] += u->number; s1->size[SUM_ROW] += u->number; if (race[u->race].battle_flags & BF_NOBLOCK) { - s1->nonblockers[fig->status + FIGHT_ROW] += u->number; + s1->nonblockers[statusrow(fig->status)] += u->number; #ifdef FAST_GETUNITROW b->nonblockers = true; #endif @@ -3533,7 +3574,7 @@ do_battle(void) troop dt; int runners = 0; /* Flucht nicht bei mehr als 600 HP. Damit Wyrme tötbar bleiben. */ - int runhp = min(600,max(4, unit_max_hp(u)/5)); + int runhp = min(600, max(4, (int)(unit_max_hp(u)*hpflee(u->status)))); side *side = fig->side; region *r = NULL; if (is_undead(u) || u->race == RC_SHADOWKNIGHT) continue; diff --git a/src/common/kernel/eressea.c b/src/common/kernel/eressea.c index 3e34e0bce..5ba52ebdd 100644 --- a/src/common/kernel/eressea.c +++ b/src/common/kernel/eressea.c @@ -123,6 +123,8 @@ const char *parameters[MAXPARAMS] = "ZAUBERBUCH", "PAUSE", "VORNE", + "AGGRESSIV", + "DEFENSIV", "STUFE", "HELFE", "FREMDES", @@ -2560,3 +2562,95 @@ month(int offset) return month; } + +void +reorder_owners(region * r) +{ + unit ** up=&r->units, ** useek; + building * b=NULL; + ship * sh=NULL; +#ifndef NDEBUG + size_t len = listlen(r->units); +#endif + for (b = r->buildings;b;b=b->next) { + unit ** ubegin = up; + unit ** uend = up; + + useek = up; + while (*useek) { + unit * u = *useek; + if (u->building==b) { + unit ** insert; + if (fval(u, FL_OWNER)) { + unit * nu = *ubegin; + insert=ubegin; + if (nu!=u && nu->building==u->building && fval(nu, FL_OWNER)) { + log_error(("[reorder_owners] %s hat mehrere Besitzer mit FL_OWNER.\n", buildingname(nu->building))); + freset(nu, FL_OWNER); + } + } + else insert = uend; + if (insert!=useek) { + *useek = u->next; /* raus aus der liste */ + u->next = *insert; + *insert = u; + } + if (insert==uend) uend=&u->next; + } + if (*useek==u) useek = &u->next; + } + up = uend; + } + + useek=up; + while (*useek) { + unit * u = *useek; + assert(!u->building); + if (u->ship==NULL) { + if (fval(u, FL_OWNER)) { + log_warning(("[reorder_owners] Einheit %s war Besitzer von nichts.\n", unitname(u))); + freset(u, FL_OWNER); + } + if (useek!=up) { + *useek = u->next; /* raus aus der liste */ + u->next = *up; + *up = u; + } + up = &u->next; + } + if (*useek==u) useek = &u->next; + } + + for (sh = r->ships;sh;sh=sh->next) { + unit ** ubegin = up; + unit ** uend = up; + + useek = up; + while (*useek) { + unit * u = *useek; + if (u->ship==sh) { + unit ** insert; + if (fval(u, FL_OWNER)) { + unit * nu = *ubegin; + insert = ubegin; + if (nu!=u && nu->ship==u->ship && fval(nu, FL_OWNER)) { + log_error(("[reorder_owners] %s hat mehrere Besitzer mit FL_OWNER.\n", shipname(nu->ship))); + freset(nu, FL_OWNER); + } + } + else insert = uend; + if (insert!=useek) { + *useek = u->next; /* raus aus der liste */ + u->next = *insert; + *insert = u; + } + if (insert==uend) uend=&u->next; + } + if (*useek==u) useek = &u->next; + } + up = uend; + } +#ifndef NDEBUG + assert(len==listlen(r->units)); +#endif +} diff --git a/src/common/kernel/eressea.h b/src/common/kernel/eressea.h index c5232ec9b..c10e100a9 100644 --- a/src/common/kernel/eressea.h +++ b/src/common/kernel/eressea.h @@ -137,7 +137,7 @@ struct building_type; #define GLOBAL_ATTRIB_VERSION 196 #define BASE36IDS_VERSION 197 #define NEWSOURCE_VERSION 197 -#define NEWHASH_VERSION 198 +#define NEWSTATUS_VERSION 198 #define LOCALE_VERSION 300 /* TODO */ /* globale settings des Spieles */ @@ -148,7 +148,7 @@ typedef struct settings { } settings; extern settings global; -#define RELEASE_VERSION NEWSOURCE_VERSION +#define RELEASE_VERSION NEWSTATUS_VERSION #define ECHECK_VERSION "3.11" /* changes from->to: 72->73: struct unit::lock entfernt. @@ -421,16 +421,10 @@ extern const char *keywords[MAXKEYWORDS]; typedef int status_t; enum { + ST_AGGRO, ST_FIGHT, ST_BEHIND, -#ifdef MULTIROWS - ST_BEHIND1, - ST_BEHIND2, - ST_BEHIND3, - ST_BEHIND4, - ST_BEHIND5, - ST_BEHIND6, -#endif + ST_CHICKEN, ST_AVOID, ST_FLEE }; @@ -468,6 +462,8 @@ enum { P_ZAUBER, P_PAUSE, P_VORNE, + P_AGGRO, + P_CHICKEN, P_LEVEL, P_HELP, P_FOREIGN, @@ -1115,6 +1111,8 @@ extern const char * resourcepath(void); extern void kernel_init(void); extern void kernel_done(void); +extern void reorder_owners(struct region * r); + #define FIRST_TURN 184 #include diff --git a/src/common/kernel/item.c b/src/common/kernel/item.c index 614f2c235..ef2a33a66 100644 --- a/src/common/kernel/item.c +++ b/src/common/kernel/item.c @@ -1,6 +1,6 @@ /* vi: set ts=2: * - * $Id: item.c,v 1.15 2001/04/11 18:01:50 corwin Exp $ + * $Id: item.c,v 1.16 2001/04/13 14:39:55 enno Exp $ * Eressea PB(E)M host Copyright (C) 1998-2000 * Christian Schlittchen (corwin@amber.kn-bremen.de) * Katja Zedel (katze@felidae.kn-bremen.de) @@ -2212,10 +2212,6 @@ rt_read(FILE * F) } } rt_register(rt); -#ifndef NDEBUG - if (global.data_version >= NEWHASH_VERSION) - assert(rt->hashkey==hash); -#endif return rt; } diff --git a/src/common/kernel/reports.c b/src/common/kernel/reports.c index 2b80276d8..5e7a6416c 100644 --- a/src/common/kernel/reports.c +++ b/src/common/kernel/reports.c @@ -108,6 +108,10 @@ report_kampfstatus(const unit * u) case ST_FLEE: strcpy(fsbuf, ", flieht"); break; + + default: + strcpy(fsbuf, ", unbekannt"); + break; } #ifdef NOAID if(fval(u, FL_NOAID)) strcat(fsbuf, ", bekommt keine Hilfe"); diff --git a/src/common/kernel/save.c b/src/common/kernel/save.c index 75b79d5e5..c8e7d2924 100644 --- a/src/common/kernel/save.c +++ b/src/common/kernel/save.c @@ -1296,6 +1296,15 @@ readgame(boolean backup) } } u->status = (status_t) ri(F); + if (global.data_version < NEWSTATUS_VERSION) { + switch (u->status) { + case 0: u->status = ST_FIGHT; break; + case 1: u->status = ST_BEHIND; break; + case 2: u->status = ST_AVOID; break; + case 3: u->status = ST_FLEE; break; + default: assert(0); + } + } if (global.data_version <= 73) { if (ri(F)) { guard(u, GUARD_ALL); diff --git a/src/common/util/goodies.c b/src/common/util/goodies.c index d95d6b612..9ee967294 100644 --- a/src/common/util/goodies.c +++ b/src/common/util/goodies.c @@ -1,6 +1,6 @@ /* vi: set ts=2: * - * $Id: goodies.c,v 1.8 2001/04/12 17:21:45 enno Exp $ + * $Id: goodies.c,v 1.9 2001/04/13 14:39:55 enno Exp $ * Eressea PB(E)M host Copyright (C) 1998-2000 * Christian Schlittchen (corwin@amber.kn-bremen.de) * Katja Zedel (katze@felidae.kn-bremen.de) @@ -105,3 +105,23 @@ set_string (char **s, const char *neu) *s = realloc(*s, strlen(neu) + 1); return strcpy(*s, neu); } + +boolean +locale_check(void) +{ + int i, errorlevel = 0; + unsigned char * umlaute = (unsigned char*)"äöüÄÖÜß"; + /* E: das prüft, ob umlaute funktionieren. Wenn äöü nicht mit isalpha() true sind, kriegen wir ärger. */ + for (i=0;i!=3;++i) { + if (toupper(umlaute[i])!=(int)umlaute[i+3]) { + ++errorlevel; + } + } + for (i=0;umlaute[i]!=0;++i) { + if (!isalpha(umlaute[i]) || isspace(umlaute[i]) || iscntrl(umlaute[i])) { + ++errorlevel; + } + } + if (errorlevel) return false; + return true; +} diff --git a/src/common/util/goodies.h b/src/common/util/goodies.h index da6befea5..869410c70 100644 --- a/src/common/util/goodies.h +++ b/src/common/util/goodies.h @@ -1,6 +1,6 @@ /* vi: set ts=2: * - * $Id: goodies.h,v 1.4 2001/04/12 17:21:45 enno Exp $ + * $Id: goodies.h,v 1.5 2001/04/13 14:39:55 enno Exp $ * Eressea PB(E)M host Copyright (C) 1998-2000 * Christian Schlittchen (corwin@amber.kn-bremen.de) * Katja Zedel (katze@felidae.kn-bremen.de) @@ -21,6 +21,7 @@ extern int *intlist_find(int *i_p, int i); extern unsigned int hashstring(const char* s); extern char *space_replace(char * str, char replace); extern const char *escape_string(const char * str, char * buffer, size_t len); +extern boolean locale_check(void); /* grammar constants: */ #define GR_PLURAL 0x01 /* 0x02-0x08 left unused for individual use */ diff --git a/src/common/util/graph.c b/src/common/util/graph.c index 9c46bee31..ccc2396f3 100644 --- a/src/common/util/graph.c +++ b/src/common/util/graph.c @@ -8,7 +8,6 @@ This program may not be used, modified or distributed without prior permission by the authors of Eressea. - $Id: graph.c,v 1.1 2001/04/11 17:28:07 corwin Exp $ */ /* This is a very simple graph library. It is not optimized in any @@ -21,57 +20,53 @@ void graph_init(graph *g) { - g->nodes = malloc(sizeof(vset)); - g->vertices = malloc(sizeof(vset)); - vset_init(g->nodes); - vset_init(g->vertices); + vset_init(&g->nodes); + vset_init(&g->edges); } void graph_free(graph *g) { - vset_destroy(g->nodes); - vset_destroy(g->vertices); - free(g->nodes); - free(g->vertices); + vset_destroy(&g->nodes); + vset_destroy(&g->edges); } void graph_add_node(graph *g, node *n) { - vset_add(g->nodes, n); + vset_add(&g->nodes, n); } void -graph_add_vertex(graph *g, vertex *v) +graph_add_edge(graph *g, edge *v) { - vset_add(g->nodes, v); + vset_add(&g->nodes, v); } void graph_remove_node(graph *g, node *n) { - int i; + unsigned int i; - for(i=0; i != g->vertices->size; ++i) { - vertex *v = g->vertices->data[i]; + for(i=0; i != g->edges.size; ++i) { + edge *v = g->edges.data[i]; if(v->node1 == n || v->node2 == n) { - vset_erase(g->nodes, v); + vset_erase(&g->nodes, v); i--; } } - vset_erase(g->nodes, n); + vset_erase(&g->nodes, n); } node * graph_find_node(graph *g, void *object) { - int i; + unsigned int i; - for(i=0; i != g->nodes->size; ++i) { - node *node = g->nodes->data[i]; + for(i=0; i != g->nodes.size; ++i) { + node *node = g->nodes.data[i]; if(node->object == object) { - return g->nodes->data[i]; + return g->nodes.data[i]; } } return NULL; @@ -83,11 +78,11 @@ graph_find_node(graph *g, void *object) vset * graph_neighbours(graph *g, node *n) { - int i; - vset *vs = malloc(sizeof(vset)); + unsigned int i; + vset * vs = malloc(sizeof(vs)); vset_init(vs); - for(i=0; i != g->vertices->size; ++i) { - vertex *v = g->vertices->data[i]; + for(i=0; i != g->edges.size; ++i) { + edge *v = g->edges.data[i]; if(v->node1 == n && vset_count(vs, v->node2) == 0) { vset_add(vs, v->node2); } else if(v->node2 == n && vset_count(vs, v->node1) == 0) { @@ -101,15 +96,15 @@ graph_neighbours(graph *g, node *n) void graph_resetmarkers(graph *g) { - int i; + unsigned int i; - for(i=0; i != g->nodes->size; ++i) { - node *node = g->nodes->data[i]; + for(i=0; i != g->nodes.size; ++i) { + node *node = g->nodes.data[i]; node->marker = 0; } - for(i=0; i != g->vertices->size; ++i) { - vertex *vertex = g->vertices->data[i]; - vertex->marker = 0; + for(i=0; i != g->edges.size; ++i) { + edge *edge = g->edges.data[i]; + edge->marker = 0; } } @@ -119,33 +114,32 @@ graph_resetmarkers(graph *g) vset * graph_connected_nodes(graph *g, node *n) { - vset *vs = malloc(sizeof(vset)); - vset *s = malloc(sizeof(vset)); + vset * vs = malloc(sizeof(vset)); + vset s; vset_init(vs); - vset_init(s); + vset_init(&s); graph_resetmarkers(g); vset_add(vs, n); n->marker = 1; - vset_add(s, n); - while(s->size > 0) { - node *n = vset_pop(s); + vset_add(&s, n); + while(s.size > 0) { + node *n = vset_pop(&s); vset *vs_nb = graph_neighbours(g, n); - int i; + unsigned int i; for(i=0; i != vs_nb->size; ++i) { node *nb = vs_nb->data[i]; if(nb->marker == 0) { - nb->marker == 1; + nb->marker = 1; vset_add(vs, nb); - vset_add(s, nb); + vset_add(&s, nb); } } vset_destroy(vs_nb); free(vs_nb); } - vset_destroy(s); - free(s); + vset_destroy(&s); return vs; } @@ -156,33 +150,34 @@ graph_connected_nodes(graph *g, node *n) vset * graph_disjunct_graphs(graph *g) { - vset *dg = malloc(sizeof(vset)); - vset *nodes = malloc(sizeof(vset)); + vset * dg = malloc(sizeof(vset)); + vset nodes; - vset_init(nodes); - vset_concat(nodes, g->nodes); + vset_init(dg); + vset_init(&nodes); + vset_concat(&nodes, &g->nodes); - while(nodes->size > 0) { + while(nodes.size > 0) { graph *gt = malloc(sizeof(graph)); vset s; - int i; + unsigned int i; node *start; graph_init(gt); - start = vset_pop(nodes); + start = vset_pop(&nodes); graph_resetmarkers(g); graph_add_node(gt, start); start->marker = 1; vset_init(&s); vset_add(&s,start); while(s.size > 0) { - vset *nbs = graph_neighbours(g,vset_pop(&s)); + vset * nbs = graph_neighbours(g,vset_pop(&s)); for(i=0; i != nbs->size; ++i) { node *nb = nbs->data[i]; if(nb->marker == 0) { nb->marker = 1; graph_add_node(gt,nb); - vset_erase(nodes,nb); + vset_erase(&nodes,nb); vset_add(&s,nb); } } @@ -191,18 +186,17 @@ graph_disjunct_graphs(graph *g) vset_destroy(&s); - for(i=0;i != g->vertices->size; ++i) { - vertex *v = g->vertices->data[i]; - if(vset_count(g->nodes, v->node1)) { - graph_add_vertex(gt,v); + for(i=0;i != g->edges.size; ++i) { + edge *v = g->edges.data[i]; + if(vset_count(&g->nodes, v->node1)) { + graph_add_edge(gt, v); } } vset_add(dg, gt); } - vset_destroy(nodes); - free(nodes); + vset_destroy(&nodes); return dg; } diff --git a/src/common/util/graph.h b/src/common/util/graph.h index 6eed085f0..7667fb9ad 100644 --- a/src/common/util/graph.h +++ b/src/common/util/graph.h @@ -8,26 +8,25 @@ This program may not be used, modified or distributed without prior permission by the authors of Eressea. - $Id: graph.h,v 1.1 2001/04/11 17:28:07 corwin Exp $ */ #ifndef GRAPH_H #define GRAPH_H -typedef struct { +typedef struct node { int marker; void *object; } node; -typedef struct { +typedef struct edge { int marker; node *node1; node *node2; -} vertex; +} edge; -typedef struct { - vset *nodes; - vset *vertices; +typedef struct graph { + vset nodes; + vset edges; } graph; #endif diff --git a/src/common/util/language.c b/src/common/util/language.c index 7361cdc60..f460c9d7c 100644 --- a/src/common/util/language.c +++ b/src/common/util/language.c @@ -1,6 +1,6 @@ /* vi: set ts=2: * - * $Id: language.c,v 1.5 2001/04/12 17:21:45 enno Exp $ + * $Id: language.c,v 1.6 2001/04/13 14:39:55 enno Exp $ * Eressea PB(E)M host Copyright (C) 1998-2000 * Christian Schlittchen (corwin@amber.kn-bremen.de) * Katja Zedel (katze@felidae.kn-bremen.de) @@ -137,12 +137,13 @@ reverse_lookup(const locale * lang, const char * str) { int i; if (lang==NULL) lang = default_locale; - assert(lang!=NULL); - for (i=0;i!=SMAXHASH;++i) { - struct locale_string * ls; - for (ls=lang->strings[i];ls;ls=ls->nexthash) { - if (strcasecmp(ls->key, str)==0) return ls->key; - if (strcasecmp(ls->str, str)==0) return ls->key; + if (lang!=NULL) { + for (i=0;i!=SMAXHASH;++i) { + struct locale_string * ls; + for (ls=lang->strings[i];ls;ls=ls->nexthash) { + if (strcasecmp(ls->key, str)==0) return ls->key; + if (strcasecmp(ls->str, str)==0) return ls->key; + } } } return str; diff --git a/src/common/util/translation.c b/src/common/util/translation.c index 2b0230cb0..8e4df9c34 100644 --- a/src/common/util/translation.c +++ b/src/common/util/translation.c @@ -421,6 +421,15 @@ eval_localize(opstack ** stack, const void * userdata) /* (string, locale) -> st unused(userdata); } +static void +eval_locale(opstack ** stack, const void * userdata) /* (string) -> locale */ +{ + const char *c = opop(stack, const char *); + const struct locale *lang = find_locale(c); + opush(stack, lang); + unused(userdata); +} + void translation_init(void) { @@ -429,6 +438,7 @@ translation_init(void) add_function("add", &eval_add); add_function("if", &eval_if); add_function("localize", &eval_localize); + add_function("locale", &eval_locale); } void diff --git a/src/eressea/main.c b/src/eressea/main.c index 877226141..6253399d7 100644 --- a/src/eressea/main.c +++ b/src/eressea/main.c @@ -1,6 +1,6 @@ /* vi: set ts=2: * - * $Id: main.c,v 1.20 2001/04/12 17:21:46 enno Exp $ + * $Id: main.c,v 1.21 2001/04/13 14:39:55 enno Exp $ * Eressea PB(E)M host Copyright (C) 1998-2000 * Christian Schlittchen (corwin@amber.kn-bremen.de) * Katja Zedel (katze@felidae.kn-bremen.de) @@ -44,6 +44,7 @@ /* gamecode includes */ #include +#include #include /* kernel includes */ @@ -59,7 +60,6 @@ #include #include #include -#include #include #include #include @@ -73,6 +73,7 @@ #include #include #include +#include #include /** @@ -91,6 +92,10 @@ extern boolean nobattle; extern boolean nobattledebug; static boolean printpotions; +extern void debug_messagetypes(FILE * out); +extern void freeland(land_region * lr); +extern void render_init(void); + #ifdef FUZZY_BASE36 extern int fuzzy_hits; #endif /* FUZZY_BASE36 */ @@ -98,12 +103,13 @@ extern int fuzzy_hits; /** ** global variables wthat we are exporting **/ +static char * orders = NULL; +static int nowrite = 0; + struct settings global = { "Eressea", /* gamename */ }; -extern void render_init(void); - static void print_potions(FILE * F) { @@ -118,10 +124,6 @@ print_potions(FILE * F) } } -static char * orders = NULL; -static int nowrite = 0; -extern void debug_messagetypes(FILE * out); - static void game_init(void) { @@ -160,7 +162,7 @@ game_init(void) } } -void +static void create_game(void) { assert(regions==NULL || !"game is initialized"); @@ -198,8 +200,6 @@ getgarbage(void) #endif } -int quickleave = 0; - static void writepasswd(void) { @@ -265,8 +265,6 @@ processturn(char *filename) return 0; } -extern void freeland(land_region * lr); - static void game_done(void) { @@ -336,33 +334,6 @@ game_done(void) #include "magic.h" -static boolean -locale_check(void) -{ - int i, errorlevel = 0; - unsigned char * umlaute = (unsigned char*)"äöüÄÖÜß"; - /* E: das prüft, ob umlaute funktionieren. Wenn äöü nicht mit isalpha() true sind, kriegen wir ärger. */ - for (i=0;i!=3;++i) { - if (toupper(umlaute[i])!=(int)umlaute[i+3]) { - ++errorlevel; - fprintf(stderr, "error in locale[%d, %d]: toupper(%c)==%c\n", i, umlaute[i], umlaute[i], toupper(umlaute[i])); - } - } - for (i=0;umlaute[i]!=0;++i) { - if (!isalpha(umlaute[i]) || isspace(umlaute[i]) || iscntrl(umlaute[i])) { - ++errorlevel; - if (!isalpha(umlaute[i])) - fprintf(stderr, "error in locale[%d, %d]: !isalpha(%c)\n", i, umlaute[i], umlaute[i]); - if (iscntrl(umlaute[i])) - fprintf(stderr, "error in locale(%d, %d]: iscntrl(%c)\n", i, umlaute[i], umlaute[i]); - if (isspace(umlaute[i])) - fprintf(stderr, "error in locale[%d, %d]: isspace(%c)\n", i, umlaute[i], umlaute[i]); - } - } - if (errorlevel) return false; - return true; -} - #if MALLOCDBG static void init_malloc_debug(void) diff --git a/src/eressea/old/order.c b/src/eressea/old/order.c index 52edec862..13b3ed945 100644 --- a/src/eressea/old/order.c +++ b/src/eressea/old/order.c @@ -3,6 +3,7 @@ #include "order.h" #include +#include #include void diff --git a/src/mapper/map_units.c b/src/mapper/map_units.c index 6d696be3b..e10a97791 100644 --- a/src/mapper/map_units.c +++ b/src/mapper/map_units.c @@ -1,6 +1,6 @@ /* vi: set ts=2: * - * $Id: map_units.c,v 1.4 2001/02/18 10:06:10 enno Exp $ + * $Id: map_units.c,v 1.5 2001/04/13 14:39:56 enno Exp $ * Eressea PB(E)M host Copyright (C) 1998-2000 * Christian Schlittchen (corwin@amber.kn-bremen.de) * Katja Zedel (katze@felidae.kn-bremen.de) @@ -831,6 +831,9 @@ mapper_spunit(dbllist ** SP, unit * u, int indent) case ST_FLEE: sncat(buf, ", flieht", BUFSIZE); break; + default: + sncat(buf, ", unbekannt", BUFSIZE); + break; } sncat(buf, " (", BUFSIZE); icat(u->hp/u->number); sncat(buf, " HP)", BUFSIZE); diff --git a/src/res/de/messages.xml b/src/res/de/messages.xml index 7d6d34129..fe9c5ad5a 100644 --- a/src/res/de/messages.xml +++ b/src/res/de/messages.xml @@ -3807,11 +3807,11 @@ - + - "Die $ship($ship) fährt in den Mahlstrom von $region($region) und nimmt $int($damage) Schaden$sink." + "Die $ship($ship) fährt in den Mahlstrom von $region($region) und nimmt $int($damage) Schaden$if($sink," und sinkt","")." @@ -3820,11 +3820,11 @@ - + - "Die $ship($ship) wird in $region($region) von Stürmen abgetrieben$sink." + "Die $ship($ship) wird in $region($region) von Stürmen abgetrieben$if($sink," und sinkt","")." @@ -4243,11 +4243,11 @@ - + - "$unit($unit) schließen sich $int($amount) $type an." + "$unit($unit) $if($eq($amount,1),"schließt","schließen") sich $int($amount) $resource($type,$amount) an." @@ -4292,13 +4292,18 @@ - - + + - "$unit($unit) in $region($region) stellt fest, daß es hier $int($amount) $resource($herb,$amount) gibt." + "$unit($unit) in $region($region) stellt fest, daß es hier $localize($amount,$locale("en")) $resource($herb,$amount) gibt." + + + + + "$unit($unit) discovers that $localize($amount,$locale("en")) $resource($herb,$amount) grow in $region($region)." @@ -6390,11 +6395,16 @@ - + - "In $region($region) stürzte $building($building) ein.$unit($opfer)" + "In $region($region) stürzte $building($building) ein.$if($opfer," $int($opfer) Opfer sind zu beklagen.","")" + + + + + "$building($building) in $region($region) collapses.$if($opfer," There are $int($opfer) caualties.","")" diff --git a/src/res/en/messages.xml b/src/res/en/messages.xml index eee1f4d20..721d563d9 100644 --- a/src/res/en/messages.xml +++ b/src/res/en/messages.xml @@ -3091,11 +3091,11 @@ - + - "The $ship($ship) in $region($region) drifts $sink in heavy storm." + "The $ship($ship) in $region($region) drifts in heavy storm$if($sink," and sinks","")." @@ -3705,7 +3705,7 @@ - "$unit($mage) found out that $region($region) is charmed with $spell, which will last for centuries." + "$unit($mage) discovers that $region($region) is charmed with $spell, which will last for centuries." @@ -3718,7 +3718,7 @@ - "$unit($mage) found out that $unit($unit) is charmed with $spell, which will last for centuries." + "$unit($mage) discovers that $unit($unit) is charmed with $spell, which will last for centuries." @@ -3731,7 +3731,7 @@ - "$unit($mage) found out that $building($building) is charmed with $spell, which will last for centuries." + "$unit($mage) discovers that $building($building) is charmed with $spell, which will last for centuries." @@ -3744,7 +3744,7 @@ - "$unit($mage) found out that $ship($ship) is charmed with $spell, which will last for centuries." + "$unit($mage) discovers that $ship($ship) is charmed with $spell, which will last for centuries." @@ -3758,7 +3758,7 @@ - "$unit($mage) found out that $region($region) is charmed with $spell, which will last for, about $int($months) more weeks." + "$unit($mage) discovers that $region($region) is charmed with $spell, which will last for, about $int($months) more weeks." @@ -3772,7 +3772,7 @@ - "$unit($mage) found out that $unit($unit) is charmed with $spell that willlast for about $int($months) more weeks." + "$unit($mage) discovers that $unit($unit) is charmed with $spell that willlast for about $int($months) more weeks." @@ -3786,7 +3786,7 @@ - "$unit($mage) found out that $building($building) is charmed with $spell, which will last for, about $int($months) more weeks." + "$unit($mage) discovers that $building($building) is charmed with $spell, which will last for, about $int($months) more weeks." @@ -3800,7 +3800,7 @@ - "$unit($mage) found out that $ship($ship) is charmed with $spell, which will last for, about $int($months) more weeks." + "$unit($mage) discovers that $ship($ship) is charmed with $spell, which will last for, about $int($months) more weeks." @@ -3939,20 +3939,6 @@ - - - - - - - - - - "$unit($unit) found out that $int($amount) $resource($herb,$amount) grow in $region($region)." - - - - diff --git a/src/res/en/strings.txt b/src/res/en/strings.txt index e26c141b3..98baee9c4 100644 --- a/src/res/en/strings.txt +++ b/src/res/en/strings.txt @@ -15,6 +15,14 @@ section_study;en;Learning and Teaching section_battle;en;Battles section_none;en;Miscellaneous +# Burgausbaustufen +site;en;site +fortification;en;fortification +tower;en;tower +castle;en;castle +fortress;en;fortress +citadel;en;citadel + # Items herb;en;herb herbbag;en;herbbag