- neue Messages

kleine bugfixes in einzelnen messagedefinitionen

- 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.
This commit is contained in:
Enno Rehling 2001-04-13 14:39:57 +00:00
parent 1e51d0e9e2
commit a02e94b8e5
23 changed files with 333 additions and 271 deletions

View File

@ -1,6 +1,6 @@
/* vi: set ts=2: /* 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 * Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de) * Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.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) { if (global.data_version < BASE36IDS_VERSION) {
a_readdefault(a, F); 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 { } else {
read_region_reference((region**)&a->data.v, F); read_region_reference((region**)&a->data.v, F);
} }

View File

@ -1,6 +1,6 @@
/* vi: set ts=2: /* 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 * Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de) * Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de) * Katja Zedel (katze@felidae.kn-bremen.de)
@ -2416,9 +2416,8 @@ research(region *r, unit *u)
if (rht != NULL) { if (rht != NULL) {
add_message(&u->faction->msgs, new_message(u->faction, add_message(&u->faction->msgs, new_message(u->faction,
"researchherb%u:unit%r:region%s:amount%s:herb", u, r, "researchherb%u:unit%r:region%s:amount%X:herb", u, r,
rough_amount(rherbs(r), 100), locale_string(u->faction->locale, rough_amount(rherbs(r), 100), rht->itype->rtype));
resourcename(rht->itype->rtype, 1))));
} else { } else {
add_message(&u->faction->msgs, new_message(u->faction, add_message(&u->faction->msgs, new_message(u->faction,
"researchherb_none%u:unit%r:region", u, r)); "researchherb_none%u:unit%r:region", u, r));

View File

@ -1963,6 +1963,14 @@ instant_orders(void)
u->status = ST_FLEE; u->status = ST_FLEE;
break; break;
case P_CHICKEN:
u->status = ST_CHICKEN;
break;
case P_AGGRO:
u->status = ST_AGGRO;
break;
case P_VORNE: case P_VORNE:
u->status = ST_FIGHT; u->status = ST_FIGHT;
break; break;
@ -2179,99 +2187,6 @@ sinkships(void)
#include "eressea.h" #include "eressea.h"
#include "build.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 = { static attrib_type at_number = {
"faction_renum", "faction_renum",
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,

View File

@ -1137,8 +1137,8 @@ randomevents(void)
} }
if (c) { if (c) {
add_message(&u->faction->msgs, new_message(u->faction, add_message(&u->faction->msgs, new_message(u->faction,
"scunicorn%u:unit%i:amount%s:type",u,c, "scunicorn%u:unit%i:amount%X:type",u,c,
locale_string(u->faction->locale, resourcename(olditemtype[I_UNICORN]->rtype, c!=1?NMF_PLURAL:0)))); olditemtype[I_UNICORN]->rtype));
} }
} }
} }

View File

@ -58,6 +58,7 @@ static attrib_type at_lmsstory = {
des Attributs kein curse * ist */ des Attributs kein curse * ist */
}; };
#if 0
static int static int
use_lmsreward(struct unit * u, const struct item_type * itype, const char * cmd) 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); unused(cmd);
return -1; return -1;
} }
#endif
static resource_type rt_lmsreward = { static resource_type rt_lmsreward = {
{ "lmsreward", "lmsrewards" }, { "lmsreward", "lmsrewards" },

View File

@ -443,6 +443,47 @@ tactics_bonus(troop at, troop dt, boolean attacking)
} }
#endif /* NEW_TACTICS */ #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 int
get_unitrow(fighter * af) get_unitrow(fighter * af)
{ {
@ -455,7 +496,7 @@ get_unitrow(fighter * af)
int line, result; int line, result;
int retreat = 0; int retreat = 0;
int size[NUMROWS]; int size[NUMROWS];
int row = af->status + FIRST_ROW; int row = statusrow(af->status);
int front = 0; int front = 0;
size_t bsize; size_t bsize;
@ -808,11 +849,11 @@ rmtroop(troop dt)
df->person[dt.index] = df->person[df->alive - df->removed]; df->person[dt.index] = df->person[df->alive - df->removed];
df->person[df->alive - df->removed].hp = 0; df->person[df->alive - df->removed].hp = 0;
--ds->size[SUM_ROW]; --ds->size[SUM_ROW];
--ds->size[df->status + FIRST_ROW]; --ds->size[statusrow(df->status)];
/* z.B. Schattenritter */ /* z.B. Schattenritter */
if (race[df->unit->race].battle_flags & BF_NOBLOCK) { if (race[df->unit->race].battle_flags & BF_NOBLOCK) {
--ds->nonblockers[SUM_ROW]; --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); battlerecord(b, buf);
} }
s1->size[fig->status + FIGHT_ROW] += u->number; s1->size[statusrow(fig->status)] += u->number;
s1->size[SUM_ROW] += u->number; s1->size[SUM_ROW] += u->number;
if (race[u->race].battle_flags & BF_NOBLOCK) { 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 #ifdef FAST_GETUNITROW
b->nonblockers = true; b->nonblockers = true;
#endif #endif
@ -3533,7 +3574,7 @@ do_battle(void)
troop dt; troop dt;
int runners = 0; int runners = 0;
/* Flucht nicht bei mehr als 600 HP. Damit Wyrme tötbar bleiben. */ /* 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; side *side = fig->side;
region *r = NULL; region *r = NULL;
if (is_undead(u) || u->race == RC_SHADOWKNIGHT) continue; if (is_undead(u) || u->race == RC_SHADOWKNIGHT) continue;

View File

@ -123,6 +123,8 @@ const char *parameters[MAXPARAMS] =
"ZAUBERBUCH", "ZAUBERBUCH",
"PAUSE", "PAUSE",
"VORNE", "VORNE",
"AGGRESSIV",
"DEFENSIV",
"STUFE", "STUFE",
"HELFE", "HELFE",
"FREMDES", "FREMDES",
@ -2560,3 +2562,95 @@ month(int offset)
return month; 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
}

View File

@ -137,7 +137,7 @@ struct building_type;
#define GLOBAL_ATTRIB_VERSION 196 #define GLOBAL_ATTRIB_VERSION 196
#define BASE36IDS_VERSION 197 #define BASE36IDS_VERSION 197
#define NEWSOURCE_VERSION 197 #define NEWSOURCE_VERSION 197
#define NEWHASH_VERSION 198 #define NEWSTATUS_VERSION 198
#define LOCALE_VERSION 300 /* TODO */ #define LOCALE_VERSION 300 /* TODO */
/* globale settings des Spieles */ /* globale settings des Spieles */
@ -148,7 +148,7 @@ typedef struct settings {
} settings; } settings;
extern settings global; extern settings global;
#define RELEASE_VERSION NEWSOURCE_VERSION #define RELEASE_VERSION NEWSTATUS_VERSION
#define ECHECK_VERSION "3.11" #define ECHECK_VERSION "3.11"
/* changes from->to: 72->73: struct unit::lock entfernt. /* changes from->to: 72->73: struct unit::lock entfernt.
@ -421,16 +421,10 @@ extern const char *keywords[MAXKEYWORDS];
typedef int status_t; typedef int status_t;
enum { enum {
ST_AGGRO,
ST_FIGHT, ST_FIGHT,
ST_BEHIND, ST_BEHIND,
#ifdef MULTIROWS ST_CHICKEN,
ST_BEHIND1,
ST_BEHIND2,
ST_BEHIND3,
ST_BEHIND4,
ST_BEHIND5,
ST_BEHIND6,
#endif
ST_AVOID, ST_AVOID,
ST_FLEE ST_FLEE
}; };
@ -468,6 +462,8 @@ enum {
P_ZAUBER, P_ZAUBER,
P_PAUSE, P_PAUSE,
P_VORNE, P_VORNE,
P_AGGRO,
P_CHICKEN,
P_LEVEL, P_LEVEL,
P_HELP, P_HELP,
P_FOREIGN, P_FOREIGN,
@ -1115,6 +1111,8 @@ extern const char * resourcepath(void);
extern void kernel_init(void); extern void kernel_init(void);
extern void kernel_done(void); extern void kernel_done(void);
extern void reorder_owners(struct region * r);
#define FIRST_TURN 184 #define FIRST_TURN 184
#include <log.h> #include <log.h>

View File

@ -1,6 +1,6 @@
/* vi: set ts=2: /* 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 * Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de) * Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de) * Katja Zedel (katze@felidae.kn-bremen.de)
@ -2212,10 +2212,6 @@ rt_read(FILE * F)
} }
} }
rt_register(rt); rt_register(rt);
#ifndef NDEBUG
if (global.data_version >= NEWHASH_VERSION)
assert(rt->hashkey==hash);
#endif
return rt; return rt;
} }

View File

@ -108,6 +108,10 @@ report_kampfstatus(const unit * u)
case ST_FLEE: case ST_FLEE:
strcpy(fsbuf, ", flieht"); strcpy(fsbuf, ", flieht");
break; break;
default:
strcpy(fsbuf, ", unbekannt");
break;
} }
#ifdef NOAID #ifdef NOAID
if(fval(u, FL_NOAID)) strcat(fsbuf, ", bekommt keine Hilfe"); if(fval(u, FL_NOAID)) strcat(fsbuf, ", bekommt keine Hilfe");

View File

@ -1296,6 +1296,15 @@ readgame(boolean backup)
} }
} }
u->status = (status_t) ri(F); 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 (global.data_version <= 73) {
if (ri(F)) { if (ri(F)) {
guard(u, GUARD_ALL); guard(u, GUARD_ALL);

View File

@ -1,6 +1,6 @@
/* vi: set ts=2: /* 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 * Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de) * Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.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); *s = realloc(*s, strlen(neu) + 1);
return strcpy(*s, neu); 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;
}

View File

@ -1,6 +1,6 @@
/* vi: set ts=2: /* 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 * Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de) * Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.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 unsigned int hashstring(const char* s);
extern char *space_replace(char * str, char replace); extern char *space_replace(char * str, char replace);
extern const char *escape_string(const char * str, char * buffer, size_t len); extern const char *escape_string(const char * str, char * buffer, size_t len);
extern boolean locale_check(void);
/* grammar constants: */ /* grammar constants: */
#define GR_PLURAL 0x01 #define GR_PLURAL 0x01
/* 0x02-0x08 left unused for individual use */ /* 0x02-0x08 left unused for individual use */

View File

@ -8,7 +8,6 @@
This program may not be used, modified or distributed This program may not be used, modified or distributed
without prior permission by the authors of Eressea. 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 /* This is a very simple graph library. It is not optimized in any
@ -21,57 +20,53 @@
void void
graph_init(graph *g) graph_init(graph *g)
{ {
g->nodes = malloc(sizeof(vset)); vset_init(&g->nodes);
g->vertices = malloc(sizeof(vset)); vset_init(&g->edges);
vset_init(g->nodes);
vset_init(g->vertices);
} }
void void
graph_free(graph *g) graph_free(graph *g)
{ {
vset_destroy(g->nodes); vset_destroy(&g->nodes);
vset_destroy(g->vertices); vset_destroy(&g->edges);
free(g->nodes);
free(g->vertices);
} }
void void
graph_add_node(graph *g, node *n) graph_add_node(graph *g, node *n)
{ {
vset_add(g->nodes, n); vset_add(&g->nodes, n);
} }
void 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 void
graph_remove_node(graph *g, node *n) graph_remove_node(graph *g, node *n)
{ {
int i; unsigned int i;
for(i=0; i != g->vertices->size; ++i) { for(i=0; i != g->edges.size; ++i) {
vertex *v = g->vertices->data[i]; edge *v = g->edges.data[i];
if(v->node1 == n || v->node2 == n) { if(v->node1 == n || v->node2 == n) {
vset_erase(g->nodes, v); vset_erase(&g->nodes, v);
i--; i--;
} }
} }
vset_erase(g->nodes, n); vset_erase(&g->nodes, n);
} }
node * node *
graph_find_node(graph *g, void *object) graph_find_node(graph *g, void *object)
{ {
int i; unsigned int i;
for(i=0; i != g->nodes->size; ++i) { for(i=0; i != g->nodes.size; ++i) {
node *node = g->nodes->data[i]; node *node = g->nodes.data[i];
if(node->object == object) { if(node->object == object) {
return g->nodes->data[i]; return g->nodes.data[i];
} }
} }
return NULL; return NULL;
@ -83,11 +78,11 @@ graph_find_node(graph *g, void *object)
vset * vset *
graph_neighbours(graph *g, node *n) graph_neighbours(graph *g, node *n)
{ {
int i; unsigned int i;
vset *vs = malloc(sizeof(vset)); vset * vs = malloc(sizeof(vs));
vset_init(vs); vset_init(vs);
for(i=0; i != g->vertices->size; ++i) { for(i=0; i != g->edges.size; ++i) {
vertex *v = g->vertices->data[i]; edge *v = g->edges.data[i];
if(v->node1 == n && vset_count(vs, v->node2) == 0) { if(v->node1 == n && vset_count(vs, v->node2) == 0) {
vset_add(vs, v->node2); vset_add(vs, v->node2);
} else if(v->node2 == n && vset_count(vs, v->node1) == 0) { } else if(v->node2 == n && vset_count(vs, v->node1) == 0) {
@ -101,15 +96,15 @@ graph_neighbours(graph *g, node *n)
void void
graph_resetmarkers(graph *g) graph_resetmarkers(graph *g)
{ {
int i; unsigned int i;
for(i=0; i != g->nodes->size; ++i) { for(i=0; i != g->nodes.size; ++i) {
node *node = g->nodes->data[i]; node *node = g->nodes.data[i];
node->marker = 0; node->marker = 0;
} }
for(i=0; i != g->vertices->size; ++i) { for(i=0; i != g->edges.size; ++i) {
vertex *vertex = g->vertices->data[i]; edge *edge = g->edges.data[i];
vertex->marker = 0; edge->marker = 0;
} }
} }
@ -119,33 +114,32 @@ graph_resetmarkers(graph *g)
vset * vset *
graph_connected_nodes(graph *g, node *n) graph_connected_nodes(graph *g, node *n)
{ {
vset *vs = malloc(sizeof(vset)); vset * vs = malloc(sizeof(vset));
vset *s = malloc(sizeof(vset)); vset s;
vset_init(vs); vset_init(vs);
vset_init(s); vset_init(&s);
graph_resetmarkers(g); graph_resetmarkers(g);
vset_add(vs, n); vset_add(vs, n);
n->marker = 1; n->marker = 1;
vset_add(s, n); vset_add(&s, n);
while(s->size > 0) { while(s.size > 0) {
node *n = vset_pop(s); node *n = vset_pop(&s);
vset *vs_nb = graph_neighbours(g, n); vset *vs_nb = graph_neighbours(g, n);
int i; unsigned int i;
for(i=0; i != vs_nb->size; ++i) { for(i=0; i != vs_nb->size; ++i) {
node *nb = vs_nb->data[i]; node *nb = vs_nb->data[i];
if(nb->marker == 0) { if(nb->marker == 0) {
nb->marker == 1; nb->marker = 1;
vset_add(vs, nb); vset_add(vs, nb);
vset_add(s, nb); vset_add(&s, nb);
} }
} }
vset_destroy(vs_nb); vset_destroy(vs_nb);
free(vs_nb); free(vs_nb);
} }
vset_destroy(s); vset_destroy(&s);
free(s);
return vs; return vs;
} }
@ -156,33 +150,34 @@ graph_connected_nodes(graph *g, node *n)
vset * vset *
graph_disjunct_graphs(graph *g) graph_disjunct_graphs(graph *g)
{ {
vset *dg = malloc(sizeof(vset)); vset * dg = malloc(sizeof(vset));
vset *nodes = malloc(sizeof(vset)); vset nodes;
vset_init(nodes); vset_init(dg);
vset_concat(nodes, g->nodes); vset_init(&nodes);
vset_concat(&nodes, &g->nodes);
while(nodes->size > 0) { while(nodes.size > 0) {
graph *gt = malloc(sizeof(graph)); graph *gt = malloc(sizeof(graph));
vset s; vset s;
int i; unsigned int i;
node *start; node *start;
graph_init(gt); graph_init(gt);
start = vset_pop(nodes); start = vset_pop(&nodes);
graph_resetmarkers(g); graph_resetmarkers(g);
graph_add_node(gt, start); graph_add_node(gt, start);
start->marker = 1; start->marker = 1;
vset_init(&s); vset_init(&s);
vset_add(&s,start); vset_add(&s,start);
while(s.size > 0) { 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) { for(i=0; i != nbs->size; ++i) {
node *nb = nbs->data[i]; node *nb = nbs->data[i];
if(nb->marker == 0) { if(nb->marker == 0) {
nb->marker = 1; nb->marker = 1;
graph_add_node(gt,nb); graph_add_node(gt,nb);
vset_erase(nodes,nb); vset_erase(&nodes,nb);
vset_add(&s,nb); vset_add(&s,nb);
} }
} }
@ -191,18 +186,17 @@ graph_disjunct_graphs(graph *g)
vset_destroy(&s); vset_destroy(&s);
for(i=0;i != g->vertices->size; ++i) { for(i=0;i != g->edges.size; ++i) {
vertex *v = g->vertices->data[i]; edge *v = g->edges.data[i];
if(vset_count(g->nodes, v->node1)) { if(vset_count(&g->nodes, v->node1)) {
graph_add_vertex(gt,v); graph_add_edge(gt, v);
} }
} }
vset_add(dg, gt); vset_add(dg, gt);
} }
vset_destroy(nodes); vset_destroy(&nodes);
free(nodes);
return dg; return dg;
} }

View File

@ -8,26 +8,25 @@
This program may not be used, modified or distributed This program may not be used, modified or distributed
without prior permission by the authors of Eressea. 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 #ifndef GRAPH_H
#define GRAPH_H #define GRAPH_H
typedef struct { typedef struct node {
int marker; int marker;
void *object; void *object;
} node; } node;
typedef struct { typedef struct edge {
int marker; int marker;
node *node1; node *node1;
node *node2; node *node2;
} vertex; } edge;
typedef struct { typedef struct graph {
vset *nodes; vset nodes;
vset *vertices; vset edges;
} graph; } graph;
#endif #endif

View File

@ -1,6 +1,6 @@
/* vi: set ts=2: /* 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 * Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de) * Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de) * Katja Zedel (katze@felidae.kn-bremen.de)
@ -137,7 +137,7 @@ reverse_lookup(const locale * lang, const char * str)
{ {
int i; int i;
if (lang==NULL) lang = default_locale; if (lang==NULL) lang = default_locale;
assert(lang!=NULL); if (lang!=NULL) {
for (i=0;i!=SMAXHASH;++i) { for (i=0;i!=SMAXHASH;++i) {
struct locale_string * ls; struct locale_string * ls;
for (ls=lang->strings[i];ls;ls=ls->nexthash) { for (ls=lang->strings[i];ls;ls=ls->nexthash) {
@ -145,5 +145,6 @@ reverse_lookup(const locale * lang, const char * str)
if (strcasecmp(ls->str, str)==0) return ls->key; if (strcasecmp(ls->str, str)==0) return ls->key;
} }
} }
}
return str; return str;
} }

View File

@ -421,6 +421,15 @@ eval_localize(opstack ** stack, const void * userdata) /* (string, locale) -> st
unused(userdata); 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 void
translation_init(void) translation_init(void)
{ {
@ -429,6 +438,7 @@ translation_init(void)
add_function("add", &eval_add); add_function("add", &eval_add);
add_function("if", &eval_if); add_function("if", &eval_if);
add_function("localize", &eval_localize); add_function("localize", &eval_localize);
add_function("locale", &eval_locale);
} }
void void

View File

@ -1,6 +1,6 @@
/* vi: set ts=2: /* 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 * Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de) * Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de) * Katja Zedel (katze@felidae.kn-bremen.de)
@ -44,6 +44,7 @@
/* gamecode includes */ /* gamecode includes */
#include <creation.h> #include <creation.h>
#include <goodies.h>
#include <laws.h> #include <laws.h>
/* kernel includes */ /* kernel includes */
@ -59,7 +60,6 @@
#include <region.h> #include <region.h>
#include <save.h> #include <save.h>
#include <ship.h> #include <ship.h>
#include <time.h>
#include <border.h> #include <border.h>
#include <region.h> #include <region.h>
#include <item.h> #include <item.h>
@ -73,6 +73,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <ctype.h> #include <ctype.h>
#include <string.h> #include <string.h>
#include <time.h>
#include <locale.h> #include <locale.h>
/** /**
@ -91,6 +92,10 @@ extern boolean nobattle;
extern boolean nobattledebug; extern boolean nobattledebug;
static boolean printpotions; static boolean printpotions;
extern void debug_messagetypes(FILE * out);
extern void freeland(land_region * lr);
extern void render_init(void);
#ifdef FUZZY_BASE36 #ifdef FUZZY_BASE36
extern int fuzzy_hits; extern int fuzzy_hits;
#endif /* FUZZY_BASE36 */ #endif /* FUZZY_BASE36 */
@ -98,12 +103,13 @@ extern int fuzzy_hits;
/** /**
** global variables wthat we are exporting ** global variables wthat we are exporting
**/ **/
static char * orders = NULL;
static int nowrite = 0;
struct settings global = { struct settings global = {
"Eressea", /* gamename */ "Eressea", /* gamename */
}; };
extern void render_init(void);
static void static void
print_potions(FILE * F) 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 static void
game_init(void) game_init(void)
{ {
@ -160,7 +162,7 @@ game_init(void)
} }
} }
void static void
create_game(void) create_game(void)
{ {
assert(regions==NULL || !"game is initialized"); assert(regions==NULL || !"game is initialized");
@ -198,8 +200,6 @@ getgarbage(void)
#endif #endif
} }
int quickleave = 0;
static void static void
writepasswd(void) writepasswd(void)
{ {
@ -265,8 +265,6 @@ processturn(char *filename)
return 0; return 0;
} }
extern void freeland(land_region * lr);
static void static void
game_done(void) game_done(void)
{ {
@ -336,33 +334,6 @@ game_done(void)
#include "magic.h" #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 #if MALLOCDBG
static void static void
init_malloc_debug(void) init_malloc_debug(void)

View File

@ -3,6 +3,7 @@
#include "order.h" #include "order.h"
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <assert.h> #include <assert.h>
void void

View File

@ -1,6 +1,6 @@
/* vi: set ts=2: /* 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 * Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de) * Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.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: case ST_FLEE:
sncat(buf, ", flieht", BUFSIZE); sncat(buf, ", flieht", BUFSIZE);
break; break;
default:
sncat(buf, ", unbekannt", BUFSIZE);
break;
} }
sncat(buf, " (", BUFSIZE); icat(u->hp/u->number); sncat(buf, " HP)", BUFSIZE); sncat(buf, " (", BUFSIZE); icat(u->hp/u->number); sncat(buf, " HP)", BUFSIZE);

View File

@ -3807,11 +3807,11 @@
<arg name="ship" type="ship"></arg> <arg name="ship" type="ship"></arg>
<arg name="region" type="region"></arg> <arg name="region" type="region"></arg>
<arg name="damage" type="int"></arg> <arg name="damage" type="int"></arg>
<arg name="sink" type="string"></arg> <arg name="sink" type="int"></arg>
</type> </type>
<locale name="de"> <locale name="de">
<nr section="events"> <nr section="events">
<text>"Die $ship($ship) fährt in den Mahlstrom von $region($region) und nimmt $int($damage) Schaden$sink."</text> <text>"Die $ship($ship) fährt in den Mahlstrom von $region($region) und nimmt $int($damage) Schaden$if($sink," und sinkt","")."</text>
</nr> </nr>
</locale> </locale>
</message> </message>
@ -3820,11 +3820,11 @@
<type> <type>
<arg name="ship" type="ship"></arg> <arg name="ship" type="ship"></arg>
<arg name="region" type="region"></arg> <arg name="region" type="region"></arg>
<arg name="sink" type="string"></arg> <arg name="sink" type="int"></arg>
</type> </type>
<locale name="de"> <locale name="de">
<nr section="events"> <nr section="events">
<text>"Die $ship($ship) wird in $region($region) von Stürmen abgetrieben$sink."</text> <text>"Die $ship($ship) wird in $region($region) von Stürmen abgetrieben$if($sink," und sinkt","")."</text>
</nr> </nr>
</locale> </locale>
</message> </message>
@ -4243,11 +4243,11 @@
<type> <type>
<arg name="unit" type="unit"></arg> <arg name="unit" type="unit"></arg>
<arg name="amount" type="int"></arg> <arg name="amount" type="int"></arg>
<arg name="type" type="string"></arg> <arg name="type" type="resource"></arg>
</type> </type>
<locale name="de"> <locale name="de">
<nr section="events"> <nr section="events">
<text>"$unit($unit) schließen sich $int($amount) $type an."</text> <text>"$unit($unit) $if($eq($amount,1),"schließt","schließen") sich $int($amount) $resource($type,$amount) an."</text>
</nr> </nr>
</locale> </locale>
</message> </message>
@ -4292,13 +4292,18 @@
<message name="researchherb"> <message name="researchherb">
<type> <type>
<arg name="unit" type="unit"></arg> <arg name="unit" type="unit"></arg>
<arg name="region" type="region"></arg> <arg name="amount" type="string"></arg>
<arg name="amount" type="int"></arg>
<arg name="herb" type="resource"></arg> <arg name="herb" type="resource"></arg>
<arg name="region" type="region"></arg>
</type> </type>
<locale name="de"> <locale name="de">
<nr section="events"> <nr section="events">
<text>"$unit($unit) in $region($region) stellt fest, daß es hier $int($amount) $resource($herb,$amount) gibt."</text> <text>"$unit($unit) in $region($region) stellt fest, daß es hier $localize($amount,$locale("en")) $resource($herb,$amount) gibt."</text>
</nr>
</locale>
<locale name="en">
<nr section="none">
<text>"$unit($unit) discovers that $localize($amount,$locale("en")) $resource($herb,$amount) grow in $region($region)."</text>
</nr> </nr>
</locale> </locale>
</message> </message>
@ -6390,11 +6395,16 @@
<type> <type>
<arg name="region" type="region"></arg> <arg name="region" type="region"></arg>
<arg name="building" type="building"></arg> <arg name="building" type="building"></arg>
<arg name="opfer" type="unit"></arg> <arg name="opfer" type="int"></arg>
</type> </type>
<locale name="de"> <locale name="de">
<nr section="events"> <nr section="events">
<text>"In $region($region) stürzte $building($building) ein.$unit($opfer)"</text> <text>"In $region($region) stürzte $building($building) ein.$if($opfer," $int($opfer) Opfer sind zu beklagen.","")"</text>
</nr>
</locale>
<locale name="en">
<nr section="events">
<text>"$building($building) in $region($region) collapses.$if($opfer," There are $int($opfer) caualties.","")"</text>
</nr> </nr>
</locale> </locale>
</message> </message>

View File

@ -3091,11 +3091,11 @@
<type> <type>
<arg name="ship" type="ship"></arg> <arg name="ship" type="ship"></arg>
<arg name="region" type="region"></arg> <arg name="region" type="region"></arg>
<arg name="sink" type="string"></arg> <arg name="sink" type="int"></arg>
</type> </type>
<locale name="en"> <locale name="en">
<nr section="none"> <nr section="none">
<text>"The $ship($ship) in $region($region) drifts $sink in heavy storm."</text> <text>"The $ship($ship) in $region($region) drifts in heavy storm$if($sink," and sinks","")."</text>
</nr> </nr>
</locale> </locale>
</message> </message>
@ -3705,7 +3705,7 @@
</type> </type>
<locale name="en"> <locale name="en">
<nr section="none"> <nr section="none">
<text>"$unit($mage) found out that $region($region) is charmed with $spell, which will last for centuries."</text> <text>"$unit($mage) discovers that $region($region) is charmed with $spell, which will last for centuries."</text>
</nr> </nr>
</locale> </locale>
</message> </message>
@ -3718,7 +3718,7 @@
</type> </type>
<locale name="en"> <locale name="en">
<nr section="none"> <nr section="none">
<text>"$unit($mage) found out that $unit($unit) is charmed with $spell, which will last for centuries."</text> <text>"$unit($mage) discovers that $unit($unit) is charmed with $spell, which will last for centuries."</text>
</nr> </nr>
</locale> </locale>
</message> </message>
@ -3731,7 +3731,7 @@
</type> </type>
<locale name="en"> <locale name="en">
<nr section="none"> <nr section="none">
<text>"$unit($mage) found out that $building($building) is charmed with $spell, which will last for centuries."</text> <text>"$unit($mage) discovers that $building($building) is charmed with $spell, which will last for centuries."</text>
</nr> </nr>
</locale> </locale>
</message> </message>
@ -3744,7 +3744,7 @@
</type> </type>
<locale name="en"> <locale name="en">
<nr section="none"> <nr section="none">
<text>"$unit($mage) found out that $ship($ship) is charmed with $spell, which will last for centuries."</text> <text>"$unit($mage) discovers that $ship($ship) is charmed with $spell, which will last for centuries."</text>
</nr> </nr>
</locale> </locale>
</message> </message>
@ -3758,7 +3758,7 @@
</type> </type>
<locale name="en"> <locale name="en">
<nr section="none"> <nr section="none">
<text>"$unit($mage) found out that $region($region) is charmed with $spell, which will last for, about $int($months) more weeks."</text> <text>"$unit($mage) discovers that $region($region) is charmed with $spell, which will last for, about $int($months) more weeks."</text>
</nr> </nr>
</locale> </locale>
</message> </message>
@ -3772,7 +3772,7 @@
</type> </type>
<locale name="en"> <locale name="en">
<nr section="none"> <nr section="none">
<text>"$unit($mage) found out that $unit($unit) is charmed with $spell that willlast for about $int($months) more weeks."</text> <text>"$unit($mage) discovers that $unit($unit) is charmed with $spell that willlast for about $int($months) more weeks."</text>
</nr> </nr>
</locale> </locale>
</message> </message>
@ -3786,7 +3786,7 @@
</type> </type>
<locale name="en"> <locale name="en">
<nr section="none"> <nr section="none">
<text>"$unit($mage) found out that $building($building) is charmed with $spell, which will last for, about $int($months) more weeks."</text> <text>"$unit($mage) discovers that $building($building) is charmed with $spell, which will last for, about $int($months) more weeks."</text>
</nr> </nr>
</locale> </locale>
</message> </message>
@ -3800,7 +3800,7 @@
</type> </type>
<locale name="en"> <locale name="en">
<nr section="none"> <nr section="none">
<text>"$unit($mage) found out that $ship($ship) is charmed with $spell, which will last for, about $int($months) more weeks."</text> <text>"$unit($mage) discovers that $ship($ship) is charmed with $spell, which will last for, about $int($months) more weeks."</text>
</nr> </nr>
</locale> </locale>
</message> </message>
@ -3939,20 +3939,6 @@
</locale> </locale>
</message> </message>
<message name="researchherb">
<type>
<arg name="unit" type="unit"></arg>
<arg name="amount" type="int"></arg>
<arg name="herb" type="resource"></arg>
<arg name="region" type="region"></arg>
</type>
<locale name="en">
<nr section="none">
<text>"$unit($unit) found out that $int($amount) $resource($herb,$amount) grow in $region($region)."</text>
</nr>
</locale>
</message>
<message name="researchherb_none"> <message name="researchherb_none">
<type> <type>
<arg name="unit" type="unit"></arg> <arg name="unit" type="unit"></arg>

View File

@ -15,6 +15,14 @@ section_study;en;Learning and Teaching
section_battle;en;Battles section_battle;en;Battles
section_none;en;Miscellaneous section_none;en;Miscellaneous
# Burgausbaustufen
site;en;site
fortification;en;fortification
tower;en;tower
castle;en;castle
fortress;en;fortress
citadel;en;citadel
# Items # Items
herb;en;herb herb;en;herb
herbbag;en;herbbag herbbag;en;herbbag