forked from github/server
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:
parent
ea07884657
commit
39ce1bd0dd
|
@ -50,7 +50,7 @@ write_variable(const struct attrib * a, FILE *F)
|
|||
static int
|
||||
read_variable(struct attrib *a, FILE *F)
|
||||
{
|
||||
char localBuffer[BUFSIZE];
|
||||
char localBuffer[1024];
|
||||
|
||||
freadstr(F, localBuffer, sizeof(localBuffer));
|
||||
((variable *)(a->data.v))->key = strdup(localBuffer);
|
||||
|
|
|
@ -450,9 +450,9 @@ recruit(unit * u, struct order * ord, request ** recruitorders)
|
|||
const xmlChar * str = getstrtoken();
|
||||
if (str!=NULL && *str) {
|
||||
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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -1737,14 +1737,15 @@ make_cmd(unit * u, struct order * ord)
|
|||
const item_type * itype;
|
||||
const xmlChar *s;
|
||||
const struct locale * lang = u->faction->locale;
|
||||
char ibuf[16];
|
||||
|
||||
init_tokens(ord);
|
||||
skip_token();
|
||||
s = getstrtoken();
|
||||
|
||||
m = atoi((const char *)s);
|
||||
sprintf(buf, "%d", m);
|
||||
if (!strcmp(buf, (const char *)s)) {
|
||||
sprintf(ibuf, "%d", m);
|
||||
if (!strcmp(ibuf, (const char *)s)) {
|
||||
/* first came a want-paramter */
|
||||
s = getstrtoken();
|
||||
} else {
|
||||
|
@ -1801,12 +1802,12 @@ make_cmd(unit * u, struct order * ord)
|
|||
} else if (stype!=NULL) {
|
||||
const xmlChar * sname = LOC(lang, stype->name[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 {
|
||||
const xmlChar * bname = LOC(lang, btype->_name);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -1814,7 +1815,7 @@ make_cmd(unit * u, struct order * ord)
|
|||
if (btype!=NULL && stype!=NULL) {
|
||||
const xmlChar * bname = LOC(lang, btype->_name);
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -58,6 +58,7 @@
|
|||
#include <kernel/save.h>
|
||||
#include <kernel/ship.h>
|
||||
#include <kernel/skill.h>
|
||||
#include <kernel/spell.h>
|
||||
#include <kernel/spy.h>
|
||||
#include <kernel/teleport.h>
|
||||
#include <kernel/terrain.h>
|
||||
|
@ -1445,8 +1446,8 @@ display_cmd(unit * u, struct order * ord)
|
|||
if (s!=NULL) {
|
||||
const xmlChar * s2 = getstrtoken();
|
||||
|
||||
if (strlen(s2)>=DISPLAYSIZE) {
|
||||
xmlChar * s3 = strdup(s2);
|
||||
if (xstrlen(s2)>=DISPLAYSIZE) {
|
||||
xmlChar * s3 = xstrdup(s2);
|
||||
s3[DISPLAYSIZE] = 0;
|
||||
set_string(s, s3);
|
||||
free(s3);
|
||||
|
@ -1462,9 +1463,9 @@ renamed_building(const building * b)
|
|||
{
|
||||
const struct locale * lang = locales;
|
||||
for (;lang;lang=nextlocale(lang)) {
|
||||
const char * bdname = LOC(lang, b->type->_name);
|
||||
size_t bdlen = strlen(bdname);
|
||||
if (strlen(b->name)>=bdlen && strncmp(b->name, bdname, bdlen)==0) {
|
||||
const xmlChar * bdname = LOC(lang, b->type->_name);
|
||||
size_t bdlen = xstrlen(bdname);
|
||||
if (xstrlen(b->name)>=bdlen && xstrncmp(b->name, bdname, bdlen)==0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1476,7 +1477,7 @@ name_cmd(unit * u, struct order * ord)
|
|||
{
|
||||
building * b = u->building;
|
||||
region * r = u->region;
|
||||
char **s = NULL;
|
||||
xmlChar **s = NULL;
|
||||
param_t p;
|
||||
boolean foreign = false;
|
||||
|
||||
|
@ -1564,9 +1565,9 @@ name_cmd(unit * u, struct order * ord)
|
|||
} else {
|
||||
const struct locale * lang = locales;
|
||||
for (;lang;lang=nextlocale(lang)) {
|
||||
const char * fdname = LOC(lang, "factiondefault");
|
||||
size_t fdlen = strlen(fdname);
|
||||
if (strlen(f->name)>=fdlen && strncmp(f->name, fdname, fdlen)==0) {
|
||||
const xmlChar * fdname = LOC(lang, "factiondefault");
|
||||
size_t fdlen = xstrlen(fdname);
|
||||
if (xstrlen(f->name)>=fdlen && xstrncmp(f->name, fdname, fdlen)==0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1597,15 +1598,15 @@ name_cmd(unit * u, struct order * ord)
|
|||
} else {
|
||||
const struct locale * lang = locales;
|
||||
for (;lang;lang=nextlocale(lang)) {
|
||||
const char * sdname = LOC(lang, sh->type->name[0]);
|
||||
size_t sdlen = strlen(sdname);
|
||||
if (strlen(sh->name)>=sdlen && strncmp(sh->name, sdname, sdlen)==0) {
|
||||
const xmlChar * sdname = LOC(lang, sh->type->name[0]);
|
||||
size_t sdlen = xstrlen(sdname);
|
||||
if (xstrlen(sh->name)>=sdlen && xstrncmp(sh->name, sdname, sdlen)==0) {
|
||||
break;
|
||||
}
|
||||
|
||||
sdname = LOC(lang, parameters[P_SHIP]);
|
||||
sdlen = strlen(sdname);
|
||||
if (strlen(sh->name)>=sdlen && strncmp(sh->name, sdname, sdlen)==0) {
|
||||
sdlen = xstrlen(sdname);
|
||||
if (xstrlen(sh->name)>=sdlen && xstrncmp(sh->name, sdname, sdlen)==0) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1647,10 +1648,10 @@ name_cmd(unit * u, struct order * ord)
|
|||
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "feedback_unit_not_found", ""));
|
||||
break;
|
||||
} else {
|
||||
const char * udefault = LOC(u2->faction->locale, "unitdefault");
|
||||
size_t udlen = strlen(udefault);
|
||||
size_t unlen = strlen(u2->name);
|
||||
if (unlen>=udlen && strncmp(u2->name, udefault, udlen)!=0) {
|
||||
const xmlChar * udefault = LOC(u2->faction->locale, "unitdefault");
|
||||
size_t udlen = xstrlen(udefault);
|
||||
size_t unlen = xstrlen(u2->name);
|
||||
if (unlen>=udlen && xstrncmp(u2->name, udefault, udlen)!=0) {
|
||||
cmistake(u2, ord, 244, MSG_EVENT);
|
||||
break;
|
||||
}
|
||||
|
@ -1704,20 +1705,18 @@ name_cmd(unit * u, struct order * ord)
|
|||
}
|
||||
|
||||
if (s!=NULL) {
|
||||
const char * s2 = getstrtoken();
|
||||
const xmlChar * s2 = getstrtoken();
|
||||
|
||||
if (!s2[0]) {
|
||||
cmistake(u, ord, 84, MSG_EVENT);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (strchr(s2, '(')!=NULL) {
|
||||
cmistake(u, ord, 112, MSG_EVENT);
|
||||
return 0;
|
||||
}
|
||||
/* TODO: Validate to make sure people don't have illegal characters in
|
||||
* names, phishing-style? () come to mind. */
|
||||
|
||||
if (strlen(s2)>=NAMESIZE) {
|
||||
char * s3 = strdup(s2);
|
||||
if (xstrlen(s2)>=NAMESIZE) {
|
||||
xmlChar * s3 = xstrdup(s2);
|
||||
s3[NAMESIZE] = 0;
|
||||
set_string(s, s3);
|
||||
free(s3);
|
||||
|
@ -1731,7 +1730,7 @@ name_cmd(unit * u, struct order * ord)
|
|||
/* ------------------------------------------------------------- */
|
||||
|
||||
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)) {
|
||||
u = NULL;
|
||||
|
@ -1744,7 +1743,7 @@ deliverMail(faction * f, region * r, unit * u, const char *s, unit * receiver)
|
|||
}
|
||||
|
||||
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);
|
||||
|
||||
|
@ -1760,7 +1759,7 @@ mailunit(region * r, unit * u, int n, struct order * ord, const char * s)
|
|||
}
|
||||
|
||||
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;
|
||||
|
||||
|
@ -1776,8 +1775,8 @@ mail_cmd(unit * u, struct order * ord)
|
|||
{
|
||||
region * r = u->region;
|
||||
unit *u2;
|
||||
const char *s;
|
||||
int n;
|
||||
const xmlChar *s;
|
||||
int n, cont;
|
||||
|
||||
init_tokens(ord);
|
||||
skip_token(); /* skip the keyword */
|
||||
|
@ -1786,148 +1785,151 @@ mail_cmd(unit * u, struct order * ord)
|
|||
/* Falls kein Parameter, ist das eine Einheitsnummer;
|
||||
* das Füllwort "AN" muß wegfallen, da gültige Nummer! */
|
||||
|
||||
if (strcasecmp(s, "to") == 0) s = getstrtoken();
|
||||
else if (strcasecmp(s, "an") == 0) s = getstrtoken();
|
||||
|
||||
switch (findparam(s, u->faction->locale)) {
|
||||
case P_REGION:
|
||||
/* 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;
|
||||
}
|
||||
|
||||
do {
|
||||
cont = 0;
|
||||
switch (findparam(s, u->faction->locale)) {
|
||||
case P_REGION:
|
||||
/* können alle Einheiten in der Region sehen */
|
||||
s = getstrtoken();
|
||||
if (!s[0]) {
|
||||
cmistake(u, ord, 30, MSG_MESSAGE);
|
||||
break;
|
||||
} else {
|
||||
attrib * a = a_find(u2->attribs, &at_eventhandler);
|
||||
if (a!=NULL) {
|
||||
event_arg args[3];
|
||||
args[0].data.v = (void*)s;
|
||||
args[0].type = "string";
|
||||
args[1].data.v = (void*)u;
|
||||
args[1].type = "unit";
|
||||
args[2].type = NULL;
|
||||
handle_event(a, "message", args);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
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_GEBAEUDE:
|
||||
{
|
||||
building *b = getbuilding(r);
|
||||
case P_UNIT:
|
||||
{
|
||||
boolean see = false;
|
||||
n = getid();
|
||||
|
||||
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);
|
||||
for (u2=r->units; u2; u2=u2->next) {
|
||||
if (u2->no == n && cansee(u->faction, r, u2, 0)) {
|
||||
see = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case P_SHIP:
|
||||
{
|
||||
ship *sh = getship(r);
|
||||
if (see == false) {
|
||||
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "feedback_unit_not_found", ""));
|
||||
break;
|
||||
}
|
||||
|
||||
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);
|
||||
s = getstrtoken();
|
||||
if (!s[0]) {
|
||||
cmistake(u, ord, 30, MSG_MESSAGE);
|
||||
break;
|
||||
} else {
|
||||
attrib * a = a_find(u2->attribs, &at_eventhandler);
|
||||
if (a!=NULL) {
|
||||
event_arg args[3];
|
||||
args[0].data.v = (void*)s;
|
||||
args[0].type = "string";
|
||||
args[1].data.v = (void*)u;
|
||||
args[1].type = "unit";
|
||||
args[2].type = NULL;
|
||||
handle_event(a, "message", args);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
cmistake(u, ord, 149, MSG_MESSAGE);
|
||||
break;
|
||||
}
|
||||
mailunit(r, u, n, ord, s);
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
/* ------------------------------------------------------------- */
|
||||
|
@ -1948,7 +1950,7 @@ banner_cmd(unit * u, struct order * ord)
|
|||
static int
|
||||
email_cmd(unit * u, struct order * ord)
|
||||
{
|
||||
const char * s;
|
||||
const xmlChar * s;
|
||||
|
||||
init_tokens(ord);
|
||||
skip_token();
|
||||
|
@ -1958,7 +1960,7 @@ email_cmd(unit * u, struct order * ord)
|
|||
cmistake(u, ord, 85, MSG_EVENT);
|
||||
} else {
|
||||
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));
|
||||
ADDMSG(&f->msgs, msg_message("changemail_invalid", "value", s));
|
||||
} else {
|
||||
|
@ -1971,9 +1973,9 @@ email_cmd(unit * u, struct order * ord)
|
|||
static int
|
||||
password_cmd(unit * u, struct order * ord)
|
||||
{
|
||||
char pbuf[32];
|
||||
xmlChar pbuf[32];
|
||||
int i;
|
||||
const char * s;
|
||||
const xmlChar * s;
|
||||
|
||||
init_tokens(ord);
|
||||
skip_token();
|
||||
|
@ -1984,9 +1986,9 @@ password_cmd(unit * u, struct order * ord)
|
|||
pbuf[6] = 0;
|
||||
} else {
|
||||
boolean pwok = true;
|
||||
char *c;
|
||||
xmlChar *c;
|
||||
|
||||
strncpy(pbuf, s, 31);
|
||||
xstrlcpy(pbuf, s, 31);
|
||||
pbuf[31] = 0;
|
||||
c = pbuf;
|
||||
while (*c) {
|
||||
|
@ -2009,7 +2011,7 @@ password_cmd(unit * u, struct order * ord)
|
|||
static int
|
||||
send_cmd(unit * u, struct order * ord)
|
||||
{
|
||||
const char * s;
|
||||
const xmlChar * s;
|
||||
int option;
|
||||
|
||||
init_tokens(ord);
|
||||
|
@ -2062,8 +2064,8 @@ static boolean
|
|||
display_item(faction *f, unit *u, const item_type * itype)
|
||||
{
|
||||
const char *name;
|
||||
const char *info;
|
||||
const char *key;
|
||||
const xmlChar *info;
|
||||
|
||||
if (u!=NULL) {
|
||||
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);
|
||||
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"));
|
||||
}
|
||||
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
|
||||
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;
|
||||
char buf2[2048];
|
||||
char buf[2048];
|
||||
char buf2[128];
|
||||
char * bufp = buf;
|
||||
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]);
|
||||
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"));
|
||||
}
|
||||
|
||||
rsize = strlcpy(bufp, info, size);
|
||||
rsize = xstrlcpy(bufp, info, size);
|
||||
if (rsize>size) rsize = size-1;
|
||||
size -= rsize;
|
||||
bufp += rsize;
|
||||
|
@ -2257,7 +2261,7 @@ display_race(faction *f, unit *u, const race * rc)
|
|||
}
|
||||
|
||||
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;
|
||||
const potion_type * ptype;
|
||||
|
@ -2346,7 +2350,7 @@ promotion_cmd(unit * u, struct order * ord)
|
|||
static int
|
||||
group_cmd(unit * u, struct order * ord)
|
||||
{
|
||||
const char * s;
|
||||
const xmlChar * s;
|
||||
|
||||
init_tokens(ord);
|
||||
skip_token();
|
||||
|
@ -2387,7 +2391,7 @@ guard_off_cmd(unit * u, struct order * ord)
|
|||
static int
|
||||
reshow_cmd(unit * u, struct order * ord)
|
||||
{
|
||||
const char * s;
|
||||
const xmlChar * s;
|
||||
param_t p = NOPARAM;
|
||||
|
||||
init_tokens(ord);
|
||||
|
@ -2406,7 +2410,7 @@ reshow_cmd(unit * u, struct order * ord)
|
|||
static int
|
||||
status_cmd(unit * u, struct order * ord)
|
||||
{
|
||||
const char * param;
|
||||
const xmlChar * param;
|
||||
|
||||
init_tokens(ord);
|
||||
skip_token();
|
||||
|
@ -2452,7 +2456,7 @@ status_cmd(unit * u, struct order * ord)
|
|||
static int
|
||||
combatspell_cmd(unit * u, struct order * ord)
|
||||
{
|
||||
const char * s;
|
||||
const xmlChar * s;
|
||||
int level = 0;
|
||||
spell * spell;
|
||||
|
||||
|
@ -2680,7 +2684,7 @@ reorder(void)
|
|||
struct order * ord;
|
||||
for (ord = u->orders;ord;ord=ord->next) {
|
||||
if (get_keyword(ord)==K_SORT) {
|
||||
const char * s;
|
||||
const xmlChar * s;
|
||||
param_t p;
|
||||
int id;
|
||||
unit *v;
|
||||
|
@ -2808,7 +2812,7 @@ declare_war(void)
|
|||
init_tokens(ord);
|
||||
skip_token();
|
||||
for (;;) {
|
||||
const char * s = getstrtoken();
|
||||
const xmlChar * s = getstrtoken();
|
||||
if (s[0]==0) break;
|
||||
else {
|
||||
faction * enemy = findfaction(atoi36(s));
|
||||
|
@ -2828,7 +2832,7 @@ declare_war(void)
|
|||
init_tokens(ord);
|
||||
skip_token();
|
||||
for (;;) {
|
||||
const char * s = getstrtoken();
|
||||
const xmlChar * s = getstrtoken();
|
||||
if (s[0]==0) break;
|
||||
else {
|
||||
faction * enemy = findfaction(atoi36(s));
|
||||
|
@ -2856,7 +2860,7 @@ declare_war(void)
|
|||
static int
|
||||
renumber_cmd(unit * u, order * ord)
|
||||
{
|
||||
const char * s;
|
||||
const xmlChar * s;
|
||||
int i;
|
||||
faction * f = u->faction;
|
||||
|
||||
|
@ -3190,7 +3194,7 @@ new_units (void)
|
|||
init_tokens(makeord);
|
||||
skip_token();
|
||||
if (getparam(u->faction->locale) == P_TEMP) {
|
||||
const char * token;
|
||||
const xmlChar * token;
|
||||
char * name = NULL;
|
||||
int alias;
|
||||
order ** newordersp;
|
||||
|
@ -3576,7 +3580,7 @@ age_factions(void)
|
|||
static int
|
||||
use_cmd(unit * u, struct order * ord)
|
||||
{
|
||||
const char * t;
|
||||
const xmlChar * t;
|
||||
int n;
|
||||
const item_type * itype;
|
||||
|
||||
|
@ -3615,7 +3619,7 @@ use_cmd(unit * u, struct order * ord)
|
|||
static int
|
||||
claim_cmd(unit * u, struct order * ord)
|
||||
{
|
||||
const char * t;
|
||||
const xmlChar * t;
|
||||
int n;
|
||||
const item_type * itype;
|
||||
|
||||
|
@ -3855,7 +3859,7 @@ warn_password(void)
|
|||
faction * f = factions;
|
||||
while (f) {
|
||||
boolean pwok = true;
|
||||
const char * c = f->passw;
|
||||
const xmlChar * c = f->passw;
|
||||
while (*c) {
|
||||
if (!isalnum((unsigned char)*c)) pwok = false;
|
||||
c++;
|
||||
|
|
|
@ -32,7 +32,7 @@ void demographics(void);
|
|||
void last_orders(void);
|
||||
void find_address(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. */
|
||||
#include "resolve.h"
|
||||
|
|
|
@ -878,7 +878,7 @@ plan_dragon(unit * u)
|
|||
const struct locale * lang = u->faction->locale;
|
||||
/* do a growl */
|
||||
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(),
|
||||
u->number==1?"Ich rieche":"Wir riechen",
|
||||
"etwas in", rname(tr, u->faction->locale)));
|
||||
|
|
|
@ -348,14 +348,12 @@ teach_cmd(unit * u, struct order * ord)
|
|||
else
|
||||
#endif
|
||||
{
|
||||
static xmlChar zOrder[BUFSIZE];
|
||||
char zOrder[4096];
|
||||
order * new_order;
|
||||
|
||||
init_tokens(ord);
|
||||
skip_token();
|
||||
|
||||
strcpy((char*)zOrder, (const char *)locale_string(u->faction->locale, keywords[K_TEACH]));
|
||||
|
||||
while (!parser_end()) {
|
||||
unit * u2 = getunit(r, u->faction);
|
||||
++count;
|
||||
|
@ -379,8 +377,6 @@ teach_cmd(unit * u, struct order * ord)
|
|||
token = getstrtoken();
|
||||
|
||||
/* Beginne die Fehlermeldung */
|
||||
strcpy(buf, "Die Einheit '");
|
||||
|
||||
if (findparam(token, u->faction->locale) != P_TEMP) {
|
||||
uid = token;
|
||||
} else {
|
||||
|
@ -398,8 +394,8 @@ teach_cmd(unit * u, struct order * ord)
|
|||
|
||||
/* Neuen Befehl zusammenbauen. TEMP-Einheiten werden automatisch in
|
||||
* ihre neuen Nummern übersetzt. */
|
||||
strcat((char*)zOrder, " ");
|
||||
strcat((char*)zOrder, unitid(u2));
|
||||
strcat(zOrder, " ");
|
||||
strcat(zOrder, unitid(u2));
|
||||
|
||||
if (get_keyword(u2->thisorder) != K_STUDY) {
|
||||
ADDMSG(&u->faction->msgs,
|
||||
|
@ -432,16 +428,14 @@ teach_cmd(unit * u, struct order * ord)
|
|||
if (find_magetype(u2) != 0
|
||||
&& find_magetype(u) != find_magetype(u2))
|
||||
{
|
||||
sprintf(buf, "%s versteht unsere Art von Magie nicht", unitname(u2));
|
||||
mistake(u, ord, buf, MSG_EVENT);
|
||||
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_different_magic", "target", u2));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
set_order(&u->lastorder, new_order);
|
||||
#else
|
||||
|
@ -479,8 +473,7 @@ learn_cmd(unit * u, order * ord)
|
|||
}
|
||||
|
||||
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)));
|
||||
mistake(u, ord, buf, MSG_EVENT);
|
||||
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_race_nolearn", "race", u->race));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -528,8 +521,7 @@ learn_cmd(unit * u, order * ord)
|
|||
* keine Migranten, wird in is_migrant abgefangen. Vorsicht,
|
||||
* studycost darf hier noch nicht durch Akademie erhöht sein */
|
||||
if (studycost > 0 && !ExpensiveMigrants() && is_migrant(u)) {
|
||||
sprintf(buf, "Migranten können keine kostenpflichtigen Talente lernen");
|
||||
mistake(u, ord, buf, MSG_EVENT);
|
||||
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_migrants_nolearn", ""));
|
||||
return 0;
|
||||
}
|
||||
/* Akademie: */
|
||||
|
@ -553,13 +545,11 @@ learn_cmd(unit * u, order * ord)
|
|||
mtyp = M_GRAU;
|
||||
if (!is_mage(u)) create_mage(u, mtyp);
|
||||
} else if (!has_skill(u, SK_MAGIC)) {
|
||||
int mmax = max_skill(u->faction, SK_MAGIC);
|
||||
/* Die Einheit ist noch kein Magier */
|
||||
if (count_skill(u->faction, SK_MAGIC) + u->number >
|
||||
max_skill(u->faction, SK_MAGIC))
|
||||
if (count_skill(u->faction, SK_MAGIC) + u->number > mmax)
|
||||
{
|
||||
sprintf(buf, "Es kann maximal %d Magier pro Partei geben",
|
||||
max_skill(u->faction, SK_MAGIC));
|
||||
mistake(u, ord, buf, MSG_EVENT);
|
||||
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_max_magicians", "amount", mmax));
|
||||
return 0;
|
||||
}
|
||||
mtyp = getmagicskill(u->faction->locale);
|
||||
|
@ -605,14 +595,13 @@ learn_cmd(unit * u, order * ord)
|
|||
}
|
||||
if (sk == SK_ALCHEMY) {
|
||||
maxalchemy = eff_skill(u, SK_ALCHEMY, r);
|
||||
if (has_skill(u, SK_ALCHEMY)==0
|
||||
&& count_skill(u->faction, SK_ALCHEMY) + u->number >
|
||||
max_skill(u->faction, SK_ALCHEMY)) {
|
||||
sprintf(buf, "Es kann maximal %d Alchemisten pro Partei geben",
|
||||
max_skill(u->faction, SK_ALCHEMY));
|
||||
mistake(u, ord, buf, MSG_EVENT);
|
||||
if (!has_skill(u, SK_ALCHEMY)) {
|
||||
int amax = max_skill(u->faction, SK_ALCHEMY);
|
||||
if (count_skill(u->faction, SK_ALCHEMY) + u->number > amax) {
|
||||
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_max_alchemists", "amount", amax));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (studycost) {
|
||||
int cost = studycost * u->number;
|
||||
|
|
|
@ -934,16 +934,13 @@ build_building(unit * u, const building_type * btype, int want, order * ord)
|
|||
|
||||
if (n-built <= 0) {
|
||||
/* gebäude fertig */
|
||||
strcpy(buffer, LOC(lang, "defaultorder"));
|
||||
new_order = parse_order(buffer, lang);
|
||||
new_order = default_order(lang);
|
||||
} else if (n!=INT_MAX) {
|
||||
/* reduzierte restgröße */
|
||||
sprintf(buffer, "%s %d %s %s", LOC(lang, keywords[K_MAKE]), n-built, btname, buildingid(b));
|
||||
new_order = parse_order(buffer, lang);
|
||||
new_order = create_order(K_MAKE, lang, "%d '%s' %i", n-built, btname, b->no);
|
||||
} else if (btname) {
|
||||
/* Neues Haus, Befehl mit Gebäudename */
|
||||
sprintf(buffer, "%s %s %s", LOC(lang, keywords[K_MAKE]), btname, buildingid(b));
|
||||
new_order = parse_order(buffer, u->faction->locale);
|
||||
new_order = create_order(K_MAKE, lang, "'%s' %i", btname, b->no);
|
||||
}
|
||||
|
||||
if (new_order) {
|
||||
|
@ -1037,10 +1034,7 @@ create_ship(region * r, unit * u, const struct ship_type * newtype, int want, or
|
|||
u->ship = sh;
|
||||
}
|
||||
fset(u, UFL_OWNER);
|
||||
sprintf(buffer, "%s %s %s",
|
||||
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);
|
||||
new_order = create_order(K_MAKE, u->faction->locale, "%s %i", LOC(u->faction->locale, parameters[P_SHIP]), sh->no);
|
||||
#ifdef LASTORDER
|
||||
set_order(&u->lastorder, new_order);
|
||||
#else
|
||||
|
|
|
@ -396,7 +396,7 @@ int
|
|||
read_building_reference(struct building ** b, FILE * F)
|
||||
{
|
||||
variant var;
|
||||
char zText[10];
|
||||
char zText[16];
|
||||
fscanf(F, "%s ", zText);
|
||||
var.i = atoi36(zText);
|
||||
if (var.i==0) {
|
||||
|
|
|
@ -1396,32 +1396,11 @@ getparam (const struct locale * lang)
|
|||
return findparam (getstrtoken (), lang);
|
||||
}
|
||||
|
||||
#ifdef FUZZY_BASE36
|
||||
extern int fuzzy_hits;
|
||||
boolean enable_fuzzy = false;
|
||||
#endif /* FUZZY_BASE36 */
|
||||
|
||||
faction *
|
||||
findfaction (int n)
|
||||
{
|
||||
faction * f = ffindhash(n);
|
||||
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 *
|
||||
|
@ -2628,11 +2607,11 @@ findspecialdirection(const region *r, const xmlChar *token)
|
|||
attrib *a;
|
||||
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) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -188,7 +188,7 @@ read_faction_reference(faction ** f, FILE * F)
|
|||
{
|
||||
variant id;
|
||||
if (global.data_version >= BASE36IDS_VERSION) {
|
||||
char zText[10];
|
||||
char zText[16];
|
||||
fscanf(F, "%s ", zText);
|
||||
id.i = atoi36(zText);
|
||||
} else {
|
||||
|
|
|
@ -39,7 +39,7 @@ static group * ghash[GMAXHASH];
|
|||
static int maxgid;
|
||||
|
||||
static group *
|
||||
new_group(faction * f, const char * name, int gid)
|
||||
new_group(faction * f, const xmlChar * name, int gid)
|
||||
{
|
||||
group ** gp = &f->groups;
|
||||
int index = gid % GMAXHASH;
|
||||
|
@ -49,7 +49,7 @@ new_group(faction * f, const char * name, int gid)
|
|||
*gp = g;
|
||||
|
||||
maxgid = max(gid, maxgid);
|
||||
g->name = strdup(name);
|
||||
g->name = xstrdup(name);
|
||||
g->gid = gid;
|
||||
|
||||
g->nexthash = ghash[index];
|
||||
|
@ -71,7 +71,7 @@ init_group(faction * f, group * g)
|
|||
}
|
||||
|
||||
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;
|
||||
return g;
|
||||
|
@ -131,7 +131,7 @@ free_group(group * g)
|
|||
}
|
||||
|
||||
boolean
|
||||
join_group(unit * u, const char * name)
|
||||
join_group(unit * u, const xmlChar * name)
|
||||
{
|
||||
attrib * a = NULL;
|
||||
group * g;
|
||||
|
@ -184,9 +184,11 @@ read_groups(FILE * F, faction * f)
|
|||
ally ** pa;
|
||||
group * g;
|
||||
int gid;
|
||||
fscanf(F, "%d ", &gid);
|
||||
char buf[1024];
|
||||
|
||||
fscanf(F, "%d ", &gid);
|
||||
if (!gid) break;
|
||||
rsf(F, buf, 1024);
|
||||
rsf(F, buf, sizeof(buf));
|
||||
g = new_group(f, buf, gid);
|
||||
pa = &g->allies;
|
||||
for (;;) {
|
||||
|
|
|
@ -25,7 +25,7 @@ typedef struct group {
|
|||
struct group * nexthash;
|
||||
struct faction * f;
|
||||
struct attrib *attribs;
|
||||
char * name;
|
||||
xmlChar * name;
|
||||
struct ally * allies;
|
||||
int flags;
|
||||
int gid;
|
||||
|
@ -33,7 +33,7 @@ typedef struct group {
|
|||
} 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 write_groups(FILE * F, struct group * g);
|
||||
|
|
|
@ -125,13 +125,14 @@ a_readicastle(attrib * a, FILE * f)
|
|||
return AT_READ_FAIL;
|
||||
} else {
|
||||
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);
|
||||
if (!data->building) {
|
||||
/* this shouldn't happen, but just in case it does: */
|
||||
ur_add(bno, (void**)&data->building, resolve_building);
|
||||
}
|
||||
data->type = bt_find(buf);
|
||||
data->type = bt_find(token);
|
||||
return AT_READ_OK;
|
||||
}
|
||||
}
|
||||
|
@ -370,15 +371,16 @@ read_seenspell(attrib * a, FILE * f)
|
|||
{
|
||||
int i;
|
||||
spell * sp = NULL;
|
||||
char token[32];
|
||||
|
||||
fscanf(f, "%s", buf);
|
||||
i = atoi(buf);
|
||||
fscanf(f, "%s", token);
|
||||
i = atoi(token);
|
||||
if (i!=0) {
|
||||
sp = find_spellbyid(M_GRAU, (spellid_t)i);
|
||||
} else {
|
||||
int mtype;
|
||||
fscanf(f, "%d", &mtype);
|
||||
sp = find_spell((magic_t)mtype, buf);
|
||||
sp = find_spell((magic_t)mtype, token);
|
||||
}
|
||||
if (sp==NULL) {
|
||||
/* log_error(("could not find seenspell '%s'\n", buf)); */
|
||||
|
@ -2233,8 +2235,10 @@ static int
|
|||
read_familiar(attrib * a, FILE * F)
|
||||
{
|
||||
variant id;
|
||||
fscanf(F, "%s", buf);
|
||||
id.i = atoi36(buf);
|
||||
char token[32];
|
||||
|
||||
fscanf(F, "%s", token);
|
||||
id.i = atoi36(token);
|
||||
ur_add(id, &a->data.v, resolve_familiar);
|
||||
return AT_READ_OK;
|
||||
}
|
||||
|
@ -2310,8 +2314,10 @@ static int
|
|||
read_clone(attrib * a, FILE * F)
|
||||
{
|
||||
variant id;
|
||||
fscanf(F, "%s", buf);
|
||||
id.i = atoi36(buf);
|
||||
char token[32];
|
||||
|
||||
fscanf(F, "%s", token);
|
||||
id.i = atoi36(token);
|
||||
ur_add(id, &a->data.v, resolve_clone);
|
||||
return AT_READ_OK;
|
||||
}
|
||||
|
@ -2336,8 +2342,10 @@ static int
|
|||
read_magician(attrib * a, FILE * F)
|
||||
{
|
||||
variant id;
|
||||
fscanf(F, "%s", buf);
|
||||
id.i = atoi36(buf);
|
||||
char token[32];
|
||||
|
||||
fscanf(F, "%s", token);
|
||||
id.i = atoi36(token);
|
||||
ur_add(id, &a->data.v, resolve_mage);
|
||||
return AT_READ_OK;
|
||||
}
|
||||
|
@ -2497,7 +2505,7 @@ cast_cmd(unit * u, order * ord)
|
|||
}
|
||||
s = getstrtoken();
|
||||
}
|
||||
if (!s[0] || xmlStrlen(s) == 0) {
|
||||
if (!s[0] || xstrlen(s) == 0) {
|
||||
/* Fehler "Es wurde kein Zauber angegeben" */
|
||||
cmistake(u, ord, 172, MSG_MAGIC);
|
||||
return 0;
|
||||
|
|
|
@ -945,7 +945,7 @@ cycle_route(order * ord, unit *u, int gereist)
|
|||
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) {
|
||||
size_t size = sizeof(tail)-(tail_end-tail);
|
||||
const xmlChar * loc = LOC(lang, parameters[P_PAUSE]);
|
||||
|
@ -2063,14 +2063,11 @@ travel(unit * u, region_list ** routep)
|
|||
|
||||
if (uf->region == r) {
|
||||
order * follow_order;
|
||||
char str[32];
|
||||
const struct locale * lang = u->faction->locale;
|
||||
|
||||
/* construct an order */
|
||||
sprintf(str, "%s %s %s",
|
||||
locale_string(uf->faction->locale, keywords[K_FOLLOW]),
|
||||
locale_string(uf->faction->locale, parameters[P_UNIT]),
|
||||
itoa36(ut->no));
|
||||
follow_order = parse_order(str, uf->faction->locale);
|
||||
follow_order = create_order(K_FOLLOW, lang, "%s %i",
|
||||
LOC(uf->faction->locale, parameters[P_UNIT]), ut->no);
|
||||
|
||||
route_end = reroute(uf, route_begin, route_end);
|
||||
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));
|
||||
|
||||
/* Befehl konstruieren */
|
||||
sprintf(buf, "%s %s", locale_string(u->faction->locale, keywords[K_MOVE]),
|
||||
locale_string(u->faction->locale, directions[target_dir]));
|
||||
set_order(&u->thisorder, parse_order(buf, u->faction->locale));
|
||||
set_order(&u->thisorder, create_order(K_MOVE, u->faction->locale, "%s",
|
||||
LOC(u->faction->locale, directions[target_dir])));
|
||||
|
||||
/* Bewegung ausführen */
|
||||
init_tokens(u->thisorder);
|
||||
|
|
|
@ -662,7 +662,7 @@ abkz(const xmlChar *s, size_t max)
|
|||
|
||||
/* Prüfen, ob Kurz genug */
|
||||
|
||||
if (xmlStrlen(s) <= max) {
|
||||
if (xstrlen(s) <= max) {
|
||||
return s;
|
||||
}
|
||||
/* Anzahl der Wörter feststellen */
|
||||
|
|
|
@ -184,7 +184,7 @@ create_data(keyword_t kwd, const xmlChar * sptr, int lindex)
|
|||
data->_keyword = kwd;
|
||||
data->_lindex = lindex;
|
||||
if (xmlStrchr(skname, ' ')!=NULL) {
|
||||
size_t len = xmlStrlen(skname);
|
||||
size_t len = xstrlen(skname);
|
||||
data->_str = (xmlChar*)malloc(len+3);
|
||||
data->_str[0]='\"';
|
||||
memcpy(data->_str+1, skname, len);
|
||||
|
|
|
@ -62,7 +62,7 @@ struct rawmaterial;
|
|||
struct donation;
|
||||
|
||||
typedef struct land_region {
|
||||
char *name;
|
||||
xmlChar *name;
|
||||
/* TODO: demand kann nach Konvertierung entfernt werden. */
|
||||
struct demand {
|
||||
struct demand * next;
|
||||
|
|
|
@ -360,7 +360,7 @@ ri(FILE * F)
|
|||
static int
|
||||
ri36(FILE * F)
|
||||
{
|
||||
char buf[10];
|
||||
char buf[16];
|
||||
int i = 0;
|
||||
rc(F);
|
||||
while (!isalnum(nextc)) rc(F);
|
||||
|
@ -488,34 +488,20 @@ unitorders(FILE * F, int enc, struct faction * f)
|
|||
static faction *
|
||||
factionorders(void)
|
||||
{
|
||||
char fid[16];
|
||||
faction * f = NULL;
|
||||
int fid = getid();
|
||||
|
||||
strlcpy(fid, getstrtoken(), sizeof(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
|
||||
f = findfaction(fid);
|
||||
|
||||
if (f!=NULL) {
|
||||
const char * pass = getstrtoken();
|
||||
/* Kontrolliere, ob das Passwort richtig eingegeben wurde. Es
|
||||
* muß in "Gänsefüßchen" stehen!! */
|
||||
|
||||
/* War vorher in main.c:getgarbage() */
|
||||
const xmlChar * pass = getstrtoken();
|
||||
if (quiet==0) {
|
||||
printf(" %4s;", factionid(f));
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
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",
|
||||
f->no, pass));
|
||||
return 0;
|
||||
|
@ -528,7 +514,7 @@ factionorders(void)
|
|||
f->lastorders = global.data_turn+1;
|
||||
|
||||
} 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;
|
||||
}
|
||||
|
|
|
@ -63,6 +63,7 @@
|
|||
void
|
||||
spy_message(int spy, const unit *u, const unit *target)
|
||||
{
|
||||
char buf[4096];
|
||||
const char *c;
|
||||
|
||||
/* Infos:
|
||||
|
|
|
@ -539,7 +539,7 @@ resolve_unit(variant id)
|
|||
int
|
||||
read_unit_reference(unit ** up, FILE * F)
|
||||
{
|
||||
char zId[10];
|
||||
char zId[16];
|
||||
variant var;
|
||||
|
||||
assert(up!=NULL);
|
||||
|
|
|
@ -86,7 +86,7 @@ xml_to_locale(const xmlChar * xmlStr)
|
|||
static char zText[1024];
|
||||
const xmlChar * inbuf = xmlStr;
|
||||
char * outbuf = zText;
|
||||
int inbytes = (int)xmlStrlen(xmlStr)+1;
|
||||
int inbytes = (int)xstrlen(xmlStr)+1;
|
||||
int outbytes = (int)sizeof(zText);
|
||||
|
||||
if (UTF8Toisolat1((xmlChar*)outbuf, &outbytes, inbuf, &inbytes)<0) {
|
||||
|
|
|
@ -44,7 +44,6 @@
|
|||
#define WORMHOLE_MODULE
|
||||
#define XECMD_MODULE
|
||||
|
||||
#undef FUZZY_BASE36
|
||||
#define SIMPLE_COMBAT
|
||||
#define SIMPLE_ESCAPE
|
||||
|
||||
|
|
|
@ -44,6 +44,5 @@
|
|||
#undef WORMHOLE_MODULE
|
||||
#undef XECMD_MODULE
|
||||
|
||||
#undef FUZZY_BASE36
|
||||
#define SIMPLE_COMBAT
|
||||
#define SIMPLE_ESCAPE
|
||||
|
|
|
@ -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);
|
||||
fset(u, UFL_ISNEW);
|
||||
/* 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));
|
||||
a = a_new(&at_unitdissolve);
|
||||
a->data.ca[0] = 1; /* An rpeasants(r). */
|
||||
|
@ -3229,7 +3229,7 @@ static int
|
|||
dc_read_compat(struct attrib * a, FILE* F)
|
||||
/* return AT_READ_OK on success, AT_READ_FAIL if attrib needs removal */
|
||||
{
|
||||
char zId[10];
|
||||
char zId[16];
|
||||
region * r = NULL;
|
||||
unit * u;
|
||||
variant var;
|
||||
|
|
|
@ -180,26 +180,6 @@ locale_name(const locale * lang)
|
|||
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 *
|
||||
mkname_buf(const char * space, const char * name, char * buffer)
|
||||
{
|
||||
|
|
|
@ -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 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 char * mkname_buf(const char * namespc, const char * key, char * buffer);
|
||||
|
||||
|
|
|
@ -255,5 +255,11 @@ extern char * strdup(const char *s);
|
|||
|
||||
#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
|
||||
|
||||
|
|
|
@ -367,10 +367,6 @@ fix_allies(void)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef FUZZY_BASE36
|
||||
extern boolean enable_fuzzy;
|
||||
#endif
|
||||
|
||||
static void
|
||||
fix_icastles(void)
|
||||
{
|
||||
|
@ -968,7 +964,4 @@ korrektur(void)
|
|||
create_teleport_plane();
|
||||
|
||||
if (global.data_version<TYPES_VERSION) fix_icastles();
|
||||
#ifdef FUZZY_BASE36
|
||||
enable_fuzzy = true;
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -67,6 +67,7 @@
|
|||
#include <kernel/building.h>
|
||||
#include <kernel/faction.h>
|
||||
#include <kernel/message.h>
|
||||
#include <kernel/names.h>
|
||||
#include <kernel/plane.h>
|
||||
#include <kernel/race.h>
|
||||
#include <kernel/skill.h>
|
||||
|
@ -127,10 +128,6 @@ extern void render_init(void);
|
|||
extern void free_borders(void);
|
||||
|
||||
|
||||
#ifdef FUZZY_BASE36
|
||||
extern int fuzzy_hits;
|
||||
#endif /* FUZZY_BASE36 */
|
||||
|
||||
/**
|
||||
** global variables that we are exporting
|
||||
**/
|
||||
|
@ -244,6 +241,7 @@ processturn(char *filename)
|
|||
struct summary * begin, * end;
|
||||
newfaction * players;
|
||||
int i;
|
||||
char path[MAX_PATH];
|
||||
|
||||
if (turn == 0) rng_init((int)time(0));
|
||||
else rng_init(turn);
|
||||
|
@ -261,7 +259,7 @@ processturn(char *filename)
|
|||
plan_monsters();
|
||||
}
|
||||
processorders();
|
||||
sprintf(buf, "%s/newfactions", basepath());
|
||||
sprintf(path, "%s/newfactions", basepath());
|
||||
players = read_newfactions(filename);
|
||||
while (players) {
|
||||
int n = listlen(players);
|
||||
|
@ -284,11 +282,6 @@ processturn(char *filename)
|
|||
free(end);
|
||||
free(begin);
|
||||
writepasswd();
|
||||
#ifdef FUZZY_BASE36
|
||||
fputs("==--------------------------==\n", stdout);
|
||||
fprintf(stdout, "## fuzzy base10 hits: %5d ##\n", fuzzy_hits);
|
||||
fputs("==--------------------------==\n", stdout);
|
||||
#endif /* FUZZY_BASE36 */
|
||||
if (!nowrite) {
|
||||
char ztext[64];
|
||||
sprintf(ztext, "%d", turn);
|
||||
|
|
|
@ -150,9 +150,6 @@ extern "C" {
|
|||
extern void free_borders(void);
|
||||
extern boolean opt_cr_absolute_coords;
|
||||
|
||||
#ifdef FUZZY_BASE36
|
||||
extern int fuzzy_hits;
|
||||
#endif /* FUZZY_BASE36 */
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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>
|
||||
</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">
|
||||
<type>
|
||||
<arg name="region" type="region"/>
|
||||
|
|
Loading…
Reference in New Issue