Unicode WIP, does not compile.

- xmlStr functions have bad signatures, replacing them with defines in config.h
- more removal of buf[] usage
This commit is contained in:
Enno Rehling 2007-06-27 00:08:46 +00:00
parent ea07884657
commit 39ce1bd0dd
31 changed files with 334 additions and 354 deletions

View File

@ -50,7 +50,7 @@ write_variable(const struct attrib * a, FILE *F)
static int static int
read_variable(struct attrib *a, FILE *F) read_variable(struct attrib *a, FILE *F)
{ {
char localBuffer[BUFSIZE]; char localBuffer[1024];
freadstr(F, localBuffer, sizeof(localBuffer)); freadstr(F, localBuffer, sizeof(localBuffer));
((variable *)(a->data.v))->key = strdup(localBuffer); ((variable *)(a->data.v))->key = strdup(localBuffer);

View File

@ -450,9 +450,9 @@ recruit(unit * u, struct order * ord, request ** recruitorders)
const xmlChar * str = getstrtoken(); const xmlChar * str = getstrtoken();
if (str!=NULL && *str) { if (str!=NULL && *str) {
for (rc = races;rc;rc=rc->next) { for (rc = races;rc;rc=rc->next) {
if (xmlStrncasecmp(LOC(f->locale, rc->_name[0]), str, xmlStrlen(str))==0) if (xmlStrncasecmp(LOC(f->locale, rc->_name[0]), str, xstrlen(str))==0)
break; break;
if (xmlStrncasecmp(LOC(f->locale, rc->_name[1]), str, xmlStrlen(str))==0) if (xmlStrncasecmp(LOC(f->locale, rc->_name[1]), str, xstrlen(str))==0)
break; break;
} }
} }
@ -1737,14 +1737,15 @@ make_cmd(unit * u, struct order * ord)
const item_type * itype; const item_type * itype;
const xmlChar *s; const xmlChar *s;
const struct locale * lang = u->faction->locale; const struct locale * lang = u->faction->locale;
char ibuf[16];
init_tokens(ord); init_tokens(ord);
skip_token(); skip_token();
s = getstrtoken(); s = getstrtoken();
m = atoi((const char *)s); m = atoi((const char *)s);
sprintf(buf, "%d", m); sprintf(ibuf, "%d", m);
if (!strcmp(buf, (const char *)s)) { if (!strcmp(ibuf, (const char *)s)) {
/* first came a want-paramter */ /* first came a want-paramter */
s = getstrtoken(); s = getstrtoken();
} else { } else {
@ -1801,12 +1802,12 @@ make_cmd(unit * u, struct order * ord)
} else if (stype!=NULL) { } else if (stype!=NULL) {
const xmlChar * sname = LOC(lang, stype->name[0]); const xmlChar * sname = LOC(lang, stype->name[0]);
const xmlChar * iname = LOC(lang, resourcename(itype->rtype, 0)); const xmlChar * iname = LOC(lang, resourcename(itype->rtype, 0));
if (xmlStrlen(iname)<xmlStrlen(sname)) stype = NULL; if (xstrlen(iname)<xstrlen(sname)) stype = NULL;
else itype = NULL; else itype = NULL;
} else { } else {
const xmlChar * bname = LOC(lang, btype->_name); const xmlChar * bname = LOC(lang, btype->_name);
const xmlChar * iname = LOC(lang, resourcename(itype->rtype, 0)); const xmlChar * iname = LOC(lang, resourcename(itype->rtype, 0));
if (xmlStrlen(iname)<xmlStrlen(bname)) btype = NULL; if (xstrlen(iname)<xstrlen(bname)) btype = NULL;
else itype = NULL; else itype = NULL;
} }
} }
@ -1814,7 +1815,7 @@ make_cmd(unit * u, struct order * ord)
if (btype!=NULL && stype!=NULL) { if (btype!=NULL && stype!=NULL) {
const xmlChar * bname = LOC(lang, btype->_name); const xmlChar * bname = LOC(lang, btype->_name);
const xmlChar * sname = LOC(lang, stype->name[0]); const xmlChar * sname = LOC(lang, stype->name[0]);
if (xmlStrlen(sname)<xmlStrlen(bname)) btype = NULL; if (xstrlen(sname)<xstrlen(bname)) btype = NULL;
else stype = NULL; else stype = NULL;
} }

View File

@ -58,6 +58,7 @@
#include <kernel/save.h> #include <kernel/save.h>
#include <kernel/ship.h> #include <kernel/ship.h>
#include <kernel/skill.h> #include <kernel/skill.h>
#include <kernel/spell.h>
#include <kernel/spy.h> #include <kernel/spy.h>
#include <kernel/teleport.h> #include <kernel/teleport.h>
#include <kernel/terrain.h> #include <kernel/terrain.h>
@ -1445,8 +1446,8 @@ display_cmd(unit * u, struct order * ord)
if (s!=NULL) { if (s!=NULL) {
const xmlChar * s2 = getstrtoken(); const xmlChar * s2 = getstrtoken();
if (strlen(s2)>=DISPLAYSIZE) { if (xstrlen(s2)>=DISPLAYSIZE) {
xmlChar * s3 = strdup(s2); xmlChar * s3 = xstrdup(s2);
s3[DISPLAYSIZE] = 0; s3[DISPLAYSIZE] = 0;
set_string(s, s3); set_string(s, s3);
free(s3); free(s3);
@ -1462,9 +1463,9 @@ renamed_building(const building * b)
{ {
const struct locale * lang = locales; const struct locale * lang = locales;
for (;lang;lang=nextlocale(lang)) { for (;lang;lang=nextlocale(lang)) {
const char * bdname = LOC(lang, b->type->_name); const xmlChar * bdname = LOC(lang, b->type->_name);
size_t bdlen = strlen(bdname); size_t bdlen = xstrlen(bdname);
if (strlen(b->name)>=bdlen && strncmp(b->name, bdname, bdlen)==0) { if (xstrlen(b->name)>=bdlen && xstrncmp(b->name, bdname, bdlen)==0) {
return false; return false;
} }
} }
@ -1476,7 +1477,7 @@ name_cmd(unit * u, struct order * ord)
{ {
building * b = u->building; building * b = u->building;
region * r = u->region; region * r = u->region;
char **s = NULL; xmlChar **s = NULL;
param_t p; param_t p;
boolean foreign = false; boolean foreign = false;
@ -1564,9 +1565,9 @@ name_cmd(unit * u, struct order * ord)
} else { } else {
const struct locale * lang = locales; const struct locale * lang = locales;
for (;lang;lang=nextlocale(lang)) { for (;lang;lang=nextlocale(lang)) {
const char * fdname = LOC(lang, "factiondefault"); const xmlChar * fdname = LOC(lang, "factiondefault");
size_t fdlen = strlen(fdname); size_t fdlen = xstrlen(fdname);
if (strlen(f->name)>=fdlen && strncmp(f->name, fdname, fdlen)==0) { if (xstrlen(f->name)>=fdlen && xstrncmp(f->name, fdname, fdlen)==0) {
break; break;
} }
} }
@ -1597,15 +1598,15 @@ name_cmd(unit * u, struct order * ord)
} else { } else {
const struct locale * lang = locales; const struct locale * lang = locales;
for (;lang;lang=nextlocale(lang)) { for (;lang;lang=nextlocale(lang)) {
const char * sdname = LOC(lang, sh->type->name[0]); const xmlChar * sdname = LOC(lang, sh->type->name[0]);
size_t sdlen = strlen(sdname); size_t sdlen = xstrlen(sdname);
if (strlen(sh->name)>=sdlen && strncmp(sh->name, sdname, sdlen)==0) { if (xstrlen(sh->name)>=sdlen && xstrncmp(sh->name, sdname, sdlen)==0) {
break; break;
} }
sdname = LOC(lang, parameters[P_SHIP]); sdname = LOC(lang, parameters[P_SHIP]);
sdlen = strlen(sdname); sdlen = xstrlen(sdname);
if (strlen(sh->name)>=sdlen && strncmp(sh->name, sdname, sdlen)==0) { if (xstrlen(sh->name)>=sdlen && xstrncmp(sh->name, sdname, sdlen)==0) {
break; break;
} }
@ -1647,10 +1648,10 @@ name_cmd(unit * u, struct order * ord)
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "feedback_unit_not_found", "")); ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "feedback_unit_not_found", ""));
break; break;
} else { } else {
const char * udefault = LOC(u2->faction->locale, "unitdefault"); const xmlChar * udefault = LOC(u2->faction->locale, "unitdefault");
size_t udlen = strlen(udefault); size_t udlen = xstrlen(udefault);
size_t unlen = strlen(u2->name); size_t unlen = xstrlen(u2->name);
if (unlen>=udlen && strncmp(u2->name, udefault, udlen)!=0) { if (unlen>=udlen && xstrncmp(u2->name, udefault, udlen)!=0) {
cmistake(u2, ord, 244, MSG_EVENT); cmistake(u2, ord, 244, MSG_EVENT);
break; break;
} }
@ -1704,20 +1705,18 @@ name_cmd(unit * u, struct order * ord)
} }
if (s!=NULL) { if (s!=NULL) {
const char * s2 = getstrtoken(); const xmlChar * s2 = getstrtoken();
if (!s2[0]) { if (!s2[0]) {
cmistake(u, ord, 84, MSG_EVENT); cmistake(u, ord, 84, MSG_EVENT);
return 0; return 0;
} }
if (strchr(s2, '(')!=NULL) { /* TODO: Validate to make sure people don't have illegal characters in
cmistake(u, ord, 112, MSG_EVENT); * names, phishing-style? () come to mind. */
return 0;
}
if (strlen(s2)>=NAMESIZE) { if (xstrlen(s2)>=NAMESIZE) {
char * s3 = strdup(s2); xmlChar * s3 = xstrdup(s2);
s3[NAMESIZE] = 0; s3[NAMESIZE] = 0;
set_string(s, s3); set_string(s, s3);
free(s3); free(s3);
@ -1731,7 +1730,7 @@ name_cmd(unit * u, struct order * ord)
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */
void void
deliverMail(faction * f, region * r, unit * u, const char *s, unit * receiver) deliverMail(faction * f, region * r, unit * u, const xmlChar *s, unit * receiver)
{ {
if (!cansee(f, r, u, 0)) { if (!cansee(f, r, u, 0)) {
u = NULL; u = NULL;
@ -1744,7 +1743,7 @@ deliverMail(faction * f, region * r, unit * u, const char *s, unit * receiver)
} }
static void static void
mailunit(region * r, unit * u, int n, struct order * ord, const char * s) mailunit(region * r, unit * u, int n, struct order * ord, const xmlChar * s)
{ {
unit * u2 = findunitr(r,n); unit * u2 = findunitr(r,n);
@ -1760,7 +1759,7 @@ mailunit(region * r, unit * u, int n, struct order * ord, const char * s)
} }
static void static void
mailfaction(unit * u, int n, struct order * ord, const char * s) mailfaction(unit * u, int n, struct order * ord, const xmlChar * s)
{ {
faction *f; faction *f;
@ -1776,8 +1775,8 @@ mail_cmd(unit * u, struct order * ord)
{ {
region * r = u->region; region * r = u->region;
unit *u2; unit *u2;
const char *s; const xmlChar *s;
int n; int n, cont;
init_tokens(ord); init_tokens(ord);
skip_token(); /* skip the keyword */ skip_token(); /* skip the keyword */
@ -1786,148 +1785,151 @@ mail_cmd(unit * u, struct order * ord)
/* Falls kein Parameter, ist das eine Einheitsnummer; /* Falls kein Parameter, ist das eine Einheitsnummer;
* das Füllwort "AN" muß wegfallen, da gültige Nummer! */ * das Füllwort "AN" muß wegfallen, da gültige Nummer! */
if (strcasecmp(s, "to") == 0) s = getstrtoken(); do {
else if (strcasecmp(s, "an") == 0) s = getstrtoken(); cont = 0;
switch (findparam(s, u->faction->locale)) {
switch (findparam(s, u->faction->locale)) { case P_REGION:
case P_REGION: /* können alle Einheiten in der Region sehen */
/* können alle Einheiten in der Region sehen */
s = getstrtoken();
if (!s[0]) {
cmistake(u, ord, 30, MSG_MESSAGE);
break;
} else {
ADDMSG(&r->msgs, msg_message("mail_result", "unit message", u, s));
break;
}
break;
case P_FACTION:
{
boolean see = false;
n = getfactionid();
for(u2=r->units; u2; u2=u2->next) {
if(u2->faction->no == n && seefaction(u->faction, r, u2, 0)) {
see = true;
break;
}
}
if(see == false) {
cmistake(u, ord, 66, MSG_MESSAGE);
break;
}
s = getstrtoken();
if (!s[0]) {
cmistake(u, ord, 30, MSG_MESSAGE);
break;
}
mailfaction(u, n, ord, s);
}
break;
case P_UNIT:
{
boolean see = false;
n = getid();
for (u2=r->units; u2; u2=u2->next) {
if (u2->no == n && cansee(u->faction, r, u2, 0)) {
see = true;
break;
}
}
if (see == false) {
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "feedback_unit_not_found", ""));
break;
}
s = getstrtoken(); s = getstrtoken();
if (!s[0]) { if (!s[0]) {
cmistake(u, ord, 30, MSG_MESSAGE); cmistake(u, ord, 30, MSG_MESSAGE);
break; break;
} else { } else {
attrib * a = a_find(u2->attribs, &at_eventhandler); ADDMSG(&r->msgs, msg_message("mail_result", "unit message", u, s));
if (a!=NULL) { break;
event_arg args[3]; }
args[0].data.v = (void*)s; break;
args[0].type = "string";
args[1].data.v = (void*)u; case P_FACTION:
args[1].type = "unit"; {
args[2].type = NULL; boolean see = false;
handle_event(a, "message", args);
n = getfactionid();
for(u2=r->units; u2; u2=u2->next) {
if(u2->faction->no == n && seefaction(u->faction, r, u2, 0)) {
see = true;
break;
}
} }
mailunit(r, u, n, ord, s); if(see == false) {
cmistake(u, ord, 66, MSG_MESSAGE);
break;
}
s = getstrtoken();
if (!s[0]) {
cmistake(u, ord, 30, MSG_MESSAGE);
break;
}
mailfaction(u, n, ord, s);
} }
} break;
break;
case P_BUILDING: case P_UNIT:
case P_GEBAEUDE: {
{ boolean see = false;
building *b = getbuilding(r); n = getid();
if(!b) { for (u2=r->units; u2; u2=u2->next) {
cmistake(u, ord, 6, MSG_MESSAGE); if (u2->no == n && cansee(u->faction, r, u2, 0)) {
break; see = true;
} break;
s = getstrtoken();
if (!s[0]) {
cmistake(u, ord, 30, MSG_MESSAGE);
break;
}
for (u2 = r->units; u2; u2 = u2->next) freset(u2->faction, FFL_SELECT);
for(u2=r->units; u2; u2=u2->next) {
if(u2->building == b && !fval(u2->faction, FFL_SELECT)
&& cansee(u->faction, r, u2, 0)) {
mailunit(r, u, u2->no, ord, s);
fset(u2->faction, FFL_SELECT);
} }
} }
}
break;
case P_SHIP: if (see == false) {
{ ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "feedback_unit_not_found", ""));
ship *sh = getship(r); break;
}
if(!sh) { s = getstrtoken();
cmistake(u, ord, 20, MSG_MESSAGE); if (!s[0]) {
break; cmistake(u, ord, 30, MSG_MESSAGE);
} break;
} else {
s = getstrtoken(); attrib * a = a_find(u2->attribs, &at_eventhandler);
if (a!=NULL) {
if (!s[0]) { event_arg args[3];
cmistake(u, ord, 30, MSG_MESSAGE); args[0].data.v = (void*)s;
break; args[0].type = "string";
} args[1].data.v = (void*)u;
args[1].type = "unit";
for (u2 = r->units; u2; u2 = u2->next) freset(u2->faction, FFL_SELECT); args[2].type = NULL;
handle_event(a, "message", args);
for(u2=r->units; u2; u2=u2->next) {
if(u2->ship == sh && !fval(u2->faction, FFL_SELECT)
&& cansee(u->faction, r, u2, 0)) {
mailunit(r, u, u2->no, ord, s);
fset(u2->faction, FFL_SELECT);
} }
}
}
break;
default: mailunit(r, u, n, ord, s);
cmistake(u, ord, 149, MSG_MESSAGE); }
break; }
} break;
case P_BUILDING:
case P_GEBAEUDE:
{
building *b = getbuilding(r);
if(!b) {
cmistake(u, ord, 6, MSG_MESSAGE);
break;
}
s = getstrtoken();
if (!s[0]) {
cmistake(u, ord, 30, MSG_MESSAGE);
break;
}
for (u2 = r->units; u2; u2 = u2->next) freset(u2->faction, FFL_SELECT);
for (u2=r->units; u2; u2=u2->next) {
if(u2->building == b && !fval(u2->faction, FFL_SELECT)
&& cansee(u->faction, r, u2, 0)) {
mailunit(r, u, u2->no, ord, s);
fset(u2->faction, FFL_SELECT);
}
}
}
break;
case P_SHIP:
{
ship *sh = getship(r);
if(!sh) {
cmistake(u, ord, 20, MSG_MESSAGE);
break;
}
s = getstrtoken();
if (!s[0]) {
cmistake(u, ord, 30, MSG_MESSAGE);
break;
}
for (u2 = r->units; u2; u2 = u2->next) freset(u2->faction, FFL_SELECT);
for(u2=r->units; u2; u2=u2->next) {
if(u2->ship == sh && !fval(u2->faction, FFL_SELECT)
&& cansee(u->faction, r, u2, 0)) {
mailunit(r, u, u2->no, ord, s);
fset(u2->faction, FFL_SELECT);
}
}
}
break;
default:
/* possibly filler token? */
s = getstrtoken();
cont = 1;
break;
}
} while (cont);
cmistake(u, ord, 149, MSG_MESSAGE);
return 0; return 0;
} }
/* ------------------------------------------------------------- */ /* ------------------------------------------------------------- */
@ -1948,7 +1950,7 @@ banner_cmd(unit * u, struct order * ord)
static int static int
email_cmd(unit * u, struct order * ord) email_cmd(unit * u, struct order * ord)
{ {
const char * s; const xmlChar * s;
init_tokens(ord); init_tokens(ord);
skip_token(); skip_token();
@ -1958,7 +1960,7 @@ email_cmd(unit * u, struct order * ord)
cmistake(u, ord, 85, MSG_EVENT); cmistake(u, ord, 85, MSG_EVENT);
} else { } else {
faction * f = u->faction; faction * f = u->faction;
if (set_email(&f->email, s)!=0) { if (set_email(&f->email, (const char *)s)!=0) {
log_error(("Invalid email address for faction %s: %s\n", itoa36(f->no), s)); log_error(("Invalid email address for faction %s: %s\n", itoa36(f->no), s));
ADDMSG(&f->msgs, msg_message("changemail_invalid", "value", s)); ADDMSG(&f->msgs, msg_message("changemail_invalid", "value", s));
} else { } else {
@ -1971,9 +1973,9 @@ email_cmd(unit * u, struct order * ord)
static int static int
password_cmd(unit * u, struct order * ord) password_cmd(unit * u, struct order * ord)
{ {
char pbuf[32]; xmlChar pbuf[32];
int i; int i;
const char * s; const xmlChar * s;
init_tokens(ord); init_tokens(ord);
skip_token(); skip_token();
@ -1984,9 +1986,9 @@ password_cmd(unit * u, struct order * ord)
pbuf[6] = 0; pbuf[6] = 0;
} else { } else {
boolean pwok = true; boolean pwok = true;
char *c; xmlChar *c;
strncpy(pbuf, s, 31); xstrlcpy(pbuf, s, 31);
pbuf[31] = 0; pbuf[31] = 0;
c = pbuf; c = pbuf;
while (*c) { while (*c) {
@ -2009,7 +2011,7 @@ password_cmd(unit * u, struct order * ord)
static int static int
send_cmd(unit * u, struct order * ord) send_cmd(unit * u, struct order * ord)
{ {
const char * s; const xmlChar * s;
int option; int option;
init_tokens(ord); init_tokens(ord);
@ -2062,8 +2064,8 @@ static boolean
display_item(faction *f, unit *u, const item_type * itype) display_item(faction *f, unit *u, const item_type * itype)
{ {
const char *name; const char *name;
const char *info;
const char *key; const char *key;
const xmlChar *info;
if (u!=NULL) { if (u!=NULL) {
int i = i_get(u->items, itype); int i = i_get(u->items, itype);
@ -2082,7 +2084,7 @@ display_item(faction *f, unit *u, const item_type * itype)
key = mkname("iteminfo", name); key = mkname("iteminfo", name);
info = locale_getstring(f->locale, key); info = locale_getstring(f->locale, key);
if (info==NULL || info==key || strcmp(info, key)==0) { if (info==NULL) {
info = locale_string(f->locale, mkname("iteminfo", "no_info")); info = locale_string(f->locale, mkname("iteminfo", "no_info"));
} }
ADDMSG(&f->msgs, msg_message("displayitem", "weight item description", ADDMSG(&f->msgs, msg_message("displayitem", "weight item description",
@ -2117,9 +2119,11 @@ display_potion(faction *f, unit *u, const potion_type * ptype)
static boolean static boolean
display_race(faction *f, unit *u, const race * rc) display_race(faction *f, unit *u, const race * rc)
{ {
const char *name, *info, *key; const char *name, *key;
const xmlChar *info;
int a, at_count; int a, at_count;
char buf2[2048]; char buf[2048];
char buf2[128];
char * bufp = buf; char * bufp = buf;
size_t size = sizeof(buf), rsize; size_t size = sizeof(buf), rsize;
@ -2133,11 +2137,11 @@ display_race(faction *f, unit *u, const race * rc)
key = mkname("raceinfo", rc->_name[0]); key = mkname("raceinfo", rc->_name[0]);
info = locale_getstring(f->locale, key); info = locale_getstring(f->locale, key);
if (info==NULL || info==key || strcmp(info, key)==0) { if (info==NULL) {
info = locale_string(f->locale, mkname("raceinfo", "no_info")); info = locale_string(f->locale, mkname("raceinfo", "no_info"));
} }
rsize = strlcpy(bufp, info, size); rsize = xstrlcpy(bufp, info, size);
if (rsize>size) rsize = size-1; if (rsize>size) rsize = size-1;
size -= rsize; size -= rsize;
bufp += rsize; bufp += rsize;
@ -2257,7 +2261,7 @@ display_race(faction *f, unit *u, const race * rc)
} }
static void static void
reshow(unit * u, struct order * ord, const char * s, param_t p) reshow(unit * u, struct order * ord, const xmlChar * s, param_t p)
{ {
int skill, c; int skill, c;
const potion_type * ptype; const potion_type * ptype;
@ -2346,7 +2350,7 @@ promotion_cmd(unit * u, struct order * ord)
static int static int
group_cmd(unit * u, struct order * ord) group_cmd(unit * u, struct order * ord)
{ {
const char * s; const xmlChar * s;
init_tokens(ord); init_tokens(ord);
skip_token(); skip_token();
@ -2387,7 +2391,7 @@ guard_off_cmd(unit * u, struct order * ord)
static int static int
reshow_cmd(unit * u, struct order * ord) reshow_cmd(unit * u, struct order * ord)
{ {
const char * s; const xmlChar * s;
param_t p = NOPARAM; param_t p = NOPARAM;
init_tokens(ord); init_tokens(ord);
@ -2406,7 +2410,7 @@ reshow_cmd(unit * u, struct order * ord)
static int static int
status_cmd(unit * u, struct order * ord) status_cmd(unit * u, struct order * ord)
{ {
const char * param; const xmlChar * param;
init_tokens(ord); init_tokens(ord);
skip_token(); skip_token();
@ -2452,7 +2456,7 @@ status_cmd(unit * u, struct order * ord)
static int static int
combatspell_cmd(unit * u, struct order * ord) combatspell_cmd(unit * u, struct order * ord)
{ {
const char * s; const xmlChar * s;
int level = 0; int level = 0;
spell * spell; spell * spell;
@ -2680,7 +2684,7 @@ reorder(void)
struct order * ord; struct order * ord;
for (ord = u->orders;ord;ord=ord->next) { for (ord = u->orders;ord;ord=ord->next) {
if (get_keyword(ord)==K_SORT) { if (get_keyword(ord)==K_SORT) {
const char * s; const xmlChar * s;
param_t p; param_t p;
int id; int id;
unit *v; unit *v;
@ -2808,7 +2812,7 @@ declare_war(void)
init_tokens(ord); init_tokens(ord);
skip_token(); skip_token();
for (;;) { for (;;) {
const char * s = getstrtoken(); const xmlChar * s = getstrtoken();
if (s[0]==0) break; if (s[0]==0) break;
else { else {
faction * enemy = findfaction(atoi36(s)); faction * enemy = findfaction(atoi36(s));
@ -2828,7 +2832,7 @@ declare_war(void)
init_tokens(ord); init_tokens(ord);
skip_token(); skip_token();
for (;;) { for (;;) {
const char * s = getstrtoken(); const xmlChar * s = getstrtoken();
if (s[0]==0) break; if (s[0]==0) break;
else { else {
faction * enemy = findfaction(atoi36(s)); faction * enemy = findfaction(atoi36(s));
@ -2856,7 +2860,7 @@ declare_war(void)
static int static int
renumber_cmd(unit * u, order * ord) renumber_cmd(unit * u, order * ord)
{ {
const char * s; const xmlChar * s;
int i; int i;
faction * f = u->faction; faction * f = u->faction;
@ -3190,7 +3194,7 @@ new_units (void)
init_tokens(makeord); init_tokens(makeord);
skip_token(); skip_token();
if (getparam(u->faction->locale) == P_TEMP) { if (getparam(u->faction->locale) == P_TEMP) {
const char * token; const xmlChar * token;
char * name = NULL; char * name = NULL;
int alias; int alias;
order ** newordersp; order ** newordersp;
@ -3576,7 +3580,7 @@ age_factions(void)
static int static int
use_cmd(unit * u, struct order * ord) use_cmd(unit * u, struct order * ord)
{ {
const char * t; const xmlChar * t;
int n; int n;
const item_type * itype; const item_type * itype;
@ -3615,7 +3619,7 @@ use_cmd(unit * u, struct order * ord)
static int static int
claim_cmd(unit * u, struct order * ord) claim_cmd(unit * u, struct order * ord)
{ {
const char * t; const xmlChar * t;
int n; int n;
const item_type * itype; const item_type * itype;
@ -3855,7 +3859,7 @@ warn_password(void)
faction * f = factions; faction * f = factions;
while (f) { while (f) {
boolean pwok = true; boolean pwok = true;
const char * c = f->passw; const xmlChar * c = f->passw;
while (*c) { while (*c) {
if (!isalnum((unsigned char)*c)) pwok = false; if (!isalnum((unsigned char)*c)) pwok = false;
c++; c++;

View File

@ -32,7 +32,7 @@ void demographics(void);
void last_orders(void); void last_orders(void);
void find_address(void); void find_address(void);
void update_guards(void); void update_guards(void);
extern void deliverMail(struct faction * f, struct region * r, struct unit * u, const char *s, struct unit * receiver); extern void deliverMail(struct faction * f, struct region * r, struct unit * u, const xmlChar *s, struct unit * receiver);
/* eressea-specific. put somewhere else, please. */ /* eressea-specific. put somewhere else, please. */
#include "resolve.h" #include "resolve.h"

View File

@ -878,7 +878,7 @@ plan_dragon(unit * u)
const struct locale * lang = u->faction->locale; const struct locale * lang = u->faction->locale;
/* do a growl */ /* do a growl */
if (rname(tr, lang)) { if (rname(tr, lang)) {
addlist(&u->orders, create_order(K_MAIL, lang, "%s '%s %s %s %s'", addlist(&u->orders, create_order(K_MAIL, lang, "%s '%s... %s %s %s'",
LOC(lang, parameters[P_REGION]), random_growl(), LOC(lang, parameters[P_REGION]), random_growl(),
u->number==1?"Ich rieche":"Wir riechen", u->number==1?"Ich rieche":"Wir riechen",
"etwas in", rname(tr, u->faction->locale))); "etwas in", rname(tr, u->faction->locale)));

View File

@ -348,14 +348,12 @@ teach_cmd(unit * u, struct order * ord)
else else
#endif #endif
{ {
static xmlChar zOrder[BUFSIZE]; char zOrder[4096];
order * new_order; order * new_order;
init_tokens(ord); init_tokens(ord);
skip_token(); skip_token();
strcpy((char*)zOrder, (const char *)locale_string(u->faction->locale, keywords[K_TEACH]));
while (!parser_end()) { while (!parser_end()) {
unit * u2 = getunit(r, u->faction); unit * u2 = getunit(r, u->faction);
++count; ++count;
@ -379,8 +377,6 @@ teach_cmd(unit * u, struct order * ord)
token = getstrtoken(); token = getstrtoken();
/* Beginne die Fehlermeldung */ /* Beginne die Fehlermeldung */
strcpy(buf, "Die Einheit '");
if (findparam(token, u->faction->locale) != P_TEMP) { if (findparam(token, u->faction->locale) != P_TEMP) {
uid = token; uid = token;
} else { } else {
@ -398,8 +394,8 @@ teach_cmd(unit * u, struct order * ord)
/* Neuen Befehl zusammenbauen. TEMP-Einheiten werden automatisch in /* Neuen Befehl zusammenbauen. TEMP-Einheiten werden automatisch in
* ihre neuen Nummern übersetzt. */ * ihre neuen Nummern übersetzt. */
strcat((char*)zOrder, " "); strcat(zOrder, " ");
strcat((char*)zOrder, unitid(u2)); strcat(zOrder, unitid(u2));
if (get_keyword(u2->thisorder) != K_STUDY) { if (get_keyword(u2->thisorder) != K_STUDY) {
ADDMSG(&u->faction->msgs, ADDMSG(&u->faction->msgs,
@ -432,16 +428,14 @@ teach_cmd(unit * u, struct order * ord)
if (find_magetype(u2) != 0 if (find_magetype(u2) != 0
&& find_magetype(u) != find_magetype(u2)) && find_magetype(u) != find_magetype(u2))
{ {
sprintf(buf, "%s versteht unsere Art von Magie nicht", unitname(u2)); ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_different_magic", "target", u2));
mistake(u, ord, buf, MSG_EVENT);
continue; continue;
} }
} }
teaching -= teach_unit(u, u2, teaching, sk, false, &academy); teaching -= teach_unit(u, u2, teaching, sk, false, &academy);
} }
new_order = parse_order(zOrder, u->faction->locale); new_order = create_order(K_TEACH, u->faction->locale, "%s", zOrder);
#ifdef LASTORDER #ifdef LASTORDER
set_order(&u->lastorder, new_order); set_order(&u->lastorder, new_order);
#else #else
@ -479,8 +473,7 @@ learn_cmd(unit * u, order * ord)
} }
if ((u->race->flags & RCF_NOLEARN) || fval(u, UFL_WERE)) { if ((u->race->flags & RCF_NOLEARN) || fval(u, UFL_WERE)) {
sprintf(buf, "%s können nichts lernen", LOC(default_locale, rc_name(u->race, 1))); ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_race_nolearn", "race", u->race));
mistake(u, ord, buf, MSG_EVENT);
return 0; return 0;
} }
@ -528,8 +521,7 @@ learn_cmd(unit * u, order * ord)
* keine Migranten, wird in is_migrant abgefangen. Vorsicht, * keine Migranten, wird in is_migrant abgefangen. Vorsicht,
* studycost darf hier noch nicht durch Akademie erhöht sein */ * studycost darf hier noch nicht durch Akademie erhöht sein */
if (studycost > 0 && !ExpensiveMigrants() && is_migrant(u)) { if (studycost > 0 && !ExpensiveMigrants() && is_migrant(u)) {
sprintf(buf, "Migranten können keine kostenpflichtigen Talente lernen"); ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_migrants_nolearn", ""));
mistake(u, ord, buf, MSG_EVENT);
return 0; return 0;
} }
/* Akademie: */ /* Akademie: */
@ -553,13 +545,11 @@ learn_cmd(unit * u, order * ord)
mtyp = M_GRAU; mtyp = M_GRAU;
if (!is_mage(u)) create_mage(u, mtyp); if (!is_mage(u)) create_mage(u, mtyp);
} else if (!has_skill(u, SK_MAGIC)) { } else if (!has_skill(u, SK_MAGIC)) {
int mmax = max_skill(u->faction, SK_MAGIC);
/* Die Einheit ist noch kein Magier */ /* Die Einheit ist noch kein Magier */
if (count_skill(u->faction, SK_MAGIC) + u->number > if (count_skill(u->faction, SK_MAGIC) + u->number > mmax)
max_skill(u->faction, SK_MAGIC))
{ {
sprintf(buf, "Es kann maximal %d Magier pro Partei geben", ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_max_magicians", "amount", mmax));
max_skill(u->faction, SK_MAGIC));
mistake(u, ord, buf, MSG_EVENT);
return 0; return 0;
} }
mtyp = getmagicskill(u->faction->locale); mtyp = getmagicskill(u->faction->locale);
@ -605,14 +595,13 @@ learn_cmd(unit * u, order * ord)
} }
if (sk == SK_ALCHEMY) { if (sk == SK_ALCHEMY) {
maxalchemy = eff_skill(u, SK_ALCHEMY, r); maxalchemy = eff_skill(u, SK_ALCHEMY, r);
if (has_skill(u, SK_ALCHEMY)==0 if (!has_skill(u, SK_ALCHEMY)) {
&& count_skill(u->faction, SK_ALCHEMY) + u->number > int amax = max_skill(u->faction, SK_ALCHEMY);
max_skill(u->faction, SK_ALCHEMY)) { if (count_skill(u->faction, SK_ALCHEMY) + u->number > amax) {
sprintf(buf, "Es kann maximal %d Alchemisten pro Partei geben", ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_max_alchemists", "amount", amax));
max_skill(u->faction, SK_ALCHEMY));
mistake(u, ord, buf, MSG_EVENT);
return 0; return 0;
} }
}
} }
if (studycost) { if (studycost) {
int cost = studycost * u->number; int cost = studycost * u->number;

View File

@ -934,16 +934,13 @@ build_building(unit * u, const building_type * btype, int want, order * ord)
if (n-built <= 0) { if (n-built <= 0) {
/* gebäude fertig */ /* gebäude fertig */
strcpy(buffer, LOC(lang, "defaultorder")); new_order = default_order(lang);
new_order = parse_order(buffer, lang);
} else if (n!=INT_MAX) { } else if (n!=INT_MAX) {
/* reduzierte restgröße */ /* reduzierte restgröße */
sprintf(buffer, "%s %d %s %s", LOC(lang, keywords[K_MAKE]), n-built, btname, buildingid(b)); new_order = create_order(K_MAKE, lang, "%d '%s' %i", n-built, btname, b->no);
new_order = parse_order(buffer, lang);
} else if (btname) { } else if (btname) {
/* Neues Haus, Befehl mit Gebäudename */ /* Neues Haus, Befehl mit Gebäudename */
sprintf(buffer, "%s %s %s", LOC(lang, keywords[K_MAKE]), btname, buildingid(b)); new_order = create_order(K_MAKE, lang, "'%s' %i", btname, b->no);
new_order = parse_order(buffer, u->faction->locale);
} }
if (new_order) { if (new_order) {
@ -1037,10 +1034,7 @@ create_ship(region * r, unit * u, const struct ship_type * newtype, int want, or
u->ship = sh; u->ship = sh;
} }
fset(u, UFL_OWNER); fset(u, UFL_OWNER);
sprintf(buffer, "%s %s %s", new_order = create_order(K_MAKE, u->faction->locale, "%s %i", LOC(u->faction->locale, parameters[P_SHIP]), sh->no);
locale_string(u->faction->locale, keywords[K_MAKE]), locale_string(u->faction->locale, parameters[P_SHIP]), shipid(sh));
new_order = parse_order(buffer, u->faction->locale);
#ifdef LASTORDER #ifdef LASTORDER
set_order(&u->lastorder, new_order); set_order(&u->lastorder, new_order);
#else #else

View File

@ -396,7 +396,7 @@ int
read_building_reference(struct building ** b, FILE * F) read_building_reference(struct building ** b, FILE * F)
{ {
variant var; variant var;
char zText[10]; char zText[16];
fscanf(F, "%s ", zText); fscanf(F, "%s ", zText);
var.i = atoi36(zText); var.i = atoi36(zText);
if (var.i==0) { if (var.i==0) {

View File

@ -1396,32 +1396,11 @@ getparam (const struct locale * lang)
return findparam (getstrtoken (), lang); return findparam (getstrtoken (), lang);
} }
#ifdef FUZZY_BASE36
extern int fuzzy_hits;
boolean enable_fuzzy = false;
#endif /* FUZZY_BASE36 */
faction * faction *
findfaction (int n) findfaction (int n)
{ {
faction * f = ffindhash(n); faction * f = ffindhash(n);
return f; return f;
#ifdef FUZZY_BASE36
if(enable_fuzzy) {
n = atoi(itoa36(n));
if (n) {
f = ffindhash(n);
if (f) return f;
for (f = factions; f; f = f->next) {
if (f->no == n) {
fhash(f);
return (f);
}
}
}
}
return NULL;
#endif /* FUZZY_BASE36 */
} }
faction * faction *
@ -2628,11 +2607,11 @@ findspecialdirection(const region *r, const xmlChar *token)
attrib *a; attrib *a;
spec_direction *d; spec_direction *d;
if (xmlStrlen(token)==0) return NULL; if (xstrlen(token)==0) return NULL;
for (a = a_find(r->attribs, &at_direction);a && a->type==&at_direction;a=a->next) { for (a = a_find(r->attribs, &at_direction);a && a->type==&at_direction;a=a->next) {
d = (spec_direction *)(a->data.v); d = (spec_direction *)(a->data.v);
if (d->active && xmlStrncasecmp(d->keyword, token, xmlStrlen(token)) == 0) { if (d->active && xmlStrncasecmp(d->keyword, token, xstrlen(token)) == 0) {
return findregion(d->x, d->y); return findregion(d->x, d->y);
} }
} }

View File

@ -188,7 +188,7 @@ read_faction_reference(faction ** f, FILE * F)
{ {
variant id; variant id;
if (global.data_version >= BASE36IDS_VERSION) { if (global.data_version >= BASE36IDS_VERSION) {
char zText[10]; char zText[16];
fscanf(F, "%s ", zText); fscanf(F, "%s ", zText);
id.i = atoi36(zText); id.i = atoi36(zText);
} else { } else {

View File

@ -39,7 +39,7 @@ static group * ghash[GMAXHASH];
static int maxgid; static int maxgid;
static group * static group *
new_group(faction * f, const char * name, int gid) new_group(faction * f, const xmlChar * name, int gid)
{ {
group ** gp = &f->groups; group ** gp = &f->groups;
int index = gid % GMAXHASH; int index = gid % GMAXHASH;
@ -49,7 +49,7 @@ new_group(faction * f, const char * name, int gid)
*gp = g; *gp = g;
maxgid = max(gid, maxgid); maxgid = max(gid, maxgid);
g->name = strdup(name); g->name = xstrdup(name);
g->gid = gid; g->gid = gid;
g->nexthash = ghash[index]; g->nexthash = ghash[index];
@ -71,7 +71,7 @@ init_group(faction * f, group * g)
} }
static group * static group *
find_groupbyname(group * g, const char * name) find_groupbyname(group * g, const xmlChar * name)
{ {
while (g && strcasecmp(name, g->name)) g = g->next; while (g && strcasecmp(name, g->name)) g = g->next;
return g; return g;
@ -131,7 +131,7 @@ free_group(group * g)
} }
boolean boolean
join_group(unit * u, const char * name) join_group(unit * u, const xmlChar * name)
{ {
attrib * a = NULL; attrib * a = NULL;
group * g; group * g;
@ -184,9 +184,11 @@ read_groups(FILE * F, faction * f)
ally ** pa; ally ** pa;
group * g; group * g;
int gid; int gid;
fscanf(F, "%d ", &gid); char buf[1024];
fscanf(F, "%d ", &gid);
if (!gid) break; if (!gid) break;
rsf(F, buf, 1024); rsf(F, buf, sizeof(buf));
g = new_group(f, buf, gid); g = new_group(f, buf, gid);
pa = &g->allies; pa = &g->allies;
for (;;) { for (;;) {

View File

@ -25,7 +25,7 @@ typedef struct group {
struct group * nexthash; struct group * nexthash;
struct faction * f; struct faction * f;
struct attrib *attribs; struct attrib *attribs;
char * name; xmlChar * name;
struct ally * allies; struct ally * allies;
int flags; int flags;
int gid; int gid;
@ -33,7 +33,7 @@ typedef struct group {
} group; } group;
extern struct attrib_type at_group; /* attribute for units assigned to a group */ extern struct attrib_type at_group; /* attribute for units assigned to a group */
extern boolean join_group(struct unit * u, const char* name); extern boolean join_group(struct unit * u, const xmlChar* name);
extern void free_group(struct group * g); extern void free_group(struct group * g);
extern void write_groups(FILE * F, struct group * g); extern void write_groups(FILE * F, struct group * g);

View File

@ -125,13 +125,14 @@ a_readicastle(attrib * a, FILE * f)
return AT_READ_FAIL; return AT_READ_FAIL;
} else { } else {
variant bno; variant bno;
fscanf(f, "%s %d %d", buf, &bno.i, &data->time); char token[32];
fscanf(f, "%s %d %d", token, &bno.i, &data->time);
data->building = findbuilding(bno.i); data->building = findbuilding(bno.i);
if (!data->building) { if (!data->building) {
/* this shouldn't happen, but just in case it does: */ /* this shouldn't happen, but just in case it does: */
ur_add(bno, (void**)&data->building, resolve_building); ur_add(bno, (void**)&data->building, resolve_building);
} }
data->type = bt_find(buf); data->type = bt_find(token);
return AT_READ_OK; return AT_READ_OK;
} }
} }
@ -370,15 +371,16 @@ read_seenspell(attrib * a, FILE * f)
{ {
int i; int i;
spell * sp = NULL; spell * sp = NULL;
char token[32];
fscanf(f, "%s", buf); fscanf(f, "%s", token);
i = atoi(buf); i = atoi(token);
if (i!=0) { if (i!=0) {
sp = find_spellbyid(M_GRAU, (spellid_t)i); sp = find_spellbyid(M_GRAU, (spellid_t)i);
} else { } else {
int mtype; int mtype;
fscanf(f, "%d", &mtype); fscanf(f, "%d", &mtype);
sp = find_spell((magic_t)mtype, buf); sp = find_spell((magic_t)mtype, token);
} }
if (sp==NULL) { if (sp==NULL) {
/* log_error(("could not find seenspell '%s'\n", buf)); */ /* log_error(("could not find seenspell '%s'\n", buf)); */
@ -2233,8 +2235,10 @@ static int
read_familiar(attrib * a, FILE * F) read_familiar(attrib * a, FILE * F)
{ {
variant id; variant id;
fscanf(F, "%s", buf); char token[32];
id.i = atoi36(buf);
fscanf(F, "%s", token);
id.i = atoi36(token);
ur_add(id, &a->data.v, resolve_familiar); ur_add(id, &a->data.v, resolve_familiar);
return AT_READ_OK; return AT_READ_OK;
} }
@ -2310,8 +2314,10 @@ static int
read_clone(attrib * a, FILE * F) read_clone(attrib * a, FILE * F)
{ {
variant id; variant id;
fscanf(F, "%s", buf); char token[32];
id.i = atoi36(buf);
fscanf(F, "%s", token);
id.i = atoi36(token);
ur_add(id, &a->data.v, resolve_clone); ur_add(id, &a->data.v, resolve_clone);
return AT_READ_OK; return AT_READ_OK;
} }
@ -2336,8 +2342,10 @@ static int
read_magician(attrib * a, FILE * F) read_magician(attrib * a, FILE * F)
{ {
variant id; variant id;
fscanf(F, "%s", buf); char token[32];
id.i = atoi36(buf);
fscanf(F, "%s", token);
id.i = atoi36(token);
ur_add(id, &a->data.v, resolve_mage); ur_add(id, &a->data.v, resolve_mage);
return AT_READ_OK; return AT_READ_OK;
} }
@ -2497,7 +2505,7 @@ cast_cmd(unit * u, order * ord)
} }
s = getstrtoken(); s = getstrtoken();
} }
if (!s[0] || xmlStrlen(s) == 0) { if (!s[0] || xstrlen(s) == 0) {
/* Fehler "Es wurde kein Zauber angegeben" */ /* Fehler "Es wurde kein Zauber angegeben" */
cmistake(u, ord, 172, MSG_MAGIC); cmistake(u, ord, 172, MSG_MAGIC);
return 0; return 0;

View File

@ -945,7 +945,7 @@ cycle_route(order * ord, unit *u, int gereist)
tail_end += strlcpy((char*)tail_end, (const char *)loc, size-1); tail_end += strlcpy((char*)tail_end, (const char *)loc, size-1);
} }
} }
else if (xmlStrlen(neworder)>sizeof(neworder)/2) break; else if (xstrlen(neworder)>sizeof(neworder)/2) break;
else if (cm == gereist && !paused && pause) { else if (cm == gereist && !paused && pause) {
size_t size = sizeof(tail)-(tail_end-tail); size_t size = sizeof(tail)-(tail_end-tail);
const xmlChar * loc = LOC(lang, parameters[P_PAUSE]); const xmlChar * loc = LOC(lang, parameters[P_PAUSE]);
@ -2063,14 +2063,11 @@ travel(unit * u, region_list ** routep)
if (uf->region == r) { if (uf->region == r) {
order * follow_order; order * follow_order;
char str[32]; const struct locale * lang = u->faction->locale;
/* construct an order */ /* construct an order */
sprintf(str, "%s %s %s", follow_order = create_order(K_FOLLOW, lang, "%s %i",
locale_string(uf->faction->locale, keywords[K_FOLLOW]), LOC(uf->faction->locale, parameters[P_UNIT]), ut->no);
locale_string(uf->faction->locale, parameters[P_UNIT]),
itoa36(ut->no));
follow_order = parse_order(str, uf->faction->locale);
route_end = reroute(uf, route_begin, route_end); route_end = reroute(uf, route_begin, route_end);
travel_i(uf, route_begin, route_end, follow_order, TRAVEL_FOLLOWING, &followers); travel_i(uf, route_begin, route_end, follow_order, TRAVEL_FOLLOWING, &followers);
@ -2247,9 +2244,8 @@ piracy_cmd(unit *u, struct order * ord)
"ship region dir", sh, r, target_dir)); "ship region dir", sh, r, target_dir));
/* Befehl konstruieren */ /* Befehl konstruieren */
sprintf(buf, "%s %s", locale_string(u->faction->locale, keywords[K_MOVE]), set_order(&u->thisorder, create_order(K_MOVE, u->faction->locale, "%s",
locale_string(u->faction->locale, directions[target_dir])); LOC(u->faction->locale, directions[target_dir])));
set_order(&u->thisorder, parse_order(buf, u->faction->locale));
/* Bewegung ausführen */ /* Bewegung ausführen */
init_tokens(u->thisorder); init_tokens(u->thisorder);

View File

@ -662,7 +662,7 @@ abkz(const xmlChar *s, size_t max)
/* Prüfen, ob Kurz genug */ /* Prüfen, ob Kurz genug */
if (xmlStrlen(s) <= max) { if (xstrlen(s) <= max) {
return s; return s;
} }
/* Anzahl der Wörter feststellen */ /* Anzahl der Wörter feststellen */

View File

@ -184,7 +184,7 @@ create_data(keyword_t kwd, const xmlChar * sptr, int lindex)
data->_keyword = kwd; data->_keyword = kwd;
data->_lindex = lindex; data->_lindex = lindex;
if (xmlStrchr(skname, ' ')!=NULL) { if (xmlStrchr(skname, ' ')!=NULL) {
size_t len = xmlStrlen(skname); size_t len = xstrlen(skname);
data->_str = (xmlChar*)malloc(len+3); data->_str = (xmlChar*)malloc(len+3);
data->_str[0]='\"'; data->_str[0]='\"';
memcpy(data->_str+1, skname, len); memcpy(data->_str+1, skname, len);

View File

@ -62,7 +62,7 @@ struct rawmaterial;
struct donation; struct donation;
typedef struct land_region { typedef struct land_region {
char *name; xmlChar *name;
/* TODO: demand kann nach Konvertierung entfernt werden. */ /* TODO: demand kann nach Konvertierung entfernt werden. */
struct demand { struct demand {
struct demand * next; struct demand * next;

View File

@ -360,7 +360,7 @@ ri(FILE * F)
static int static int
ri36(FILE * F) ri36(FILE * F)
{ {
char buf[10]; char buf[16];
int i = 0; int i = 0;
rc(F); rc(F);
while (!isalnum(nextc)) rc(F); while (!isalnum(nextc)) rc(F);
@ -488,34 +488,20 @@ unitorders(FILE * F, int enc, struct faction * f)
static faction * static faction *
factionorders(void) factionorders(void)
{ {
char fid[16];
faction * f = NULL; faction * f = NULL;
int fid = getid();
strlcpy(fid, getstrtoken(), sizeof(fid)); f = findfaction(fid);
#ifdef FUZZY_BASE36
int id = atoi36(fid);
if (id!=0) f = findfaction(id);
if (f==NULL) {
id = atoi(fid);
if (id!=0) f = findfaction(id);
}
#else
f = findfaction(atoi36(fid));
#endif
if (f!=NULL) { if (f!=NULL) {
const char * pass = getstrtoken(); const xmlChar * pass = getstrtoken();
/* Kontrolliere, ob das Passwort richtig eingegeben wurde. Es
* muß in "Gänsefüßchen" stehen!! */
/* War vorher in main.c:getgarbage() */
if (quiet==0) { if (quiet==0) {
printf(" %4s;", factionid(f)); printf(" %4s;", factionid(f));
fflush(stdout); fflush(stdout);
} }
if (checkpasswd(f, pass, true) == false) { if (checkpasswd(f, pass, true) == false) {
log_warning(("Invalid password for faction %s\n", fid)); log_warning(("Invalid password for faction %s\n", itoa36(fid)));
ADDMSG(&f->msgs, msg_message("wrongpasswd", "faction password", ADDMSG(&f->msgs, msg_message("wrongpasswd", "faction password",
f->no, pass)); f->no, pass));
return 0; return 0;
@ -528,7 +514,7 @@ factionorders(void)
f->lastorders = global.data_turn+1; f->lastorders = global.data_turn+1;
} else { } else {
log_warning(("Befehle für die ungültige Partei %s\n", fid)); log_warning(("orders for invalid faction %s\n", itoa36(fid)));
} }
return f; return f;
} }

View File

@ -63,6 +63,7 @@
void void
spy_message(int spy, const unit *u, const unit *target) spy_message(int spy, const unit *u, const unit *target)
{ {
char buf[4096];
const char *c; const char *c;
/* Infos: /* Infos:

View File

@ -539,7 +539,7 @@ resolve_unit(variant id)
int int
read_unit_reference(unit ** up, FILE * F) read_unit_reference(unit ** up, FILE * F)
{ {
char zId[10]; char zId[16];
variant var; variant var;
assert(up!=NULL); assert(up!=NULL);

View File

@ -86,7 +86,7 @@ xml_to_locale(const xmlChar * xmlStr)
static char zText[1024]; static char zText[1024];
const xmlChar * inbuf = xmlStr; const xmlChar * inbuf = xmlStr;
char * outbuf = zText; char * outbuf = zText;
int inbytes = (int)xmlStrlen(xmlStr)+1; int inbytes = (int)xstrlen(xmlStr)+1;
int outbytes = (int)sizeof(zText); int outbytes = (int)sizeof(zText);
if (UTF8Toisolat1((xmlChar*)outbuf, &outbytes, inbuf, &inbytes)<0) { if (UTF8Toisolat1((xmlChar*)outbuf, &outbytes, inbuf, &inbytes)<0) {

View File

@ -44,7 +44,6 @@
#define WORMHOLE_MODULE #define WORMHOLE_MODULE
#define XECMD_MODULE #define XECMD_MODULE
#undef FUZZY_BASE36
#define SIMPLE_COMBAT #define SIMPLE_COMBAT
#define SIMPLE_ESCAPE #define SIMPLE_ESCAPE

View File

@ -44,6 +44,5 @@
#undef WORMHOLE_MODULE #undef WORMHOLE_MODULE
#undef XECMD_MODULE #undef XECMD_MODULE
#undef FUZZY_BASE36
#define SIMPLE_COMBAT #define SIMPLE_COMBAT
#define SIMPLE_ESCAPE #define SIMPLE_ESCAPE

View File

@ -2405,7 +2405,7 @@ patzer_peasantmob(castorder *co)
u = create_unit(r, f, n, new_race[RC_PEASANT], 0, LOC(f->locale, "angry_mob"), NULL); u = create_unit(r, f, n, new_race[RC_PEASANT], 0, LOC(f->locale, "angry_mob"), NULL);
fset(u, UFL_ISNEW); fset(u, UFL_ISNEW);
/* guard(u, GUARD_ALL); hier zu früh! Befehl BEWACHE setzten */ /* guard(u, GUARD_ALL); hier zu früh! Befehl BEWACHE setzten */
addlist(&u->orders, parse_order(LOC(lang, keywords[K_GUARD]), lang)); addlist(&u->orders, create_order(K_GUARD, lang, ""));
set_order(&u->thisorder, default_order(lang)); set_order(&u->thisorder, default_order(lang));
a = a_new(&at_unitdissolve); a = a_new(&at_unitdissolve);
a->data.ca[0] = 1; /* An rpeasants(r). */ a->data.ca[0] = 1; /* An rpeasants(r). */
@ -3229,7 +3229,7 @@ static int
dc_read_compat(struct attrib * a, FILE* F) dc_read_compat(struct attrib * a, FILE* F)
/* return AT_READ_OK on success, AT_READ_FAIL if attrib needs removal */ /* return AT_READ_OK on success, AT_READ_FAIL if attrib needs removal */
{ {
char zId[10]; char zId[16];
region * r = NULL; region * r = NULL;
unit * u; unit * u;
variant var; variant var;

View File

@ -180,26 +180,6 @@ locale_name(const locale * lang)
return lang->name; return lang->name;
} }
const char *
reverse_lookup(const locale * lang, const xmlChar * str)
{
int i;
assert(lang);
if (xmlStrlen(str)) {
if (lang!=NULL) {
for (i=0;i!=SMAXHASH;++i) {
struct locale_str * ls;
for (ls=lang->strings[i];ls;ls=ls->nexthash) {
if (xmlStrcasecmp(ls->str, str)==0) return ls->key;
}
}
}
log_error(("could not do a reverse_lookup for \"%s\" in locale %s\n", str, lang->name));
assert(!"failed to do a reverse_lookup");
}
return NULL;
}
char * char *
mkname_buf(const char * space, const char * name, char * buffer) mkname_buf(const char * space, const char * name, char * buffer)
{ {

View File

@ -30,7 +30,6 @@ extern const xmlChar * locale_string(const struct locale * lang, const char * ke
extern unsigned int locale_hashkey(const struct locale * lang); extern unsigned int locale_hashkey(const struct locale * lang);
extern const char * locale_name(const struct locale * lang); extern const char * locale_name(const struct locale * lang);
extern const char * reverse_lookup(const struct locale * lang, const xmlChar * str);
extern const char * mkname(const char * namespc, const char * key); extern const char * mkname(const char * namespc, const char * key);
extern char * mkname_buf(const char * namespc, const char * key, char * buffer); extern char * mkname_buf(const char * namespc, const char * key, char * buffer);

View File

@ -255,5 +255,11 @@ extern char * strdup(const char *s);
#include <libxml/xmlstring.h> #include <libxml/xmlstring.h>
#define xstrlen(a) strlen((const char*)(a))
#define xstrcmp(a, b) strcmp((const char*)(a), (const char *)(b))
#define xstrncmp(a, b, s) strncmp((const char*)(a), (const char *)(b), s)
#define xstrdup(a) (xmlChar *)strdup((const char*)(a))
#define xstrlcpy(a, b, s) strlcpy((char*)(a), (const char*)(b), s)
#endif #endif

View File

@ -367,10 +367,6 @@ fix_allies(void)
} }
} }
#ifdef FUZZY_BASE36
extern boolean enable_fuzzy;
#endif
static void static void
fix_icastles(void) fix_icastles(void)
{ {
@ -968,7 +964,4 @@ korrektur(void)
create_teleport_plane(); create_teleport_plane();
if (global.data_version<TYPES_VERSION) fix_icastles(); if (global.data_version<TYPES_VERSION) fix_icastles();
#ifdef FUZZY_BASE36
enable_fuzzy = true;
#endif
} }

View File

@ -67,6 +67,7 @@
#include <kernel/building.h> #include <kernel/building.h>
#include <kernel/faction.h> #include <kernel/faction.h>
#include <kernel/message.h> #include <kernel/message.h>
#include <kernel/names.h>
#include <kernel/plane.h> #include <kernel/plane.h>
#include <kernel/race.h> #include <kernel/race.h>
#include <kernel/skill.h> #include <kernel/skill.h>
@ -127,10 +128,6 @@ extern void render_init(void);
extern void free_borders(void); extern void free_borders(void);
#ifdef FUZZY_BASE36
extern int fuzzy_hits;
#endif /* FUZZY_BASE36 */
/** /**
** global variables that we are exporting ** global variables that we are exporting
**/ **/
@ -244,6 +241,7 @@ processturn(char *filename)
struct summary * begin, * end; struct summary * begin, * end;
newfaction * players; newfaction * players;
int i; int i;
char path[MAX_PATH];
if (turn == 0) rng_init((int)time(0)); if (turn == 0) rng_init((int)time(0));
else rng_init(turn); else rng_init(turn);
@ -261,7 +259,7 @@ processturn(char *filename)
plan_monsters(); plan_monsters();
} }
processorders(); processorders();
sprintf(buf, "%s/newfactions", basepath()); sprintf(path, "%s/newfactions", basepath());
players = read_newfactions(filename); players = read_newfactions(filename);
while (players) { while (players) {
int n = listlen(players); int n = listlen(players);
@ -284,11 +282,6 @@ processturn(char *filename)
free(end); free(end);
free(begin); free(begin);
writepasswd(); writepasswd();
#ifdef FUZZY_BASE36
fputs("==--------------------------==\n", stdout);
fprintf(stdout, "## fuzzy base10 hits: %5d ##\n", fuzzy_hits);
fputs("==--------------------------==\n", stdout);
#endif /* FUZZY_BASE36 */
if (!nowrite) { if (!nowrite) {
char ztext[64]; char ztext[64];
sprintf(ztext, "%d", turn); sprintf(ztext, "%d", turn);

View File

@ -150,9 +150,6 @@ extern "C" {
extern void free_borders(void); extern void free_borders(void);
extern boolean opt_cr_absolute_coords; extern boolean opt_cr_absolute_coords;
#ifdef FUZZY_BASE36
extern int fuzzy_hits;
#endif /* FUZZY_BASE36 */
} }
/** /**

View File

@ -7648,6 +7648,60 @@
<text locale="en">"$unit($unit) in $region($region): '$order($command)' - It's so quiet and peaceful, nobody wants to attack anybody right now."</text> <text locale="en">"$unit($unit) in $region($region): '$order($command)' - It's so quiet and peaceful, nobody wants to attack anybody right now."</text>
</message> </message>
<message name="error_race_nolearn" section="errors">
<type>
<arg name="region" type="region"/>
<arg name="unit" type="unit"/>
<arg name="command" type="order"/>
<arg name="race" type="race"/>
</type>
<text locale="de">"$unit($unit) in $region($region): '$order($command)' - $race($race,0) können nichts lernen."</text>
<text locale="en">"$unit($unit) in $region($region): '$order($command)' - $race($race,0) cannot study."</text>
</message>
<message name="error_migrants_nolearn" section="errors">
<type>
<arg name="region" type="region"/>
<arg name="unit" type="unit"/>
<arg name="command" type="order"/>
</type>
<text locale="de">"$unit($unit) in $region($region): '$order($command)' - Migranten können keine kostenpflichtigen Talente lernen."</text>
<text locale="en">"$unit($unit) in $region($region): '$order($command)' - Migrants cannot study this."</text>
</message>
<message name="error_max_magicians" section="errors">
<type>
<arg name="region" type="region"/>
<arg name="unit" type="unit"/>
<arg name="command" type="order"/>
<arg name="amount" type="int"/>
</type>
<text locale="de">"$unit($unit) in $region($region): '$order($command)' - Es kann maximal $int($amount) Magier pro Partei geben."</text>
<text locale="en">"$unit($unit) in $region($region): '$order($command)' - There may not be more tha $int($amount) magicians in your faction."</text>
</message>
<message name="error_max_alchemists" section="errors">
<type>
<arg name="region" type="region"/>
<arg name="unit" type="unit"/>
<arg name="command" type="order"/>
<arg name="amount" type="int"/>
</type>
<text locale="de">"$unit($unit) in $region($region): '$order($command)' - Es kann maximal $int($amount) Alchemisten pro Partei geben."</text>
<text locale="en">"$unit($unit) in $region($region): '$order($command)' - There may not be more tha $int($amount) alchemists in your faction."</text>
</message>
<message name="error_different_magic" section="errors">
<type>
<arg name="region" type="region"/>
<arg name="unit" type="unit"/>
<arg name="command" type="order"/>
<arg name="target" type="unit"/>
</type>
<text locale="de">"$unit($unit) in $region($region): '$order($command)' - $unit($target) versteht unsere Art von Mague nicht."</text>
<text locale="en">"$unit($unit) in $region($region): '$order($command)' - $unit($target) does not understand our kind of magic."</text>
</message>
<message name="slave_active" section="battle"> <message name="slave_active" section="battle">
<type> <type>
<arg name="region" type="region"/> <arg name="region" type="region"/>