- Neue Messages fertig

Messages werden jetzt in einem anderen Meta-Format (message* of 
  message_type*) gespeichert, das man in beliebige Formate (CR oder NR) 
  rendern kann. crmessage.c und nrmessage.c sind die render-engines dafür.
  Die Messagetypen werden in res/{de,en}/messages.xml gesammelt, ultimativ
  kann das aber durchaus eine einzelne Datei sein. Die ist derzeit nicht 
  wirklich xml (Umlaute drin, keine Definitionsdatei), aber gut lesbar.

- make_message
  Diese Funktion ersetzt new_message, und ist etwas einfacher in der Syntax:
  make_message("dumb_mistake", "unit region command", u, r, cmd) erzeugt
  eine neue Nachricht, die dann einfach mit add_message wie bisher an die
  Nachrichtenliste gehängt werden kann.
  TODO: Messages könnte man durchaus reference-counten, und in mehrere Listen
  einfügen, solang sie a) mehrfachverwendet (Kampf!) und b) vom Betrachter
  unabhängig sind. Das spart einigen Speicher.

- CR Version erhöht.
  Weil die MESSAGETYPES Blocks anders sind als früher

- OFFENSIVE_DELAY
  Verbietet Einheiten, deren Partei eine Reigon niht bewachen, den 
  Angriff in der Region, wenn sie sich in der Runde zuvor bewegt haben.
  Status der letzten Runde wird in neuem Attribut at_moved gespeichert.

- SHORT_ATTACKS
  ein define, das angibt ob Kämpfen grundsätzlich keine lange Aktion ist.

- XML Parser
  xml.[hc] enthält einen XML-Parser, dem man ein plugin mit callbacks
  übergibt, die nach dem Parsen eines tokens aufgerufen werden.
This commit is contained in:
Enno Rehling 2001-04-12 17:21:57 +00:00
parent c4ce2efdc7
commit 1e51d0e9e2
83 changed files with 9483 additions and 3626 deletions

View file

@ -111,7 +111,7 @@ ifeq (.depend,$(wildcard .depend))
include .depend
endif
# Create dependencies
.depend depend:: $(SOURCES)
depend:: $(SOURCES)
@echo "Creating dependencies in `pwd`/.depend";
$(DEPEND) $(CFLAGS) $(DEFINES) $(INCDIRS) $(SOURCES) >| .depend
endif
@ -175,7 +175,7 @@ $(BUILD_DIR) $(PUBLISH_DIR):
# object files:
$(BUILD_DIR)/%:: $(BUILD_DIR)
$(BUILD_DIR)/%.o:: %.c .depend
$(BUILD_DIR)/%.o:: %.c
@echo $(MSG_COMPILE)
$(CC) $(CFLAGS) -o $@ -c $<
@echo

View file

@ -1,6 +1,5 @@
/* vi: set ts=2:
*
* $Id: attributes.c,v 1.10 2001/02/28 22:14: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)
@ -26,9 +25,13 @@
#include "iceberg.h"
#include "hate.h"
#include "overrideroads.h"
#include "racename.h"
#ifdef AT_OPTION
# include "option.h"
#endif
#ifdef AT_MOVED
# include "moved.h"
#endif
/* util includes */
#include <attrib.h>
@ -40,24 +43,20 @@
void
init_attributes(void)
{
/* at_register(&at_orcification); */
at_register(&at_overrideroads);
/* at_iceberg */
init_iceberg();
/* at_key */
init_key();
/* at_gm */
init_gm();
/* at_follow */
init_follow();
/* at_targetregion */
init_targetregion();
/* at_orcification */
init_orcification();
/* at_hate */
init_hate();
/* at_reduceproduction */
init_reduceproduction();
init_racename();
#ifdef AT_MOVED
init_moved();
#endif
#ifdef AT_OPTION
init_option();
#endif

View file

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: key.c,v 1.2 2001/01/26 16:19:39 enno Exp $
* $Id: key.c,v 1.3 2001/04/12 17:21:41 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)
@ -34,6 +34,14 @@ make_key(int key)
return a;
}
attrib *
find_key(attrib * alist, int key)
{
attrib * a = a_find(alist, &at_key);
while (a && a->data.i != key) a = a->nexttype;
return a;
}
void
init_key(void)
{

View file

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: key.h,v 1.2 2001/01/26 16:19:39 enno Exp $
* $Id: key.h,v 1.3 2001/04/12 17:21:41 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)
@ -15,4 +15,5 @@
extern struct attrib_type at_key;
extern struct attrib * make_key(int key);
extern struct attrib * find_key(struct attrib * alist, int key);
extern void init_key(void);

View file

@ -0,0 +1,62 @@
/* vi: set ts=2:
*
* $Id: moved.c,v 1.1 2001/04/12 17:21:41 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)
* Henning Peters (faroul@beyond.kn-bremen.de)
* Enno Rehling (enno@eressea-pbem.de)
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
*
* This program may not be used, modified or distributed without
* prior permission by the authors of Eressea.
*/
#include <config.h>
#include <eressea.h>
#include "moved.h"
#include <attrib.h>
static int
age_moved(attrib * a)
{
return a->data.i-- > 0;
}
static void
write_moved(const attrib * a, FILE * F)
{
fprintf(F, "%d", a->data.i);
}
static int
read_moved(attrib * a, FILE * F)
{
fscanf(F, "%d", &a->data.i);
return a->data.i!=0;
}
attrib_type at_moved = {
"moved", NULL, NULL, age_moved, write_moved, read_moved
};
boolean
get_moved(attrib ** alist)
{
return a_find(*alist, &at_moved) ? true : false;
}
void
set_moved(attrib ** alist)
{
attrib * a = a_find(*alist, &at_moved);
if (a==NULL) a = a_add(alist, a_new(&at_moved));
a->data.i = 1;
}
void
init_moved(void)
{
at_register(&at_moved);
}

View file

@ -0,0 +1,23 @@
/* vi: set ts=2:
*
* $Id: moved.h,v 1.1 2001/04/12 17:21:41 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)
* Henning Peters (faroul@beyond.kn-bremen.de)
* Enno Rehling (enno@eressea-pbem.de)
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
*
* This program may not be used, modified or distributed without
* prior permission by the authors of Eressea.
*/
struct attrib;
struct attrib_type;
extern boolean get_moved(attrib ** alist);
extern void set_moved(struct attrib ** alist);
extern void init_moved(void);
extern struct attrib_type at_moved;

View file

@ -0,0 +1,58 @@
/* vi: set ts=2:
*
* $Id: racename.c,v 1.2 2001/04/12 17:21:41 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)
* Henning Peters (faroul@beyond.kn-bremen.de)
* Enno Rehling (enno@eressea-pbem.de)
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
*
* This program may not be used, modified or distributed without
* prior permission by the authors of Eressea.
*/
#include <config.h>
#include <eressea.h>
#include "racename.h"
#include <attrib.h>
/* libc includes */
#include <stdlib.h>
#include <string.h>
attrib_type at_racename = {
"racename", NULL, a_finalizestring, NULL, a_writestring, a_readstring
};
const char *
get_racename(attrib * alist)
{
attrib * a = a_find(alist, &at_racename);
if (a) return (const char *)a->data.v;
return NULL;
}
void
set_racename(attrib ** palist, const char * name)
{
attrib * a = a_find(*palist, &at_racename);
if (!a && name) {
a = a_add(palist, a_new(&at_racename));
a->data.v = strdup(name);
} else if (a && !name) {
a_remove(palist, a);
} else if (a) {
if (strcmp(a->data.v, name)!=0) {
free(a->data.v);
a->data.v = strdup(name);
}
}
}
void
init_racename(void)
{
at_register(&at_racename);
}

View file

@ -0,0 +1,22 @@
/* vi: set ts=2:
*
* $Id: racename.h,v 1.2 2001/04/12 17:21:41 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)
* Henning Peters (faroul@beyond.kn-bremen.de)
* Enno Rehling (enno@eressea-pbem.de)
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
*
* This program may not be used, modified or distributed without
* prior permission by the authors of Eressea.
*/
struct attrib_type;
struct attrib;
extern void set_racename(struct attrib ** palist, const char * name);
extern const char * get_racename(struct attrib * alist);
extern void init_racename(void);
extern struct attrib_type at_racename;

View file

@ -7,26 +7,24 @@
* Enno Rehling (enno@eressea-pbem.de)
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
*
* based on:
*
* Atlantis v1.0 13 September 1993 Copyright 1993 by Russell Wallace
* Atlantis v1.7 Copyright 1996 by Alex Schröder
*
* This program may not be used, modified or distributed without
* prior permission by the authors of Eressea.
* This program may not be sold or used commercially without prior written
* permission from the authors.
*/
#include <config.h>
#include <eressea.h>
#include "creport.h"
/* tweakable features */
#define ENCODE_SPECIAL 1
#define RENDER_CRMESSAGES 1
/* modules include */
#include <modules/score.h>
/* attributes include */
#include <attributes/follow.h>
#include <attributes/racename.h>
/* gamecode includes */
#include "laws.h"
@ -46,7 +44,6 @@
#include <plane.h>
#include <race.h>
#include <region.h>
#include <render.h>
#include <reports.h>
#include <ship.h>
#include <skill.h>
@ -55,10 +52,11 @@
#include <save.h>
/* util includes */
#include <util/message.h>
#include <goodies.h>
#ifdef NEW_MESSAGES
#include <crmessage.h>
#endif
#include <nrmessage.h>
/* libc includes */
#include <math.h>
#include <stdio.h>
@ -66,15 +64,15 @@
#include <stdlib.h>
#include <string.h>
#define C_REPORT_VERSION 56
#define NEWBLOCKS (C_REPORT_VERSION>=35)
#define ENCODE_SPECIAL 1
/* imports */
extern const char *directions[];
extern const char *spelldata[];
extern int quiet;
/* globals */
#define C_REPORT_VERSION 57
/* implementation */
void
cr_output_str_list(FILE * F, const char *title, const strlist * S, faction * f)
{
@ -124,181 +122,174 @@ print_curses(FILE * F, void * obj, typ_t typ, attrib *a, int self)
}
}
#ifdef OLD_MESSAGES
#define CTMAXHASH 511
struct crtype {
struct crtype * nexthash;
struct message_type * mt;
} * crtypes[CTMAXHASH];
static int
cr_unit(const void * v, char * buffer, const void * userdata)
{
const faction * report = (const faction*)userdata;
unit * u = (unit *)v;
sprintf(buffer, "%d", u?u->no:-1);
unused(report);
return 0;
}
static struct crtype * free_crtypes;
#endif
static int
cr_ship(const void * v, char * buffer, const void * userdata)
{
const faction * report = (const faction*)userdata;
ship * u = (ship *)v;
sprintf(buffer, "%d", u?u->no:-1);
unused(report);
return 0;
}
static int
cr_building(const void * v, char * buffer, const void * userdata)
{
const faction * report = (const faction*)userdata;
building * u = (building *)v;
sprintf(buffer, "%d", u?u->no:-1);
unused(report);
return 0;
}
static int
cr_faction(const void * v, char * buffer, const void * userdata)
{
const faction * report = (const faction*)userdata;
faction * f = (faction *)v;
sprintf(buffer, "%d", f?f->no:-1);
unused(report);
return 0;
}
static int
cr_region(const void * v, char * buffer, const void * userdata)
{
const faction * report = (const faction*)userdata;
region * r = (region *)v;
if (r) {
plane * p = rplane(r);
if (!p || !(p->flags & PFL_NOCOORDS)) {
sprintf(buffer, "%d %d %d", region_x(r, report), region_y(r, report), p?p->id:0);
return 0;
}
}
return -1;
}
static int
cr_resource(const void * v, char * buffer, const void * userdata)
{
const faction * report = (const faction*)userdata;
const resource_type * r = (const resource_type *)v;
if (r) {
sprintf(buffer, "\"%s\"", locale_string(report->locale, resourcename(r, 0)));
return 0;
}
return -1;
}
static int
cr_skill(const void * v, char * buffer, const void * userdata)
{
const faction * report = (const faction*)userdata;
skill_t sk = (skill_t)v;
if (sk!=NOSKILL) sprintf(buffer, "\"%s\"", locale_string(report->locale, skillnames[sk]));
else strcpy(buffer, "\"\"");
return 0;
}
void
creport_init(void)
{
tsf_register("report", &cr_ignore);
tsf_register("string", &cr_string);
tsf_register("int", &cr_int);
tsf_register("unit", &cr_unit);
tsf_register("region", &cr_region);
tsf_register("faction", &cr_faction);
tsf_register("ship", &cr_ship);
tsf_register("building", &cr_building);
tsf_register("skill", &cr_skill);
tsf_register("resource", &cr_resource);
}
void
creport_cleanup(void)
{
#ifdef OLD_MESSAGES
while (free_crtypes) {
struct crtype * ct = free_crtypes->nexthash;
free_crtypes = ct;
}
#endif
}
#ifdef OLD_MESSAGES
static int msgno;
#define MTMAXHASH 1023
static struct known_mtype {
const struct message_type * mtype;
struct known_mtype * nexthash;
} * mtypehash[MTMAXHASH];
static void
render_message(FILE * f, faction * receiver, struct message * m)
report_crtypes(FILE * F, const struct locale* lang)
{
int i;
struct message_type * mt = m->type;
struct entry * e = mt->entries;
if (m->receiver && receiver!=m->receiver) return;
if (m->receiver && get_msglevel(receiver->warnings, receiver->msglevels, m->type) < msg_level(m))
return;
fprintf(f, "MESSAGE %u\n", receiver->index++);
fprintf(f, "%u;type\n", mt->hashkey);
if (receiver->options & want(O_DEBUG)) {
fprintf(f, "%d;level\n", mt->level);
}
#define RENDER_CR
#ifdef RENDER_CR
fprintf(f, "\"%s\";rendered\n", render(m, receiver->locale));
#endif
for (i=0;i!=mt->argc;++i) {
switch (e->type) {
case IT_RESOURCE:
fprintf(f, "\"%s\";%s\n", resname((resource_t)m->data[i], 0), e->name);
break;
case IT_RESOURCETYPE:
fprintf(f, "\"%s\";%s\n", locale_string(receiver->locale, resourcename((const resource_type *)m->data[i], 1)), e->name);
break;
case IT_STRING:
fprintf(f, "\"%s\";%s\n", (char*)m->data[i], e->name);
break;
case IT_BUILDING: {
building * b = (building*)m->data[i];
fprintf(f, "%d;%s\n", b->no, e->name);
break;
}
case IT_SHIP: {
ship * s = (ship*)m->data[i];
fprintf(f, "%d;%s\n", s->no, e->name);
break;
}
case IT_UNIT: {
unit * u = (unit*)m->data[i];
/* TODO: Wilder Hack */
if ((int)u > 1) fprintf(f, "%d;%s\n", u->no, e->name);
break;
}
case IT_SKILL: {
skill_t sk = (skill_t)m->data[i];
assert(sk!=NOSKILL && sk<MAXSKILLS);
fprintf(f, "\"%s\";%s\n", skillnames[sk], e->name);
break;
}
case IT_FACTION: {
faction * x = (faction*)m->data[i];
fprintf(f, "%d;%s\n", x->no, e->name);
break;
}
case IT_REGION: {
region * r = (region*)m->data[i];
if (!r) break;
fprintf(f, "\"%d,%d\";%s\n", region_x(r, receiver), region_y(r, receiver), e->name);
break;
}
default:
fprintf(f, "%d;%s\n", (int)m->data[i], e->name);
break;
}
e = e->next;
}
}
static void
render_messages(FILE * f, void * receiver, struct message * msgs)
{
message * m;
for (m=msgs;m;m=m->next) {
render_message(f, receiver, m);
}
}
static void
cr_output_messages(FILE * F, struct message * msgs, faction * f)
{
message * m;
if (!msgs) return;
/* fprintf(F, "%s\n", title); */
for (m=msgs;m;m=m->next) {
static messagetype * last = NULL;
messagetype * mt = m->type;
#ifdef MSG_LEVELS
if (get_msglevel(f->warnings, f->msglevels, mt) < m->level) continue;
#endif
if (mt!=last && (!m->receiver || f==m->receiver)) {
unsigned int index = mt->hashkey % CTMAXHASH;
struct crtype * ct = crtypes[index];
last = mt;
while (ct && ct->mt->hashkey!=mt->hashkey) ct=ct->nexthash;
if (!ct) {
if (free_crtypes) {
ct = free_crtypes;
free_crtypes = free_crtypes->nexthash;
} else {
ct = calloc(1, sizeof(struct crtype));
}
ct->mt = mt;
ct->nexthash = crtypes[index];
crtypes[index] = ct;
fputs("MESSAGETYPES\n", F);
for (i=0;i!=MTMAXHASH;++i) {
struct known_mtype * kmt;
for (kmt=mtypehash[i];kmt;kmt=kmt->nexthash) {
const struct nrmessage_type * nrt = nrt_find(lang, kmt->mtype);
if (nrt) {
unsigned int hash = hashstring(mt_name(kmt->mtype));
fputc('\"', F);
fputs(escape_string(nrt_string(nrt), NULL, 0), F);
fprintf(F, "\";%d\n", hash);
}
}
}
render_messages(F, f, msgs);
}
extern void rendercr(FILE * f, struct messagetype * mt, const locale * lang);
static void
report_crtypes(FILE * f, locale * lang)
{
int i;
fputs("MESSAGETYPES\n", f);
for (i=0;i!=CTMAXHASH;++i) {
struct crtype * ct;
for (ct=crtypes[i];ct;ct=ct->nexthash) {
rendercr(f, ct->mt, lang);
while (mtypehash[i]) {
kmt = mtypehash[i];
mtypehash[i] = mtypehash[i]->nexthash;
free(kmt);
}
}
}
static void
reset_crtypes(void)
{
int i;
for (i=0;i!=CTMAXHASH;++i) {
struct crtype * ct;
struct crtype * next;
for (ct=crtypes[i];ct;ct=next) {
next = ct->nexthash;
ct->nexthash=free_crtypes;
free_crtypes=ct;
}
crtypes[i] = NULL;
}
}
#else
static void
render_messages(FILE * F, faction * f, message_list *msgs)
{
char buffer[1024];
struct mlist* m = msgs->begin;
while (m) {
if (cr_render(m->msg, f->locale, buffer)==0) fputs(buffer, F);
char crbuffer[1024];
boolean printed = false;
const struct message_type * mtype = m->msg->type;
unsigned int hash = hashstring(mtype->name);
#if RENDER_CRMESSAGES
char nrbuffer[4096];
nrbuffer[0] = '\0';
if (nr_render(m->msg, f->locale, nrbuffer, f)==0 && nrbuffer[0]) {
fprintf(F, "MESSAGE %d\n", ++msgno);
fprintf(F, "%d;type\n", hash);
fputs("\"", F);
fputs(nrbuffer, F);
fputs("\";rendered\n", F);
printed = true;
}
#endif
crbuffer[0] = '\0';
if (cr_render(m->msg, crbuffer, (const void*)f)==0 && crbuffer[0]) {
if (!printed) fprintf(F, "MESSAGE %d\n", ++msgno);
fputs(crbuffer, F);
}
else log_error(("could not render cr-message %p\n", m->msg));
if (printed) {
unsigned int ihash = hash % MTMAXHASH;
struct known_mtype * kmt = mtypehash[ihash];
while (kmt && kmt->mtype != mtype) kmt = kmt->nexthash;
if (kmt==NULL) {
kmt = (struct known_mtype*)malloc(sizeof(struct known_mtype));
kmt->nexthash = mtypehash[ihash];
kmt->mtype = mtype;
mtypehash[ihash] = kmt;
}
}
m = m->next;
}
}
@ -306,11 +297,9 @@ render_messages(FILE * F, faction * f, message_list *msgs)
static void
cr_output_messages(FILE * F, message_list *msgs, faction * f)
{
render_messages(F, f, msgs);
if (msgs) render_messages(F, f, msgs);
}
#endif
/* prints a building */
static void
cr_output_buildings(FILE * F, building * b, unit * u, int fno, faction *f)
@ -409,6 +398,7 @@ cr_output_unit(FILE * F, region * r,
item *itm, *show;
boolean itemcloak = is_cursed(u->attribs, C_ITEMCLOAK, 0);
building * b;
const char * pzTmp;
skill_t sk;
strlist *S;
const attrib *a_fshidden = NULL;
@ -443,8 +433,11 @@ cr_output_unit(FILE * F, region * r,
fprintf(F, "%d;Anzahl\n", u->number);
}
fprintf(F, "\"%s\";Typ\n", race[u->irace].name[1]);
if (u->irace != u->race && u->faction==f) {
pzTmp = get_racename(u->attribs);
if (pzTmp==NULL) fprintf(F, "\"%s\";Typ\n", race[u->irace].name[1]);
else fprintf(F, "\"%s\";Typ\n", pzTmp);
if ((pzTmp || u->irace != u->race) && u->faction==f) {
fprintf(F, "\"%s\";wahrerTyp\n", race[u->race].name[1]);
}
@ -631,7 +624,6 @@ cr_find_address(FILE * F, faction * uf)
void **fp;
cvector *fcts = malloc(sizeof(cvector));
#if NEWBLOCKS
cv_init(fcts);
for (f = factions; f; f = f->next) {
if (f->no != 0 && kann_finden(uf, f) != 0) {
@ -655,7 +647,6 @@ cr_find_address(FILE * F, faction * uf)
}
}
free(cv_kill(fcts));
#endif
}
/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
@ -729,9 +720,7 @@ report_computer(FILE * F, faction * f)
fflush(stdout);
}
else printf(" - schreibe Computerreport\n");
#ifdef OLD_MESSAGES
assert(crtypes[0]==NULL);
#endif
fprintf(F, "VERSION %d\n", C_REPORT_VERSION);
fprintf(F, "\"%s\";Spiel\n", global.gamename);
fprintf(F, "\"%s\";Konfiguration\n", "Standard");
@ -776,7 +765,6 @@ report_computer(FILE * F, faction * f)
}
#endif
f->index = 0;
cr_output_str_list(F, "FEHLER", f->mistakes, f);
cr_output_messages(F, f->msgs, f);
{
@ -1009,10 +997,5 @@ report_computer(FILE * F, faction * f)
}
} /* region traversal */
}
#ifdef OLD_MESSAGES
report_crtypes(F, f->locale);
reset_crtypes();
#else
/* TODO */
#endif
}

View file

@ -1 +1,5 @@
extern void creport_cleanup(void);
extern void creport_init(void);
extern void report_init(void);
extern void report_cleanup(void);

View file

@ -1,5 +1,6 @@
/* vi: set ts=2:
*
* $Id: economy.c,v 1.11 2001/04/12 17:21:42 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)
@ -62,7 +63,8 @@
#include <limits.h>
#include <attributes/reduceproduction.h>
extern attrib_type at_orcification;
#include <attributes/racename.h>
#include <attributes/orcification.h>
/* - static global symbols ------------------------------------- */
typedef struct spende {
@ -86,7 +88,7 @@ static int entertaining;
static int norders;
static request *oa;
int
int
income(const unit * u)
{
switch(u->race) {
@ -241,39 +243,47 @@ expandrecruit(region * r, request * recruitorders)
/* Rekrutierung */
int i, n, p = rpeasants(r), h = rhorses(r);
unit *u;
int recruitcost, rfrac = p / RECRUITFRACTION;
int rfrac = p / RECRUITFRACTION;
unit * u;
expandorders(r, recruitorders);
if (!norders) return;
for (i = 0, n = 0; i != norders && n < rfrac; i++, n++) {
if (!(race[oa[i].unit->race].ec_flags & REC_HORSES)) {
recruitcost = race[oa[i].unit->faction->race].rekrutieren;
if (use_pooled(oa[i].unit, r, R_SILVER, recruitcost) != recruitcost)
break;
set_number(oa[i].unit, oa[i].unit->number + 1);
if (oa[i].unit->faction->race != RC_DAEMON) p--;
oa[i].unit->race = oa[i].unit->faction->race;
oa[i].unit->n++;
for (i = 0, n = 0; i != norders; i++) {
unit * u = oa[i].unit;
race_t rc = u->faction->race;
int recruitcost = race[rc].rekrutieren;
/* check if recruiting is limited. either horses or peasant fraction or not at all */
if ((race[rc].ec_flags & ECF_REC_UNLIMITED)==0) {
/* not unlimited, and everything's gone: */
if (race[rc].ec_flags & ECF_REC_HORSES) {
/* recruit from horses if not all gone */
if (h <= 0) continue;
}
else if ((race[rc].ec_flags & ECF_REC_ETHEREAL) == 0) {
/* recruit from peasants if any space left */
if (n > rfrac) continue;
}
}
if (recruitcost) {
if (get_pooled(oa[i].unit, r, R_SILVER) < recruitcost) continue;
use_pooled(oa[i].unit, r, R_SILVER, recruitcost);
}
if ((race[rc].ec_flags & ECF_REC_UNLIMITED)==0) {
if (race[rc].ec_flags & ECF_REC_HORSES) h--; /* use a horse */
else {
if ((race[rc].ec_flags & ECF_REC_ETHEREAL)==0) p--; /* use a peasant */
n++;
}
set_number(u, u->number + 1);
u->race = rc;
u->n++;
}
}
assert(p>=0 && h>=0);
rsetpeasants(r, p);
for (i = 0, n = 0; i != norders && n < h; i++, n++) {
if (race[oa[i].unit->race].ec_flags & REC_HORSES) {
recruitcost = race[oa[i].unit->faction->race].rekrutieren;
if (use_pooled(oa[i].unit, r, R_SILVER, recruitcost) != recruitcost)
break;
set_number(oa[i].unit, oa[i].unit->number + 1);
if (oa[i].unit->faction->race != RC_DAEMON) h--;
oa[i].unit->race = oa[i].unit->faction->race;
oa[i].unit->n++;
}
}
rsethorses(r, h);
free(oa);
@ -286,7 +296,7 @@ expandrecruit(region * r, request * recruitorders)
change_skill(u, SK_SWORD, 30 * u->n);
change_skill(u, SK_SPEAR, 30 * u->n);
}
if (race[u->race].ec_flags & REC_HORSES) {
if (race[u->race].ec_flags & ECF_REC_HORSES) {
change_skill(u, SK_RIDING, 30 * u->n);
}
i = fspecial(u->faction, FS_MILITIA);
@ -351,7 +361,7 @@ recruit(region * r, unit * u, strlist * S,
}
if (fval(r, RF_ORCIFIED) && u->faction->race != RC_ORC &&
!(race[u->faction->race].ec_flags & REC_HORSES)) {
!(race[u->faction->race].ec_flags & ECF_REC_HORSES)) {
cmistake(u, S->s, 238, MSG_EVENT);
return;
}
@ -428,15 +438,14 @@ add_give(unit * u, unit * u2, int n, const resource_type * rtype, const char * c
else if (!u2 || u2->faction!=u->faction) {
assert(rtype);
add_message(&u->faction->msgs,
new_message(u->faction, "give%u:unit%u:target%r:region%X:resource%i:amount",
new_message(u->faction, "give%u:unit%u:target%X:resource%i:amount",
u,
u2?(cansee(u->faction, u->region, u2, 0)?u2:NULL):&u_peasants,
u->region, rtype, n));
rtype, n));
if (u2) add_message(&u2->faction->msgs,
new_message(u2->faction, "give%u:unit%u:target%r:region%X:resource%i:amount",
new_message(u2->faction, "give%u:unit%u:target%X:resource%i:amount",
u?(cansee(u2->faction, u2->region, u, 0)?u:NULL):&u_peasants,
u2,
u2->region, rtype, n));
u2, rtype, n));
}
}
@ -557,6 +566,7 @@ givemen(int n, unit * u, unit * u2, strlist * S)
if (!error) {
if (u2 && u2->number == 0) {
set_racename(&u2->attribs, get_racename(u->attribs));
u2->race = u->race;
u2->irace = u->irace;
} else if (u2 && u2->race != u->race) {
@ -709,9 +719,9 @@ giveunit(region * r, unit * u, unit * u2, strlist * S)
return;
}
add_message(&u2->faction->msgs,
new_message(u2->faction, "give%u:unit%u:target%r:region%X:resource%i:amount",
new_message(u2->faction, "give%u:unit%u:target%X:resource%i:amount",
u?&u_peasants:(cansee(u2->faction, u->region, u, 0)?u:NULL),
u2, u->region, r_unit, 1));
u2, r_unit, 1));
u_setfaction(u, u2->faction);
u2->faction->newbies += n;
@ -737,9 +747,9 @@ giveunit(region * r, unit * u, unit * u2, strlist * S)
}
}
add_message(&u->faction->msgs,
new_message(u->faction, "give%u:unit%u:target%r:region%X:resource%i:amount",
new_message(u->faction, "give%u:unit%u:target%X:resource%i:amount",
u, u2?&u_peasants:u2,
u->region, r_unit, 1));
r_unit, 1));
}
@ -1344,6 +1354,7 @@ manufacture(unit * u, const item_type * itype, int want)
}
if (n>0) {
i_change(&u->items, itype, n);
if (want==INT_MAX) want = n;
add_message(&u->faction->msgs,
new_message(u->faction, "manufacture%u:unit%r:region%i:amount%i:wanted%X:resource", u, u->region, n, want, itype->rtype));
}
@ -1579,6 +1590,7 @@ split_allocations(region * r)
i_change(&al->unit->items, itype, al->get);
change_skill(al->unit, itype->construction->skill, al->unit->number * PRODUCEEXP);
}
if (al->want==INT_MAX) al->want = al->get;
add_message(&al->unit->faction->msgs, new_message(al->unit->faction, "produce%u:unit%r:region%i:amount%i:wanted%X:resource", al->unit, al->unit->region, al->get, al->want, rtype));
}
*p_al=al->next;
@ -1631,6 +1643,7 @@ create_potion(unit * u, const potion_type * ptype, int want)
break;
default:
i_change(&u->items, ptype->itype, built);
if (want==INT_MAX) want = built;
add_message(&u->faction->msgs,
new_message(u->faction, "manufacture%u:unit%r:region%i:amount%i:wanted%X:resource", u, u->region, built, want, ptype->itype->rtype));
break;

View file

@ -38,25 +38,28 @@
#include <save.h>
#include <ship.h>
#include <skill.h>
#include "movement.h"
#include "monster.h"
#include "spy.h"
#include "race.h"
#include "battle.h"
#include "region.h"
#include "unit.h"
#include "plane.h"
#include "study.h"
#include "karma.h"
#include "pool.h"
#include "building.h"
#include "group.h"
#include <movement.h>
#include <monster.h>
#include <spy.h>
#include <race.h>
#include <battle.h>
#include <region.h>
#include <unit.h>
#include <plane.h>
#include <karma.h>
#include <pool.h>
#include <building.h>
#include <group.h>
/* gamecode includes */
#include "study.h"
#include "economy.h"
#include "creation.h"
#include "randenc.h"
/* attributes includes */
#include <attributes/racename.h>
/* util includes */
#include <event.h>
#include <base36.h>
@ -2270,7 +2273,7 @@ reorder_owners(region * r)
static attrib_type at_number = {
"faction_renum",
"faction_renum",
NULL, NULL, NULL, NULL, NULL,
ATF_UNIQUE
};
@ -2651,8 +2654,10 @@ new_units (void)
if (fval(u, FL_PARTEITARNUNG))
fset(u2, FL_PARTEITARNUNG);
/* Daemonentarnung */
if(u->race == RC_DAEMON)
set_racename(&u2->attribs, get_racename(u->attribs));
if(race[u->race].flags & RCF_SHAPESHIFT) {
u2->irace = u->irace;
}
S = S->next;
@ -3121,7 +3126,7 @@ count_migrants (const faction * f)
int n = 0;
while (u) {
assert(u->faction == f);
if (u->race != f->race && u->race != RC_ILLUSION && u->race != RC_SPELL
if (u->race != f->race && u->race != RC_ILLUSION && u->race != RC_SPELL
&& !nonplayer(u) && !(is_cursed(u->attribs, C_SLAVE, 0)))
{
n += u->number;

View file

@ -55,6 +55,9 @@
#include <attributes/targetregion.h>
#include <attributes/hate.h>
/* spezialmonster */
#include <spells/alp.h>
#ifdef HAVE_ZLIB
#include <zlib.h>
static gzFile dragonlog;
@ -461,6 +464,78 @@ set_movement_order(unit * u, const region * target, int moves, boolean (*allowed
}
/* ------------------------------------------------------------- */
void
monster_seeks_target(region *r, unit *u)
{
direction_t d;
strlist *S, **SP;
unit *target = NULL;
int dist, dist2;
direction_t i;
region *nr;
/* Das Monster sucht ein bestimmtes Opfer. Welches, steht
* in einer Referenz/attribut
* derzeit gibt es nur den alp
*/
switch( u->race ) {
case RC_ALP:
target = alp_target(u);
break;
default:
assert(!"Seeker-Monster gibt kein Ziel an");
}
/* TODO: prüfen, ob target überhaupt noch existiert... */
if( r == target->region ) { /* Wir haben ihn! */
switch( u->race ) {
case RC_ALP:
alp_findet_opfer(u, r);
break;
default:
assert(!"Seeker-Monster hat keine Aktion fuer Ziel");
}
return;
}
/* Simpler Ansatz: Nachbarregion mit gerinster Distanz suchen.
* Sinnvoll momentan nur bei Monstern, die sich nicht um das
* Terrain kümmern. Nebelwände & Co machen derzeit auch nix...
*/
dist2 = distance(r, target->region);
d = NODIRECTION;
for( i = 0; i < MAXDIRECTIONS; i++ ) {
nr = rconnect(r, i);
assert(nr);
dist = distance(nr, target->region);
if( dist < dist2 ) {
dist2 = dist;
d = i;
}
}
assert(d != NODIRECTION );
switch( u->race ) {
case RC_ALP:
if( !(u->age % 2) ) /* bewegt sich nur jede zweite Runde */
d = NODIRECTION;
break;
default:
break;
}
if( d == NODIRECTION )
return;
sprintf(buf, "%s %s", keywords[K_MOVE], directions[d]);
SP = &u->orders;
S = makestrlist(buf);
addlist2(SP, S);
*SP = 0;
}
/* ------------------------------------------------------------- */
unit *
random_unit(const region * r)
{
@ -921,6 +996,10 @@ plan_monsters(void)
case RC_ILLUSION:
if (u->no==atoi36("ponn")) ponnuki(u);
break;
/* Alp */
case RC_ALP:
monster_seeks_target(r, u);
break;
case RC_FIREDRAGON:
case RC_DRAGON:
case RC_WYRM:

View file

@ -1,6 +1,5 @@
/* vi: set ts=2:
*
* $Id: randenc.c,v 1.10 2001/04/01 06:58:36 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)
@ -45,6 +44,9 @@
#include "ship.h"
#include "battle.h"
/* attributes includes */
#include <attributes/racename.h>
/* util includes */
#include <rand.h>
@ -452,7 +454,10 @@ get_allies(region * r, unit * u)
}
u_setfaction(newunit, u->faction);
if (u->race==RC_DAEMON) newunit->irace=u->irace;
set_racename(&newunit->attribs, get_racename(u->attribs));
if(race[u->race].flags & RCF_SHAPESHIFT) {
newunit->irace = u->irace;
}
if (fval(u, FL_PARTEITARNUNG)) fset(newunit, FL_PARTEITARNUNG);
fset(u, FL_ISNEW);
@ -966,6 +971,9 @@ randomevents(void)
/* Orks vermehren sich */
for (r = regions; r; r = r->next) {
plane * p = rplane(r);
/* there is a flag for planes without orc growth: */
if (p && (p->flags & PFL_NOORCGROWTH)) continue;
for (u = r->units; u; u = u->next) {
if ( (u->race == RC_ORC || is_cursed(u->attribs, C_ORC, 0))
&& get_skill(u, SK_MAGIC) == 0
@ -1275,7 +1283,7 @@ randomevents(void)
set_skill(u, SK_AUSDAUER, u->number * 30);
set_skill(u, SK_STEALTH, u->number * 30);
fprintf(stderr, "%d %s in %s.\n", u->number,
race[u->race].name[1], tregionid(r, NULL));
race[u->race].name[1], regionname(r, NULL));
name_unit(u);
set_string(&u->lastorder, "WARTEN");
@ -1314,7 +1322,7 @@ randomevents(void)
/* Chance 0.1% * chaosfactor */
if (r->land && unburied > r->land->peasants / 20 && rand() % 10000 < (100 + 100 * chaosfactor(r))) {
/* es ist sinnfrei, wenn irgendwo im Wald 3er-Einheiten Untote entstehen.
/* es ist sinnfrei, wenn irgendwo im Wald 3er-Einheiten Untote entstehen.
* Lieber sammeln lassen, bis sie mindestens 5% der Bevölkerung sind, und
* dann erst auferstehen. */
int undead = unburied / (rand() % 2 + 1);
@ -1355,7 +1363,7 @@ randomevents(void)
name_unit(u);
fprintf(stderr, "%d %s in %s.\n", u->number,
race[u->race].name[1], tregionid(r, NULL));
race[u->race].name[1], regionname(r, NULL));
add_message(&r->msgs, new_message(NULL,
"undeadrise%r:region", r));
for (u=r->units;u;u=u->next) freset(u->faction, FL_DH);
@ -1406,7 +1414,7 @@ randomevents(void)
else
set_string(&u->name, "Wütende Ents");
fprintf(stderr, "%d Ents in %s.\n", u->number, tregionid(r, NULL));
fprintf(stderr, "%d Ents in %s.\n", u->number, regionname(r, NULL));
add_message(&r->msgs, new_message(NULL,
"entrise%r:region", r));
for (u=r->units;u;u=u->next) freset(u->faction, FL_DH);

View file

@ -7,15 +7,8 @@
* Enno Rehling (enno@eressea-pbem.de)
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
*
* based on:
*
* Atlantis v1.0 13 September 1993 Copyright 1993 by Russell Wallace
* Atlantis v1.7 Copyright 1996 by Alex Schröder
*
* This program may not be used, modified or distributed without
* prior permission by the authors of Eressea.
* This program may not be sold or used commercially without prior written
* permission from the authors.
*/
#define FAST_SEEN 0
@ -56,7 +49,6 @@
#include <pool.h>
#include <race.h>
#include <region.h>
#include <render.h>
#include <reports.h>
#include <save.h>
#include <ship.h>
@ -67,10 +59,10 @@
/* util includes */
#include <goodies.h>
#include <base36.h>
#ifdef NEW_MESSAGES
#include <nrmessage.h>
#include <translation.h>
#include <util/message.h>
#endif
/* libc includes */
#include <assert.h>
#include <ctype.h>
@ -732,29 +724,17 @@ rp_messages(FILE * F, message_list * msgs, faction * viewer, int indent, boolean
if (!msgs) return;
for (category=msgclasses; category; category=category->next) {
int k = 0;
#ifdef NEW_MESSAGES
struct mlist * m = msgs->begin;
#else
message_list * m = msgs;
#endif
while (m) {
boolean debug = viewer->options & want(O_DEBUG);
#ifdef MSG_LEVELS
if (!debug && get_msglevel(viewer->warnings, viewer->msglevels, m->type) < m->level) continue;
#endif
/* messagetype * mt = m->type; */
#ifdef NEW_MESSAGES
if (strcmp(nr_section(m->msg), category->name)==0)
#else
if (m->receiver==NULL || !viewer || viewer==m->receiver)
#endif
{
#ifdef OLD_MESSAGES
const char * s = render(m, viewer->locale);
#else
char buf[4096], *s = buf;
nr_render(m->msg, viewer->locale, s);
#endif
nr_render(m->msg, viewer->locale, s, viewer);
if (!k && categorized) {
const char * name;
char cat_identifier[24];
@ -2615,7 +2595,6 @@ void
reports(void)
{
faction *f;
region *r;
boolean gotit;
FILE *shfp, *F, *BAT;
int wants_report, wants_computer_report,
@ -2638,20 +2617,13 @@ reports(void)
wants_bzip2 = 1 << O_BZIP2;
printf("\n");
for (r=regions;r;r=r->next) {
invert_list(&r->msgs);
}
report_donations();
#if FAST_SEEN
init_intervals();
#endif
remove_empty_units();
for (f = factions; f; f = f->next) {
struct bmsg * b;
attrib * a = a_find(f->attribs, &at_reportspell);
for (b = f->battles;b;b=b->next)
invert_list(&b->msgs);
invert_list(&f->battles);
current_faction = f;
gotit = false;
@ -2661,7 +2633,6 @@ reports(void)
}
else printf("%s\n", factionname(f));
prepare_report(f);
invert_list(&f->msgs);
if (!nonr && (f->options & wants_report))
{
sprintf(buf, "%s/%s.nr", reportpath(), factionid(f));
@ -2776,7 +2747,7 @@ reports(void)
}
void
reports_cleanup(void)
report_cleanup(void)
{
int i;
for (i=0;i!=FMAXHASH;++i) {
@ -3147,18 +3118,20 @@ writenewssubscriptions(void)
{
char zText[MAX_PATH];
FILE *F;
faction *f;
sprintf(zText, "%s/news-subscriptions", basepath());
F = cfopen(zText, "w");
if (!F) return;
#ifdef AT_OPTION
for(f=factions; f; f=f->next) {
attrib *a = a_find(f->attribs, &at_option_news);
if(!a) {
fprintf(F, "%s:0\n", f->email);
} else {
fprintf(F, "%s:%d\n", f->email, a->data.i);
{
faction *f;
for(f=factions; f; f=f->next) {
attrib *a = a_find(f->attribs, &at_option_news);
if(!a) {
fprintf(F, "%s:0\n", f->email);
} else {
fprintf(F, "%s:%d\n", f->email, a->data.i);
}
}
}
#endif
@ -3351,3 +3324,82 @@ report_summary(summary * s, summary * o, boolean full)
}
}
/******* end summary ******/
static void
eval_unit(struct opstack ** stack, const void * userdata) /* unit -> string */
{
const struct unit * u = opop(stack, const struct unit *);
const char * c = u?unitname(u):"nobody";
size_t len = strlen(c);
opush(stack, strcpy(balloc(len+1), c));
}
static void
eval_faction(struct opstack ** stack, const void * userdata) /* faction -> string */
{
const struct faction * f = opop(stack, const struct faction *);
const char * c = factionname(f);
size_t len = strlen(c);
opush(stack, strcpy(balloc(len+1), c));
}
static void
eval_region(struct opstack ** stack, const void * userdata) /* region -> string */
{
const struct faction * f = (const struct faction *)userdata;
const struct region * r = opop(stack, const struct region *);
const char * c = regionname(r, f);
size_t len = strlen(c);
opush(stack, strcpy(balloc(len+1), c));
}
static void
eval_ship(struct opstack ** stack, const void * userdata) /* ship -> string */
{
const struct ship * u = opop(stack, const struct ship *);
const char * c = u?shipname(u):"nobody";
size_t len = strlen(c);
opush(stack, strcpy(balloc(len+1), c));
}
static void
eval_building(struct opstack ** stack, const void * userdata) /* building -> string */
{
const struct building * u = opop(stack, const struct building *);
const char * c = u?buildingname(u):"nobody";
size_t len = strlen(c);
opush(stack, strcpy(balloc(len+1), c));
}
static void
eval_resource(struct opstack ** stack, const void * userdata)
{
const faction * report = (const faction*)userdata;
int j = opop(stack, int);
struct resource_type * res = opop(stack, struct resource_type *);
const char * c = locale_string(report->locale, resourcename(res, j!=1));
opush(stack, strcpy(balloc(strlen(c)+1), c));
}
static void
eval_skill(struct opstack ** stack, const void * userdata)
{
const faction * report = (const faction*)userdata;
int sk = opop(stack, int);
const char * c = locale_string(report->locale, skillnames[sk]);
opush(stack, strcpy(balloc(strlen(c)+1), c));
unused(userdata);
}
void
report_init(void)
{
add_function("region", &eval_region);
add_function("resource", &eval_resource);
add_function("faction", &eval_faction);
add_function("ship", &eval_ship);
add_function("unit", &eval_unit);
add_function("building", &eval_building);
add_function("skill", &eval_skill);
}

View file

@ -38,11 +38,15 @@
#include "skill.h"
#include "unit.h"
/* attributes includes */
#include <attributes/racename.h>
/* util includes */
#include "vset.h"
/* libc includes */
#include <assert.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -113,6 +117,8 @@ setstealth(unit * u, strlist * S)
if (u->race == RC_PSEUDODRAGON || u->race == RC_BIRTHDAYDRAGON) {
if (t==RC_PSEUDODRAGON||t==RC_FIREDRAGON||t==RC_DRAGON||t==RC_WYRM) {
u->irace = t;
if (race[u->race].flags & RCF_SHAPESHIFTANY && get_racename(u->attribs))
set_racename(&u->attribs, NULL);
}
return;
}
@ -121,6 +127,8 @@ setstealth(unit * u, strlist * S)
if (race[u->race].flags & RCF_SHAPESHIFT) {
if (!race[t].nonplayer) {
u->irace = t;
if (race[u->race].flags & RCF_SHAPESHIFTANY && get_racename(u->attribs))
set_racename(&u->attribs, NULL);
}
}
return;
@ -174,14 +182,18 @@ setstealth(unit * u, strlist * S)
}
break;
default:
/* Sonst: Tarnungslevel setzen */
level = (char) atoip(s);
if (level > effskill(u, SK_STEALTH)) {
sprintf(buf, "%s kann sich nicht so gut tarnen.", unitname(u));
mistake(u, S->s, buf, MSG_EVENT);
return;
if (isdigit(s[0])) {
/* Tarnungslevel setzen */
level = (char) atoip(s);
if (level > effskill(u, SK_STEALTH)) {
sprintf(buf, "%s kann sich nicht so gut tarnen.", unitname(u));
mistake(u, S->s, buf, MSG_EVENT);
return;
}
u_seteffstealth(u, level);
} else if (race[u->race].flags & RCF_SHAPESHIFTANY) {
set_racename(&u->attribs, s);
}
u_seteffstealth(u, level);
}
return;
}

View file

@ -1,6 +1,5 @@
/* vi: set ts=2:
*
* $Id: study.c,v 1.9 2001/04/01 06:58:37 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)
@ -19,6 +18,9 @@
* permission from the authors.
*/
#define TEACH_ALL 1
#define TEACH_FRIENDS 1
#include <config.h>
#include "eressea.h"
@ -116,13 +118,95 @@ static const attrib_type at_learning = {
ATF_UNIQUE
};
static int
teach_unit(unit * teacher, unit * student, int teaching, skill_t sk, boolean report)
{
attrib * a;
int n;
/* learning sind die Tage, die sie schon durch andere Lehrer zugute
* geschrieben bekommen haben. Total darf dies nicht über 30 Tage pro Mann
* steigen.
*
* n ist die Anzahl zusätzlich gelernter Tage. n darf max. die Differenz
* von schon gelernten Tagen zum max(30 Tage pro Mann) betragen. */
#ifdef RANDOMIZED_LEARNING
n = student->number * dice(2,30);
#else
n = student->number * 30;
#endif
a = a_find(student->attribs, &at_learning);
if (a!=NULL) n -= a->data.i;
n = min(n, teaching);
if (n != 0) {
struct building * b = inside_building(teacher);
const struct building_type * btype = b?b->type:NULL;
if (a==NULL) a = a_add(&student->attribs, a_new(&at_learning));
a->data.i += n;
if (btype == &bt_academy && student->building==teacher->building && inside_building(student)!=NULL) {
int j = study_cost(teacher, sk);
j = max(50, j * 2);
if (get_pooled(teacher, teacher->region, R_SILVER) >= j) { /* kann Einheit das zahlen? */
/* Jeder Schüler zusätzlich +10 Tage wenn in Uni. */
a->data.i += (n / 30) * 10; /* learning erhöhen */
/* Lehrer zusätzlich +1 Tag pro Schüler. */
set_skill(teacher, sk, get_skill(teacher, sk) + (n / 30));
} /* sonst nehmen sie nicht am Unterricht teil */
}
/* Teaching ist die Anzahl Leute, denen man noch was beibringen kann. Da
* hier nicht n verwendet wird, werden die Leute gezählt und nicht die
* effektiv gelernten Tage. -> FALSCH ? (ENNO)
*
* Eine Einheit A von 11 Mann mit Talent 0 profitiert vom ersten Lehrer B
* also 10x30=300 tage, und der zweite Lehrer C lehrt für nur noch 1x30=30
* Tage (damit das Maximum von 11x30=330 nicht überschritten wird).
*
* Damit es aber in der Ausführung nicht auf die Reihenfolge drauf ankommt,
* darf der zweite Lehrer C keine weiteren Einheiten D mehr lehren. Also
* wird student 30 Tage gutgeschrieben, aber teaching sinkt auf 0 (300-11x30 <=
* 0).
*
* Sonst träte dies auf:
*
* A: lernt B: lehrt A C: lehrt A D D: lernt
*
* Wenn B vor C dran ist, lehrt C nur 30 Tage an A (wie oben) und
* 270 Tage an D.
*
* Ist C aber vor B dran, lehrt C 300 tage an A, und 0 tage an D,
* und B lehrt auch 0 tage an A.
*
* Deswegen darf C D nie lehren dürfen.
*
* -> Das ist wirr. wer hat das entworfen?
* Besser wäre, man macht erst vorab alle zuordnungen, und dann
* die Talentänderung (enno).
*/
teaching = max(0, teaching - student->number * 30);
if (report || teacher->faction != student->faction) {
add_message(&student->faction->msgs, new_message(student->faction,
"teach%u:teacher%u:student%t:skill", teacher, student, sk));
add_message(&teacher->faction->msgs, new_message(teacher->faction,
"teach%u:teacher%u:student%t:skill", teacher, student, sk));
}
}
return n;
}
static void
teach(region * r, unit * u)
{
/* Parameter r gebraucht, um kontrollieren zu können, daß die Ziel-Unit auch
* in der selben Region ist (getunit). Lehren vor lernen. */
static char order[BUFSIZE];
int teaching, n, i, j, count;
int teaching, i, j, count;
unit *u2;
char *s;
skill_t sk;
@ -155,8 +239,49 @@ teach(region * r, unit * u)
u2 = 0;
count = 0;
#if TEACH_ALL
if (getparam()==P_ANY) {
unit * student = r->units;
skill_t teachskill[MAXSKILLS];
int i = 0;
do {
sk = getskill();
teachskill[i++]=sk;
} while (sk!=NOSKILL);
while (teaching && student) {
if (student->faction == u->faction) {
if (igetkeyword(student->thisorder) == K_STUDY) {
/* Input ist nun von student->thisorder !! */
sk = getskill();
if (sk!=NOSKILL && teachskill[0]!=NOSKILL) {
for (i=0;teachskill[i]!=NOSKILL;++i) if (sk==teachskill[i]) break;
sk = teachskill[i];
}
if (sk != NOSKILL && eff_skill(u, sk, r) > eff_skill(student, sk, r)) {
teaching -= teach_unit(u, student, teaching, sk, true);
}
}
}
student = student->next;
}
#if TEACH_FRIENDS
while (teaching && student) {
if (student->faction != u->faction && allied(u, student->faction, HELP_GUARD)) {
if (igetkeyword(student->thisorder) == K_STUDY) {
/* Input ist nun von student->thisorder !! */
sk = getskill();
if (sk != NOSKILL && eff_skill(u, sk, r) > eff_skill(student, sk, r)) {
teaching -= teach_unit(u, student, teaching, sk, true);
}
}
}
student = student->next;
}
#endif
}
else
#endif
for (;;) {
attrib * a;
/* Da später in der Schleife igetkeyword (u2->thisorder) verwendet wird,
* muß hier wieder von vorne gelesen werden. Also merken wir uns, an
* welcher Stelle wir hier waren...
@ -259,75 +384,9 @@ teach(region * r, unit * u)
continue;
}
}
/* learning sind die Tage, die sie schon durch andere Lehrer zugute
* geschrieben bekommen haben. Total darf dies nicht über 30 Tage pro Mann
* steigen.
*
* n ist die Anzahl zusätzlich gelernter Tage. n darf max. die Differenz
* von schon gelernten Tagen zum max(30 Tage pro Mann) betragen. */
#ifdef RANDOMIZED_LEARNING
n = u2->number * dice(2,30);
#else
n = u2->number * 30;
#endif
a = a_find(u2->attribs, &at_learning);
if (a!=NULL) n -= a->data.i;
teaching -= teach_unit(u, u2, teaching, sk, false);
n = min(n, teaching);
if (n != 0) {
struct building * b = inside_building(u);
const struct building_type * btype = b?b->type:NULL;
if (a==NULL) a = a_add(&u2->attribs, a_new(&at_learning));
a->data.i += n;
if (btype == &bt_academy && u2->building==u->building && inside_building(u2)!=NULL) {
j = study_cost(u, sk);
j = max(50, j * 2);
if (get_pooled(u, r, R_SILVER) >= j) { /* kann Einheit das zahlen? */
/* Jeder Schüler zusätzlich +10 Tage wenn in Uni. */
a->data.i += (n / 30) * 10; /* learning erhöhen */
/* Lehrer zusätzlich +1 Tag pro Schüler. */
set_skill(u, sk, get_skill(u, sk) + (n / 30));
} /* sonst nehmen sie nicht am Unterricht teil */
}
/* Teaching ist die Anzahl Leute, denen man noch was beibringen kann. Da
* hier nicht n verwendet wird, werden die Leute gezählt und nicht die
* effektiv gelernten Tage.
*
* Eine Einheit A von 11 Mann mit Talent 0 profitiert vom ersten Lehrer B
* also 10x30=300 tage, und der zweite Lehrer C lehrt für nur noch 1x30=30
* Tage (damit das Maximum von 11x30=330 nicht überschritten wird).
*
* Damit es aber in der Ausführung nicht auf die Reihenfolge drauf ankommt,
* darf der zweite Lehrer C keine weiteren Einheiten D mehr lehren. Also
* wird u2 30 Tage gutgeschrieben, aber teaching sinkt auf 0 (300-11x30 <=
* 0).
*
* Sonst träte dies auf:
*
* A: lernt B: lehrt A C: lehrt A D D: lernt
*
* Wenn B vor C dran ist, lehrt C nur 30 Tage an A (wie oben) und
* 270 Tage an D.
*
* Ist C aber vor B dran, lehrt C 300 tage an A, und 0 tage an D,
* und B lehrt auch 0 tage an A.
*
* Deswegen darf C D nie lehren dürfen.
*/
teaching = max(0, teaching - u2->number * 30);
if (u->faction != u2->faction) {
add_message(&u2->faction->msgs, new_message(u2->faction,
"teach%u:teacher%u:student%t:skill", u, u2, sk));
add_message(&u->faction->msgs, new_message(u->faction,
"teach%u:teacher%u:student%t:skill", u, u2, sk));
}
}
}
}
/* ------------------------------------------------------------- */

View file

@ -1,6 +1,5 @@
/* vi: set ts=2:
*
* $Id: lmsreward.c,v 1.3 2001/04/01 06:58:37 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)

View file

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: weapons.c,v 1.3 2001/02/03 13:45:30 enno Exp $
* $Id: weapons.c,v 1.4 2001/04/12 17:21:42 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)
@ -25,28 +25,28 @@
#include <assert.h>
#include <stdlib.h>
weapon_mod wm_bow[] = {
static weapon_mod wm_bow[] = {
{ 2, WMF_MISSILE_TARGET },
{ 0, 0 }
};
weapon_mod wm_catapult[] = {
static weapon_mod wm_catapult[] = {
{ 1, WMF_MISSILE_TARGET },
{ 0, 0 }
};
weapon_mod wm_spear[] = {
static weapon_mod wm_spear[] = {
{ 1, WMF_SKILL|WMF_RIDING|WMF_AGAINST_ANYONE|WMF_OFFENSIVE },
{ 1, WMF_SKILL|WMF_WALKING|WMF_AGAINST_RIDING|WMF_DEFENSIVE },
{ 0, 0 }
};
weapon_mod wm_lance[] = {
static weapon_mod wm_lance[] = {
{ 1, WMF_SKILL|WMF_RIDING|WMF_AGAINST_ANYONE|WMF_OFFENSIVE },
{ 0, 0 }
};
weapon_mod wm_halberd[] = {
static weapon_mod wm_halberd[] = {
{ 1, WMF_SKILL|WMF_WALKING|WMF_AGAINST_RIDING|WMF_DEFENSIVE },
{ 0, 0 }
};

View file

@ -9,11 +9,11 @@
*
* This program may not be used, modified or distributed without
* prior permission by the authors of Eressea.
* This program may not be sold or used commercially without prior written
* permission from the authors.
*/
#define SHOW_KILLS
#define DELAYED_OFFENSE /* non-guarding factions cannot attack after moving */
#define SHORT_ATTACKS /* attacking is always a short order */
#define TACTICS_RANDOM 5 /* define this as 1 to deactivate */
#define CATAPULT_INITIAL_RELOAD 4 /* erster schuss in runde 1 + rand() % INITIAL */
@ -62,6 +62,10 @@ typedef enum combatmagic {
/* attributes includes */
#include <attributes/key.h>
#include <attributes/racename.h>
#ifdef AT_MOVED
# include <attributes/moved.h>
#endif
/* libc includes */
#include <assert.h>
@ -71,13 +75,10 @@ typedef enum combatmagic {
#include <stdlib.h>
#include <string.h>
#ifndef _MSC_VER
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#if !defined(AT_MOVED) && defined(DELAYED_OFFENSE)
# error "must define AT_MOVED to use combat option DELAYED_OFFENSE"
#endif
#ifdef HAVE_ZLIB
# include <zlib.h>
# define dbgprintf(a) gzprintf a;
@ -2216,13 +2217,14 @@ aftermath(battle * b)
int dead = du->number - df->alive - df->run.number;
int sum_hp = 0;
int n;
#ifndef SHORT_ATTACKS
if (relevant && df->action_counter >= df->unit->number) {
fset(df->unit, FL_LONGACTION);
/* TODO: das sollte hier weg sobald anderswo üb
* erall HADBATTLE getestet wird. */
set_string(&du->thisorder, "");
}
#endif
for (n = 0; n != df->alive; ++n) {
if (df->person[n].hp > 0)
sum_hp += df->person[n].hp;
@ -2283,6 +2285,7 @@ aftermath(battle * b)
if (fval(du, FL_PARTEITARNUNG))
fset(nu, FL_PARTEITARNUNG);
/* Daemonentarnung */
set_racename(&nu->attribs, get_racename(du->attribs));
nu->irace = du->irace;
/* Fliehenden nehmen mit, was sie tragen können*/
@ -3234,7 +3237,7 @@ flee(const troop dt)
{
fighter * fig = dt.fighter;
unit * u = fig->unit;
int carry = PERSONCAPACITY(u) - race[u->race].weight;
int carry = personcapacity(u) - race[u->race].weight;
int money;
item ** ip = &u->items;
@ -3279,6 +3282,18 @@ flee(const troop dt)
remove_troop(dt);
}
#ifdef DELAYED_OFFENSE
static boolean
guarded_by(region * r, faction * f)
{
unit * u;
for (u=r->units;u;u=u->next) {
if (u->faction == f && getguard(u)) return true;
}
return false;
}
#endif
void
do_battle(void)
{
@ -3315,14 +3330,15 @@ do_battle(void)
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, sl->s, buf, MSG_BATTLE);
list_continue(sl);
/**
** Fehlerbehandlung Angreifer
**/
#ifdef DELAYED_OFFENSE
if (get_moved(&u->attribs) && !guarded_by(r, u->faction)) {
add_message(&u->faction->msgs,
make_message("no_attack_after_advance", "unit region command", u, u->region, sl->s));
}
#endif
if (fval(u, FL_HUNGER)) {
cmistake(u, sl->s, 225, MSG_BATTLE);
list_continue(sl);
@ -3336,6 +3352,13 @@ do_battle(void)
/* ist ein Flüchtling aus einem andern Kampf */
if (fval(u, FL_MOVED)) list_continue(sl);
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, sl->s, buf, MSG_BATTLE);
list_continue(sl);
}
if (is_cursed(u->attribs, C_SLAVE, 0)) {
sprintf(buf, "%s kämpft nicht.", unitname(u));
mistake(u, sl->s, buf, MSG_BATTLE);

View file

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: border.c,v 1.7 2001/02/18 12:11:32 enno Exp $
* $Id: border.c,v 1.8 2001/04/12 17:21:43 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)
@ -117,7 +117,7 @@ read_borders(FILE * f)
if (to==from) {
direction_t dir = (direction_t) (rand() % MAXDIRECTIONS);
region * r = rconnect(from, dir);
log_error(("[read_borders] invalid %s in %s\n", type->__name, tregionid(from, NULL)));
log_error(("[read_borders] invalid %s in %s\n", type->__name, regionname(from, NULL)));
if (r!=NULL) to = r;
}
b = new_border(type, from, to);

View file

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: building.c,v 1.7 2001/02/15 02:41:46 enno Exp $
* $Id: building.c,v 1.8 2001/04/12 17:21:43 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)
@ -977,8 +977,9 @@ buildingowner(const region * r, const building * b)
{
unit *u = NULL;
unit *first = NULL;
#ifndef BROKEN_OWNERS
assert(r == b->region);
#endif
/* Prüfen ob Eigentümer am leben. */
for (u = r->units; u; u = u->next) {

View file

@ -42,7 +42,6 @@
#include "monster.h"
#include "race.h"
#include "pool.h"
#include "study.h"
#include "region.h"
#include "unit.h"
#include "skill.h"
@ -55,9 +54,9 @@
#include <base36.h>
#include <event.h>
#include <umlaut.h>
#ifdef NEW_MESSAGES
# include <translation.h>
#endif
#include <translation.h>
#include <crmessage.h>
/* libc includes */
#include <stdio.h>
#include <stdlib.h>
@ -491,13 +490,13 @@ verify_data (void)
lf = f->no;
printf("Partei %s:\n", factionid(f));
}
printf("WARNUNG: Einheit %s hat %d Personen\n", unitid(u), u->number);
log_warning(("Einheit %s hat %d Personen\n", unitid(u), u->number));
}
}
if (f->no != 0 && ((mage > 3 && f->race != RC_ELF) || mage > 4))
printf("FEHLER: Partei %s hat %d Magier.\n", factionid(f), mage);
log_error(("Partei %s hat %d Magier.\n", factionid(f), mage));
if (alchemist > 3)
printf("FEHLER: Partei %s hat %d Alchemisten.\n", factionid(f), alchemist);
log_error(("Partei %s hat %d Alchemisten.\n", factionid(f), alchemist));
}
list_next(f);
#endif
@ -1416,7 +1415,7 @@ cstring(const char *s)
return r;
}
char *
const char *
regionid(const region * r)
{
char *buf = idbuf[(++nextbuf) % 8];
@ -1461,7 +1460,7 @@ largestbuilding (const region * r, boolean img)
return best;
}
char *
const char *
unitname(const unit * u)
{
char *ubuf = idbuf[(++nextbuf) % 8];
@ -1844,25 +1843,18 @@ init_tokens(void)
}
}
extern void render_cleanup(void);
void
kernel_done(void)
{
/* calling this function releases memory assigned to static variables, etc.
* calling it is optional, e.g. a release server will most likely not do it.
*/
#ifdef OLD_MESSAGES
render_cleanup();
#else
translation_done();
#endif
skill_done();
gc_done();
}
extern void attrib_init(void);
extern void render_init(void);
void
read_strings(FILE * F)
@ -1894,12 +1886,8 @@ kernel_init(void)
init_tokens();
skill_init();
attrib_init();
init_locales();
#ifdef OLD_MESSAGES
render_init();
#else
translation_init();
#endif
if (!turn) turn = lastturn();
if (turn == 0)
srand(time((time_t *) NULL));
@ -2238,7 +2226,7 @@ besieged(const unit * u)
{
/* belagert kann man in schiffen und burgen werden */
return (u
&& u->building
&& u->building && u->building->besieged
&& u->building->besieged >= u->building->size * SIEGEFACTOR);
}
@ -2550,6 +2538,7 @@ move_blocked(const unit * u, const region *r, direction_t dir)
void
add_income(unit * u, int type, int want, int qty)
{
if (want==INT_MAX) want = qty;
add_message(&u->faction->msgs, new_message(u->faction, "income%u:unit%r:region%i:mode%i:wanted%i:amount",
u, u->region, type, want, qty));
}

View file

@ -21,22 +21,9 @@
#ifndef ERESSEA_H
#define ERESSEA_H
#ifndef NEW_MESSAGES
#define MSG_LEVELS /* msg-levels wieder aktiviert */
#define OLD_MESSAGES
#define message_type messagetype
#define message_list message
#define report_section message
#else
#undef MSG_LEVELS
#endif
#ifndef NEW_MESSAGES
#define OLD_MESSAGES
#define message_type messagetype
#define message_list message
#define report_section message
#endif
#define AT_MOVED
#undef MSG_LEVELS /* msg-levels wieder aktiviert */
#undef OLD_MESSAGES
/* basic types used in the eressea "kernel" */
typedef unsigned char order_t;
@ -795,8 +782,6 @@ enum {
extern vmap region_map;
#define unused(var) var = var
#define i2b(i) ((boolean)((i)?(true):(false)))
typedef struct ally {
@ -994,11 +979,9 @@ struct region *findunitregion(const struct unit * su);
char *estring(const char *s);
char *cstring(const char *s);
char *factionname(const struct faction * f);
char *regionid(const struct region * r);
char *unitname(const struct unit * u);
const char *regionid(const struct region * r);
const char *unitname(const struct unit * u);
char *xunitid(const struct unit * u);
char *shipname(const struct ship * sh);
struct building *largestbuilding(const struct region * r, boolean img);

View file

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: faction.c,v 1.2 2001/01/26 16:19:39 enno Exp $
* $Id: faction.c,v 1.3 2001/04/12 17:21:44 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,7 +21,7 @@
/* libc includes */
#include <stdio.h>
char *
const char *
factionname(const faction * f)
{
typedef char name[OBJECTIDSIZE + 1];

View file

@ -50,7 +50,6 @@ typedef struct faction {
int number; /* enno: unterschied zu num_people ? */
int money;
int score;
short index; /* Für die Reportgenerierung - enno: wirklich nötig? */
#ifndef FAST_REGION
vset regions;
#endif
@ -64,7 +63,7 @@ typedef struct faction {
} * battles;
} faction;
extern char * factionname(const struct faction * f);
extern const char * factionname(const struct faction * f);
extern void * resolve_faction(void * data);
#endif

View file

@ -250,6 +250,16 @@ struct fspecialdata fspecials[MAXFACTIONSPECIALS] = {
"verlieren jedoch ihre Fähigkeit zur Regeneration erlittenen Schadens "
"komplett.",
100
},
{ /* TODO: Namen ändern */
"Schnell",
"Ein solches Volk ist sehr athletisch und die Kinder üben besonders "
"den Langstreckenlauf von kleinauf. Nach jahrelangem Training sind "
"sie dann in der Lage, sich zu Fuß so schnell zu bewegen als würden "
"sie reiten. Allerdings hat das jahrelange Konditionstraining ihre "
"Kräfte schwinden lassen, und ihre Tragkraft ist um 2 Gewichtseinheiten "
"verringert.",
1
}
};

View file

@ -34,6 +34,7 @@ typedef enum {
FS_VARIEDMAGIC,
FS_JIHAD,
FS_UNDEAD,
FS_QUICK,
MAXFACTIONSPECIALS
} fspecial_t;

View file

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: message.c,v 1.11 2001/03/01 01:38:12 enno Exp $
* $Id: message.c,v 1.12 2001/04/12 17:21:44 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)
@ -19,11 +19,6 @@
* permission from the authors.
*/
/** defines:
*
* NEW_MESSAGES - new message-classes
*
*/
#include <config.h>
#include "eressea.h"
#include "message.h"
@ -38,11 +33,9 @@
/* util includes */
#include <goodies.h>
#include <base36.h>
#ifdef NEW_MESSAGES
#include <message.h>
#include <nrmessage.h>
#include <crmessage.h>
#endif
/* libc includes */
#include <stddef.h>
@ -129,7 +122,163 @@ translate_regions(const char *st, faction * f)
return s;
}
#ifdef NEW_MESSAGES
#include <xml.h>
typedef struct xml_state {
const char * mtname;
const message_type * mtype;
int argc;
char * argv[32];
struct locale * lang;
const char * nrsection;
int nrlevel;
char * nrtext;
} xml_state;
static int
parse_plaintext(const struct xml_stack *stack, const char *str, void *data)
{
xml_state * state = (xml_state*)data;
if (stack) {
const xml_tag * tag = stack->tag;
if (strcmp(tag->name, "text")==0) {
state->nrtext = strdup(str);
}
}
return XML_OK;
}
static int
parse_tagbegin(const struct xml_stack *stack, void *data)
{
xml_state * state = (xml_state*)data;
const xml_tag * tag = stack->tag;
if (strcmp(tag->name, "messages")==0) {
memset(state, 0, sizeof(xml_state));
return XML_OK;
} else if (strcmp(tag->name, "message")==0) {
const char * tname = xml_value(tag, "name");
state->argc = 0;
if (tname) {
state->mtname = tname;
return XML_OK;
}
else state->mtname = NULL;
} else if (strcasecmp(tag->name, "arg")==0) {
if (state->mtname!=NULL) {
const char * zName = xml_value(tag, "name");
const char * zType = xml_value(tag, "type");
if (zName && zType) {
char zBuffer[128];
sprintf(zBuffer, "%s:%s", zName, zType);
state->argv[state->argc++] = strdup(zBuffer);
return XML_OK;
}
}
} else if (strcasecmp(tag->name, "locale")==0) {
if (state->mtname!=NULL) {
const char * zName = xml_value(tag, "name");
if (zName) {
state->lang = find_locale(zName);
}
}
} else if (strcasecmp(tag->name, "nr")==0) {
if (state->mtname!=NULL) {
const char * zSection = xml_value(tag, "section");
const char * zLevel = xml_value(tag, "level");
if (zSection) {
state->nrsection = zSection;
mc_add(zSection);
}
if (zLevel) state->nrlevel = atoi(zLevel);
}
}
return XML_USERERROR;
}
static int
parse_tagend(const struct xml_stack *stack, void *data)
{
xml_state * state = (xml_state*)data;
const xml_tag * tag = stack->tag;
if (strcasecmp(tag->name, "type")==0) {
const struct message_type * mtype;
state->argv[state->argc]=0;
/* add the messagetype */
mtype = mt_find(state->mtname);
if (!mtype) mtype = mt_register(mt_new(state->mtname, state->argv));
while (state->argc--) {
free(state->argv[state->argc]);
}
if (state->nrtext) {
free(state->nrtext);
state->nrtext = 0;
}
state->mtype = mtype;
} else if (strcasecmp(tag->name, "locale")==0) {
crt_register(state->mtype);
state->lang = NULL;
} else if (strcasecmp(tag->name, "nr")==0) {
nrt_register(state->mtype, state->lang, state->nrtext, state->nrlevel, state->nrsection);
state->nrsection = NULL;
}
return XML_OK;
}
static xml_callbacks msgcallback = {
parse_plaintext,
parse_tagbegin,
parse_tagend,
NULL
};
void
read_messages(FILE * F, const locale * lang)
{
xml_state state;
xml_parse(F, &msgcallback, &state);
unused(lang);
}
message *
make_message(const char * name, const char* sig, ...)
/* make_message("oops_error", "unit region command", u, r, cmd) */
{
int i;
va_list marker;
const message_type * mtype = mt_find(name);
char buffer[64], *oc = buffer;
const char *ic = sig;
void * args[16];
memset(args, 0, sizeof(args));
if (!mtype) {
fprintf(stderr, "trying to create message of unknown type \"%s\"\n", name);
return NULL;
}
va_start(marker, sig);
while (*ic && !isalnum(*ic)) ic++;
while (*ic) {
void * v = va_arg(marker, void *);
while (isalnum(*ic)) *oc++ = *ic++;
*oc = '\0';
for (i=0;i!=mtype->nparameters;++i) {
if (!strcmp(buffer, mtype->pnames[i])) break;
}
if (i!=mtype->nparameters) args[i] = v;
while (*ic && !isalnum(*ic)) ic++;
}
va_end(marker);
return msg_create(mtype, (void**)args);
}
message *
new_message(struct faction * receiver, const char* sig, ...)
/* compatibility function, to keep the old function calls valid *
@ -143,7 +292,7 @@ new_message(struct faction * receiver, const char* sig, ...)
char buffer[128];
int i=0;
const char * c = sig;
const char * args[16];
void * args[16];
memset(args, 0, sizeof(args));
strncpy(buffer, sig, signature-sig);
@ -190,151 +339,47 @@ new_message(struct faction * receiver, const char* sig, ...)
}
switch(type) {
case 's':
args[i] = va_arg(marker, const char *);
args[i] = (void*)va_arg(marker, const char *);
break;
case 'i':
args[i] = strdup(itoa10(va_arg(marker, int)));
args[i] = (void*)va_arg(marker, int);
break;
case 'f':
args[i] = factionname(va_arg(marker, const struct faction*));
args[i] = (void*)va_arg(marker, const struct faction*);
break;
case 'u':
args[i] = (void*)va_arg(marker, const struct unit*);
break;
case 'r':
args[i] = (void*)va_arg(marker, const struct region*);
break;
case 'h':
args[i] = (void*)va_arg(marker, const struct ship*);
break;
case 'b':
args[i] = (void*)va_arg(marker, const struct building*);
break;
case 'u': {
const struct unit * u = va_arg(marker, const struct unit*);
if (u) args[i] = unitname(u);
}
break;
case 'r': {
const struct region * r = va_arg(marker, const struct region*);
if (r) args[i] = rname(r, receiver->locale);
}
break;
case 'h': {
const struct ship * sh = va_arg(marker, const struct ship*);
if (sh) args[i] = shipname(sh);
}
break;
case 'b': {
const struct building * b = va_arg(marker, const struct building*);
if (b) args[i] = buildingname(b);
}
break;
case 'X':
args[i] = resourcename(va_arg(marker, const resource_type *), 0);
args[i] = (void*)va_arg(marker, const resource_type *);
break;
case 'x':
args[i] = resourcename(oldresourcetype[(resource_t)va_arg(marker, resource_t)], 0);
args[i] = (void*)oldresourcetype[(resource_t)va_arg(marker, resource_t)];
break;
case 't':
args[i] = skillnames[va_arg(marker, skill_t)];
args[i] = (void*)va_arg(marker, skill_t);
break;
case 'd':
args[i] = directions[i];
args[i] = (void*)directions[i];
break;
case 'S':
default:
args[i] = NULL;
}
}
va_end(marker);
return msg_create(mtype, (void**)args);
}
static void
parse_message(char * b, const struct locale * deflocale)
{
char *m, *a = NULL, message[8192];
char * name;
char * language;
const struct locale * lang;
char * section = NULL;
int i, level = 0;
char * args[16];
boolean f_symbol = false;
const struct message_type * mtype;
/* skip comments */
if (b[0]=='#' || b[0]==0) return;
/* the name of this type */
name = b;
while (*b && *b!=';') ++b;
if (!*b) return;
*b++ = 0;
/* the section for this type */
section = b;
while (*b && *b!=';' && *b!=':') ++b;
if (!strcmp(section, "none")) section=NULL;
/* if available, the level for this type */
if (*b==':') {
char * x;
*b++ = 0;
x = b;
while (*b && *b!=';') ++b;
level=atoi(x);
}
*b++ = 0;
/* the locale */
language = b;
while (*b && *b!=';') ++b;
*b++ = 0;
if (strlen(language)==0) lang = deflocale;
else {
lang = find_locale(language);
if (!lang) lang = make_locale(language);
}
/* parse the message */
i = 0;
m = message;
*m++='\"';
while (*b) {
switch (*b) {
case '{':
f_symbol = true;
a = ++b;
break;
case '}':
*b++ = '\0';
args[i] = strdup(a);
sprintf(m, "$%s", args[i]);
m+=strlen(m);
i++;
f_symbol = false;
break;
case ' ':
if (f_symbol) {
a = ++b;
break;
}
/* fall-through intended */
default:
if (!f_symbol) {
*m++ = *b++;
} else b++;
}
}
strcpy(m, "\"");
args[i] = NULL;
/* add the messagetype */
mtype = mt_register(mt_new(name, (const char**)args));
nrt_register(mtype, lang, message, level, section);
crt_register(mtype, lang);
}
void
read_messages(FILE * F, const struct locale * lang)
{
char buf[8192];
while (fgets(buf, sizeof(buf), F)) {
buf[strlen(buf)-1] = 0; /* \n weg */
parse_message(buf, lang);
}
}
#endif
void
addmessage(region * r, faction * f, const char *s, msg_t mtype, int level)
{
@ -385,9 +430,6 @@ caddmessage(region * r, faction * f, char *s, msg_t mtype, int level)
default:
fprintf(stderr, "Warnung: Ungültige Msg-Klasse!");
}
#ifdef OLD_MESSAGES
if (m) m->level = level;
#endif
}
void
@ -403,8 +445,8 @@ cmistake(const unit * u, const char *cmd, int mno, int mtype)
static char lbuf[64];
if (u->faction->no == MONSTER_FACTION) return;
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));
strcat(lbuf, "%s:command%u:unit%r:region");
add_message(&u->faction->msgs, new_message(u->faction, lbuf, cmd, u, u->region));
}
void
@ -428,182 +470,6 @@ old_hashstring(const char* s)
return key & 0x7fff;
}
#ifdef OLD_MESSAGES
static messagetype * messagetypes;
void
debug_messagetypes(FILE * out)
{
messagetype * mt;
for (mt=messagetypes;mt;mt=mt->next) {
fprintf(out, "%ut%u\n", old_hashstring(mt->name), mt->hashkey);
}
}
messagetype *
new_messagetype(const char * name, int level, const char * section)
{
messagetype * mt = calloc(1, sizeof(messagetype));
mt->section = mc_add(section);
mt->name = strdup(name);
mt->level = level;
mt->hashkey = hashstring(mt->name);
#ifndef NDEBUG
{
messagetype * mt2 = messagetypes;
while(mt2 && mt2->hashkey != mt->hashkey) mt2 = mt2->next;
if (mt2) {
fprintf(stderr, "duplicate hashkey %u for messagetype %s and %s\n",
mt->hashkey, name, mt2->name);
}
}
#endif
mt->next = messagetypes;
messagetypes = mt;
return mt;
}
void
add_signature(messagetype * mt, const char * sig)
{
static char buffer[128];
int i=0;
struct entry ** ep = &mt->entries;
const char * c = sig;
if (mt->entries) return;
while(*c!='%') buffer[i++] = *(c++);
buffer[i] = 0;
while (*c) {
char *p = buffer;
assert(*c=='%');
*ep = calloc(1, sizeof(struct entry));
switch (*(++c)) {
case 'f': (*ep)->type = IT_FACTION; break;
case 'u': (*ep)->type = IT_UNIT; break;
case 'r': (*ep)->type = IT_REGION; break;
case 'h': (*ep)->type = IT_SHIP; break;
case 'b': (*ep)->type = IT_BUILDING; break;
case 'X': (*ep)->type = IT_RESOURCETYPE; break;
case 'x': (*ep)->type = IT_RESOURCE; break;
case 't': (*ep)->type = IT_SKILL; break;
case 's': (*ep)->type = IT_STRING; break;
case 'i': (*ep)->type = IT_INT; break;
case 'd': (*ep)->type = IT_DIRECTION; break;
case 'S': (*ep)->type = IT_FSPECIAL; break;
}
++c;
assert(*c==':');
++c;
while (*c && isalnum((int)*c))
*(p++) = *(c++);
*p = 0;
(*ep)->name = strdup(buffer);
ep = &(*ep)->next;
++mt->argc;
}
}
messagetype *
find_messagetype(const char * name)
{
messagetype * mt = messagetypes;
while(mt && strcmp(mt->name, name)!=0) mt = mt->next;
return mt;
}
message *
new_message(struct faction * receiver, const char* sig, ...)
{
message * m = (message*)calloc(1, sizeof(message));
messagetype * mt;
struct entry * e;
va_list marker;
int i;
unit * u;
const char * signature = strchr(sig, '%');
char name[64];
assert(signature-sig<64);
memcpy(name, sig, signature-sig);
name[signature-sig] = 0;
mt = find_messagetype(name);
if (!mt) {
fprintf(stderr, "unknown message %s\n", name);
return NULL;
}
if (mt->entries==NULL) add_signature(mt, signature);
m->receiver = receiver;
m->type = mt;
m->data = calloc(mt->argc, sizeof(void*));
m->level = mt->level;
e = mt->entries;
va_start(marker, sig);
for (i=0;i!=mt->argc;++i) {
switch (e->type) {
case IT_INT:
m->data[i] = (void*)va_arg(marker, int);
break;
case IT_RESOURCETYPE:
m->data[i] = (void*)va_arg(marker, const resource_type *);
break;
case IT_RESOURCE:
m->data[i] = (void*)oldresourcetype[(resource_t)va_arg(marker, resource_t)];
break;
case IT_UNIT:
u = (unit*)va_arg(marker, void*);
/* TODO: Ergibt keine richtige Grammatik */
if (u == NULL)
m->data[i] = NULL;
else {
m->data[i] = u;
}
#if 0
if (u && (!receiver || cansee(receiver, u->region, u, 0)))
m->data[i] = u;
else
m->data[i] = NULL;
#endif
break;
default:
m->data[i] = va_arg(marker, void*);
break;
}
e = e->next;
}
assert(!e);
va_end(marker);
return m;
}
int
get_msglevel(const struct warning * warnings, const msglevel * levels, const messagetype * mtype)
{
#ifdef MSG_LEVELS
/* hier ist ein bug drin, irgendwo */
const struct warning * w = warnings;
while (levels && levels->type!=mtype) levels=levels->next;
if (levels) return levels->level;
while (w) {
if (w->section == mtype->section) break;
w = w->next;
}
if (w) return w->level;
#endif
return 0x7F;
}
int
msg_level(const message * m)
{
return m->level;
}
#endif
void
set_msglevel(struct warning ** warnings, const char * type, int level)
{
@ -629,7 +495,6 @@ message *
add_message(message_list** pm, message * m)
{
if (m==NULL) return NULL;
#ifdef NEW_MESSAGES
else {
struct mlist * mnew = malloc(sizeof(struct mlist));
if (*pm==NULL) {
@ -641,31 +506,18 @@ add_message(message_list** pm, message * m)
*((*pm)->end) = mnew;
(*pm)->end=&mnew->next;
}
#else
m->next = *pm;
*pm = m;
#endif
return m;
}
void
free_messages(message_list * m)
{
#ifdef NEW_MESSAGES
struct mlist * x = m->begin;
while (x) {
m->begin = x->next;
msg_free(x->msg);
free(x);
}
#else
while (m) {
message_list * x = m;
m = x->next;
free(x->data);
free(x);
}
#endif
}
messageclass * msgclasses;

View file

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: message.h,v 1.4 2001/02/24 12:50:48 enno Exp $
* $Id: message.h,v 1.5 2001/04/12 17:21:44 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)
@ -23,7 +23,6 @@ struct messageclass;
struct warning;
struct msglevel;
#ifdef NEW_MESSAGES
struct message_type;
typedef struct message_list {
@ -33,56 +32,6 @@ typedef struct message_list {
} * begin, **end;
} message_list;
#else /* NEW_MESSAGES */
typedef struct messagetype
{
struct messagetype * next;
const struct messageclass * section;
int level;
char * name;
int argc;
struct entry {
struct entry * next;
enum {
IT_FACTION,
IT_UNIT,
IT_REGION,
IT_SHIP,
IT_BUILDING,
#ifdef NEW_ITEMS
IT_RESOURCETYPE,
#endif
IT_RESOURCE,
IT_SKILL,
IT_INT,
IT_STRING,
IT_DIRECTION,
IT_FSPECIAL
} type;
char * name;
} * entries;
unsigned int hashkey;
} messagetype;
extern struct messagetype * find_messagetype(const char * name);
extern struct messagetype * new_messagetype(const char * name, int level, const char * section);
typedef struct message {
struct message * next;
struct messagetype * type;
void ** data;
void * receiver;
int level;
} message;
extern int msg_level(const struct message * msg);
int get_msglevel(const struct warning * warnings, const struct msglevel * levels, const struct messagetype * mtype);
void debug_messagetypes(FILE * out);
#endif /* NEW_MESSAGES */
typedef struct messageclass
{
struct messageclass * next;
@ -100,8 +49,9 @@ void write_msglevels(struct warning * warnings, FILE * F);
void read_msglevels(struct warning ** w, FILE * F);
void set_msglevel(struct warning ** warnings, const char * type, int level);
extern struct message * make_message(const char * name, const char* sig, ...);
extern struct message * new_message(struct faction * receiver, const char * signature, ...);
extern struct message* add_message(struct message_list** pm, struct message* m);
extern struct message * add_message(struct message_list** pm, struct message * m);
extern void free_messages(struct message_list * m);
extern void read_messages(FILE * F, const struct locale * lang);

View file

@ -1,6 +1,5 @@
/* vi: set ts=2:
*
* $Id: movement.c,v 1.17 2001/04/08 17:36:48 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)
@ -141,6 +140,18 @@ static attrib_type at_driveweight = {
"driveweight", NULL, NULL, NULL, NULL, NULL
};
int
personcapacity(unit *u)
{
int cap = race[u->race].weight+540;
if(fspecial(u->faction, FS_QUICK)) {
cap -= 2000;
}
return cap;
}
static int
eff_weight(const unit *u)
{
@ -212,15 +223,8 @@ walkingcapacity(unit * u)
}
n += pferde * HORSECAPACITY;
if (u->race == RC_TROLL) {
n += personen * PERSONCAPACITY(u) * 2;
} else {
n += personen * PERSONCAPACITY(u);
}
n += get_effect(u, oldpotiontype[P_STRONG]) * PERSONCAPACITY(u);
n += personen * personcapacity(u);
n += get_effect(u, oldpotiontype[P_STRONG]) * personcapacity(u);
n += min(get_item(u, I_TROLLBELT), u->number) * STRENGTHCAPACITY;
return n;
@ -883,7 +887,6 @@ travel(region * first, unit * u, region * next, int flucht)
char buf2[80];
static direction_t route[MAXSPEED];
/* tech:
*
* zu Fuß reist man 1 Region, zu Pferd 2 Regionen. Mit Straßen reist
@ -956,9 +959,16 @@ travel(region * first, unit * u, region * next, int flucht)
default:
{
int mp = 1;
if (get_effect(u, oldpotiontype[P_FAST]) >= u->number)
mp *= 2; /* Siebenmeilentee */
/* faction special */
if(fspecial(u->faction, FS_QUICK))
mp = BP_RIDING;
/* Siebenmeilentee */
if (get_effect(u, oldpotiontype[P_FAST]) >= u->number)
mp *= 2;
/* unicorn in inventory */
if (u->number <= get_item(u, I_FEENSTIEFEL))
mp *= 2;
@ -1128,7 +1138,7 @@ travel(region * first, unit * u, region * next, int flucht)
travelthru(u, rv[i]);
sprintf(buf2, trailinto(rv[i], u->faction->locale),
tregionid(rv[i], u->faction));
regionname(rv[i], u->faction));
scat(buf2);
}
}
@ -1334,9 +1344,7 @@ sail(region * starting_point, unit * u, region * next_point, boolean move_on_lan
return NULL;
/* Wir suchen so lange nach neuen Richtungen, wie es geht. Diese werden
* dann nacheinander ausgeführt.
* Im array rv[] speichern wir die Küstenregionen ab, durch die wir
* segeln (geht nur bei Halbinseln). */
* dann nacheinander ausgeführt. */
k = shipspeed(u->ship, u);
@ -1518,7 +1526,7 @@ sail(region * starting_point, unit * u, region * next_point, boolean move_on_lan
}
}
if (starting_point != current_point) {
if (u->ship->moved) {
ship * sh = u->ship;
sh->moved = 1;
sprintf(buf, "Die %s ", shipname(sh));
@ -1567,64 +1575,67 @@ sail(region * starting_point, unit * u, region * next_point, boolean move_on_lan
/* Das Schiff und alle Einheiten darin werden nun von
* starting_point nach current_point verschoben */
tt[t - 1] = 0;
sh = move_ship(sh, starting_point, current_point, tt);
/* Verfolgungen melden */
if (fval(u, FL_FOLLOWING)) caught_target(current_point, u);
/* Hafengebühren ? */
if (starting_point != current_point) {
tt[t - 1] = 0;
sh = move_ship(sh, starting_point, current_point, tt);
hafenmeister = owner_buildingtyp(current_point, &bt_harbour);
if (sh && hafenmeister != NULL) {
item * itm;
assert(trans==NULL);
for (u2 = current_point->units; u2; u2 = u2->next) {
if (u2->ship == u->ship &&
!allied(hafenmeister, u->faction, HELP_GUARD)) {
/* Hafengebühren ? */
hafenmeister = owner_buildingtyp(current_point, &bt_harbour);
if (sh && hafenmeister != NULL) {
item * itm;
assert(trans==NULL);
for (u2 = current_point->units; u2; u2 = u2->next) {
if (u2->ship == u->ship &&
!allied(hafenmeister, u->faction, HELP_GUARD)) {
if (effskill(hafenmeister, SK_OBSERVATION) > effskill(u2, SK_STEALTH)) {
for (itm=u2->items; itm; itm=itm->next) {
const luxury_type * ltype = resource2luxury(itm->type->rtype);
if (ltype!=NULL && itm->number>0) {
st = itm->number * effskill(hafenmeister, SK_TRADE) / 50;
st = min(itm->number, st);
if (effskill(hafenmeister, SK_OBSERVATION) > effskill(u2, SK_STEALTH)) {
for (itm=u2->items; itm; itm=itm->next) {
const luxury_type * ltype = resource2luxury(itm->type->rtype);
if (ltype!=NULL && itm->number>0) {
st = itm->number * effskill(hafenmeister, SK_TRADE) / 50;
st = min(itm->number, st);
if (st > 0) {
i_change(&u2->items, itm->type, -st);
i_change(&hafenmeister->items, itm->type, st);
i_add(&trans, i_new(itm->type));
if (st > 0) {
i_change(&u2->items, itm->type, -st);
i_change(&hafenmeister->items, itm->type, st);
i_add(&trans, i_new(itm->type));
}
}
}
}
}
}
}
if (trans) {
sprintf(buf, "%s erhielt ", hafenmeister->name);
for (itm = trans; itm; itm=itm->next) {
if (first != 1) {
if (itm->next!=NULL && itm->next->next==NULL) {
scat(" und ");
if (trans) {
sprintf(buf, "%s erhielt ", hafenmeister->name);
for (itm = trans; itm; itm=itm->next) {
if (first != 1) {
if (itm->next!=NULL && itm->next->next==NULL) {
scat(" und ");
} else {
scat(", ");
}
}
first = 0;
icat(trans->number);
scat(" ");
if (itm->number == 1) {
scat(locale_string(NULL, resourcename(itm->type->rtype, 0)));
} else {
scat(", ");
scat(locale_string(NULL, resourcename(itm->type->rtype, NMF_PLURAL)));
}
}
first = 0;
icat(trans->number);
scat(" ");
if (itm->number == 1) {
scat(locale_string(NULL, resourcename(itm->type->rtype, 0)));
} else {
scat(locale_string(NULL, resourcename(itm->type->rtype, NMF_PLURAL)));
}
scat(" von der ");
scat(shipname(u->ship));
scat(".");
addmessage(0, u->faction, buf, MSG_COMMERCE, ML_INFO);
addmessage(0, hafenmeister->faction, buf, MSG_INCOME, ML_INFO);
while (trans) i_remove(&trans, trans);
}
scat(" von der ");
scat(shipname(u->ship));
scat(".");
addmessage(0, u->faction, buf, MSG_COMMERCE, ML_INFO);
addmessage(0, hafenmeister->faction, buf, MSG_INCOME, ML_INFO);
while (trans) i_remove(&trans, trans);
}
}
}

View file

@ -1,6 +1,5 @@
/* vi: set ts=2:
*
* $Id: movement.h,v 1.4 2001/03/04 18:41:25 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)
@ -28,16 +27,10 @@ struct ship;
#define SCALEWEIGHT 100 /* Faktor, um den die Anzeige von gewichten
* * skaliert wird */
#define INC_CAPACITIES 0
#if INC_CAPACITIES
#define PERSONCAPACITY(u) (race[(u)->race].weight+600)
#define HORSECAPACITY 7700
#define WAGONCAPACITY 15400
#else
#define PERSONCAPACITY(u) (race[(u)->race].weight+540)
extern int personcapacity(struct unit *u);
#define HORSECAPACITY 7000
#define WAGONCAPACITY 14000
#endif
#define HORSESNEEDED 2
@ -59,7 +52,7 @@ extern struct ship * move_ship(struct ship * sh, struct region * from, struct re
extern attrib_type at_piracy_direction;
void follow(void);
extern void follow(void);
struct building_type;
boolean buildingtype_exists(const struct region * r, const struct building_type * bt);

View file

@ -1,6 +1,5 @@
/* vi: set ts=2:
*
* $Id: plane.h,v 1.5 2001/04/01 06:58:40 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)
@ -22,19 +21,20 @@
#ifndef PLANES_H
#define PLANES_H
#define PFL_NOCOORDS 1
#define PFL_NORECRUITS 2
#define PFL_NOALLIANCES 4
#define PFL_LOWSTEALING 8
#define PFL_NOGIVE 16 /* Übergaben sind unmöglich */
#define PFL_NOATTACK 32 /* Angriffe und Diebstähle sind unmöglich */
#define PFL_NOTERRAIN 64 /* Terraintyp wird nicht angezeigt TODO? */
#define PFL_NOMAGIC 128 /* Zaubern ist unmöglich */
#define PFL_NOSTEALTH 256 /* Tarnung außer Betrieb */
#define PFL_NOTEACH 512 /* Lehre außer Betrieb */
#define PFL_NOBUILD 1024 /* Lehre außer Betrieb */
#define PFL_NOFEED 2048 /* Kein Unterhalt nötig TODO */
#define PFL_FRIENDLY 4096 /* everyone is your ally */
#define PFL_NOCOORDS 1
#define PFL_NORECRUITS 2
#define PFL_NOALLIANCES 4
#define PFL_LOWSTEALING 8
#define PFL_NOGIVE 16 /* Übergaben sind unmöglich */
#define PFL_NOATTACK 32 /* Angriffe und Diebstähle sind unmöglich */
#define PFL_NOTERRAIN 64 /* Terraintyp wird nicht angezeigt TODO? */
#define PFL_NOMAGIC 128 /* Zaubern ist unmöglich */
#define PFL_NOSTEALTH 256 /* Tarnung außer Betrieb */
#define PFL_NOTEACH 512 /* Lehre außer Betrieb */
#define PFL_NOBUILD 1024 /* Lehre außer Betrieb */
#define PFL_NOFEED 2048 /* Kein Unterhalt nötig TODO */
#define PFL_FRIENDLY 4096 /* everyone is your ally */
#define PFL_NOORCGROWTH 8192 /* orcs don't grow */
#define PFL_MUSEUM PFL_NOCOORDS | PFL_NORECRUITS | PFL_NOGIVE | PFL_NOATTACK | PFL_NOTERRAIN | PFL_NOMAGIC | PFL_NOSTEALTH | PFL_NOTEACH | PFL_NOBUILD | PFL_NOFEED

View file

@ -580,7 +580,7 @@ struct racedata race[MAXRACES] =
true,
RCF_KILLPEASANTS|RCF_SCAREPEASANTS|RCF_ATTACKRANDOM|RCF_MOVERANDOM|RCF_LEARN|RCF_WALK|RCF_NOTEACH|RCF_DESERT,
BF_MAGIC_EQUIPMENT,
0,
ECF_REC_ETHEREAL,
{NORACE,NORACE,NORACE,NORACE,NORACE,NORACE},
&shadow_name, NULL,
},
@ -1150,7 +1150,7 @@ struct racedata race[MAXRACES] =
BF_EQUIPMENT | BF_MAGIC_EQUIPMENT,
/* Economic-Flags */
GIVEITEM | GIVEPERSON | GIVEUNIT | GETITEM | REC_HORSES,
GIVEITEM | GIVEPERSON | GIVEUNIT | GETITEM | ECF_REC_HORSES,
/* Vertraute für den Zauber
(Generisch, Illaun, Tybied, Cerddor, Gwyrrd, Draig) */
@ -1793,9 +1793,9 @@ struct racedata race[MAXRACES] =
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
},
true, /* Nonplayer (bei Gelegenheit entfernen) */
(RCF_SHAPESHIFT | RCF_FLY | RCF_WALK | RCF_LEARN | RCF_MOVERANDOM | RCF_ATTACKRANDOM), /* flags */
(RCF_SHAPESHIFTANY | RCF_SHAPESHIFT | RCF_FLY | RCF_WALK | RCF_LEARN | RCF_MOVERANDOM | RCF_ATTACKRANDOM), /* flags */
(BF_EQUIPMENT | BF_MAGIC_EQUIPMENT), /* battle */
(CANGUARD | GIVEITEM | GIVEPERSON | GIVEUNIT | GETITEM), /* economy */
(ECF_REC_ETHEREAL | ECF_REC_UNLIMITED | CANGUARD | GIVEITEM | GIVEPERSON | GIVEUNIT | GETITEM), /* economy */
/* Vertraute für den Zauber (Gen, Ill, Tyb, Cer, Gwy, Dra) */
{NORACE,NORACE,NORACE,NORACE,NORACE,NORACE}
}
@ -1950,7 +1950,7 @@ boolean is_undead(const unit *u)
|| u->race == RC_GHOUL_LORD;
}
extern void
extern void
init_races(void)
{
a_add(&race[RC_TROLL].attribs, make_skillmod(NOSKILL, SMF_RIDING, NULL, 0.0, -1));

View file

@ -97,6 +97,7 @@ typedef struct race_type {
#define RCF_NOHEAL (1<<16) /* Einheit kann nicht geheilt werden */
#define RCF_NOWEAPONS (1<<17) /* Einheit kann keine Waffen bneutzen */
#define RCF_SHAPESHIFT (1<<18) /* Kann TARNE RASSE benutzen. */
#define RCF_SHAPESHIFTANY (1<<19) /* Kann TARNE RASSE "string" benutzen. */
/* Economic flags */
#define NOGIVE (1<<0) /* gibt niemals nix */
@ -106,7 +107,9 @@ typedef struct race_type {
#define GETITEM (1<<4) /* nimmt Gegenstände an */
#define HOARDMONEY (1<<5) /* geben niemals Silber weg */
#define CANGUARD (1<<6) /* bewachen auch ohne Waffen */
#define REC_HORSES (1<<7) /* Rekrutiert aus Pferden */
#define ECF_REC_HORSES (1<<7) /* Rekrutiert aus Pferden */
#define ECF_REC_ETHEREAL (1<<8) /* Rekrutiert aus dem Nichts */
#define ECF_REC_UNLIMITED (1<<9) /* Rekrutiert ohne Limit */
/* Battle-Flags */
#define BF_EQUIPMENT (1<<0)

View file

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: region.c,v 1.9 2001/02/11 08:55:48 corwin Exp $
* $Id: region.c,v 1.10 2001/04/12 17:21:44 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)
@ -65,7 +65,7 @@ const direction_t back[MAXDIRECTIONS] =
};
const char *
tregionid(const region * r, const faction * f)
regionname(const region * r, const faction * f)
{
static char buf[65];
plane *pl = getplane(r);
@ -636,7 +636,7 @@ new_region(int x, int y)
region *r = rfindhash(x, y);
if (r) {
fprintf(stderr, "\ndoppelte regionen entdeckt: %s\n", tregionid(r, NULL));
fprintf(stderr, "\ndoppelte regionen entdeckt: %s\n", regionname(r, NULL));
if (r->units)
fprintf(stderr, "doppelte region enthält einheiten\n");
return r;

View file

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: region.h,v 1.5 2001/02/24 12:50:48 enno Exp $
* $Id: region.h,v 1.6 2001/04/12 17:21:44 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)
@ -177,7 +177,7 @@ extern const char * rname(const struct region * r, const locale * lang);
extern void r_setdemand(struct region * r, const struct luxury_type * ltype, int value);
extern int r_demand(const struct region * r, const struct luxury_type * ltype);
extern const char * tregionid(const struct region * r, const struct faction * f);
extern const char * regionname(const struct region * r, const struct faction * f);
extern void * resolve_region(void * data);
extern struct region * new_region(int x, int y);
extern void terraform(struct region * r, terrain_t terrain);

View file

@ -44,6 +44,7 @@
/* attributes includes */
#include <attributes/follow.h>
#include <attributes/racename.h>
const char * g_reportdir;
@ -173,7 +174,7 @@ bufunit(const faction * f, const unit * u, int indent,
int i, dh;
skill_t sk;
int getarnt = fval(u, FL_PARTEITARNUNG);
const char *c;
const char *pzTmp;
spell *sp;
building * b;
boolean itemcloak = is_cursed(u->attribs, C_ITEMCLOAK, 0);
@ -213,8 +214,10 @@ bufunit(const faction * f, const unit * u, int indent,
scat(" ");
}
if (u->irace != u->race) {
scat(race[u->irace].name[u->number != 1]);
pzTmp = get_racename(u->attribs);
if (pzTmp || u->irace != u->race) {
if (pzTmp) scat(pzTmp);
else scat(race[u->irace].name[u->number != 1]);
if (u->faction == f) {
scat(" (");
scat(race[u->race].name[u->number != 1]);
@ -227,8 +230,8 @@ bufunit(const faction * f, const unit * u, int indent,
/* status */
if (u->number && (u->faction == f || telepath_see || isbattle)) {
const char * c = hp_status(u);
scat(report_kampfstatus(u));
c = hp_status(u);
if (c || fval(u, FL_HUNGER)) {
scat(" (");
if(c) scat(c);
@ -391,10 +394,10 @@ bufunit(const faction * f, const unit * u, int indent,
if (i != '!' && i != '?' && i != '.')
scat(".");
c = uprivate(u);
if (u->faction == f && c) {
pzTmp = uprivate(u);
if (u->faction == f && pzTmp) {
scat(" (Bem: ");
scat(c);
scat(pzTmp);
scat(")");
}

View file

@ -2159,7 +2159,7 @@ extern void create_teleport_plane(void);
void read_strings(FILE * F);
const char * messages[] = {
"%s/%s/messages.txt",
"%s/%s/messages.xml",
NULL
};

View file

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: ship.c,v 1.3 2001/02/18 10:06:09 enno Exp $
* $Id: ship.c,v 1.4 2001/04/12 17:21:44 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)
@ -257,7 +257,7 @@ destroy_ship(ship * s, region * r)
handle_event(&s->attribs, "destroy", s);
}
char *
const char *
shipname(const ship * sh)
{
typedef char name[OBJECTIDSIZE + 1];

View file

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: ship.h,v 1.3 2001/02/18 10:06:09 enno Exp $
* $Id: ship.h,v 1.4 2001/04/12 17:21:44 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)
@ -88,6 +88,6 @@ extern struct unit *captain(ship *sh, struct region *r);
extern struct unit *shipowner(const struct region * r, const struct ship * sh);
extern ship *new_ship(const struct ship_type * stype, struct region * r);
extern char *shipname(const struct ship * sh);
extern const char *shipname(const struct ship * sh);
extern ship *findship(int n);
#endif

View file

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: unit.c,v 1.8 2001/02/19 16:45:23 katze Exp $
* $Id: unit.c,v 1.9 2001/04/12 17:21:44 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)
@ -34,12 +34,16 @@
#include "region.h"
#include "ship.h"
#ifdef AT_MOVED
# include <attributes/moved.h>
#endif
/* util includes */
#include <resolve.h>
#include <base36.h>
#include <event.h>
#ifdef OLD_TRIGGER
#include <old/trigger.h>
# include <old/trigger.h>
#endif
/* libc includes */
@ -649,6 +653,9 @@ move_unit(unit * u, region * r, unit ** ulist)
if (u->region == r) return;
if (!ulist) ulist = (&r->units);
if (u->region) {
#ifdef AT_MOVED
set_moved(&u->attribs);
#endif
setguard(u, GUARD_NONE);
fset(u, FL_MOVED);
if (u->ship || u->building) leave(u->region, u);

View file

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: arena.c,v 1.4 2001/02/11 20:54:01 enno Exp $
* $Id: arena.c,v 1.5 2001/04/12 17:21:44 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)
@ -267,7 +267,7 @@ read_hurting(attrib * a, FILE * F) {
fscanf(F, "%d", &i);
a->data.v = (void*)findbuilding(i);
if (a->data.v==NULL) {
fprintf(stderr, "WARNING: temple of pain is broken\n");
log_error(("temple of pain is broken\n"));
return 0;
}
return 1;
@ -434,7 +434,7 @@ caldera_handle(trigger * t, void * data)
if (*up==u) up = &u->next;
}
} else
fprintf(stderr, "\aERROR: could not perform caldera::handle()\n");
log_error(("could not perform caldera::handle()\n"));
unused(data);
return 0;
}

View file

@ -130,14 +130,6 @@ gm_create(const char * str, struct unit * u)
}
}
struct attrib *
find_key(struct attrib * attribs, int key)
{
attrib * a = a_find(attribs, &at_key);
while (a && a->data.i!=key) a=a->nexttype;
return a;
}
/**
** GM: TERRAFORM <terrain> <x> <y>
** requires: permission-key "gmterf"
@ -225,6 +217,40 @@ gm_give(const char * str, struct unit * u)
}
}
/**
** GM: TAKE <unit> <int> <itemtype>
** requires: permission-key "gmtake"
**/
static void
gm_take(const char * str, struct unit * u)
{
unit * to = findunit(atoi36(igetstrtoken(str)));
int num = atoi(getstrtoken());
const item_type * itype = finditemtype(getstrtoken(), u->faction->locale);
if (to==NULL || rplane(to->region) != rplane(u->region)) {
/* unknown or in another plane */
mistake(u, str, "Die Einheit wurde nicht gefunden.\n", 0);
} else if (itype==NULL || i_get(to->items, itype)==0) {
/* unknown or not enough */
mistake(u, str, "So einen Gegenstand hat die Einheit nicht.\n", 0);
} else {
/* checking permissions */
attrib * permissions = a_find(u->faction->attribs, &at_permissions);
if (!permissions || !find_key((attrib*)permissions->data.v, atoi36("gmtake"))) {
mistake(u, str, "Unzureichende Rechte für diesen Befehl.\n", 0);
}
else {
int i = i_get(to->items, itype);
if (i<num) num=i;
if (num) {
i_change(&to->items, itype, -num);
i_change(&u->items, itype, num);
}
}
}
}
/**
** GM: SKILL <unit> <skill> <tage>
** requires: permission-key "gmskil"
@ -283,6 +309,7 @@ init_gmcmd(void)
add_gmcommand(&g_cmds, "terraform", &gm_terraform);
add_gmcommand(&g_cmds, "create", &gm_create);
add_gmcommand(&g_cmds, "give", &gm_give);
add_gmcommand(&g_cmds, "take", &gm_take);
add_gmcommand(&g_cmds, "teleport", &gm_teleport);
add_gmcommand(&g_cmds, "skill", &gm_skill);
}
@ -387,6 +414,7 @@ gm_addquest(const char * email, const char * name, int radius, unsigned int flag
a_add((attrib**)&a->data.v, make_key(atoi36("gmtele")));
a_add((attrib**)&a->data.v, make_key(atoi36("gmgive")));
a_add((attrib**)&a->data.v, make_key(atoi36("gmskil")));
a_add((attrib**)&a->data.v, make_key(atoi36("gmtake")));
a_add((attrib**)&a->data.v, make_atgmcreate(resource2item(r_silver)));

View file

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: xmas2000.c,v 1.5 2001/04/01 06:58:41 enno Exp $
* $Id: xmas2000.c,v 1.6 2001/04/12 17:21:44 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)
@ -71,7 +71,7 @@ xmasgate_handle(trigger * t, void * data)
if (*up==u) up = &u->next;
}
} else
fprintf(stderr, "ERROR: could not perform xmasgate::handle()\n");
log_error(("could not perform xmasgate::handle()\n"));
unused(data);
return 0;
}

View file

@ -1,6 +1,5 @@
/* vi: set ts=2:
*
* $Id: alp.c,v 1.3 2001/04/01 06:58:41 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)
@ -150,7 +149,7 @@ sp_summon_alp(struct castorder *co)
}
static void
void
alp_findet_opfer(unit *alp, region *r)
{
curse * c;
@ -201,71 +200,24 @@ alp_findet_opfer(unit *alp, region *r)
}
}
void
monster_seeks_target(region *r, unit *u)
{
direction_t d;
strlist *S, **SP;
unit *target;
int dist, dist2;
direction_t i;
region *nr;
/* Das Monster sucht ein bestimmtes Opfer. Welches, steht
* in einer Referenz (alles noch nicht richtig implementiert...)
*/
target = NULL; /* TODO: aus Referenz holen */
/* TODO: prüfen, ob target überhaupt noch existiert... */
if( r == target->region ) { /* Wir haben ihn! */
switch( u->race ) {
case RC_ALP:
alp_findet_opfer(u, r);
break;
default:
assert(!"Seeker-Monster hat keine Aktion fuer Ziel");
}
return;
}
/* Simpler Ansatz: Nachbarregion mit gerinster Distanz suchen.
* Sinnvoll momentan nur bei Monstern, die sich nicht um das
* Terrain kümmern. Nebelwände & Co machen derzeit auch nix...
*/
dist2 = distance(r, target->region);
d = NODIRECTION;
for( i = 0; i < MAXDIRECTIONS; i++ ) {
nr = rconnect(r, i);
assert(nr);
dist = distance(nr, target->region);
if( dist < dist2 ) {
dist2 = dist;
d = i;
}
}
assert(d != NODIRECTION );
switch( u->race ) {
case RC_ALP:
if( !(u->age % 2) ) /* bewegt sich nur jede zweite Runde */
d = NODIRECTION;
break;
default:
break;
}
if( d == NODIRECTION )
return;
sprintf(buf, "%s %s", keywords[K_MOVE], directions[d]);
SP = &u->orders;
S = makestrlist(buf);
addlist2(SP, S);
*SP = 0;
}
void
init_alp(void)
{
at_register(&at_alp);
}
unit *
alp_target(unit *alp)
{
alp_data* ad;
unit * target = NULL;
attrib * a = a_find(alp->attribs, &at_alp);
if (a) {
ad = (alp_data*) a->data.v;
target = ad->target;
}
return target;
}

View file

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: alp.h,v 1.2 2001/01/26 16:19:41 enno Exp $
* $Id: alp.h,v 1.3 2001/04/12 17:21:45 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)
@ -39,4 +39,9 @@ struct castorder;
extern int sp_summon_alp(struct castorder *co);
extern void init_alp(void);
struct unit* alp_target(struct unit *alp);
void alp_findet_opfer(struct unit *alp, struct region *r);
#endif

View file

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: changerace.c,v 1.2 2001/01/26 16:19:41 enno Exp $
* $Id: changerace.c,v 1.3 2001/04/12 17:21:45 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)
@ -64,7 +64,7 @@ changerace_handle(trigger * t, void * data)
if (td->race!=NORACE) td->u->race = td->race;
if (td->irace!=NORACE) td->u->irace = td->irace;
} else {
fprintf(stderr, "\aERROR: could not perform changerace::handle()\n");
log_error(("could not perform changerace::handle()\n"));
}
unused(data);
return 0;

View file

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: createcurse.c,v 1.2 2001/01/26 16:19:41 enno Exp $
* $Id: createcurse.c,v 1.3 2001/04/12 17:21:45 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)
@ -70,7 +70,7 @@ createcurse_handle(trigger * t, void * data)
create_curse(td->mage, &td->target->attribs,
td->id, td->id2, td->vigour, td->duration, td->effect, td->men);
} else {
fprintf(stderr, "\aERROR: could not perform createcurse::handle()\n");
log_error(("could not perform createcurse::handle()\n"));
}
unused(data);
return 0;

View file

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: createunit.c,v 1.2 2001/01/26 16:19:41 enno Exp $
* $Id: createunit.c,v 1.3 2001/04/12 17:21:45 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)
@ -66,7 +66,7 @@ createunit_handle(trigger * t, void * data)
if (td->r!=NULL && td->f!=NULL) {
createunit(td->r, td->f, td->number, td->race);
} else {
fprintf(stderr, "\aERROR: could not perform createunit::handle()\n");
log_error(("could not perform createunit::handle()\n"));
}
unused(data);
return 0;

View file

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: giveitem.c,v 1.2 2001/01/26 16:19:41 enno Exp $
* $Id: giveitem.c,v 1.3 2001/04/12 17:21:45 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)
@ -62,7 +62,7 @@ giveitem_handle(trigger * t, void * data)
if (td->u!=NULL) {
i_change(&td->u->items, td->itype, td->number);
} else
fprintf(stderr, "\aERROR: could not perform giveitem::handle()\n");
log_error(("could not perform giveitem::handle()\n"));
unused(data);
return 0;
}

View file

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: killunit.c,v 1.3 2001/02/25 19:31:39 enno Exp $
* $Id: killunit.c,v 1.4 2001/04/12 17:21:45 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)
@ -39,7 +39,7 @@ killunit_handle(trigger * t, void * data)
if (u!=NULL) {
destroy_unit(u);
} else
fprintf(stderr, "\aERROR: could not perform killunit::handle()\n");
log_error(("could not perform killunit::handle()\n"));
unused(data);
return 0;
}

View file

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: removecurse.c,v 1.2 2001/01/26 16:19:41 enno Exp $
* $Id: removecurse.c,v 1.3 2001/04/12 17:21:45 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)
@ -62,9 +62,9 @@ removecurse_handle(trigger * t, void * data)
if (a) {
a_remove(&td->target->attribs, a);
}
else fprintf(stderr, "\aERROR: could not perform removecurse::handle()\n");
else log_error(("ERROR: could not perform removecurse::handle()\n"));
} else {
fprintf(stderr, "\aERROR: could not perform removecurse::handle()\n");
log_error(("could not perform removecurse::handle()\n"));
}
unused(data);
return 0;

View file

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: shock.c,v 1.3 2001/02/15 02:41:47 enno Exp $
* $Id: shock.c,v 1.4 2001/04/12 17:21:45 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)
@ -40,7 +40,7 @@ shock_handle(trigger * t, void * data)
if (u!=NULL) {
do_shock(u, "trigger");
} else
fprintf(stderr, "\aERROR: could not perform shock::handle()\n");
log_error(("could not perform shock::handle()\n"));
unused(data);
return 0;
}

View file

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: unitmessage.c,v 1.2 2001/01/26 16:19:41 enno Exp $
* $Id: unitmessage.c,v 1.3 2001/04/12 17:21:45 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)
@ -65,7 +65,7 @@ unitmessage_handle(trigger * t, void * data)
if (td->target!=NULL) {
addmessage(td->target->region, td->target->faction, td->string, td->type, td->level);
} else
fprintf(stderr, "\aERROR: could not perform unitmessage::handle()\n");
log_error(("could not perform unitmessage::handle()\n"));
unused(data);
return 0;
}
@ -111,7 +111,7 @@ trigger_unitmessage(unit * target, const char * string, int type, int level)
trigger * t = t_new(&tt_unitmessage);
unitmessage_data * td = (unitmessage_data*)t->data.v;
td->target = target;
td->string = escape_string(strdup(string), SPACE_REPLACEMENT);
td->string = space_replace(strdup(string), SPACE_REPLACEMENT);
td->type = type;
td->level = level;
return t;

View file

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: attrib.c,v 1.4 2001/02/14 07:44:57 enno Exp $
* $Id: attrib.c,v 1.5 2001/04/12 17:21:45 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)
@ -15,6 +15,8 @@
#include <config.h>
#include "attrib.h"
#include "log.h"
#include <assert.h>
#include <string.h>
#include <stdlib.h>
@ -44,7 +46,7 @@ at_register(attrib_type * at)
find = at_hash[at->hashkey % MAXATHASH];
while (find && at->hashkey!=find->hashkey) find = find->nexthash;
if (find && find==at) {
fprintf(stderr, "WARNING: attribute '%s' was registered more than once\n", at->name);
log_warning(("attribute '%s' was registered more than once\n", at->name));
return;
} else {
assert(!find || !"hashkey is already in use");

View file

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: base36.c,v 1.3 2001/02/09 13:53:52 corwin Exp $
* $Id: base36.c,v 1.4 2001/04/12 17:21:45 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)
@ -67,8 +67,8 @@ itoab(int i, int base)
}
s = as[index];
index = (index+1) % 4;
dst = s+6;
dst = s+7;
(*dst--)=0;
if (i!=0) {
if (i<0) {
i=-i;

View file

@ -8,13 +8,14 @@
This program may not be used, modified or distributed
without prior permission by the authors of Eressea.
$Id: crmessage.c,v 1.1 2001/02/24 12:50:50 enno Exp $
$Id: crmessage.c,v 1.2 2001/04/12 17:21:45 enno Exp $
*/
#include <config.h>
#include "crmessage.h"
#include "message.h"
#include "log.h"
#include <stdio.h>
#include <stdlib.h>
@ -61,7 +62,6 @@ tsf_register(const char * name, tostring_f fun)
/** crmesssage **/
typedef struct crmessage_type {
const struct message_type * mtype;
const struct locale * lang;
tostring_f * renderers;
struct crmessage_type * next;
} crmessage_type;
@ -69,32 +69,27 @@ typedef struct crmessage_type {
static crmessage_type * messagetypes;
static crmessage_type *
crt_find(const struct locale * lang, const struct message_type * mtype)
crt_find(const struct message_type * mtype)
{
crmessage_type * found = NULL;
crmessage_type * type = messagetypes;
while (type) {
if (type->mtype==mtype) {
if (found==NULL) found = type;
else if (type->lang==NULL) found = type;
if (lang==type->lang) break;
}
if (type->mtype==mtype) found = type;
type = type->next;
}
return found;
}
void
crt_register(const struct message_type * mtype, const struct locale * lang)
crt_register(const struct message_type * mtype)
{
crmessage_type * crt = messagetypes;
while (crt && (crt->lang!=lang || crt->mtype!=mtype)) {
while (crt && crt->mtype!=mtype) {
crt = crt->next;
}
if (!crt) {
int i;
crt = malloc(sizeof(crmessage_type));
crt->lang = lang;
crt->mtype = mtype;
crt->next = messagetypes;
messagetypes = crt;
@ -108,18 +103,20 @@ crt_register(const struct message_type * mtype, const struct locale * lang)
}
int
cr_render(const message * msg, const struct locale * lang, char * buffer)
cr_render(const message * msg, char * buffer, const void * userdata)
{
int i;
char * c = buffer;
struct crmessage_type * crt = crt_find(lang, msg->type);
struct crmessage_type * crt = crt_find(msg->type);
if (crt==NULL) return -1;
for (i=0;i!=msg->type->nparameters;++i) {
if (crt->renderers[i]==NULL) {
strcpy(c, (const char*)msg->parameters[i]);
log_error(("No renderer for argument %s:%s of \"%s\"\n",
msg->type->pnames[i], msg->type->types[i], msg->type->name));
continue; /* strcpy(c, (const char*)msg->parameters[i]); */
} else {
crt->renderers[i](msg->parameters[i], c);
if (crt->renderers[i](msg->parameters[i], c, userdata)!=0) continue;
}
c += strlen(c);
sprintf(c, ";%s\n", msg->type->pnames[i]);
@ -128,14 +125,27 @@ cr_render(const message * msg, const struct locale * lang, char * buffer)
return 0;
}
void
cr_string(const void * v, char * buffer)
int
cr_string(const void * v, char * buffer, const void * userdata)
{
sprintf(buffer, "\"%s\"", (const char *)v);
unused(userdata);
return 0;
}
void
cr_int(const void * v, char * buffer)
int
cr_int(const void * v, char * buffer, const void * userdata)
{
sprintf(buffer, "%d", (int)v);
unused(userdata);
return 0;
}
int
cr_ignore(const void * v, char * buffer, const void * userdata)
{
unused(v);
unused(buffer);
unused(userdata);
return -1;
}

View file

@ -14,13 +14,14 @@ struct locale;
struct message;
struct message_type;
typedef void (*tostring_f)(const void * data, char * buffer);
typedef int (*tostring_f)(const void * data, char * buffer, const void * userdata);
extern void tsf_register(const char * name, tostring_f fun);
/* registers a new type->string-function */
extern void cr_string(const void * v, char * buffer);
extern void cr_int(const void * v, char * buffer);
extern int cr_string(const void * v, char * buffer, const void * userdata);
extern int cr_int(const void * v, char * buffer, const void * userdata);
extern int cr_ignore(const void * v, char * buffer, const void * userdata);
extern void crt_register(const struct message_type * mtype, const struct locale * lang);
extern int cr_render(const struct message * msg, const struct locale * lang, char * buffer);
extern void crt_register(const struct message_type * mtype);
extern int cr_render(const struct message * msg, char * buffer, const void * userdata);

View file

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: goodies.c,v 1.7 2001/02/14 01:38:50 enno Exp $
* $Id: goodies.c,v 1.8 2001/04/12 17:21:45 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)
@ -70,19 +70,33 @@ hashstring(const char* s)
}
char *
escape_string(char * str, char replace)
space_replace(char * str, char replace)
{
char * c = str;
while (*c) {if (isspace(*c)) *c = replace; c++;}
return str;
}
char *
unescape_string(char * str, char replace)
const char *
escape_string(const char * str, char * buffer, size_t len)
{
char * c = str;
while (*c) { if (*c==replace) *c = ' '; c++; }
return str;
char s_buffer[4096];
const char * p = str;
char * o;
if (buffer==NULL) {
buffer = s_buffer;
len = sizeof(s_buffer);
}
o = buffer;
do {
switch (*p) {
case '\"':
case '\\':
(*o++) = '\\';
}
(*o++) = (*p);
} while (*p++);
return buffer;
}
char *

View file

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: goodies.h,v 1.3 2001/02/10 11:38:29 enno Exp $
* $Id: goodies.h,v 1.4 2001/04/12 17:21:45 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)
@ -19,8 +19,8 @@ extern int *intlist_init(void);
extern int *intlist_add(int *i_p, int i);
extern int *intlist_find(int *i_p, int i);
extern unsigned int hashstring(const char* s);
extern char *escape_string(char * str, char replace);
extern char *unescape_string(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);
/* grammar constants: */
#define GR_PLURAL 0x01
/* 0x02-0x08 left unused for individual use */

View file

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: language.c,v 1.4 2001/02/11 20:54:01 enno Exp $
* $Id: language.c,v 1.5 2001/04/12 17:21:45 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)
@ -12,8 +12,9 @@
* prior permission by the authors of Eressea.
*/
#include <config.h>
#include "language.h"
#include "log.h"
#include "goodies.h"
#include <stdlib.h>
@ -90,10 +91,10 @@ locale_string(const locale * lang, const char * key)
}
if (!find) {
if (lang==default_locale) {
fprintf(stderr, "WARNING: missing translation for \"%s\"\n", key);
log_warning(("missing translation for \"%s\"\n", key));
return key;
}
fprintf(stderr, "WARNING: missing translation for \"%s\" in locale %s\n", key, lang->name);
log_warning(("missing translation for \"%s\" in locale %s\n", key, lang->name));
return locale_string(default_locale, key);
}
return find->str;

View file

@ -4,6 +4,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <time.h>
#define LOG_FLUSH (1<<0)
#define LOG_CPERROR (1<<1)
@ -35,12 +36,24 @@ log_open(const char * filename)
{
if (logfile) log_close();
logfile = fopen(filename, "a");
if (logfile) {
/* Get UNIX-style time and display as number and string. */
time_t ltime;
time( &ltime );
log_printf( "===\n=== Logfile started at %s===\n", ctime( &ltime ) );
}
}
void
log_close(void)
{
if (!logfile || logfile == stderr || logfile == stdout) return;
if (logfile) {
/* Get UNIX-style time and display as number and string. */
time_t ltime;
time( &ltime );
log_printf("===\n=== Logfile closed at %s===\n\n", ctime( &ltime ) );
}
fclose(logfile);
}

View file

@ -8,7 +8,7 @@
This program may not be used, modified or distributed
without prior permission by the authors of Eressea.
$Id: message.c,v 1.2 2001/02/28 22:14:58 enno Exp $
$Id: message.c,v 1.3 2001/04/12 17:21:45 enno Exp $
*/
#include <config.h>
@ -20,6 +20,12 @@
#include <string.h>
#include <stdarg.h>
const char *
mt_name(const message_type* mtype)
{
return mtype->name;
}
message_type *
mt_new(const char * name, const char * args[])
{

View file

@ -36,6 +36,8 @@ extern struct message * msg_create_va(const struct message_type * type, ...);
extern void msg_free(struct message *m);
/* remove message and associated data from memory */
extern const char * mt_name(const struct message_type* mtype);
/** message_type registry (optional): **/
extern const struct message_type * mt_register(const struct message_type *);
extern const struct message_type * mt_find(const char *);

View file

@ -8,15 +8,18 @@
This program may not be used, modified or distributed
without prior permission by the authors of Eressea.
$Id: nrmessage.c,v 1.3 2001/02/28 22:14:59 enno Exp $
$Id: nrmessage.c,v 1.4 2001/04/12 17:21:45 enno Exp $
*/
#include <config.h>
#include "nrmessage.h"
/* util includes */
#include "log.h"
#include "message.h"
#include "translation.h"
/* libc includes */
#include <string.h>
#include <stdlib.h>
@ -32,7 +35,13 @@ typedef struct nrmessage_type {
static nrmessage_type * messagetypes;
static nrmessage_type *
const char *
nrt_string(const struct nrmessage_type *type)
{
return type->string;
}
nrmessage_type *
nrt_find(const struct locale * lang, const struct message_type * mtype)
{
nrmessage_type * found = NULL;
@ -41,7 +50,10 @@ nrt_find(const struct locale * lang, const struct message_type * mtype)
if (type->mtype==mtype) {
if (found==NULL) found = type;
else if (type->lang==NULL) found = type;
if (lang==type->lang) break;
if (lang==type->lang) {
found = type;
break;
}
}
type = type->next;
}
@ -76,15 +88,20 @@ nrt_register(const struct message_type * mtype, const struct locale * lang, cons
}
}
int
nr_render(const struct message * msg, const struct locale * lang, char * buffer)
nr_render(const struct message * msg, const struct locale * lang, char * buffer, const void * userdata)
{
struct nrmessage_type * nrt = nrt_find(lang, msg->type);
if (nrt) {
strcpy(buffer, translate(nrt->string, nrt->vars, msg->parameters));
return 0;
const char * m = translate(nrt->string, userdata, nrt->vars, msg->parameters);
if (m) {
strcpy(buffer, m);
return 0;
}
else {
log_error(("Couldn't render message %s\n", nrt->mtype->name));
}
}
return -1;
}

View file

@ -15,15 +15,19 @@ struct message;
struct message_type;
struct nrmessage_type;
extern int nr_render(const struct message * msg, const struct locale * lang,
char * buffer);
extern void nrt_register(const struct message_type * mtype,
const struct locale * lang, const char * script,
int level, const char * section);
extern struct nrmessage_type * nrt_find(const struct locale *,
const struct message_type *);
extern const char * nrt_string(const struct nrmessage_type *type);
extern int nr_render(const struct message * msg, const struct locale * lang,
char * buffer, const void * userdata);
extern int nr_level(const struct message *msg);
extern const char * nr_section(const struct message *msg);
/* before:
* fogblock;movement:0;de;{unit} konnte von {region} nicht nach {$dir direction} ausreisen, der Nebel war zu dicht.
* after:

View file

@ -1,5 +1,8 @@
#include <config.h>
#include "translation.h"
/* libc includes */
#include <assert.h>
#include <ctype.h>
#include <string.h>
@ -36,11 +39,6 @@ opstack_push(opstack ** stack, void * data)
*stack = os;
}
static opstack * stack;
#define opush(i) opstack_push(&stack, (void *)(i))
#define opop(T) (T)opstack_pop(&stack)
/**
** static buffer malloc
**/
@ -132,7 +130,6 @@ find_variable(const char * symbol)
** constant values
**/
typedef void (*evalfun)(void);
typedef struct function {
struct function * next;
const char * symbol;
@ -151,7 +148,7 @@ free_functions(void)
}
}
static void
void
add_function(const char * symbol, evalfun parse)
{
function * fun = (function*)malloc(sizeof(function));
@ -174,11 +171,11 @@ find_function(const char * symbol)
return fun;
}
static const char * parse(const char* in);
static const char * parse(opstack **, const char* in, const void *);
/* static const char * sample = "\"enno and $bool($if($eq($i,0),\"noone else\",\"$i other people\"))\""; */
static const char *
parse_symbol(const char* in)
parse_symbol(opstack ** stack, const char* in, const void * userdata)
/* in is the symbol name and following text, starting after the $
* result goes on the stack
*/
@ -195,24 +192,24 @@ parse_symbol(const char* in)
*/
function * foo;
while (*in != ')') {
in = parse(++in); /* will push the result on the stack */
in = parse(stack, ++in, userdata); /* will push the result on the stack */
if (in==NULL) return NULL;
}
++in;
foo = find_function(symbol);
if (foo==NULL) return NULL;
foo->parse(); /* will pop parameters from stack (reverse order!) and push the result */
foo->parse(stack, userdata); /* will pop parameters from stack (reverse order!) and push the result */
} else {
/* it's a constant (variable is a misnomer, but heck, const was taken;)) */
variable * var = find_variable(symbol);
if (var==NULL) return NULL;
opush(var->value);
opush(stack, var->value);
}
return in;
}
static const char *
parse_string(const char* in) /* (char*) -> char* */
parse_string(opstack ** stack, const char* in, const void * userdata) /* (char*) -> char* */
{
char * c;
char * buffer = balloc(4*1024);
@ -247,9 +244,9 @@ parse_string(const char* in) /* (char*) -> char* */
++ic;
break;
case '$':
ic = parse_symbol(++ic);
ic = parse_symbol(stack, ++ic, userdata);
if (ic==NULL) return NULL;
c = opop(char*);
c = opop(stack, char*);
oc += strlen(strcpy(oc, c));
bfree(c);
break;
@ -260,12 +257,12 @@ parse_string(const char* in) /* (char*) -> char* */
}
*oc++ = '\0';
bfree(oc);
opush(buffer);
opush(stack, buffer);
return ic;
}
static const char *
parse_int(const char * in)
parse_int(opstack ** stack, const char * in)
{
int k = 0;
int vz = 1;
@ -286,25 +283,25 @@ parse_int(const char * in)
while (isdigit(*in)) {
k = k * 10 + (*in++)-'0';
}
opush(k*vz);
opush(stack, k*vz);
return in;
}
static const char *
parse(const char* in)
parse(opstack ** stack, const char* in, const void * userdata)
{
while (*in) {
switch (*in) {
case '"':
return parse_string(++in);
return parse_string(stack, ++in, userdata);
break;
case '$':
return parse_symbol(++in);
return parse_symbol(stack, ++in, userdata);
break;
default:
if (isdigit(*in) || *in=='-' || *in=='+') {
return parse_int(in);
return parse_int(stack, in);
}
else ++in;
}
@ -313,14 +310,14 @@ parse(const char* in)
}
char *
translate(const char* format, const char* vars, const void* args[])
translate(const char* format, const void * userdata, const char* vars, const void* args[])
{
int i = 0;
char * retval;
const char *ic = vars;
char symbol[32];
char *oc = symbol;
opstack * stack = NULL;
brelease();
free_variables();
@ -336,21 +333,21 @@ translate(const char* format, const char* vars, const void* args[])
}
}
if (parse(format)==NULL) return NULL;
retval = strdup(opop(const char*));
if (parse(&stack, format, userdata)==NULL) return NULL;
retval = strdup(opop(&stack, const char*));
return retval;
}
char *
translate_va(const char* format, const char* vars, ...)
translate_va(const char* format, const void * userdata, const char* vars, ...)
{
char * retval;
va_list marker;
const char *ic = vars;
char symbol[32];
char *oc = symbol;
opstack * stack = NULL;
brelease();
free_variables();
@ -368,76 +365,66 @@ translate_va(const char* format, const char* vars, ...)
}
va_end(marker); /* Reset variable arguments. */
if (parse(format)==NULL) return NULL;
retval = strdup(opop(const char*));
if (parse(&stack, format, userdata)==NULL) return NULL;
retval = strdup(opop(&stack, const char*));
return retval;
}
static void
eval_eq(void) /* (int, int) -> int */
eval_eq(opstack ** stack, const void * userdata) /* (int, int) -> int */
{
int a = opop(int);
int b = opop(int);
int a = opop(stack, int);
int b = opop(stack, int);
int rval = (a==b)?1:0;
opush(rval);
opush(stack, rval);
unused(userdata);
}
static void
eval_add(void) /* (int, int) -> int */
eval_add(opstack ** stack, const void * userdata) /* (int, int) -> int */
{
int a = opop(int);
int b = opop(int);
opush(a+b);
int a = opop(stack, int);
int b = opop(stack, int);
opush(stack, a+b);
unused(userdata);
}
static void
eval_if(void) /* (int, int) -> int */
eval_if(opstack ** stack, const void * userdata) /* (int, int) -> int */
{
void * a = opop(void *);
void * b = opop(void *);
int cond = opop(int);
opush(cond?b:a);
void * a = opop(stack, void *);
void * b = opop(stack, void *);
int cond = opop(stack, int);
opush(stack, cond?b:a);
unused(userdata);
}
#include "base36.h"
static void
eval_int(void)
eval_int(opstack ** stack, const void * userdata)
{
int i = opop(int);
int i = opop(stack, int);
const char * c = itoa10(i);
opush(strcpy(balloc(strlen(c)+1), c));
opush(stack, strcpy(balloc(strlen(c)+1), c));
unused(userdata);
}
#include "language.h"
static void
eval_localize(void) /* (locale, string) -> string */
eval_localize(opstack ** stack, const void * userdata) /* (string, locale) -> string */
{
const struct locale *lang = opop(const struct locale *);
const char *c = opop(const char *);
const char *r = locale_string(lang, c);
bfree((char*)c);
opush(r);
}
struct unit;
extern const char * unitname(const struct unit *u);
static void
eval_unit(void) /* unit -> string */
{
const struct unit * u = opop(const struct unit *);
const char * c = u?"unit u":"nobody";
size_t len = strlen(c);
opush(strcpy(balloc(len+1), c));
const struct locale *lang = opop(stack, const struct locale *);
const char *c = opop(stack, const char *);
c = locale_string(lang, c);
opush(stack, strcpy(balloc(strlen(c)+1), c));
unused(userdata);
}
void
translation_init(void)
{
add_function("eq", &eval_eq);
add_function("unit", &eval_unit);
add_function("int", &eval_int);
add_function("add", &eval_add);
add_function("if", &eval_if);

View file

@ -10,7 +10,21 @@
without prior permission by the authors of Eressea.
*/
struct opstack;
extern void * opstack_pop(struct opstack ** stack);
extern void opstack_push(struct opstack ** stack, void * data);
#define opush(stack, i) opstack_push(stack, (void *)(i))
#define opop(stack, T) (T)opstack_pop(stack)
extern void translation_init(void);
extern void translation_done(void);
extern char * translate_va(const char* format, const char* vars, ...);
extern char * translate(const char* format, const char* vars, const void* args[]);
extern char * translate_va(const char* format, const void * userdata, const char* vars, ...);
extern char * translate(const char* format, const void * userdata, const char* vars, const void* args[]);
/* eval_x functions */
typedef void (*evalfun)(struct opstack ** stack, const void *);
extern void add_function(const char * symbol, evalfun parse);
/* transient memory blocks */
extern char * balloc(size_t size);

View file

@ -9,8 +9,9 @@
#include <ctype.h>
static int
__cberror(const struct xml_stack * stack, const char* parsed, unsigned int line, int error)
__cberror(const struct xml_stack * stack, const char* parsed, unsigned int line, int error, void *data)
{
unused(data);
fprintf(stderr, "Error #%d in line %u while parsing \"%s\"\n", -error, line, parsed);
return error;
}
@ -72,7 +73,7 @@ pop_tag(xml_stack ** ostack)
}
int
xml_parse(FILE * stream, struct xml_callbacks * cb)
xml_parse(FILE * stream, struct xml_callbacks * cb, void * data)
{
xml_stack * stack = NULL;
enum { TAG, ENDTAG, ATNAME, ATVALUE, PLAIN } state = PLAIN;
@ -82,7 +83,7 @@ xml_parse(FILE * stream, struct xml_callbacks * cb)
unsigned int line = 0;
xml_tag * tag = NULL;
xml_attrib * attrib = NULL;
int (*cb_error)(const struct xml_stack*, const char*, unsigned int, int) = __cberror;
int (*cb_error)(const struct xml_stack*, const char*, unsigned int, int, void*) = __cberror;
if (cb && cb->error) cb_error = cb->error;
for (;;) {
@ -93,11 +94,11 @@ xml_parse(FILE * stream, struct xml_callbacks * cb)
} else if (c==EOF) {
if (state==PLAIN) {
*pos='\0';
if (cb && cb->plaintext && pos!=tokbuffer) cb->plaintext(stack, tokbuffer);
if (cb && cb->plaintext && pos!=tokbuffer) cb->plaintext(stack, tokbuffer, data);
break;
} else {
*pos='\0';
return cb_error(stack, tokbuffer, line, XML_BROKENSTREAM);
return cb_error(stack, tokbuffer, line, XML_BROKENSTREAM, data);
}
}
do {
@ -108,14 +109,14 @@ xml_parse(FILE * stream, struct xml_callbacks * cb)
case '<':
case '/':
*pos='\0';
return cb_error(stack, tokbuffer, line, XML_INVALIDCHAR);
return cb_error(stack, tokbuffer, line, XML_INVALIDCHAR, data);
case '"':
quoted = !quoted;
break;
case '>':
if (quoted) {
*pos='\0';
return cb_error(stack, tokbuffer, line, XML_INVALIDCHAR);
return cb_error(stack, tokbuffer, line, XML_INVALIDCHAR, data);
}
state = TAG;
/* intentional fallthrough */
@ -146,11 +147,11 @@ xml_parse(FILE * stream, struct xml_callbacks * cb)
case '<':
case '/':
*pos='\0';
return cb_error(stack, tokbuffer, line, XML_INVALIDCHAR);
return cb_error(stack, tokbuffer, line, XML_INVALIDCHAR, data);
default:
if (isspace(c)) {
*pos='\0';
return cb_error(stack, tokbuffer, line, XML_INVALIDCHAR);
return cb_error(stack, tokbuffer, line, XML_INVALIDCHAR, data);
}
*pos++ = (char)c;
}
@ -160,7 +161,7 @@ xml_parse(FILE * stream, struct xml_callbacks * cb)
case '<':
if (cb && cb->plaintext && pos!=tokbuffer) {
*pos = '\0';
cb->plaintext(stack, tokbuffer);
cb->plaintext(stack, tokbuffer, data);
}
state = TAG;
tag = NULL;
@ -168,7 +169,7 @@ xml_parse(FILE * stream, struct xml_callbacks * cb)
break;
case '>':
*pos='\0';
return cb_error(stack, tokbuffer, line, XML_INVALIDCHAR);
return cb_error(stack, tokbuffer, line, XML_INVALIDCHAR, data);
default:
*pos++ = (char)c;
}
@ -179,7 +180,7 @@ xml_parse(FILE * stream, struct xml_callbacks * cb)
if (pos==tokbuffer) state = ENDTAG;
else {
*pos='\0';
return cb_error(stack, tokbuffer, line, XML_INVALIDCHAR);
return cb_error(stack, tokbuffer, line, XML_INVALIDCHAR, data);
}
break;
case '>':
@ -187,7 +188,7 @@ xml_parse(FILE * stream, struct xml_callbacks * cb)
*pos='\0';
push_tag(&stack, make_tag(tokbuffer));
}
if (cb && cb->tagbegin) cb->tagbegin(stack);
if (cb && cb->tagbegin) cb->tagbegin(stack, data);
state = PLAIN;
pos = tokbuffer;
break;
@ -214,8 +215,8 @@ xml_parse(FILE * stream, struct xml_callbacks * cb)
case '>':
*pos = '\0';
while (stack && strcmp(stack->tag->name, tokbuffer)!=0) free_tag(pop_tag(&stack));
if (stack==NULL) return cb_error(stack, tokbuffer, line, XML_NESTINGERROR);
if (cb && cb->tagend) cb->tagend(stack);
if (stack==NULL) return cb_error(stack, tokbuffer, line, XML_NESTINGERROR, data);
if (cb && cb->tagend) cb->tagend(stack, data);
free_tag(pop_tag(&stack));
state = PLAIN;
pos = tokbuffer;
@ -225,7 +226,7 @@ xml_parse(FILE * stream, struct xml_callbacks * cb)
case '=':
case '/':
*pos='\0';
return cb_error(stack, tokbuffer, line, XML_INVALIDCHAR);
return cb_error(stack, tokbuffer, line, XML_INVALIDCHAR, data);
default:
*pos++ = (char)c;
}
@ -235,3 +236,12 @@ xml_parse(FILE * stream, struct xml_callbacks * cb)
} /* for(;;) */
return XML_OK; /* SUCCESS */
}
const char *
xml_value(const xml_tag * tag, const char * name)
{
const xml_attrib * xa = tag->attribs;
while (xa && strcmp(name, xa->name)!=0) xa = xa->next;
if (xa) return xa->value;
return NULL;
}

View file

@ -18,16 +18,17 @@ typedef struct xml_attrib {
#define XML_INVALIDCHAR -1
#define XML_NESTINGERROR -2
#define XML_BROKENSTREAM -3
#define XML_USERERROR -10
/* callbacks */
typedef struct xml_callbacks {
int (*plaintext)(const struct xml_stack *, const char*);
int (*tagbegin)(const struct xml_stack *);
int (*tagend)(const struct xml_stack *);
int (*error)(const struct xml_stack *, const char*, unsigned int, int);
int (*plaintext)(const struct xml_stack *, const char*, void *);
int (*tagbegin)(const struct xml_stack *, void *);
int (*tagend)(const struct xml_stack *, void *);
int (*error)(const struct xml_stack *, const char*, unsigned int, int, void *);
} xml_callbacks;
/* parser */
#include <stdio.h>
extern int xml_parse(FILE * stream, struct xml_callbacks *);
extern int xml_parse(FILE * stream, struct xml_callbacks *, void *);
extern const char * xml_value(const struct xml_tag * tag, const char * name);

View file

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: config.h,v 1.5 2001/02/05 16:11:57 enno Exp $
* $Id: config.h,v 1.6 2001/04/12 17:21:40 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)
@ -230,4 +230,6 @@ extern char * strdup(const char *s);
#endif
#endif
#define unused(var) var = var
#endif

View file

@ -1,6 +1,5 @@
/* vi: set ts=2:
*
* $Id: attributes.c,v 1.7 2001/02/18 12:20:20 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)
@ -26,6 +25,13 @@
#include <attributes/iceberg.h>
#include <attributes/hate.h>
#include <attributes/overrideroads.h>
#include <attributes/racename.h>
#ifdef AT_OPTION
# include <attributes/option.h>
#endif
#ifdef AT_MOVED
# include <attributes/moved.h>
#endif
/* util includes */
#include <attrib.h>
@ -34,20 +40,19 @@ void
init_attributes(void)
{
at_register(&at_overrideroads);
/* at_gm */
init_gm();
/* at_iceberg */
init_iceberg();
/* at_key */
init_key();
/* at_orcification */
init_orcification();
/* at_follow */
init_gm();
init_follow();
/* at_targetregion */
init_targetregion();
/* at_hate */
init_orcification();
init_hate();
/* at_reduceproduction */
init_reduceproduction();
init_racename();
#ifdef AT_MOVED
init_moved();
#endif
#ifdef AT_OPTION
init_option();
#endif
}

View file

@ -123,14 +123,12 @@ fix_skills(void)
fscanf(F, "%s", zText);
magic = atoi36(zText);
{ /* check for magic key */
attrib * a = a_find(global.attribs, &at_key);
/* make sure that this is done only once! */
while (a && a->data.i!=magic) a=a->next;
attrib * a = find_key(global.attribs, magic);
if (a) {
log_warning(("[fix_skills] function was called a second time\n"));
return;
}
a_add(&global.attribs, a_new(&at_key))->data.i = magic;
a_add(&global.attribs, make_key(magic));
}
for (;;) {
int from, self, teach, skill;
@ -155,8 +153,7 @@ fix_skills(void)
/* make sure that this is done only once! */
#define do_once(magic, fun) \
{ \
attrib * a = a_find(global.attribs, &at_key); \
while (a && a->data.i!=(magic)) a=a->next; \
attrib * a = find_key(global.attribs, (magic)); \
if (a) { \
log_warning(("[do_once] a unique fix %d=\"%s\" was called a second time\n", magic, itoa36(magic))); \
} else { \
@ -488,7 +485,7 @@ resolve_border(void * data)
{
border_info * info = (border_info *)data;
region * to = rconnect(info->from, info->dir);
if (!to) fprintf(stderr, "WARNING: border can only exist between two regions\n");
if (!to) log_warning(("border can only exist between two regions\n"));
else {
border * b = new_border(info->type, info->from, to);
b->attribs = info->attribs;
@ -823,21 +820,6 @@ fix_score_option(void)
}
#endif
#if 0
static void
fix_randencounter(void) {
region * r;
for (r=regions;r;r=r->next) {
if (!r->land || rterrain(r)==T_GLACIER || r->units || r->ships || r->buildings) continue;
if (fval(r, RF_ENCOUNTER)) {
fputs("\n\nWARNING: FI_RANDENCOUNTER WAS STILL ENABLED\n\n", stderr);
return;
}
fset(r, RF_ENCOUNTER);
}
}
#endif
#if 0
static void
fix_wounds(void)
@ -912,37 +894,6 @@ name_seaserpents(void)
}
}
static void
give_questling(void)
{
unit *u1, *u2;
if((u1=findunitg(15474, NULL))==NULL) /* Questling */
return;
if((u2=findunitg(1429665, NULL))==NULL) /* Harmloser Wanderer */
return;
if (u1->faction==u2->faction) return;
add_message(&u1->faction->msgs,
new_message(u1->faction, "give%u:unit%u:target%r:region%X:resource%i:amount",
u1, u2, u1->region, r_unit, 1));
u_setfaction(u1, u2->faction);
add_message(&u2->faction->msgs,
new_message(u1->faction, "give%u:unit%u:target%r:region%X:resource%i:amount",
u1, u2, u1->region, r_unit, 1));
}
#if 0
static void
old_rsetroad(region * r, int val)
{
attrib * a = a_find(r->attribs, &at_road);
if (!a && val) a = a_add(&r->attribs, a_new(&at_road));
else if (a && !val) a_remove(&r->attribs, a);
if (val) a->data.i = val;
}
#endif
static int
old_rroad(region * r)
{
@ -1103,7 +1054,7 @@ fix_buildings(void)
int first;
if((statfile=fopen("building.txt","r"))==NULL) {
printf("WARNING: fix_buildings: cannot open building.txt!\n");
log_warning(("fix_buildings: cannot open building.txt!\n"));
return;
}
@ -1602,7 +1553,7 @@ fix_prices(void)
for(r=regions; r; r=r->next) if(r->land) {
int sales = 0, buys = 0;
const luxury_type *sale, *ltype;
const luxury_type *sale = NULL, *ltype;
struct demand *dmd;
for (dmd=r->land->demands;dmd;dmd=dmd->next) {
if(dmd->value == 0) {
@ -1620,6 +1571,7 @@ fix_prices(void)
r_setdemand(r, ltype, 0);
sale = ltype;
}
assert(sale);
if(buys == 0) {
for(ltype=luxurytypes; ltype; ltype=ltype->next) {
if(ltype != sale) r_setdemand(r, ltype, 1 + rand() % 5);
@ -2131,28 +2083,59 @@ fix_timeouts(void)
}
#include <modules/gmcmd.h>
static void
update_gmquests(void)
{
struct faction * f;
/* Isilpetz wil keine Orks */
f = findfaction(atoi36("gm00"));
while (f && (strstr(f->name, "gelsen")==0 || find_key(f->attribs, atoi36("quest")))) f = f->next; /* Isilpetz finden */
if (f) {
unit * u = f->units;
plane * p = rplane(u->region);
p->flags |= PFL_NOORCGROWTH;
}
/* neue gm commands */
/* alle muessen noch ein gm:take kriegen */
for (f=factions;f;f=f->next) {
attrib * a;
if (!find_key(f->attribs, atoi36("quest"))) continue;
a = a_find(f->attribs, &at_permissions);
assert(a || !"gm-partei ohne permissions!");
if (!find_key((attrib*)a->data.v, atoi36("gmtake")))
a_add((attrib**)&a->data.v, make_key(atoi36("gmtake")));
}
/*
* f = gm_addquest("BigBear@nord-com.net", "Leonidas Vermächtnis", 15, PFL_NOMAGIC|PFL_NOSTEALTH);
* log_printf("Neue Questenpartei %s\n", factionname(f));
*/
}
static void
test_gmquest(void)
{
const struct faction * f;
/* enno's world */
f = gm_addquest("enno@eressea.upb.de", "GM Zone", 1, PFL_NOATTACK|PFL_NOALLIANCES|PFL_NOFEED|PFL_FRIENDLY);
log_printf("Neue Questenpartei %s\n", factionname(f));
const struct faction * f;
/* enno's world */
f = gm_addquest("enno@eressea.upb.de", "GM Zone", 1, PFL_NOATTACK|PFL_NOALLIANCES|PFL_NOFEED|PFL_FRIENDLY);
log_printf("Neue Questenpartei %s\n", factionname(f));
f = gm_addquest("xandril@att.net", "Mardallas Welt", 40, 0);
log_printf("Neue Questenpartei %s\n", factionname(f));
f = gm_addquest("xandril@att.net", "Mardallas Welt", 40, 0);
log_printf("Neue Questenpartei %s\n", factionname(f));
f = gm_addquest("moritzsalinger@web.de", "Laen-Kaiser", 7, /*PFL_NORECRUITS |*/ PFL_NOMAGIC /*| PFL_NOBUILD*/);
log_printf("Neue Questenpartei %s\n", factionname(f));
f = gm_addquest("moritzsalinger@web.de", "Laen-Kaiser", 7, /*PFL_NORECRUITS |*/ PFL_NOMAGIC /*| PFL_NOBUILD*/);
log_printf("Neue Questenpartei %s\n", factionname(f));
f = gm_addquest("Denise.Muenstermann@home.gelsen-net.de", "Mochikas Queste", 7, PFL_NOMAGIC);
log_printf("Neue Questenpartei %s\n", factionname(f));
f = gm_addquest("Denise.Muenstermann@home.gelsen-net.de", "Mochikas Queste", 7, PFL_NOMAGIC);
log_printf("Neue Questenpartei %s\n", factionname(f));
f = gm_addquest("feeron@aol.com", "Eternath", 11, 0);
log_printf("Neue Questenpartei %s\n", factionname(f));
f = gm_addquest("BigBear@nord-com.net", "Leonidas Vermächtnis", 15, PFL_NOMAGIC|PFL_NOSTEALTH);
log_printf("Neue Questenpartei %s\n", factionname(f));
f = gm_addquest("feeron@aol.com", "Eternath", 11, 0);
log_printf("Neue Questenpartei %s\n", factionname(f));
f = gm_addquest("BigBear@nord-com.net", "Leonidas Vermächtnis", 15, PFL_NOMAGIC|PFL_NOSTEALTH);
log_printf("Neue Questenpartei %s\n", factionname(f));
}
@ -2164,8 +2147,9 @@ korrektur(void)
#endif
make_gms();
/* Wieder entfernen! */
#ifdef BROKEN_OWNERS
verify_owners(false);
#endif
/* fix_herbtypes(); */
#ifdef CONVERT_TRIGGER
convert_triggers();
@ -2174,8 +2158,9 @@ korrektur(void)
fix_allies();
do_once(atoi36("fhrb"), fix_herbs());
do_once(atoi36("ftos"), fix_timeouts());
do_once(atoi36("gmtst"), test_gmquest()); /* test gm quests */
do_once(atoi36("fixsl"), fix_prices());
do_once(atoi36("gmtst"), test_gmquest()); /* test gm quests */
update_gmquests(); /* test gm quests */
#ifndef SKILLFIX_SAVE
fix_skills();
#endif
@ -2189,12 +2174,6 @@ korrektur(void)
break;
case 189:
break;
case 190:
give_questling();
break;
case 191:
give_questling(); /* try again */
break;
case 194:
remove_impossible_dragontargets();
break;

View file

@ -1,6 +1,6 @@
/* vi: set ts=2:
*
* $Id: main.c,v 1.19 2001/03/04 18:41:27 enno Exp $
* $Id: main.c,v 1.20 2001/04/12 17:21:46 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)
@ -55,6 +55,7 @@
#include <plane.h>
#include <race.h>
#include <reports.h>
#include <creport.h>
#include <region.h>
#include <save.h>
#include <ship.h>
@ -126,6 +127,11 @@ game_init(void)
{
init_triggers();
report_init();
creport_init();
init_locales();
init_races();
init_spells();
init_resources();
@ -259,8 +265,6 @@ processturn(char *filename)
return 0;
}
extern void creport_cleanup(void);
extern void reports_cleanup(void);
extern void freeland(land_region * lr);
static void
@ -327,7 +331,7 @@ game_done(void)
leak_report(stderr);
#endif
creport_cleanup();
reports_cleanup();
report_cleanup();
}
#include "magic.h"
@ -532,7 +536,7 @@ main(int argc, char *argv[])
setlocale(LC_ALL, "");
#ifdef LOCALE_CHECK
if (!locale_check()) {
puts("ERROR: The current locale is not suitable for international Eressea.\n");
log_error(("The current locale is not suitable for international Eressea.\n"));
return -1;
}
#endif

File diff suppressed because it is too large Load diff

View file

@ -18,8 +18,6 @@ hell;de;Ebene aus Feuer und Dunkelheit
activevolcano;de;Aktiver Vulkan
hall1;de;Halle
corridor1;de;Gang
xmas_exit;de;Pforte
caldera;de;Krater
maelstrom_trail;de;ein %s
ocean_trail;de;%s
@ -41,6 +39,8 @@ activevolcano_trail;de;ein %s
hall1_trail;de;die %s
corridor1_trail;de;die %s
caldera;de;Krater
xmas_exit;de;Pforte
coal;de;Kohlenstück
coals;de;Kohlenstücke

4417
src/res/en/messages.xml Normal file

File diff suppressed because it is too large Load diff

View file

@ -13,6 +13,7 @@ section_magic;en;Magic and Artefacts
section_movement;en;Movement and Travel
section_study;en;Learning and Teaching
section_battle;en;Battles
section_none;en;Miscellaneous
# Items
herb;en;herb
@ -155,3 +156,47 @@ trollbelt;en;trollbelt
# Spezialitems
lmsreward;en;Belt of Heroic Legends
# Terraintypen
maelstrom;en;maelstrom
ocean;en;ocean
plain;en;plain
forest;en;forest
swamp;en;swamp
desert;en;desert
highland;en;highland
mountain;en;mountain
glacier;en;glacier
firewall;en;firewall
grassland;en;steppe
volcano;en;volcano
fog;en;fog
iceberg;en;iceberg
thickfog;en;thick fog
hell;en;hell
activevolcano;en;active volcano
hall1;en;hallway
corridor1;en;corridor
maelstrom_trail;en;a %s
ocean_trail;en;an %s
plain_trail;en;the plain of %s
forest_trail;en;the forests of %s
swamp_trail;en;the swamps of %s
desert_trail;en;the deserts of %s
highland_trail;en;the highlands of %s
mountain_trail;en;the mountains of %s
glacier_trail;en;the glacier of %s
firewall_trail;en;a %s
grassland_trail;en;the steppe of %s
volcano_trail;en;a %s
fog_trail;en;fog_trail
iceberg_trail;en;an %s
thickfog_trail;en;%s
hell_trail;en;%s
activevolcano_trail;en;an %s
hall1_trail;en;the %s
corridor1_trail;en;a %s
caldera;en;caldera
xmas_exit;en;portal

9
src/tools/atoi36.c Normal file
View file

@ -0,0 +1,9 @@
#include <base36.h>
int main(int argc, char**argv)
{
int i;
for (i=1;i!=argc;++i) {
printf("%s -> %d\n", argv[i], atoi36(argv[i]));
}
}

View file

@ -9,17 +9,17 @@ static struct vartype {
const char * msg;
} vartype[] = {
{ "from", "unit", "donation"},
{ "to", "unit", "donation" },
/* strange and to be changed */
{ "destruction", "int", "siege" },
{ "mode", "int", "travel" },
{ "discover", "string", "givedumb" },
{ "receipient", "unit", "givecommand" },
{ "sink", "string", "entermaelstrom" },
{ "sink", "string", "storm" },
{ "using", "resource", "errusingpotion" },
{ "type", "string", "scunicorn" },
{ "mode", "string", "travel" },
{ "special", "string", "new_fspecial" },
{ "special", "string", "new_fspecial_level" },
@ -116,6 +116,7 @@ type(const char * name,const char * msg)
static void
parse_message(char * b, FILE * ostream)
{
const char * vtype;
char *m, *a = NULL, message[8192];
char * name;
char * language;
@ -166,7 +167,12 @@ parse_message(char * b, FILE * ostream)
case '}':
*b++ = '\0';
args[i] = strdup(a);
sprintf(m, "$%s", args[i]);
vtype = type(args[i], name);
if (strcmp(vtype, "string")==0) {
sprintf(m, "$%s", args[i]);
} else {
sprintf(m, "$%s($%s)", vtype, args[i]);
}
m+=strlen(m);
i++;
f_symbol = false;
@ -188,12 +194,14 @@ parse_message(char * b, FILE * ostream)
/* add the messagetype */
fprintf(ostream, "<message name=\"%s\">\n", name);
fputs("\t<type>\n", ostream);
for (i=0;args[i];++i) {
fprintf(ostream, "\t<param name=\"%s\" type=\"%s\"></param>\n", args[i], type(args[i], name));
fprintf(ostream, "\t\t<arg name=\"%s\" type=\"%s\"></arg>\n", args[i], type(args[i], name));
}
fputs("\t</type>\n", ostream);
fprintf(ostream, "\t<locale name=\"%s\">\n", language);
fprintf(ostream, "\t\t<nr section=\"%s\">\n",
language, section);
section);
fprintf(ostream, "\t\t\t<text>%s</text>\n", message);
fputs("\t\t</nr>\n", ostream);
fputs("\t</locale>\n", ostream);

View file

@ -42,9 +42,9 @@ test_message(void)
tsf_register("string", &cr_string);
tsf_register("int", &cr_int);
crt_register(mt_example, NULL);
nrt_register(mt_example, NULL, "\"$subject hat $int($number) $object\"");
cr_render(msg, NULL, buffer);
crt_register(mt_example);
nrt_register(mt_example, NULL, "\"$subject hat $int($number) $object\"", 0, "default");
cr_render(msg, buffer);
puts(buffer);
nr_render(msg, NULL, buffer);
puts(buffer);
@ -232,8 +232,8 @@ parse_message(char * b)
/* add the messagetype */
mtype = mt_register(mt_new(name, args));
nrt_register(mtype, lang, message);
crt_register(mtype, lang);
nrt_register(mtype, lang, message, 0, "default");
crt_register(mtype);
}
static void
@ -250,15 +250,15 @@ static void
test_compat()
{
char buffer[1024];
FILE * F = fopen("res/de_DE/messages.txt", "rt");
FILE * F = fopen("res/de/messages.txt", "rt");
message * msg;
if (F) {
read_messages(F);
fclose(F);
msg = new_message(NULL, "entrise%s:region", "Porzel (8,7)");
if (cr_render(msg, buffer)==0) puts(buffer);
if (nr_render(msg, NULL, buffer)==0) puts(buffer);
}
msg = new_message(NULL, "entrise%s:region", "Porzel (8,7)");
if (cr_render(msg, NULL, buffer)==0) puts(buffer);
if (nr_render(msg, NULL, buffer)==0) puts(buffer);
}
int

View file

@ -47,7 +47,7 @@ main(int argc, char** argv)
xml_cb.plaintext = cbplaintext;
xml_cb.tagbegin = cbtagbegin;
nretval = xml_parse(istream, &xml_cb);
nretval = xml_parse(istream, &xml_cb, NULL);
if (istream!=stdin) fclose(istream);
if (ostream!=stdout) fclose(ostream);
}