forked from github/server
!this commit does not compile!
Unicode WIP: - removed xmlChar and returned everything to char * again, now that conversion is complete. - added option to specify orderfile and daatafile encoding in .ini file currently: implementing reading of latin1 datafiles for backward compatibility
This commit is contained in:
parent
6acb1e22c5
commit
b837248601
84 changed files with 1067 additions and 1048 deletions
src
common
attributes
gamecode
archetype.carchetype.hcreation.ccreport.ceconomy.claws.claws.hmonster.crandenc.creport.cspy.cstudy.cxmlreport.c
kernel
battle.cbuild.cbuilding.cbuilding.hcommand.ccommand.heressea.ceressea.hfaction.cfaction.hgroup.cgroup.hitem.citem.hmagic.cmagic.hmessage.cmove.cnames.cnames.horder.corder.hpool.crace.crace.hregion.cregion.hreports.creports.hsave.csave.hship.cship.hskill.cskill.hspell.cspell.hunit.cunit.hxmlreader.c
modules
spells
triggers
util
eressea
scripts
|
@ -100,7 +100,7 @@ object_read(attrib *a, FILE *F)
|
|||
fscanf(F, "%lf", &data->data.real);
|
||||
break;
|
||||
case TSTRING:
|
||||
freadstr(F, buffer, sizeof(buffer));
|
||||
freadstr(F, enc_gamedata, buffer, sizeof(buffer));
|
||||
data->data.str = strdup(buffer);
|
||||
break;
|
||||
case TBUILDING:
|
||||
|
|
|
@ -41,8 +41,7 @@ finalize_variable(struct attrib * a)
|
|||
static void
|
||||
write_variable(const struct attrib * a, FILE *F)
|
||||
{
|
||||
fwritestr(F, ((variable *)(a->data.v))->key);
|
||||
fputc(' ', F);
|
||||
fprintf(F, "%s ", ((variable *)(a->data.v))->key);
|
||||
fwritestr(F, ((variable *)(a->data.v))->value);
|
||||
fputc(' ', F);
|
||||
}
|
||||
|
@ -52,10 +51,10 @@ read_variable(struct attrib *a, FILE *F)
|
|||
{
|
||||
char localBuffer[1024];
|
||||
|
||||
freadstr(F, localBuffer, sizeof(localBuffer));
|
||||
fscanf(F, "%s", localBuffer);
|
||||
((variable *)(a->data.v))->key = strdup(localBuffer);
|
||||
|
||||
freadstr(F, localBuffer, sizeof(localBuffer));
|
||||
freadstr(F, enc_gamedata, localBuffer, sizeof(localBuffer));
|
||||
((variable *)(a->data.v))->value = strdup(localBuffer);
|
||||
|
||||
return AT_READ_OK;
|
||||
|
|
|
@ -30,7 +30,7 @@ struct attrib_type at_recruit = {
|
|||
};
|
||||
|
||||
const struct archetype *
|
||||
find_archetype(const xmlChar * s, const struct locale * lang)
|
||||
find_archetype(const char * s, const struct locale * lang)
|
||||
{
|
||||
struct tnode * tokens = get_translations(lang, UT_ARCHETYPES);
|
||||
variant token;
|
||||
|
@ -57,13 +57,13 @@ init_archetypes(void)
|
|||
archetype * arch = archetypes;
|
||||
struct tnode * tokens = get_translations(lang, UT_ARCHETYPES);
|
||||
for (;arch;arch=arch->next) {
|
||||
const xmlChar *s1, *s2;
|
||||
const char *s1, *s2;
|
||||
var.v = arch;
|
||||
|
||||
s1 = LOC(lang, arch->name[0]);
|
||||
addtoken(tokens, s1, var);
|
||||
s2 = LOC(lang, arch->name[1]);
|
||||
if (xmlStrcmp(s2, s1)!=0) {
|
||||
if (strcmp(s2, s1)!=0) {
|
||||
addtoken(tokens, s2, var);
|
||||
}
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ parse_archetypes(xmlDocPtr doc)
|
|||
xmlXPathObjectPtr result = xmlXPathEvalExpression(BAD_CAST "/eressea/archetypes/archetype", xpath);
|
||||
xmlNodeSetPtr nodes = result->nodesetval;
|
||||
|
||||
xmlChar * property;
|
||||
xmlChar * propValue;
|
||||
if (nodes) {
|
||||
int i;
|
||||
for (i=0;i!=nodes->nodeNr;++i) {
|
||||
|
@ -86,25 +86,25 @@ parse_archetypes(xmlDocPtr doc)
|
|||
archetype * arch = calloc(1, sizeof(archetype));
|
||||
xmlXPathObjectPtr sub;
|
||||
|
||||
property = xmlGetProp(node, BAD_CAST "name");
|
||||
assert(property!=NULL);
|
||||
arch->name[0] = strdup((const char *)property);
|
||||
propValue = xmlGetProp(node, BAD_CAST "name");
|
||||
assert(propValue!=NULL);
|
||||
arch->name[0] = strdup((const char *)propValue);
|
||||
sprintf(zName, "%s_p", arch->name[0]);
|
||||
arch->name[1] = strdup(zName);
|
||||
xmlFree(property);
|
||||
xmlFree(propValue);
|
||||
|
||||
property = xmlGetProp(node, BAD_CAST "equip");
|
||||
if (property!=NULL) {
|
||||
arch->equip = get_equipment((const char*)property);
|
||||
xmlFree(property);
|
||||
propValue = xmlGetProp(node, BAD_CAST "equip");
|
||||
if (propValue!=NULL) {
|
||||
arch->equip = get_equipment((const char*)propValue);
|
||||
xmlFree(propValue);
|
||||
} else {
|
||||
arch->equip = get_equipment(arch->name[0]);
|
||||
}
|
||||
|
||||
property = xmlGetProp(node, BAD_CAST "building");
|
||||
if (property!=NULL) {
|
||||
arch->btype = bt_find((const char*)property);
|
||||
xmlFree(property);
|
||||
propValue = xmlGetProp(node, BAD_CAST "building");
|
||||
if (propValue!=NULL) {
|
||||
arch->btype = bt_find((const char*)propValue);
|
||||
xmlFree(propValue);
|
||||
}
|
||||
|
||||
arch->size = xml_ivalue(node, "cost", 0);
|
||||
|
@ -118,13 +118,13 @@ parse_archetypes(xmlDocPtr doc)
|
|||
xmlNodePtr rule = sub->nodesetval->nodeTab[k];
|
||||
arch->rules[k].allow = (rule->name[0]=='a');
|
||||
|
||||
property = xmlGetProp(rule, BAD_CAST "property");
|
||||
arch->rules[k].property = strdup((const char *)property);
|
||||
xmlFree(property);
|
||||
propValue = xmlGetProp(rule, BAD_CAST "property");
|
||||
arch->rules[k].property = strdup((const char *)propValue);
|
||||
xmlFree(propValue);
|
||||
|
||||
property = xmlGetProp(rule, BAD_CAST "value");
|
||||
arch->rules[k].value = strdup((const char *)property);
|
||||
xmlFree(property);
|
||||
propValue = xmlGetProp(rule, BAD_CAST "value");
|
||||
arch->rules[k].value = strdup((const char *)propValue);
|
||||
xmlFree(propValue);
|
||||
}
|
||||
}
|
||||
xmlXPathFreeObject(sub);
|
||||
|
|
|
@ -33,7 +33,7 @@ extern "C" {
|
|||
struct rule * rules;
|
||||
} archetype;
|
||||
|
||||
extern const struct archetype * find_archetype(const xmlChar * s, const struct locale * lang);
|
||||
extern const struct archetype * find_archetype(const char * s, const struct locale * lang);
|
||||
extern void init_archetypes(void);
|
||||
extern void register_archetype(struct archetype * arch);
|
||||
extern void register_archetypes(void);
|
||||
|
|
|
@ -69,7 +69,7 @@ createmonsters(void)
|
|||
* no 0 muss keine orders einreichen! */
|
||||
|
||||
f->email = strdup("monsters@eressea.de");
|
||||
f->name = (xmlChar*)strdup("Monster");
|
||||
f->name = strdup("Monster");
|
||||
f->alive = 1;
|
||||
f->options = (char)(1<<O_REPORT);
|
||||
addlist(&factions, f);
|
||||
|
|
|
@ -89,15 +89,15 @@ boolean opt_cr_absolute_coords = false;
|
|||
|
||||
#define TAG_LOCALE "de"
|
||||
#ifdef TAG_LOCALE
|
||||
static const xmlChar *
|
||||
static const char *
|
||||
crtag(const char * key)
|
||||
{
|
||||
static const struct locale * lang = NULL;
|
||||
if (!lang) lang = find_locale(TAG_LOCALE);
|
||||
return (const xmlChar*)locale_string(lang, key);
|
||||
return locale_string(lang, key);
|
||||
}
|
||||
#else
|
||||
#define crtag(x) (const xmlChar*)(x)
|
||||
#define crtag(x) (x)
|
||||
#endif
|
||||
/*
|
||||
* translation table
|
||||
|
@ -105,15 +105,15 @@ crtag(const char * key)
|
|||
typedef struct translation {
|
||||
struct translation * next;
|
||||
char * key;
|
||||
const xmlChar * value;
|
||||
const char * value;
|
||||
} translation;
|
||||
|
||||
#define TRANSMAXHASH 257
|
||||
static translation * translation_table[TRANSMAXHASH];
|
||||
static translation * junkyard;
|
||||
|
||||
static const xmlChar *
|
||||
add_translation(const char * key, const xmlChar * value)
|
||||
static const char *
|
||||
add_translation(const char * key, const char * value)
|
||||
{
|
||||
int kk = ((key[0] << 5) + key[0]) % TRANSMAXHASH;
|
||||
translation * t = translation_table[kk];
|
||||
|
@ -383,8 +383,8 @@ cr_order(variant var, char * buffer, const void * userdata)
|
|||
order * ord = (order*)var.v;
|
||||
if (ord!=NULL) {
|
||||
char * wp = buffer;
|
||||
xmlChar * cmd = getcommand(ord);
|
||||
const xmlChar * rp = cmd;
|
||||
char * cmd = getcommand(ord);
|
||||
const char * rp = cmd;
|
||||
|
||||
*wp++ = '\"';
|
||||
while (*rp) {
|
||||
|
@ -644,7 +644,7 @@ cr_output_unit(FILE * F, const region * r,
|
|||
{
|
||||
/* Race attributes are always plural and item attributes always
|
||||
* singular */
|
||||
const xmlChar * str;
|
||||
const char * str;
|
||||
const item_type * lasttype;
|
||||
int pr;
|
||||
item *itm, *show;
|
||||
|
@ -770,7 +770,7 @@ cr_output_unit(FILE * F, const region * r,
|
|||
/* additional information for own units */
|
||||
if (u->faction == f || omniscient(f)) {
|
||||
order * ord;
|
||||
const xmlChar *xc;
|
||||
const char *xc;
|
||||
const char * c;
|
||||
int i;
|
||||
|
||||
|
@ -864,14 +864,14 @@ cr_output_unit(FILE * F, const region * r,
|
|||
for (;slist; slist = slist->next) {
|
||||
spell * sp = slist->data;
|
||||
if (sp->level <= t) {
|
||||
const xmlChar * name = add_translation(mkname("spell", sp->sname), spell_name(sp, f->locale));
|
||||
const char * name = add_translation(mkname("spell", sp->sname), spell_name(sp, f->locale));
|
||||
fprintf(F, "\"%s\"\n", name);
|
||||
}
|
||||
}
|
||||
for (i=0;i!=MAXCOMBATSPELLS;++i) {
|
||||
const spell * sp = mage->combatspells[i].sp;
|
||||
if (sp) {
|
||||
const xmlChar * name = add_translation(mkname("spell", sp->sname), spell_name(sp, f->locale));
|
||||
const char * name = add_translation(mkname("spell", sp->sname), spell_name(sp, f->locale));
|
||||
fprintf(F, "KAMPFZAUBER %d\n", i);
|
||||
fprintf(F, "\"%s\";name\n", name);
|
||||
fprintf(F, "%d;level\n", mage->combatspells[i].level);
|
||||
|
@ -1016,7 +1016,7 @@ static void
|
|||
cr_reportspell(FILE * F, spell *sp, const struct locale * lang)
|
||||
{
|
||||
int k;
|
||||
const xmlChar * name = add_translation(mkname("spell", sp->sname), spell_name(sp, lang));
|
||||
const char * name = add_translation(mkname("spell", sp->sname), spell_name(sp, lang));
|
||||
|
||||
fprintf(F, "ZAUBER %d\n", hashstring(sp->sname));
|
||||
fprintf(F, "\"%s\";name\n", name);
|
||||
|
@ -1126,7 +1126,7 @@ cr_borders(seen_region ** seen, const region * r, const faction * f, int seemode
|
|||
|
||||
/* main function of the creport. creates the header and traverses all regions */
|
||||
static int
|
||||
report_computer(const char * filename, report_context * ctx)
|
||||
report_computer(const char * filename, report_context * ctx, const char * charset)
|
||||
{
|
||||
int i;
|
||||
faction * f = ctx->f;
|
||||
|
@ -1135,7 +1135,7 @@ report_computer(const char * filename, report_context * ctx)
|
|||
building *b;
|
||||
ship *sh;
|
||||
unit *u;
|
||||
const xmlChar * mailto = locale_string(f->locale, "mailto");
|
||||
const char * mailto = locale_string(f->locale, "mailto");
|
||||
const attrib * a;
|
||||
seen_region * sr = NULL;
|
||||
#ifdef SCORE_MODULE
|
||||
|
@ -1152,7 +1152,7 @@ report_computer(const char * filename, report_context * ctx)
|
|||
/* initialisations, header and lists */
|
||||
|
||||
fprintf(F, "VERSION %d\n", C_REPORT_VERSION);
|
||||
fputs("\"ISO-8859-1\";charset\n", F);
|
||||
fprintf(F, "\"%s\";charset\n", charset);
|
||||
fprintf(F, "\"%s\";locale\n", locale_name(f->locale));
|
||||
fprintf(F, "%d;noskillpoints\n", 1);
|
||||
fprintf(F, "%ld;date\n", ctx->report_time);
|
||||
|
@ -1260,7 +1260,7 @@ report_computer(const char * filename, report_context * ctx)
|
|||
const potion_type * ptype = resource2potion(((const item_type*)a->data.v)->rtype);
|
||||
requirement * m;
|
||||
const char * ch;
|
||||
const xmlChar * description = NULL;
|
||||
const char * description = NULL;
|
||||
|
||||
if (ptype==NULL) continue;
|
||||
m = ptype->itype->construction->materials;
|
||||
|
@ -1308,7 +1308,7 @@ report_computer(const char * filename, report_context * ctx)
|
|||
else fprintf(F, "REGION %d %d %d\n", region_x(r, f), region_y(r, f), r->planep->id);
|
||||
}
|
||||
if (r->land) {
|
||||
const xmlChar * str = rname(r, f->locale);
|
||||
const char * str = rname(r, f->locale);
|
||||
if (str && str[0]) {
|
||||
fprintf(F, "\"%s\";Name\n", str);
|
||||
}
|
||||
|
|
|
@ -447,7 +447,7 @@ recruit(unit * u, struct order * ord, request ** recruitorders)
|
|||
n = getuint();
|
||||
if (f->no==MONSTER_FACTION) {
|
||||
/* Monster dürfen REKRUTIERE 15 dracoid machen */
|
||||
const xmlChar * str = getstrtoken();
|
||||
const char * str = getstrtoken();
|
||||
rc = findrace(str, f->locale);
|
||||
if (rc==NULL) rc = f->race;
|
||||
}
|
||||
|
@ -565,7 +565,7 @@ give_cmd(unit * u, order * ord)
|
|||
{
|
||||
region * r = u->region;
|
||||
unit *u2;
|
||||
const xmlChar *s;
|
||||
const char *s;
|
||||
int i, n;
|
||||
const item_type * itype;
|
||||
param_t p;
|
||||
|
@ -716,7 +716,7 @@ give_cmd(unit * u, order * ord)
|
|||
}
|
||||
|
||||
else if (p==P_ANY) {
|
||||
const xmlChar * s = getstrtoken();
|
||||
const char * s = getstrtoken();
|
||||
|
||||
if (*s == 0) { /* Alle Gegenstände übergeben */
|
||||
|
||||
|
@ -852,7 +852,7 @@ static int
|
|||
forget_cmd(unit * u, order * ord)
|
||||
{
|
||||
skill_t sk;
|
||||
const xmlChar *s;
|
||||
const char *s;
|
||||
|
||||
init_tokens(ord);
|
||||
skip_token();
|
||||
|
@ -1056,7 +1056,7 @@ static int
|
|||
recruit_archetype(unit * u, order * ord)
|
||||
{
|
||||
int want;
|
||||
const xmlChar * s;
|
||||
const char * s;
|
||||
|
||||
init_tokens(ord);
|
||||
skip_token();
|
||||
|
@ -1728,7 +1728,7 @@ make_cmd(unit * u, struct order * ord)
|
|||
param_t p;
|
||||
int m;
|
||||
const item_type * itype;
|
||||
const xmlChar *s;
|
||||
const char *s;
|
||||
const struct locale * lang = u->faction->locale;
|
||||
char ibuf[16];
|
||||
|
||||
|
@ -1793,22 +1793,22 @@ make_cmd(unit * u, struct order * ord)
|
|||
/* if the item cannot be made, we probably didn't mean to make it */
|
||||
itype = NULL;
|
||||
} else if (stype!=NULL) {
|
||||
const xmlChar * sname = LOC(lang, stype->name[0]);
|
||||
const xmlChar * iname = LOC(lang, resourcename(itype->rtype, 0));
|
||||
if (xstrlen(iname)<xstrlen(sname)) stype = NULL;
|
||||
const char * sname = LOC(lang, stype->name[0]);
|
||||
const char * iname = LOC(lang, resourcename(itype->rtype, 0));
|
||||
if (strlen(iname)<strlen(sname)) stype = NULL;
|
||||
else itype = NULL;
|
||||
} else {
|
||||
const xmlChar * bname = LOC(lang, btype->_name);
|
||||
const xmlChar * iname = LOC(lang, resourcename(itype->rtype, 0));
|
||||
if (xstrlen(iname)<xstrlen(bname)) btype = NULL;
|
||||
const char * bname = LOC(lang, btype->_name);
|
||||
const char * iname = LOC(lang, resourcename(itype->rtype, 0));
|
||||
if (strlen(iname)<strlen(bname)) btype = NULL;
|
||||
else itype = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (btype!=NULL && stype!=NULL) {
|
||||
const xmlChar * bname = LOC(lang, btype->_name);
|
||||
const xmlChar * sname = LOC(lang, stype->name[0]);
|
||||
if (xstrlen(sname)<xstrlen(bname)) btype = NULL;
|
||||
const char * bname = LOC(lang, btype->_name);
|
||||
const char * sname = LOC(lang, stype->name[0]);
|
||||
if (strlen(sname)<strlen(bname)) btype = NULL;
|
||||
else stype = NULL;
|
||||
}
|
||||
|
||||
|
@ -2241,7 +2241,7 @@ sell(unit * u, request ** sellorders, struct order * ord)
|
|||
const luxury_type * ltype=NULL;
|
||||
int n;
|
||||
region * r = u->region;
|
||||
const xmlChar *s;
|
||||
const char *s;
|
||||
|
||||
if (u->ship && is_guarded(r, u, GUARD_CREWS)) {
|
||||
cmistake(u, ord, 69, MSG_INCOME);
|
||||
|
@ -2631,7 +2631,7 @@ static void
|
|||
breed_cmd(unit *u, struct order * ord)
|
||||
{
|
||||
int m;
|
||||
const xmlChar *s;
|
||||
const char *s;
|
||||
param_t p;
|
||||
region *r = u->region;
|
||||
const resource_type * rtype = NULL;
|
||||
|
|
|
@ -912,7 +912,7 @@ restart_cmd(unit * u, struct order * ord)
|
|||
if (!fval(u->region->terrain, LAND_REGION)) {
|
||||
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_onlandonly", ""));
|
||||
} else {
|
||||
const xmlChar * s_race = getstrtoken(), * s_pass;
|
||||
const char * s_race = getstrtoken(), * s_pass;
|
||||
const race * frace = findrace(s_race, u->faction->locale);
|
||||
|
||||
if (!frace) {
|
||||
|
@ -964,7 +964,7 @@ static int
|
|||
quit_cmd(unit * u, struct order * ord)
|
||||
{
|
||||
faction * f = u->faction;
|
||||
const xmlChar * passwd;
|
||||
const char * passwd;
|
||||
|
||||
init_tokens(ord);
|
||||
skip_token(); /* skip keyword */
|
||||
|
@ -1126,7 +1126,7 @@ ally_cmd(unit * u, struct order * ord)
|
|||
ally * sf, ** sfp;
|
||||
faction *f;
|
||||
int keyword, not_kw;
|
||||
const xmlChar *s;
|
||||
const char *s;
|
||||
|
||||
init_tokens(ord);
|
||||
skip_token();
|
||||
|
@ -1258,7 +1258,7 @@ init_prefixnames(void)
|
|||
int key;
|
||||
for (key=0;race_prefixes[key];++key) {
|
||||
variant var;
|
||||
const xmlChar * pname = locale_string(lang, race_prefixes[key]);
|
||||
const char * pname = locale_string(lang, race_prefixes[key]);
|
||||
if (findtoken(&in->names, pname, &var)==E_TOK_NOMATCH || var.i!=key) {
|
||||
var.i = key;
|
||||
addtoken(&in->names, pname, var);
|
||||
|
@ -1274,7 +1274,7 @@ static int
|
|||
prefix_cmd(unit * u, struct order * ord)
|
||||
{
|
||||
attrib **ap;
|
||||
const xmlChar *s;
|
||||
const char *s;
|
||||
local_names * in = pnames;
|
||||
variant var;
|
||||
const struct locale * lang = u->faction->locale;
|
||||
|
@ -1326,7 +1326,7 @@ static int
|
|||
display_cmd(unit * u, struct order * ord)
|
||||
{
|
||||
building * b = u->building;
|
||||
xmlChar **s = NULL;
|
||||
char **s = NULL;
|
||||
region * r = u->region;
|
||||
|
||||
init_tokens(ord);
|
||||
|
@ -1376,7 +1376,7 @@ display_cmd(unit * u, struct order * ord)
|
|||
|
||||
case P_PRIVAT:
|
||||
{
|
||||
const xmlChar *d = getstrtoken();
|
||||
const char *d = getstrtoken();
|
||||
if(d == NULL || *d == 0) {
|
||||
usetprivate(u, NULL);
|
||||
} else {
|
||||
|
@ -1407,11 +1407,11 @@ display_cmd(unit * u, struct order * ord)
|
|||
}
|
||||
|
||||
if (s!=NULL) {
|
||||
const xmlChar * s2 = getstrtoken();
|
||||
const char * s2 = getstrtoken();
|
||||
|
||||
free(*s);
|
||||
*s = xstrdup(s2);
|
||||
if (xstrlen(s2)>=DISPLAYSIZE) {
|
||||
*s = strdup(s2);
|
||||
if (strlen(s2)>=DISPLAYSIZE) {
|
||||
(*s)[DISPLAYSIZE] = 0;
|
||||
}
|
||||
}
|
||||
|
@ -1424,9 +1424,9 @@ renamed_building(const building * b)
|
|||
{
|
||||
const struct locale * lang = locales;
|
||||
for (;lang;lang=nextlocale(lang)) {
|
||||
const xmlChar * bdname = LOC(lang, b->type->_name);
|
||||
size_t bdlen = xstrlen(bdname);
|
||||
if (xstrlen(b->name)>=bdlen && xstrncmp(b->name, bdname, bdlen)==0) {
|
||||
const char * bdname = LOC(lang, b->type->_name);
|
||||
size_t bdlen = strlen(bdname);
|
||||
if (strlen(b->name)>=bdlen && strncmp(b->name, bdname, bdlen)==0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1438,7 +1438,7 @@ name_cmd(unit * u, struct order * ord)
|
|||
{
|
||||
building * b = u->building;
|
||||
region * r = u->region;
|
||||
xmlChar **s = NULL;
|
||||
char **s = NULL;
|
||||
param_t p;
|
||||
boolean foreign = false;
|
||||
|
||||
|
@ -1526,9 +1526,9 @@ name_cmd(unit * u, struct order * ord)
|
|||
} else {
|
||||
const struct locale * lang = locales;
|
||||
for (;lang;lang=nextlocale(lang)) {
|
||||
const xmlChar * fdname = LOC(lang, "factiondefault");
|
||||
size_t fdlen = xstrlen(fdname);
|
||||
if (xstrlen(f->name)>=fdlen && xstrncmp(f->name, fdname, fdlen)==0) {
|
||||
const char * fdname = LOC(lang, "factiondefault");
|
||||
size_t fdlen = strlen(fdname);
|
||||
if (strlen(f->name)>=fdlen && strncmp(f->name, fdname, fdlen)==0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1559,15 +1559,15 @@ name_cmd(unit * u, struct order * ord)
|
|||
} else {
|
||||
const struct locale * lang = locales;
|
||||
for (;lang;lang=nextlocale(lang)) {
|
||||
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) {
|
||||
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) {
|
||||
break;
|
||||
}
|
||||
|
||||
sdname = LOC(lang, parameters[P_SHIP]);
|
||||
sdlen = xstrlen(sdname);
|
||||
if (xstrlen(sh->name)>=sdlen && xstrncmp(sh->name, sdname, sdlen)==0) {
|
||||
sdlen = strlen(sdname);
|
||||
if (strlen(sh->name)>=sdlen && strncmp(sh->name, sdname, sdlen)==0) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1609,10 +1609,10 @@ name_cmd(unit * u, struct order * ord)
|
|||
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "feedback_unit_not_found", ""));
|
||||
break;
|
||||
} else {
|
||||
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) {
|
||||
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) {
|
||||
cmistake(u2, ord, 244, MSG_EVENT);
|
||||
break;
|
||||
}
|
||||
|
@ -1666,7 +1666,7 @@ name_cmd(unit * u, struct order * ord)
|
|||
}
|
||||
|
||||
if (s!=NULL) {
|
||||
const xmlChar * s2 = getstrtoken();
|
||||
const char * s2 = getstrtoken();
|
||||
|
||||
if (!s2[0]) {
|
||||
cmistake(u, ord, 84, MSG_EVENT);
|
||||
|
@ -1677,8 +1677,8 @@ name_cmd(unit * u, struct order * ord)
|
|||
* names, phishing-style? () come to mind. */
|
||||
|
||||
free(*s);
|
||||
*s = xstrdup(s2);
|
||||
if (xstrlen(s2)>=NAMESIZE) {
|
||||
*s = strdup(s2);
|
||||
if (strlen(s2)>=NAMESIZE) {
|
||||
(*s)[NAMESIZE] = 0;
|
||||
}
|
||||
}
|
||||
|
@ -1688,7 +1688,7 @@ name_cmd(unit * u, struct order * ord)
|
|||
/* ------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
deliverMail(faction * f, region * r, unit * u, const xmlChar *s, unit * receiver)
|
||||
deliverMail(faction * f, region * r, unit * u, const char *s, unit * receiver)
|
||||
{
|
||||
if (!cansee(f, r, u, 0)) {
|
||||
u = NULL;
|
||||
|
@ -1701,7 +1701,7 @@ deliverMail(faction * f, region * r, unit * u, const xmlChar *s, unit * receiver
|
|||
}
|
||||
|
||||
static void
|
||||
mailunit(region * r, unit * u, int n, struct order * ord, const xmlChar * s)
|
||||
mailunit(region * r, unit * u, int n, struct order * ord, const char * s)
|
||||
{
|
||||
unit * u2 = findunitr(r,n);
|
||||
|
||||
|
@ -1717,7 +1717,7 @@ mailunit(region * r, unit * u, int n, struct order * ord, const xmlChar * s)
|
|||
}
|
||||
|
||||
static void
|
||||
mailfaction(unit * u, int n, struct order * ord, const xmlChar * s)
|
||||
mailfaction(unit * u, int n, struct order * ord, const char * s)
|
||||
{
|
||||
faction *f;
|
||||
|
||||
|
@ -1733,7 +1733,7 @@ mail_cmd(unit * u, struct order * ord)
|
|||
{
|
||||
region * r = u->region;
|
||||
unit *u2;
|
||||
const xmlChar *s;
|
||||
const char *s;
|
||||
int n, cont;
|
||||
|
||||
init_tokens(ord);
|
||||
|
@ -1899,7 +1899,7 @@ banner_cmd(unit * u, struct order * ord)
|
|||
skip_token();
|
||||
|
||||
free(u->faction->banner);
|
||||
u->faction->banner = xstrdup(getstrtoken());
|
||||
u->faction->banner = strdup(getstrtoken());
|
||||
add_message(&u->faction->msgs, msg_message("changebanner", "value",
|
||||
u->faction->banner));
|
||||
|
||||
|
@ -1909,7 +1909,7 @@ banner_cmd(unit * u, struct order * ord)
|
|||
static int
|
||||
email_cmd(unit * u, struct order * ord)
|
||||
{
|
||||
const xmlChar * s;
|
||||
const char * s;
|
||||
|
||||
init_tokens(ord);
|
||||
skip_token();
|
||||
|
@ -1934,7 +1934,7 @@ password_cmd(unit * u, struct order * ord)
|
|||
{
|
||||
char pbuf[32];
|
||||
int i;
|
||||
const xmlChar * s;
|
||||
const char * s;
|
||||
boolean pwok = true;
|
||||
|
||||
init_tokens(ord);
|
||||
|
@ -1971,7 +1971,7 @@ password_cmd(unit * u, struct order * ord)
|
|||
static int
|
||||
send_cmd(unit * u, struct order * ord)
|
||||
{
|
||||
const xmlChar * s;
|
||||
const char * s;
|
||||
int option;
|
||||
|
||||
init_tokens(ord);
|
||||
|
@ -2025,7 +2025,7 @@ display_item(faction *f, unit *u, const item_type * itype)
|
|||
{
|
||||
const char *name;
|
||||
const char *key;
|
||||
const xmlChar *info;
|
||||
const char *info;
|
||||
|
||||
if (u!=NULL) {
|
||||
int i = i_get(u->items, itype);
|
||||
|
@ -2080,7 +2080,7 @@ static boolean
|
|||
display_race(faction *f, unit *u, const race * rc)
|
||||
{
|
||||
const char *name, *key;
|
||||
const xmlChar *info;
|
||||
const char *info;
|
||||
int a, at_count;
|
||||
char buf[2048];
|
||||
char buf2[128];
|
||||
|
@ -2101,7 +2101,7 @@ display_race(faction *f, unit *u, const race * rc)
|
|||
info = locale_string(f->locale, mkname("raceinfo", "no_info"));
|
||||
}
|
||||
|
||||
rsize = xstrlcpy(bufp, info, size);
|
||||
rsize = strlcpy(bufp, info, size);
|
||||
if (rsize>size) rsize = size-1;
|
||||
size -= rsize;
|
||||
bufp += rsize;
|
||||
|
@ -2216,13 +2216,13 @@ display_race(faction *f, unit *u, const race * rc)
|
|||
--size;
|
||||
}
|
||||
|
||||
addmessage(0, f, (const xmlChar *)buf, MSG_EVENT, ML_IMPORTANT);
|
||||
addmessage(0, f, buf, MSG_EVENT, ML_IMPORTANT);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void
|
||||
reshow(unit * u, struct order * ord, const xmlChar * s, param_t p)
|
||||
reshow(unit * u, struct order * ord, const char * s, param_t p)
|
||||
{
|
||||
int skill, c;
|
||||
const potion_type * ptype;
|
||||
|
@ -2311,7 +2311,7 @@ promotion_cmd(unit * u, struct order * ord)
|
|||
static int
|
||||
group_cmd(unit * u, struct order * ord)
|
||||
{
|
||||
const xmlChar * s;
|
||||
const char * s;
|
||||
|
||||
init_tokens(ord);
|
||||
skip_token();
|
||||
|
@ -2352,7 +2352,7 @@ guard_off_cmd(unit * u, struct order * ord)
|
|||
static int
|
||||
reshow_cmd(unit * u, struct order * ord)
|
||||
{
|
||||
const xmlChar * s;
|
||||
const char * s;
|
||||
param_t p = NOPARAM;
|
||||
|
||||
init_tokens(ord);
|
||||
|
@ -2371,7 +2371,7 @@ reshow_cmd(unit * u, struct order * ord)
|
|||
static int
|
||||
status_cmd(unit * u, struct order * ord)
|
||||
{
|
||||
const xmlChar * param;
|
||||
const char * param;
|
||||
|
||||
init_tokens(ord);
|
||||
skip_token();
|
||||
|
@ -2417,7 +2417,7 @@ status_cmd(unit * u, struct order * ord)
|
|||
static int
|
||||
combatspell_cmd(unit * u, struct order * ord)
|
||||
{
|
||||
const xmlChar * s;
|
||||
const char * s;
|
||||
int level = 0;
|
||||
spell * spell;
|
||||
|
||||
|
@ -2644,7 +2644,7 @@ reorder(void)
|
|||
struct order * ord;
|
||||
for (ord = u->orders;ord;ord=ord->next) {
|
||||
if (get_keyword(ord)==K_SORT) {
|
||||
const xmlChar * s;
|
||||
const char * s;
|
||||
param_t p;
|
||||
int id;
|
||||
unit *v;
|
||||
|
@ -2772,7 +2772,7 @@ declare_war(void)
|
|||
init_tokens(ord);
|
||||
skip_token();
|
||||
for (;;) {
|
||||
const xmlChar * s = getstrtoken();
|
||||
const char * s = getstrtoken();
|
||||
if (s[0]==0) break;
|
||||
else {
|
||||
faction * enemy = findfaction(atoi36(s));
|
||||
|
@ -2792,7 +2792,7 @@ declare_war(void)
|
|||
init_tokens(ord);
|
||||
skip_token();
|
||||
for (;;) {
|
||||
const xmlChar * s = getstrtoken();
|
||||
const char * s = getstrtoken();
|
||||
if (s[0]==0) break;
|
||||
else {
|
||||
faction * enemy = findfaction(atoi36(s));
|
||||
|
@ -2820,7 +2820,7 @@ declare_war(void)
|
|||
static int
|
||||
renumber_cmd(unit * u, order * ord)
|
||||
{
|
||||
const xmlChar * s;
|
||||
const char * s;
|
||||
int i;
|
||||
faction * f = u->faction;
|
||||
|
||||
|
@ -3154,8 +3154,8 @@ new_units (void)
|
|||
init_tokens(makeord);
|
||||
skip_token();
|
||||
if (getparam(u->faction->locale) == P_TEMP) {
|
||||
const xmlChar * token;
|
||||
xmlChar * name = NULL;
|
||||
const char * token;
|
||||
char * name = NULL;
|
||||
int alias;
|
||||
order ** newordersp;
|
||||
|
||||
|
@ -3184,7 +3184,7 @@ new_units (void)
|
|||
|
||||
token = getstrtoken();
|
||||
if (token && token[0]) {
|
||||
name = xstrdup(token);
|
||||
name = strdup(token);
|
||||
}
|
||||
u2 = create_unit(r, u->faction, 0, u->faction->race, alias, name, u);
|
||||
if (name!=NULL) free(name);
|
||||
|
@ -3471,7 +3471,7 @@ defaultorders (void)
|
|||
while (*ordp!=NULL) {
|
||||
order * ord = *ordp;
|
||||
if (get_keyword(ord)==K_DEFAULT) {
|
||||
const xmlChar * cmd;
|
||||
const char * cmd;
|
||||
order * new_order;
|
||||
init_tokens(ord);
|
||||
skip_token(); /* skip the keyword */
|
||||
|
@ -3539,7 +3539,7 @@ age_factions(void)
|
|||
static int
|
||||
use_cmd(unit * u, struct order * ord)
|
||||
{
|
||||
const xmlChar * t;
|
||||
const char * t;
|
||||
int n;
|
||||
const item_type * itype;
|
||||
|
||||
|
@ -3578,7 +3578,7 @@ use_cmd(unit * u, struct order * ord)
|
|||
static int
|
||||
claim_cmd(unit * u, struct order * ord)
|
||||
{
|
||||
const xmlChar * t;
|
||||
const char * t;
|
||||
int n;
|
||||
const item_type * itype;
|
||||
|
||||
|
|
|
@ -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 xmlChar *s, struct unit * receiver);
|
||||
extern void deliverMail(struct faction * f, struct region * r, struct unit * u, const char *s, struct unit * receiver);
|
||||
|
||||
/* eressea-specific. put somewhere else, please. */
|
||||
void processorders(void);
|
||||
|
|
|
@ -453,8 +453,8 @@ make_movement_order(unit * u, const region * target, int moves, boolean (*allowe
|
|||
region * r = u->region;
|
||||
region ** plan;
|
||||
int position = 0;
|
||||
xmlChar zOrder[128];
|
||||
char * c = (char*)zOrder;
|
||||
char zOrder[128];
|
||||
char * c = zOrder;
|
||||
|
||||
if (is_waiting(u)) return NULL;
|
||||
|
||||
|
|
|
@ -264,7 +264,7 @@ get_villagers(region * r, unit * u)
|
|||
{
|
||||
unit *newunit;
|
||||
message * msg = msg_message("encounter_villagers", "unit", u);
|
||||
const xmlChar * name = LOC(u->faction->locale, "villagers");
|
||||
const char * name = LOC(u->faction->locale, "villagers");
|
||||
|
||||
r_addmessage(r, u->faction, msg);
|
||||
msg_release(msg);
|
||||
|
@ -1021,7 +1021,7 @@ split_unit(region * r, unit *u)
|
|||
|
||||
if (u->display) {
|
||||
free(u2->display);
|
||||
u2->display = xstrdup(u->display);
|
||||
u2->display = strdup(u->display);
|
||||
}
|
||||
transfermen(u, u2, newsize);
|
||||
return u2;
|
||||
|
|
|
@ -720,7 +720,7 @@ see_border(const border * b, const faction * f, const region * r)
|
|||
return cs;
|
||||
}
|
||||
|
||||
const xmlChar *
|
||||
const char *
|
||||
trailinto(const region * r, const struct locale * lang)
|
||||
{
|
||||
char ref[32];
|
||||
|
|
|
@ -64,7 +64,7 @@
|
|||
void
|
||||
spy_message(int spy, const unit *u, const unit *target)
|
||||
{
|
||||
const xmlChar * str = report_kampfstatus(target, u->faction->locale);
|
||||
const char * str = report_kampfstatus(target, u->faction->locale);
|
||||
|
||||
ADDMSG(&u->faction->msgs, msg_message("spyreport", "spy target status", u, target, str));
|
||||
if (spy > 20) {
|
||||
|
@ -212,7 +212,7 @@ setwere_cmd(unit *u, struct order * ord)
|
|||
int
|
||||
setstealth_cmd(unit * u, struct order * ord)
|
||||
{
|
||||
const xmlChar *s;
|
||||
const char *s;
|
||||
int level;
|
||||
const race * trace;
|
||||
|
||||
|
@ -573,7 +573,7 @@ sink_ship(region * r, ship * sh, const char *name, char spy, unit * saboteur)
|
|||
int
|
||||
sabotage_cmd(unit * u, struct order * ord)
|
||||
{
|
||||
const xmlChar *s;
|
||||
const char *s;
|
||||
int i;
|
||||
ship *sh;
|
||||
unit *u2;
|
||||
|
|
|
@ -71,7 +71,7 @@ getmagicskill(const struct locale * lang)
|
|||
{
|
||||
struct tnode * tokens = get_translations(lang, UT_MAGIC);
|
||||
variant token;
|
||||
const xmlChar * s = getstrtoken();
|
||||
const char * s = getstrtoken();
|
||||
|
||||
if (findtoken(tokens, s, &token)==E_TOK_SUCCESS) {
|
||||
return (magic_t)token.i;
|
||||
|
@ -361,9 +361,9 @@ teach_cmd(unit * u, struct order * ord)
|
|||
/* Falls die Unit nicht gefunden wird, Fehler melden */
|
||||
|
||||
if (!u2) {
|
||||
xmlChar tbuf[20];
|
||||
const xmlChar * uid;
|
||||
const xmlChar * token;
|
||||
char tbuf[20];
|
||||
const char * uid;
|
||||
const char * token;
|
||||
/* Finde den string, der den Fehler verursacht hat */
|
||||
parser_pushstate();
|
||||
init_tokens(ord);
|
||||
|
@ -381,7 +381,7 @@ teach_cmd(unit * u, struct order * ord)
|
|||
uid = token;
|
||||
} else {
|
||||
token = getstrtoken();
|
||||
sprintf((char*)tbuf, "%s %s", LOC(u->faction->locale,
|
||||
sprintf(tbuf, "%s %s", LOC(u->faction->locale,
|
||||
parameters[P_TEMP]), token);
|
||||
uid = tbuf;
|
||||
}
|
||||
|
|
|
@ -81,25 +81,25 @@
|
|||
|
||||
#define L10N(x) x
|
||||
|
||||
static xmlChar*
|
||||
static const xmlChar *
|
||||
xml_s(const char * str)
|
||||
{
|
||||
static xmlChar buffer[1024];
|
||||
const char * inbuf = str;
|
||||
xmlChar * outbuf = buffer;
|
||||
unsigned char * outbuf = buffer;
|
||||
int inbytes = (int)strlen(str)+1;
|
||||
int outbytes = (int)sizeof(buffer);
|
||||
|
||||
isolat1ToUTF8(outbuf, &outbytes, BAD_CAST inbuf, &inbytes);
|
||||
isolat1ToUTF8(outbuf, &outbytes, (const xmlChar *)inbuf, &inbytes);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
static xmlChar*
|
||||
static const xmlChar *
|
||||
xml_i(double number)
|
||||
{
|
||||
static char buffer[128];
|
||||
sprintf(buffer, "%.0lf", number);
|
||||
return (xmlChar*)buffer;
|
||||
return (const xmlChar *)buffer;
|
||||
}
|
||||
|
||||
static xmlNodePtr
|
||||
|
@ -107,9 +107,9 @@ report_faction(report_context * ctx, faction * f)
|
|||
{
|
||||
xmlNodePtr node = xmlNewNode(NULL, BAD_CAST "faction");
|
||||
xmlNewProp(node, BAD_CAST "id", xml_i(f->no));
|
||||
xmlNewProp(node, BAD_CAST "name", f->name);
|
||||
xmlNewProp(node, BAD_CAST "name", (const xmlChar *)f->name);
|
||||
xmlNewProp(node, BAD_CAST "email", xml_s(f->email));
|
||||
if (f->banner && *f->banner) xmlNewProp(node, BAD_CAST "banner", f->banner);
|
||||
if (f->banner && *f->banner) xmlNewProp(node, BAD_CAST "banner", (const xmlChar *)f->banner);
|
||||
if (f==ctx->f) {
|
||||
const char * s;
|
||||
xmlNewProp(node, BAD_CAST "locale", BAD_CAST locale_name(f->locale));
|
||||
|
@ -138,14 +138,14 @@ report_region(report_context * ctx, seen_region * sr)
|
|||
xmlNewProp(node, BAD_CAST "plane", xml_s(r->planep->name));
|
||||
}
|
||||
if (r->land!=NULL) {
|
||||
xmlNewProp(node, BAD_CAST "name", r->land->name);
|
||||
xmlNewProp(node, BAD_CAST "name", (const xmlChar *)r->land->name);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
/* main function of the xmlreport. creates the header and traverses all regions */
|
||||
static int
|
||||
report_xml(const char * filename, report_context * ctx)
|
||||
report_xml(const char * filename, report_context * ctx, const char * encoding)
|
||||
{
|
||||
xmlDocPtr doc = xmlNewDoc(BAD_CAST "1.0");
|
||||
xmlNodePtr xmlReport = xmlNewNode(NULL, BAD_CAST "report");
|
||||
|
|
|
@ -153,7 +153,7 @@ fleeregion(const unit * u)
|
|||
}
|
||||
#endif /* SIMPLE_ESCAPE */
|
||||
|
||||
static xmlChar *
|
||||
static char *
|
||||
sidename(side * s)
|
||||
{
|
||||
#define SIDENAMEBUFLEN 256
|
||||
|
@ -166,7 +166,7 @@ sidename(side * s)
|
|||
snprintf(sidename_buf, SIDENAMEBUFLEN,
|
||||
"%s", factionname(s->bf->faction));
|
||||
}
|
||||
return (xmlChar *)sidename_buf;
|
||||
return sidename_buf;
|
||||
}
|
||||
|
||||
static const char *
|
||||
|
@ -2771,7 +2771,7 @@ print_header(battle * b)
|
|||
for (bf=b->factions;bf;bf=bf->next) {
|
||||
message * m;
|
||||
faction * f = bf->faction;
|
||||
const xmlChar * lastf = NULL;
|
||||
const char * lastf = NULL;
|
||||
boolean first = false;
|
||||
side * s;
|
||||
size_t size;
|
||||
|
@ -2821,12 +2821,12 @@ print_stats(battle * b)
|
|||
|
||||
for (bf=b->factions;bf;bf=bf->next) {
|
||||
faction * f = bf->faction;
|
||||
const xmlChar * loc_army = LOC(f->locale, "battle_army");
|
||||
const char * loc_army = LOC(f->locale, "battle_army");
|
||||
char * bufp;
|
||||
const xmlChar * header;
|
||||
const char * header;
|
||||
size_t rsize, size;
|
||||
int komma;
|
||||
const xmlChar * sname = seematrix(f, s) ? sidename(s) : LOC(f->locale, "unknown_faction");
|
||||
const char * sname = seematrix(f, s) ? sidename(s) : LOC(f->locale, "unknown_faction");
|
||||
message * msg;
|
||||
char buf[1024];
|
||||
|
||||
|
@ -3274,7 +3274,7 @@ simplename(region * r)
|
|||
{
|
||||
int i;
|
||||
static char name[17];
|
||||
const xmlChar * cp = rname(r, NULL);
|
||||
const char * cp = rname(r, NULL);
|
||||
for (i=0;*cp && i!=16;++i, ++cp) {
|
||||
int c = *cp;
|
||||
while (c && !isalpha(c) && !isspace(c)) {
|
||||
|
@ -3463,7 +3463,7 @@ battle_report(battle * b)
|
|||
int r, k = 0, * alive = get_alive(s);
|
||||
int l = FIGHT_ROW;
|
||||
const char * abbrev = seematrix(fac, s)?sideabkz(s, false):"-?-";
|
||||
const xmlChar * loc_army = LOC(fac->locale, "battle_army");
|
||||
const char * loc_army = LOC(fac->locale, "battle_army");
|
||||
char buffer[32];
|
||||
|
||||
if (komma) {
|
||||
|
|
|
@ -347,7 +347,7 @@ destroy_cmd(unit * u, struct order * ord)
|
|||
region * r = u->region;
|
||||
const construction * con = NULL;
|
||||
int size = 0;
|
||||
const xmlChar *s;
|
||||
const char *s;
|
||||
int n = INT_MAX;
|
||||
|
||||
if (u->number < 1)
|
||||
|
@ -816,7 +816,7 @@ build_building(unit * u, const building_type * btype, int want, order * ord)
|
|||
int n = want, built = 0, id;
|
||||
building * b = NULL;
|
||||
/* einmalige Korrektur */
|
||||
const xmlChar * btname;
|
||||
const char * btname;
|
||||
order * new_order = NULL;
|
||||
const struct locale * lang = u->faction->locale;
|
||||
|
||||
|
|
|
@ -72,12 +72,7 @@ lc_write(const struct attrib * a, FILE* F)
|
|||
building * b = data->b;
|
||||
|
||||
write_building_reference(b, F);
|
||||
fwritestr(F, fname);
|
||||
#if RELEASE_VERSION>=BACTION_VERSION
|
||||
fputc(' ', F);
|
||||
fwritestr(F, fparam?fparam:NULLSTRING);
|
||||
#endif
|
||||
fputc(' ', F);
|
||||
fprintf(F, "%s %s ", fname, fparam?fparam:NULLSTRING);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -87,10 +82,10 @@ lc_read(struct attrib * a, FILE* F)
|
|||
building_action * data = (building_action*)a->data.v;
|
||||
|
||||
read_building_reference(&data->b, F);
|
||||
freadstr(F, lbuf, sizeof(lbuf));
|
||||
fscanf(F, "%s", lbuf);
|
||||
data->fname = strdup(lbuf);
|
||||
if (global.data_version>=BACTION_VERSION) {
|
||||
freadstr(F, lbuf, sizeof(lbuf));
|
||||
fscanf(F, "%s", lbuf);
|
||||
if (strcmp(lbuf, NULLSTRING)==0) data->param = NULL;
|
||||
else data->param = strdup(lbuf);
|
||||
} else {
|
||||
|
@ -340,7 +335,7 @@ wdw_pyramid_level(const struct building *b)
|
|||
static local_names * bnames;
|
||||
|
||||
const building_type *
|
||||
findbuildingtype(const xmlChar * name, const struct locale * lang)
|
||||
findbuildingtype(const char * name, const struct locale * lang)
|
||||
{
|
||||
variant type;
|
||||
local_names * bn = bnames;
|
||||
|
@ -355,7 +350,7 @@ findbuildingtype(const xmlChar * name, const struct locale * lang)
|
|||
bn->next = bnames;
|
||||
bn->lang = lang;
|
||||
while (btl) {
|
||||
const xmlChar * n = locale_string(lang, btl->type->_name);
|
||||
const char * n = locale_string(lang, btl->type->_name);
|
||||
type.v = (void*)btl->type;
|
||||
addtoken(&bn->names, n, type);
|
||||
btl=btl->next;
|
||||
|
@ -440,14 +435,14 @@ new_building(const struct building_type * btype, region * r, const struct locale
|
|||
addlist(&r->buildings, b);
|
||||
|
||||
{
|
||||
const xmlChar * bname;
|
||||
const char * bname;
|
||||
if (b->type->name==NULL) {
|
||||
bname = LOC(lang, btype->_name);
|
||||
} else {
|
||||
/* TODO: optimization potential: make b->name NULL and use this as default */
|
||||
bname = LOC(lang, buildingtype(btype, b, 0));
|
||||
}
|
||||
b->name = xstrdup(bname);
|
||||
b->name = strdup(bname);
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
@ -521,22 +516,22 @@ buildingeffsize(const building * b, boolean img)
|
|||
return n;
|
||||
}
|
||||
|
||||
const xmlChar *
|
||||
write_buildingname(const building * b, xmlChar * ibuf, size_t size)
|
||||
const char *
|
||||
write_buildingname(const building * b, char * ibuf, size_t size)
|
||||
{
|
||||
snprintf((char*)ibuf, size, "%s (%s)", b->name, itoa36(b->no));
|
||||
ibuf[size-1] = 0;
|
||||
return ibuf;
|
||||
}
|
||||
|
||||
const xmlChar *
|
||||
const char *
|
||||
buildingname(const building * b)
|
||||
{
|
||||
typedef char name[OBJECTIDSIZE + 1];
|
||||
static name idbuf[8];
|
||||
static int nextbuf = 0;
|
||||
char *ibuf = idbuf[(++nextbuf) % 8];
|
||||
return write_buildingname(b, (xmlChar*)ibuf, sizeof(name));
|
||||
return write_buildingname(b, ibuf, sizeof(name));
|
||||
}
|
||||
|
||||
unit *
|
||||
|
|
|
@ -89,8 +89,8 @@ typedef struct building {
|
|||
|
||||
const struct building_type * type;
|
||||
struct region *region;
|
||||
xmlChar *name;
|
||||
xmlChar *display;
|
||||
char *name;
|
||||
char *display;
|
||||
struct attrib * attribs;
|
||||
int no;
|
||||
int size;
|
||||
|
@ -109,8 +109,8 @@ extern void add_buildinglist(building_list **bl, struct building *b);
|
|||
|
||||
extern struct attrib_type at_building_generic_type;
|
||||
extern const char * buildingtype(const building_type * btype, const struct building * b, int bsize);
|
||||
extern const xmlChar * buildingname(const struct building * b);
|
||||
extern const xmlChar * write_buildingname(const building * b, xmlChar * ibuf, size_t size);
|
||||
extern const char * buildingname(const struct building * b);
|
||||
extern const char * write_buildingname(const building * b, char * ibuf, size_t size);
|
||||
extern int buildingcapacity(const struct building * b);
|
||||
extern struct building *new_building(const struct building_type * typ, struct region * r, const struct locale * lang);
|
||||
void build_building(struct unit * u, const struct building_type * typ, int size, struct order * ord);
|
||||
|
@ -124,7 +124,7 @@ void bunhash(struct building * b);
|
|||
int buildingcapacity(const struct building * b);
|
||||
void destroy_building(struct building * b);
|
||||
|
||||
const struct building_type * findbuildingtype(const xmlChar * name, const struct locale * lang);
|
||||
const struct building_type * findbuildingtype(const char * name, const struct locale * lang);
|
||||
|
||||
#include "build.h"
|
||||
#define NOBUILDING NULL
|
||||
|
|
|
@ -59,7 +59,7 @@ stree_create(void)
|
|||
|
||||
void
|
||||
add_command(struct tnode * keys, struct tnode * tnext,
|
||||
const xmlChar * str, parser fun)
|
||||
const char * str, parser fun)
|
||||
{
|
||||
command * cmd = (command *)malloc(sizeof(command));
|
||||
variant var;
|
||||
|
@ -73,7 +73,7 @@ add_command(struct tnode * keys, struct tnode * tnext,
|
|||
static int
|
||||
do_command_i(const struct tnode * keys, void * u, struct order * ord)
|
||||
{
|
||||
const xmlChar * c;
|
||||
const char * c;
|
||||
variant var;
|
||||
|
||||
c = getstrtoken();
|
||||
|
@ -96,7 +96,7 @@ do_command(const struct tnode * keys, void * u, struct order * ord)
|
|||
init_tokens(ord);
|
||||
skip_token();
|
||||
if (do_command_i(keys, u, ord)!=E_TOK_SUCCESS) {
|
||||
xmlChar * cmd = getcommand(ord);
|
||||
char * cmd = getcommand(ord);
|
||||
log_warning(("%s failed GM command '%s'\n", unitname(u), cmd));
|
||||
free(cmd);
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ typedef struct syntaxtree {
|
|||
} syntaxtree;
|
||||
|
||||
typedef void (*parser)(const struct tnode *, void *, struct order*);
|
||||
extern void add_command(struct tnode * troot, struct tnode * tnext, const xmlChar * str, parser fun);
|
||||
extern void add_command(struct tnode * troot, struct tnode * tnext, const char * str, parser fun);
|
||||
extern void do_command(const struct tnode * troot, void * u, struct order *);
|
||||
|
||||
extern struct syntaxtree * stree_create(void);
|
||||
|
|
|
@ -1278,7 +1278,7 @@ count_maxmigrants(const faction * f)
|
|||
void
|
||||
init_tokens(const struct order * ord)
|
||||
{
|
||||
xmlChar * cmd = getcommand(ord);
|
||||
char * cmd = getcommand(ord);
|
||||
init_tokens_str(cmd, cmd);
|
||||
}
|
||||
|
||||
|
@ -1307,8 +1307,8 @@ parse(keyword_t kword, int (*dofun)(unit *, struct order *), boolean thisorder)
|
|||
}
|
||||
}
|
||||
|
||||
const xmlChar *
|
||||
igetstrtoken(const xmlChar * initstr)
|
||||
const char *
|
||||
igetstrtoken(const char * initstr)
|
||||
{
|
||||
if (initstr!=NULL) {
|
||||
init_tokens_str(initstr, NULL);
|
||||
|
@ -1330,7 +1330,7 @@ getint (void)
|
|||
}
|
||||
|
||||
const struct race *
|
||||
findrace(const xmlChar * s, const struct locale * lang)
|
||||
findrace(const char * s, const struct locale * lang)
|
||||
{
|
||||
struct tnode * tokens = get_translations(lang, UT_RACES);
|
||||
variant token;
|
||||
|
@ -1342,7 +1342,7 @@ findrace(const xmlChar * s, const struct locale * lang)
|
|||
}
|
||||
|
||||
int
|
||||
findoption(const xmlChar *s, const struct locale * lang)
|
||||
findoption(const char *s, const struct locale * lang)
|
||||
{
|
||||
struct tnode * tokens = get_translations(lang, UT_OPTIONS);
|
||||
variant token;
|
||||
|
@ -1354,7 +1354,7 @@ findoption(const xmlChar *s, const struct locale * lang)
|
|||
}
|
||||
|
||||
skill_t
|
||||
findskill(const xmlChar *s, const struct locale * lang)
|
||||
findskill(const char *s, const struct locale * lang)
|
||||
{
|
||||
struct tnode * tokens = get_translations(lang, UT_SKILLS);
|
||||
variant token;
|
||||
|
@ -1364,7 +1364,7 @@ findskill(const xmlChar *s, const struct locale * lang)
|
|||
}
|
||||
|
||||
keyword_t
|
||||
findkeyword(const xmlChar *s, const struct locale * lang)
|
||||
findkeyword(const char *s, const struct locale * lang)
|
||||
{
|
||||
struct tnode * tokens = get_translations(lang, UT_KEYWORDS);
|
||||
variant token;
|
||||
|
@ -1376,7 +1376,7 @@ findkeyword(const xmlChar *s, const struct locale * lang)
|
|||
}
|
||||
|
||||
param_t
|
||||
findparam(const xmlChar *s, const struct locale * lang)
|
||||
findparam(const char *s, const struct locale * lang)
|
||||
{
|
||||
struct tnode * tokens = get_translations(lang, UT_PARAMS);
|
||||
variant token;
|
||||
|
@ -1468,7 +1468,7 @@ read_newunitid (const faction * f, const region * r)
|
|||
int
|
||||
read_unitid (const faction * f, const region * r)
|
||||
{
|
||||
const xmlChar * s = getstrtoken();
|
||||
const char * s = getstrtoken();
|
||||
|
||||
/* Da s nun nur einen string enthaelt, suchen wir ihn direkt in der
|
||||
* paramliste. machen wir das nicht, dann wird getnewunit in s nach der
|
||||
|
@ -1625,19 +1625,19 @@ largestbuilding (const region * r, boolean img)
|
|||
return best;
|
||||
}
|
||||
|
||||
xmlChar *
|
||||
write_unitname(const unit * u, xmlChar * buffer, size_t size)
|
||||
char *
|
||||
write_unitname(const unit * u, char * buffer, size_t size)
|
||||
{
|
||||
snprintf((char*)buffer, size, "%s (%s)", (const char*)u->name, itoa36(u->no));
|
||||
buffer[size-1] = 0;
|
||||
return buffer;
|
||||
}
|
||||
|
||||
const xmlChar *
|
||||
const char *
|
||||
unitname(const unit * u)
|
||||
{
|
||||
char *ubuf = idbuf[(++nextbuf) % 8];
|
||||
return write_unitname(u, (xmlChar*)ubuf, sizeof(name));
|
||||
return write_unitname(u, ubuf, sizeof(name));
|
||||
}
|
||||
|
||||
/* -- Erschaffung neuer Einheiten ------------------------------ */
|
||||
|
@ -1992,7 +1992,7 @@ init_directions(tnode * root, const struct locale * lang)
|
|||
}
|
||||
|
||||
direction_t
|
||||
finddirection(const xmlChar *s, const struct locale * lang)
|
||||
finddirection(const char *s, const struct locale * lang)
|
||||
{
|
||||
struct tnode * tokens = get_translations(lang, UT_DIRECTIONS);
|
||||
variant token;
|
||||
|
@ -2037,7 +2037,7 @@ init_locale(const struct locale * lang)
|
|||
tokens = get_translations(lang, UT_SKILLS);
|
||||
for (i=0;i!=MAXSKILLS;++i) {
|
||||
if (i!=SK_TRADE || !TradeDisabled()) {
|
||||
const xmlChar * skname = skillname((skill_t)i, lang);
|
||||
const char * skname = skillname((skill_t)i, lang);
|
||||
if (skname!=NULL) {
|
||||
var.i = i;
|
||||
addtoken(tokens, skname, var);
|
||||
|
@ -2614,7 +2614,7 @@ maintenance_cost(const struct unit * u)
|
|||
}
|
||||
|
||||
message *
|
||||
movement_error(unit * u, const xmlChar * token, order * ord, int error_code)
|
||||
movement_error(unit * u, const char * token, order * ord, int error_code)
|
||||
{
|
||||
direction_t d;
|
||||
switch (error_code) {
|
||||
|
@ -2628,7 +2628,7 @@ movement_error(unit * u, const xmlChar * token, order * ord, int error_code)
|
|||
}
|
||||
|
||||
int
|
||||
movewhere(const unit *u, const xmlChar * token, region * r, region** resultp)
|
||||
movewhere(const unit *u, const char * token, region * r, region** resultp)
|
||||
{
|
||||
region * r2;
|
||||
direction_t d;
|
||||
|
|
|
@ -176,9 +176,9 @@ extern int count_skill(struct faction * f, skill_t sk);
|
|||
|
||||
/* direction, geography */
|
||||
extern const char *directions[];
|
||||
extern direction_t finddirection(const xmlChar *s, const struct locale *);
|
||||
extern direction_t finddirection(const char *s, const struct locale *);
|
||||
|
||||
extern int findoption(const xmlChar *s, const struct locale * lang);
|
||||
extern int findoption(const char *s, const struct locale * lang);
|
||||
|
||||
/* special units */
|
||||
void make_undead_unit(struct unit *);
|
||||
|
@ -194,14 +194,14 @@ unsigned int atoip(const char *s);
|
|||
unsigned int getuint(void);
|
||||
int getint(void);
|
||||
|
||||
extern const xmlChar *igetstrtoken(const xmlChar *s);
|
||||
extern const char *igetstrtoken(const char *s);
|
||||
|
||||
extern void init_tokens(const struct order * ord); /* initialize token parsing */
|
||||
extern skill_t findskill(const xmlChar *s, const struct locale * lang);
|
||||
extern skill_t findskill(const char *s, const struct locale * lang);
|
||||
|
||||
extern keyword_t findkeyword(const xmlChar *s, const struct locale * lang);
|
||||
extern keyword_t findkeyword(const char *s, const struct locale * lang);
|
||||
|
||||
extern param_t findparam(const xmlChar *s, const struct locale * lang);
|
||||
extern param_t findparam(const char *s, const struct locale * lang);
|
||||
extern param_t getparam(const struct locale * lang);
|
||||
|
||||
extern int atoi36(const char * s);
|
||||
|
@ -259,8 +259,8 @@ extern char *estring(const char *s);
|
|||
extern char *estring_i(char *s);
|
||||
extern char *cstring(const char *s);
|
||||
extern char *cstring_i(char *s);
|
||||
extern const xmlChar *unitname(const struct unit * u);
|
||||
extern xmlChar * write_unitname(const struct unit * u, xmlChar * buffer, size_t size);
|
||||
extern const char *unitname(const struct unit * u);
|
||||
extern char * write_unitname(const struct unit * u, char * buffer, size_t size);
|
||||
|
||||
struct building *largestbuilding(const struct region * r, boolean img);
|
||||
|
||||
|
@ -269,7 +269,7 @@ extern int count_migrants (const struct faction * f);
|
|||
extern int count_maxmigrants(const struct faction * f);
|
||||
|
||||
extern boolean teure_talente(const struct unit * u);
|
||||
extern const struct race * findrace(const xmlChar *, const struct locale *);
|
||||
extern const struct race * findrace(const char *, const struct locale *);
|
||||
|
||||
int eff_stealth(const struct unit * u, const struct region * r);
|
||||
void scale_number(struct unit * u, int n);
|
||||
|
@ -309,7 +309,7 @@ boolean unit_has_cursed_item(struct unit *u);
|
|||
|
||||
/* simple garbage collection: */
|
||||
void * gc_add(void * p);
|
||||
void addmessage(struct region * r, struct faction * f, const xmlChar *s, msg_t mtype, int level);
|
||||
void addmessage(struct region * r, struct faction * f, const char *s, msg_t mtype, int level);
|
||||
|
||||
/* grammatik-flags: */
|
||||
#define GF_NONE 0
|
||||
|
@ -360,7 +360,7 @@ extern int maxworkingpeasants(const struct region * r);
|
|||
|
||||
extern int wage(const struct region *r, const struct faction *f, const struct race * rc);
|
||||
extern int maintenance_cost(const struct unit * u);
|
||||
extern struct message * movement_error(struct unit * u, const xmlChar * token, struct order * ord, int error_code);
|
||||
extern struct message * movement_error(struct unit * u, const char * token, struct order * ord, int error_code);
|
||||
extern boolean move_blocked(const struct unit * u, const struct region *src, const struct region *dest);
|
||||
extern void add_income(struct unit * u, int type, int want, int qty);
|
||||
|
||||
|
@ -370,7 +370,7 @@ enum {
|
|||
E_MOVE_NOREGION, /* no region exists in this direction */
|
||||
E_MOVE_BLOCKED /* cannot see this region, there is a blocking border. */
|
||||
};
|
||||
extern int movewhere(const struct unit *u, const xmlChar * token, struct region * r, struct region** resultp);
|
||||
extern int movewhere(const struct unit *u, const char * token, struct region * r, struct region** resultp);
|
||||
|
||||
extern const char * basepath(void);
|
||||
extern const char * resourcepath(void);
|
||||
|
@ -430,7 +430,7 @@ extern int AllianceRestricted(void); /* flags restricted to allied factions */
|
|||
extern struct order * default_order(const struct locale * lang);
|
||||
extern int entertainmoney(const struct region * r);
|
||||
|
||||
extern int freadstr(FILE * F, char * str, size_t size);
|
||||
extern int freadstr(FILE * F, int encoding, char * str, size_t size);
|
||||
extern int fwritestr(FILE * F, const char * str);
|
||||
|
||||
extern void plagues(struct region * r, boolean ismagic);
|
||||
|
|
|
@ -138,7 +138,7 @@ addfaction(const char *email, const char * password,
|
|||
fhash(f);
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s %s", LOC(loc, "factiondefault"), factionid(f));
|
||||
f->name = xstrdup(buf);
|
||||
f->name = strdup(buf);
|
||||
|
||||
return f;
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ checkpasswd(const faction * f, const char * passwd, boolean shortp)
|
|||
#ifdef SHORTPWDS
|
||||
shortpwd * slist = f->shortpwds;
|
||||
if (shortp) while (slist) {
|
||||
if (xstrcmp(slist->pwd, passwd)==0) {
|
||||
if (strcmp(slist->pwd, passwd)==0) {
|
||||
slist->used = true;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -64,8 +64,8 @@ typedef struct faction {
|
|||
int no;
|
||||
int subscription;
|
||||
unsigned int flags;
|
||||
xmlChar *name;
|
||||
xmlChar *banner;
|
||||
char *name;
|
||||
char *banner;
|
||||
char *email;
|
||||
char *passw;
|
||||
char *override;
|
||||
|
|
|
@ -41,7 +41,7 @@ static group * ghash[GMAXHASH];
|
|||
static int maxgid;
|
||||
|
||||
static group *
|
||||
new_group(faction * f, const xmlChar * name, int gid)
|
||||
new_group(faction * f, const char * name, int gid)
|
||||
{
|
||||
group ** gp = &f->groups;
|
||||
int index = gid % GMAXHASH;
|
||||
|
@ -51,7 +51,7 @@ new_group(faction * f, const xmlChar * name, int gid)
|
|||
*gp = g;
|
||||
|
||||
maxgid = max(gid, maxgid);
|
||||
g->name = xstrdup(name);
|
||||
g->name = strdup(name);
|
||||
g->gid = gid;
|
||||
|
||||
g->nexthash = ghash[index];
|
||||
|
@ -73,7 +73,7 @@ init_group(faction * f, group * g)
|
|||
}
|
||||
|
||||
static group *
|
||||
find_groupbyname(group * g, const xmlChar * name)
|
||||
find_groupbyname(group * g, const char * name)
|
||||
{
|
||||
while (g && unicode_utf8_strcasecmp(name, g->name)!=0) g = g->next;
|
||||
return g;
|
||||
|
@ -133,7 +133,7 @@ free_group(group * g)
|
|||
}
|
||||
|
||||
boolean
|
||||
join_group(unit * u, const xmlChar * name)
|
||||
join_group(unit * u, const char * name)
|
||||
{
|
||||
attrib * a = NULL;
|
||||
group * g;
|
||||
|
@ -142,7 +142,7 @@ join_group(unit * u, const xmlChar * name)
|
|||
}
|
||||
|
||||
if (a) ((group *)(a->data.v))->members--;
|
||||
if (!name || !xstrlen(name)) {
|
||||
if (!name || !strlen(name)) {
|
||||
if (a) {
|
||||
a_remove(&u->attribs, a);
|
||||
freset(u, UFL_GROUP);
|
||||
|
@ -191,7 +191,7 @@ read_groups(FILE * F, faction * f)
|
|||
fscanf(F, "%d ", &gid);
|
||||
if (!gid) break;
|
||||
rsf(F, buf, sizeof(buf));
|
||||
g = new_group(f, (const xmlChar *)buf, gid);
|
||||
g = new_group(f, buf, gid);
|
||||
pa = &g->allies;
|
||||
for (;;) {
|
||||
ally * a;
|
||||
|
|
|
@ -25,7 +25,7 @@ typedef struct group {
|
|||
struct group * nexthash;
|
||||
struct faction * f;
|
||||
struct attrib *attribs;
|
||||
xmlChar * name;
|
||||
char * 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 xmlChar* name);
|
||||
extern boolean join_group(struct unit * u, const char * name);
|
||||
extern void free_group(struct group * g);
|
||||
|
||||
extern void write_groups(FILE * F, struct group * g);
|
||||
|
|
|
@ -970,7 +970,7 @@ change_money(unit * u, int v)
|
|||
static local_names * rnames;
|
||||
|
||||
const resource_type *
|
||||
findresourcetype(const xmlChar * name, const struct locale * lang)
|
||||
findresourcetype(const char * name, const struct locale * lang)
|
||||
{
|
||||
local_names * rn = rnames;
|
||||
variant token;
|
||||
|
@ -1029,7 +1029,7 @@ init_itemnames(void)
|
|||
const item_type * itl;
|
||||
for (itl=itemtypes[key];itl;itl=itl->next) {
|
||||
variant var;
|
||||
const xmlChar * iname = locale_string(lang, itl->rtype->_name[0]);
|
||||
const char * iname = locale_string(lang, itl->rtype->_name[0]);
|
||||
if (findtoken(&in->names, iname, &var)==E_TOK_NOMATCH || var.v!=itl) {
|
||||
var.v = (void*)itl;
|
||||
addtoken(&in->names, iname, var);
|
||||
|
@ -1043,7 +1043,7 @@ init_itemnames(void)
|
|||
}
|
||||
|
||||
const item_type *
|
||||
finditemtype(const xmlChar * name, const struct locale * lang)
|
||||
finditemtype(const char * name, const struct locale * lang)
|
||||
{
|
||||
local_names * in = inames;
|
||||
variant var;
|
||||
|
|
|
@ -73,7 +73,7 @@ typedef struct resource_type {
|
|||
} resource_type;
|
||||
extern resource_type * resourcetypes;
|
||||
extern const char* resourcename(const resource_type * rtype, int flags);
|
||||
extern const resource_type * findresourcetype(const xmlChar * name, const struct locale * lang);
|
||||
extern const resource_type * findresourcetype(const char * name, const struct locale * lang);
|
||||
|
||||
/* resource-limits for regions */
|
||||
#define RMF_SKILL 0x01 /* int, bonus on resource production skill */
|
||||
|
@ -135,7 +135,7 @@ typedef struct item_type {
|
|||
struct item_type * next;
|
||||
} item_type;
|
||||
|
||||
extern const item_type * finditemtype(const xmlChar * name, const struct locale * lang);
|
||||
extern const item_type * finditemtype(const char * name, const struct locale * lang);
|
||||
extern void init_itemnames(void);
|
||||
|
||||
typedef struct luxury_type {
|
||||
|
|
|
@ -1794,19 +1794,19 @@ free_spellparameter(spellparameter *pa)
|
|||
}
|
||||
|
||||
static int
|
||||
addparam_string(const xmlChar * const param[], spllprm ** spobjp)
|
||||
addparam_string(const char * const param[], spllprm ** spobjp)
|
||||
{
|
||||
spllprm * spobj = *spobjp = malloc(sizeof(spllprm));
|
||||
assert(param[0]);
|
||||
|
||||
spobj->flag = 0;
|
||||
spobj->typ = SPP_STRING;
|
||||
spobj->data.xs = xmlStrdup(param[0]);
|
||||
spobj->data.xs = strdup(param[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
addparam_int(const xmlChar * const param[], spllprm ** spobjp)
|
||||
addparam_int(const char * const param[], spllprm ** spobjp)
|
||||
{
|
||||
spllprm * spobj = *spobjp = malloc(sizeof(spllprm));
|
||||
assert(param[0]);
|
||||
|
@ -1818,7 +1818,7 @@ addparam_int(const xmlChar * const param[], spllprm ** spobjp)
|
|||
}
|
||||
|
||||
static int
|
||||
addparam_ship(const xmlChar * const param[], spllprm ** spobjp)
|
||||
addparam_ship(const char * const param[], spllprm ** spobjp)
|
||||
{
|
||||
spllprm * spobj = *spobjp = malloc(sizeof(spllprm));
|
||||
int id = atoi36((const char *)param[0]);
|
||||
|
@ -1830,7 +1830,7 @@ addparam_ship(const xmlChar * const param[], spllprm ** spobjp)
|
|||
}
|
||||
|
||||
static int
|
||||
addparam_building(const xmlChar * const param[], spllprm ** spobjp)
|
||||
addparam_building(const char * const param[], spllprm ** spobjp)
|
||||
{
|
||||
spllprm * spobj = *spobjp = malloc(sizeof(spllprm));
|
||||
int id = atoi36((const char *)param[0]);
|
||||
|
@ -1842,7 +1842,7 @@ addparam_building(const xmlChar * const param[], spllprm ** spobjp)
|
|||
}
|
||||
|
||||
static int
|
||||
addparam_region(const xmlChar * const param[], spllprm ** spobjp, const unit * u, order * ord)
|
||||
addparam_region(const char * const param[], spllprm ** spobjp, const unit * u, order * ord)
|
||||
{
|
||||
assert(param[0]);
|
||||
if (param[1]==0) {
|
||||
|
@ -1872,7 +1872,7 @@ addparam_region(const xmlChar * const param[], spllprm ** spobjp, const unit * u
|
|||
|
||||
|
||||
static int
|
||||
addparam_unit(const xmlChar * const param[], spllprm ** spobjp, const unit * u, order * ord)
|
||||
addparam_unit(const char * const param[], spllprm ** spobjp, const unit * u, order * ord)
|
||||
{
|
||||
spllprm *spobj;
|
||||
int i = 0;
|
||||
|
@ -1898,7 +1898,7 @@ addparam_unit(const xmlChar * const param[], spllprm ** spobjp, const unit * u,
|
|||
}
|
||||
|
||||
static spellparameter *
|
||||
add_spellparameter(region *target_r, unit *u, const char *syntax, const xmlChar * const param[], int size, struct order * ord)
|
||||
add_spellparameter(region *target_r, unit *u, const char *syntax, const char * const param[], int size, struct order * ord)
|
||||
{
|
||||
boolean fail = false;
|
||||
int i = 0;
|
||||
|
@ -2452,7 +2452,7 @@ cast_cmd(unit * u, order * ord)
|
|||
region * target_r = r;
|
||||
int level, range;
|
||||
unit *familiar = NULL, *mage = u;
|
||||
const xmlChar * s;
|
||||
const char * s;
|
||||
spell * sp;
|
||||
spellparameter *args = NULL;
|
||||
|
||||
|
@ -2506,7 +2506,7 @@ cast_cmd(unit * u, order * ord)
|
|||
}
|
||||
s = getstrtoken();
|
||||
}
|
||||
if (!s[0] || xstrlen(s) == 0) {
|
||||
if (!s[0] || strlen(s) == 0) {
|
||||
/* Fehler "Es wurde kein Zauber angegeben" */
|
||||
cmistake(u, ord, 172, MSG_MAGIC);
|
||||
return 0;
|
||||
|
@ -2627,19 +2627,19 @@ cast_cmd(unit * u, order * ord)
|
|||
}
|
||||
/* Weitere Argumente zusammenbasteln */
|
||||
if (sp->parameter) {
|
||||
xmlChar ** params = malloc(2*sizeof(xmlChar*));
|
||||
char ** params = malloc(2*sizeof(char*));
|
||||
int p = 0, size = 2;
|
||||
for (;;) {
|
||||
s = getstrtoken();
|
||||
if (*s==0) break;
|
||||
if (p+1>=size) {
|
||||
size*=2;
|
||||
params = realloc(params, sizeof(xmlChar*)*size);
|
||||
params = realloc(params, sizeof(char*)*size);
|
||||
}
|
||||
params[p++] = xmlStrdup(s);
|
||||
params[p++] = strdup(s);
|
||||
}
|
||||
params[p] = 0;
|
||||
args = add_spellparameter(target_r, mage, sp->parameter, (const xmlChar * const *)params, p, ord);
|
||||
args = add_spellparameter(target_r, mage, sp->parameter, (const char * const *)params, p, ord);
|
||||
for (p=0;params[p];++p) free(params[p]);
|
||||
free(params);
|
||||
if (args==NULL) {
|
||||
|
@ -2826,19 +2826,19 @@ magic(void)
|
|||
remove_empty_units();
|
||||
}
|
||||
|
||||
const xmlChar *
|
||||
const char *
|
||||
spell_info(const spell * sp, const struct locale * lang)
|
||||
{
|
||||
return LOC(lang, mkname("spellinfo", sp->sname));
|
||||
}
|
||||
|
||||
const xmlChar *
|
||||
const char *
|
||||
spell_name(const spell * sp, const struct locale * lang)
|
||||
{
|
||||
return LOC(lang, mkname("spell", sp->sname));
|
||||
}
|
||||
|
||||
const xmlChar *
|
||||
const char *
|
||||
curse_name(const curse_type * ctype, const struct locale * lang)
|
||||
{
|
||||
return LOC(lang, mkname("spell", ctype->cname));
|
||||
|
|
|
@ -60,7 +60,7 @@ typedef struct spllprm{
|
|||
struct building *b;
|
||||
struct ship *sh;
|
||||
char *s;
|
||||
xmlChar * xs;
|
||||
char * xs;
|
||||
int i;
|
||||
} data;
|
||||
} spllprm;
|
||||
|
@ -371,9 +371,9 @@ extern boolean create_newfamiliar(struct unit * mage, struct unit * familiar);
|
|||
extern void create_newclone(struct unit * mage, struct unit * familiar);
|
||||
extern struct unit * has_clone(struct unit * mage);
|
||||
|
||||
extern const xmlChar * spell_info(const struct spell * sp, const struct locale * lang);
|
||||
extern const xmlChar * spell_name(const struct spell * sp, const struct locale * lang);
|
||||
extern const xmlChar * curse_name(const struct curse_type * ctype, const struct locale * lang);
|
||||
extern const char * spell_info(const struct spell * sp, const struct locale * lang);
|
||||
extern const char * spell_name(const struct spell * sp, const struct locale * lang);
|
||||
extern const char * curse_name(const struct curse_type * ctype, const struct locale * lang);
|
||||
|
||||
extern struct message * msg_unitnotfound(const struct unit * mage, struct order * ord, const struct spllprm * spobj);
|
||||
|
||||
|
|
|
@ -177,7 +177,7 @@ msg_message(const char * name, const char* sig, ...)
|
|||
}
|
||||
|
||||
static void
|
||||
caddmessage(region * r, faction * f, const xmlChar *s, msg_t mtype, int level)
|
||||
caddmessage(region * r, faction * f, const char *s, msg_t mtype, int level)
|
||||
{
|
||||
message * m = NULL;
|
||||
|
||||
|
@ -230,7 +230,7 @@ caddmessage(region * r, faction * f, const xmlChar *s, msg_t mtype, int level)
|
|||
}
|
||||
|
||||
void
|
||||
addmessage(region * r, faction * f, const xmlChar *s, msg_t mtype, int level)
|
||||
addmessage(region * r, faction * f, const char *s, msg_t mtype, int level)
|
||||
{
|
||||
caddmessage(r, f, s, mtype, level);
|
||||
}
|
||||
|
|
|
@ -908,14 +908,14 @@ static void
|
|||
cycle_route(order * ord, unit *u, int gereist)
|
||||
{
|
||||
int cm = 0;
|
||||
xmlChar tail[1024];
|
||||
xmlChar neworder[2048];
|
||||
const xmlChar *token;
|
||||
char tail[1024];
|
||||
char neworder[2048];
|
||||
const char *token;
|
||||
direction_t d = NODIRECTION;
|
||||
boolean paused = false;
|
||||
boolean pause;
|
||||
order * norder;
|
||||
xmlChar * tail_end = tail;
|
||||
char * tail_end = tail;
|
||||
|
||||
if (get_keyword(ord) != K_ROUTE) return;
|
||||
tail[0] = '\0';
|
||||
|
@ -939,32 +939,32 @@ cycle_route(order * ord, unit *u, int gereist)
|
|||
assert(!pause);
|
||||
if (!pause) {
|
||||
size_t size = sizeof(tail)-(tail_end-tail);
|
||||
const xmlChar * loc = LOC(lang, shortdirections[d]);
|
||||
const char * loc = LOC(lang, shortdirections[d]);
|
||||
*tail_end++ = ' ';
|
||||
tail_end += strlcpy((char*)tail_end, (const char *)loc, size-1);
|
||||
tail_end += strlcpy(tail_end, loc, size-1);
|
||||
}
|
||||
}
|
||||
else if (xstrlen(neworder)>sizeof(neworder)/2) break;
|
||||
else if (strlen(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]);
|
||||
const char * loc = LOC(lang, parameters[P_PAUSE]);
|
||||
*tail_end++ = ' ';
|
||||
tail_end += strlcpy((char*)tail_end, (const char *)loc, size-1);
|
||||
tail_end += strlcpy(tail_end, loc, size-1);
|
||||
paused = true;
|
||||
}
|
||||
else if (pause) {
|
||||
/* da PAUSE nicht in ein shortdirections[d] umgesetzt wird (ist
|
||||
* hier keine normale direction), muss jede PAUSE einzeln
|
||||
* herausgefiltert und explizit gesetzt werden */
|
||||
strcat((char *)neworder, " ");
|
||||
strcat((char *)neworder, (const char *)LOC(lang, parameters[P_PAUSE]));
|
||||
if (neworder[0]) strcat(neworder, " ");
|
||||
strcat(neworder, LOC(lang, parameters[P_PAUSE]));
|
||||
} else {
|
||||
strcat((char *)neworder, " ");
|
||||
strcat((char *)neworder, (const char *)LOC(lang, shortdirections[d]));
|
||||
if (neworder[0]) strcat(neworder, " ");
|
||||
strcat(neworder, LOC(lang, shortdirections[d]));
|
||||
}
|
||||
}
|
||||
|
||||
strcat((char *)neworder, (const char *)tail);
|
||||
strcat(neworder, tail);
|
||||
norder = create_order(K_ROUTE, u->faction->locale, "%s", neworder);
|
||||
#ifdef LASTORDER
|
||||
set_order(&u->lastorder, norder);
|
||||
|
@ -1228,7 +1228,7 @@ make_route(unit * u, order * ord, region_list ** routep)
|
|||
region_list **iroute = routep;
|
||||
region * current = u->region;
|
||||
region * next = NULL;
|
||||
const xmlChar * token = getstrtoken();
|
||||
const char * token = getstrtoken();
|
||||
int error = movewhere(u, token, current, &next);
|
||||
|
||||
if (error!=E_MOVE_OK) {
|
||||
|
@ -1622,7 +1622,7 @@ sail(unit * u, order * ord, boolean move_on_land, region_list **routep)
|
|||
faction * f = u->faction;
|
||||
region * next_point = NULL;
|
||||
int error;
|
||||
const xmlChar * token = getstrtoken();
|
||||
const char * token = getstrtoken();
|
||||
|
||||
if (routep) *routep = NULL;
|
||||
|
||||
|
@ -1654,7 +1654,7 @@ sail(unit * u, order * ord, boolean move_on_land, region_list **routep)
|
|||
* befahrene Region. */
|
||||
|
||||
while (next_point && current_point!=next_point && step < k) {
|
||||
const xmlChar * token;
|
||||
const char * token;
|
||||
int error;
|
||||
const terrain_type * tthis = current_point->terrain;
|
||||
/* these values need to be updated if next_point changes (due to storms): */
|
||||
|
@ -2117,7 +2117,7 @@ piracy_cmd(unit *u, struct order * ord)
|
|||
} aff[MAXDIRECTIONS];
|
||||
int saff = 0;
|
||||
int *il = NULL;
|
||||
const xmlChar *s;
|
||||
const char *s;
|
||||
attrib *a;
|
||||
|
||||
if (!sh) {
|
||||
|
@ -2140,7 +2140,7 @@ piracy_cmd(unit *u, struct order * ord)
|
|||
if (s!=NULL && *s) {
|
||||
il = intlist_init();
|
||||
while (s && *s) {
|
||||
il = intlist_add(il, atoi36((const char *)s));
|
||||
il = intlist_add(il, atoi36(s));
|
||||
s = getstrtoken();
|
||||
}
|
||||
}
|
||||
|
@ -2262,7 +2262,7 @@ hunt(unit *u, order * ord)
|
|||
{
|
||||
region *rc = u->region;
|
||||
int moves, id, speed;
|
||||
xmlChar command[256];
|
||||
char command[256];
|
||||
size_t size = sizeof(command);
|
||||
direction_t dir;
|
||||
|
||||
|
@ -2301,9 +2301,9 @@ hunt(unit *u, order * ord)
|
|||
return 0;
|
||||
}
|
||||
|
||||
sprintf((char *)command, "%s %s", locale_string(u->faction->locale, keywords[K_MOVE]),
|
||||
sprintf(command, "%s %s", locale_string(u->faction->locale, keywords[K_MOVE]),
|
||||
locale_string(u->faction->locale, directions[dir]));
|
||||
size -= xstrlen(command);
|
||||
size -= strlen(command);
|
||||
moves = 1;
|
||||
|
||||
speed = getuint();
|
||||
|
@ -2316,8 +2316,8 @@ hunt(unit *u, order * ord)
|
|||
rc = rconnect(rc, dir);
|
||||
while (moves < speed && (dir = hunted_dir(rc->attribs, id)) != NODIRECTION)
|
||||
{
|
||||
size -= xstrlcat(command, " ", size);
|
||||
size -= xstrlcat(command, LOC(u->faction->locale, directions[dir]), size);
|
||||
size -= strlcat(command, " ", size);
|
||||
size -= strlcat(command, LOC(u->faction->locale, directions[dir]), size);
|
||||
moves++;
|
||||
rc = rconnect(rc, dir);
|
||||
}
|
||||
|
|
|
@ -46,19 +46,19 @@
|
|||
/* Untote */
|
||||
|
||||
|
||||
const xmlChar *
|
||||
const char *
|
||||
describe_braineater(unit * u, const struct locale * lang)
|
||||
{
|
||||
return LOC(lang, "describe_braineater");
|
||||
}
|
||||
|
||||
static const xmlChar *
|
||||
static const char *
|
||||
make_names(const char * monster, int * num_postfix, int pprefix, int * num_name, int * num_prefix, int ppostfix)
|
||||
{
|
||||
int uv, uu, un;
|
||||
static char name[NAMESIZE + 1];
|
||||
char zText[32];
|
||||
const xmlChar * str;
|
||||
const char * str;
|
||||
|
||||
if (*num_prefix==0) {
|
||||
|
||||
|
@ -119,31 +119,31 @@ make_names(const char * monster, int * num_postfix, int pprefix, int * num_name,
|
|||
strcat(name, (const char *)str);
|
||||
}
|
||||
}
|
||||
return (const xmlChar *)name;
|
||||
return name;
|
||||
}
|
||||
|
||||
const xmlChar *
|
||||
const char *
|
||||
undead_name(const unit * u)
|
||||
{
|
||||
static int num_postfix, num_name, num_prefix;
|
||||
return make_names("undead", &num_postfix, 2, &num_name, &num_prefix, 2);
|
||||
}
|
||||
|
||||
const xmlChar *
|
||||
const char *
|
||||
skeleton_name(const unit * u)
|
||||
{
|
||||
static int num_postfix, num_name, num_prefix;
|
||||
return make_names("skeleton", &num_postfix, 5, &num_name, &num_prefix, 2);
|
||||
}
|
||||
|
||||
const xmlChar *
|
||||
const char *
|
||||
zombie_name(const unit * u)
|
||||
{
|
||||
static int num_postfix, num_name, num_prefix;
|
||||
return make_names("zombie", &num_postfix, 5, &num_name, &num_prefix, 2);
|
||||
}
|
||||
|
||||
const xmlChar *
|
||||
const char *
|
||||
ghoul_name(const unit * u)
|
||||
{
|
||||
static int num_postfix, num_name, num_prefix;
|
||||
|
@ -216,7 +216,7 @@ const char *silbe3[SIL3] = {
|
|||
"bus",
|
||||
};
|
||||
|
||||
const xmlChar *
|
||||
const char *
|
||||
generic_name(const unit *u)
|
||||
{
|
||||
if (u->no == 1) {
|
||||
|
@ -225,7 +225,7 @@ generic_name(const unit *u)
|
|||
return LOC(u->faction->locale, u->race->_name[1]);
|
||||
}
|
||||
|
||||
const xmlChar *
|
||||
const char *
|
||||
dragon_name(const unit *u)
|
||||
{
|
||||
static char name[NAMESIZE + 1];
|
||||
|
@ -233,7 +233,7 @@ dragon_name(const unit *u)
|
|||
int anzahl = 1;
|
||||
static int num_postfix;
|
||||
char zText[32];
|
||||
const xmlChar * str;
|
||||
const char * str;
|
||||
|
||||
if (num_postfix==0) {
|
||||
for (num_postfix=0;;++num_postfix) {
|
||||
|
@ -302,7 +302,7 @@ dragon_name(const unit *u)
|
|||
}
|
||||
}
|
||||
|
||||
return (xmlChar *)name;
|
||||
return name;
|
||||
}
|
||||
|
||||
/* Dracoide */
|
||||
|
@ -354,7 +354,7 @@ static const char *drac_suf[DRAC_SUF] = {
|
|||
"k"
|
||||
};
|
||||
|
||||
const xmlChar *
|
||||
const char *
|
||||
dracoid_name(const unit *u)
|
||||
{
|
||||
static char name[NAMESIZE + 1];
|
||||
|
@ -372,14 +372,14 @@ dracoid_name(const unit *u)
|
|||
strcat(name, drac_mid[rng_int()%DRAC_MID]);
|
||||
}
|
||||
strcat(name, drac_suf[rng_int()%DRAC_SUF]);
|
||||
return (const xmlChar *)name;
|
||||
return name;
|
||||
}
|
||||
|
||||
const xmlChar *
|
||||
abkz(const xmlChar *s, size_t max)
|
||||
const char *
|
||||
abkz(const char *s, size_t max)
|
||||
{
|
||||
static char buf[32];
|
||||
const xmlChar *p = s;
|
||||
const char *p = s;
|
||||
unsigned int c = 0;
|
||||
size_t bpt, i;
|
||||
|
||||
|
@ -389,7 +389,7 @@ abkz(const xmlChar *s, size_t max)
|
|||
|
||||
/* Prüfen, ob Kurz genug */
|
||||
|
||||
if (xstrlen(s) <= max) {
|
||||
if (strlen(s) <= max) {
|
||||
return s;
|
||||
}
|
||||
/* Anzahl der Wörter feststellen */
|
||||
|
@ -439,7 +439,7 @@ abkz(const xmlChar *s, size_t max)
|
|||
|
||||
buf[c] = 0;
|
||||
|
||||
return (const xmlChar *)buf;
|
||||
return buf;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -19,14 +19,14 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
extern void register_names(void);
|
||||
const xmlChar *undead_name(const struct unit * u);
|
||||
const xmlChar *skeleton_name(const struct unit * u);
|
||||
const xmlChar *zombie_name(const struct unit * u);
|
||||
const xmlChar *ghoul_name(const struct unit * u);
|
||||
const xmlChar *dragon_name(const struct unit *u);
|
||||
const xmlChar *dracoid_name(const struct unit *u);
|
||||
const xmlChar *generic_name(const struct unit *u);
|
||||
const xmlChar *abkz(const xmlChar *s, size_t max);
|
||||
const char *undead_name(const struct unit * u);
|
||||
const char *skeleton_name(const struct unit * u);
|
||||
const char *zombie_name(const struct unit * u);
|
||||
const char *ghoul_name(const struct unit * u);
|
||||
const char *dragon_name(const struct unit *u);
|
||||
const char *dracoid_name(const struct unit *u);
|
||||
const char *generic_name(const struct unit *u);
|
||||
const char *abkz(const char *s, size_t max);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
/* libc includes */
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
@ -42,7 +43,7 @@ static struct locale_data * locale_array[16];
|
|||
static int nlocales = 0;
|
||||
|
||||
typedef struct order_data {
|
||||
xmlChar * _str;
|
||||
char * _str;
|
||||
int _refcount : 20;
|
||||
int _lindex : 4;
|
||||
keyword_t _keyword;
|
||||
|
@ -88,7 +89,7 @@ static char *
|
|||
get_command(const order * ord, char * sbuffer, size_t bufsize)
|
||||
{
|
||||
char * str = sbuffer;
|
||||
const xmlChar * text = ORD_STRING(ord);
|
||||
const char * text = ORD_STRING(ord);
|
||||
keyword_t kwd = ORD_KEYWORD(ord);
|
||||
|
||||
if (ord->_persistent) *str++ = '@';
|
||||
|
@ -107,11 +108,11 @@ get_command(const order * ord, char * sbuffer, size_t bufsize)
|
|||
return sbuffer;
|
||||
}
|
||||
|
||||
xmlChar *
|
||||
char *
|
||||
getcommand(const order * ord)
|
||||
{
|
||||
char sbuffer[DISPLAYSIZE*2];
|
||||
return xmlStrdup((xmlChar *)get_command(ord, sbuffer, sizeof(sbuffer)));
|
||||
return strdup(get_command(ord, sbuffer, sizeof(sbuffer)));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -159,9 +160,9 @@ free_orders(order ** olist)
|
|||
}
|
||||
|
||||
static order_data *
|
||||
create_data(keyword_t kwd, const xmlChar * sptr, int lindex)
|
||||
create_data(keyword_t kwd, const char * sptr, int lindex)
|
||||
{
|
||||
const xmlChar * s = sptr;
|
||||
const char * s = sptr;
|
||||
order_data * data;
|
||||
const struct locale * lang = locale_array[lindex]->lang;
|
||||
|
||||
|
@ -178,20 +179,20 @@ create_data(keyword_t kwd, const xmlChar * sptr, int lindex)
|
|||
default: /* nur skill als Parameter, keine extras */
|
||||
data = locale_array[lindex]->study_orders[sk];
|
||||
if (data==NULL) {
|
||||
const xmlChar * skname = skillname(sk, lang);
|
||||
const char * skname = skillname(sk, lang);
|
||||
data = (order_data*)malloc(sizeof(order_data));
|
||||
locale_array[lindex]->study_orders[sk] = data;
|
||||
data->_keyword = kwd;
|
||||
data->_lindex = lindex;
|
||||
if (xmlStrchr(skname, ' ')!=NULL) {
|
||||
size_t len = xstrlen(skname);
|
||||
data->_str = (xmlChar*)malloc(len+3);
|
||||
if (strchr(skname, ' ')!=NULL) {
|
||||
size_t len = strlen(skname);
|
||||
data->_str = malloc(len+3);
|
||||
data->_str[0]='\"';
|
||||
memcpy(data->_str+1, skname, len);
|
||||
data->_str[len+1]='\"';
|
||||
data->_str[len+2]='\0';
|
||||
} else {
|
||||
data->_str = xmlStrdup(skname);
|
||||
data->_str = strdup(skname);
|
||||
}
|
||||
data->_refcount = 1;
|
||||
}
|
||||
|
@ -217,13 +218,13 @@ create_data(keyword_t kwd, const xmlChar * sptr, int lindex)
|
|||
data = (order_data*)malloc(sizeof(order_data));
|
||||
data->_keyword = kwd;
|
||||
data->_lindex = lindex;
|
||||
data->_str = s?xmlStrdup(s):NULL;
|
||||
data->_str = s?strdup(s):NULL;
|
||||
data->_refcount = 1;
|
||||
return data;
|
||||
}
|
||||
|
||||
static order *
|
||||
create_order_i(keyword_t kwd, const xmlChar * sptr, int persistent, const struct locale * lang)
|
||||
create_order_i(keyword_t kwd, const char * sptr, int persistent, const struct locale * lang)
|
||||
{
|
||||
order * ord = NULL;
|
||||
int lindex;
|
||||
|
@ -269,7 +270,7 @@ create_order(keyword_t kwd, const struct locale * lang, const char * params, ...
|
|||
char * sptr = zBuffer;
|
||||
|
||||
va_start(marker, params);
|
||||
while (params) {
|
||||
while (*params) {
|
||||
switch (*params) {
|
||||
case '%':
|
||||
/* ignore these, they are syntactical sugar */
|
||||
|
@ -291,19 +292,20 @@ create_order(keyword_t kwd, const struct locale * lang, const char * params, ...
|
|||
default:
|
||||
assert(!"unknown format-character in create_order");
|
||||
}
|
||||
++params;
|
||||
}
|
||||
va_end(marker);
|
||||
|
||||
return create_order_i(kwd, (const xmlChar*)sptr, 0, lang);
|
||||
return create_order_i(kwd, zBuffer, 0, lang);
|
||||
}
|
||||
|
||||
order *
|
||||
parse_order(const xmlChar * s, const struct locale * lang)
|
||||
parse_order(const char * s, const struct locale * lang)
|
||||
{
|
||||
while (*s && !isalnum(*(unsigned char*)s) && !ispunct(*(unsigned char*)s)) ++s;
|
||||
if (*s!=0) {
|
||||
keyword_t kwd;
|
||||
const xmlChar * sptr;
|
||||
const char * sptr;
|
||||
int persistent = 0;
|
||||
|
||||
while (*s=='@') {
|
||||
|
@ -467,7 +469,7 @@ write_order(const order * ord, const struct locale * lang, char * buffer, size_t
|
|||
} else {
|
||||
keyword_t kwd = ORD_KEYWORD(ord);
|
||||
if (kwd==NOKEYWORD) {
|
||||
const xmlChar * text = ORD_STRING(ord);
|
||||
const char * text = ORD_STRING(ord);
|
||||
strlcpy(buffer, (const char *)text, size);
|
||||
} else {
|
||||
get_command(ord, buffer, size);
|
||||
|
|
|
@ -36,7 +36,7 @@ typedef struct order {
|
|||
|
||||
/* constructor */
|
||||
extern order * create_order(keyword_t kwd, const struct locale * lang, const char * params, ...);
|
||||
extern order * parse_order(const xmlChar * s, const struct locale * lang);
|
||||
extern order * parse_order(const char * s, const struct locale * lang);
|
||||
extern void replace_order(order ** dst, order * orig, const order * src);
|
||||
|
||||
/* reference counted copies of orders: */
|
||||
|
@ -47,7 +47,7 @@ extern void free_orders(order ** olist);
|
|||
/* access functions for orders */
|
||||
extern keyword_t get_keyword(const order * ord);
|
||||
extern void set_order(order ** destp, order * src);
|
||||
extern xmlChar * getcommand(const order * ord);
|
||||
extern char * getcommand(const order * ord);
|
||||
extern boolean is_persistent(const order *ord);
|
||||
extern boolean is_exclusive(const order *ord);
|
||||
extern boolean is_repeated(const order * ord);
|
||||
|
|
|
@ -271,7 +271,7 @@ reserve_cmd(unit * u, struct order *ord)
|
|||
if (u->number > 0 && (urace(u)->ec_flags & GETITEM)) {
|
||||
int use, count;
|
||||
const resource_type * rtype;
|
||||
const xmlChar * s;
|
||||
const char * s;
|
||||
|
||||
init_tokens(ord);
|
||||
skip_token();
|
||||
|
|
|
@ -286,18 +286,20 @@ raceprefix(const unit *u)
|
|||
return get_prefix(asource);
|
||||
}
|
||||
|
||||
const xmlChar *
|
||||
const char *
|
||||
racename(const struct locale *loc, const unit *u, const race * rc)
|
||||
{
|
||||
const char * prefix = raceprefix(u);
|
||||
|
||||
if (prefix!=NULL) {
|
||||
static xmlChar lbuf[80];
|
||||
xmlChar * s = lbuf;
|
||||
s += xstrlcpy(lbuf, LOC(loc, mkname("prefix", prefix)), sizeof(lbuf));
|
||||
xstrlcpy(s, LOC(loc, rc_name(rc, u->number != 1)), sizeof(lbuf)-(s-lbuf));
|
||||
assert(s[0]<=0x7F || !"unicode/not implemented");
|
||||
s[0] = (xmlChar)tolower(s[0]);
|
||||
static char lbuf[80];
|
||||
char * s = lbuf;
|
||||
int ch;
|
||||
s += strlcpy(lbuf, LOC(loc, mkname("prefix", prefix)), sizeof(lbuf));
|
||||
strlcpy(s, LOC(loc, rc_name(rc, u->number != 1)), sizeof(lbuf)-(s-lbuf));
|
||||
assert(~s[0] & 0x80|| !"unicode/not implemented");
|
||||
ch = tolower(*(unsigned char *)s);
|
||||
*s = (char)ch;
|
||||
return lbuf;
|
||||
}
|
||||
return LOC(loc, rc_name(rc, u->number != 1));
|
||||
|
|
|
@ -78,8 +78,8 @@ typedef struct race {
|
|||
int ec_flags;
|
||||
race_t oldfamiliars[MAXMAGIETYP];
|
||||
|
||||
const xmlChar *(*generate_name) (const struct unit *);
|
||||
const xmlChar *(*describe) (const struct unit *, const struct locale *);
|
||||
const char *(*generate_name) (const struct unit *);
|
||||
const char *(*describe) (const struct unit *, const struct locale *);
|
||||
void (*age)(struct unit *u);
|
||||
boolean (*move_allowed)(const struct region *, const struct region *);
|
||||
struct item * (*itemdrop)(const struct race *, int size);
|
||||
|
@ -155,7 +155,7 @@ extern int rc_specialdamage(const race *, const race *, const struct weapon_type
|
|||
#define BF_CANATTACK (1<<6) /* Kann keine ATTACKIERE Befehle ausfuehren */
|
||||
|
||||
extern int unit_old_max_hp(struct unit * u);
|
||||
extern const xmlChar * racename(const struct locale *lang, const struct unit *u, const race * rc);
|
||||
extern const char * racename(const struct locale *lang, const struct unit *u, const race * rc);
|
||||
|
||||
#define omniscient(f) (((f)->race)==new_race[RC_ILLUSION] || ((f)->race)==new_race[RC_TEMPLATE])
|
||||
|
||||
|
|
|
@ -105,8 +105,8 @@ dir_invert(direction_t dir)
|
|||
return NODIRECTION;
|
||||
}
|
||||
|
||||
const xmlChar *
|
||||
write_regionname(const region * r, const faction * f, xmlChar * buffer, size_t size)
|
||||
const char *
|
||||
write_regionname(const region * r, const faction * f, char * buffer, size_t size)
|
||||
{
|
||||
char * buf = (char *)buffer;
|
||||
const struct locale * lang = f ? f->locale : 0;
|
||||
|
@ -115,7 +115,7 @@ write_regionname(const region * r, const faction * f, xmlChar * buffer, size_t s
|
|||
} else {
|
||||
plane *pl = r->planep;
|
||||
if (pl && fval(pl, PFL_NOCOORDS)) {
|
||||
strncpy(buf, (const char *)rname(r, lang), size);
|
||||
strncpy(buf, rname(r, lang), size);
|
||||
} else {
|
||||
snprintf(buf, size, "%s (%d,%d)", rname(r, lang),
|
||||
region_x(r, f), region_y(r, f));
|
||||
|
@ -125,10 +125,10 @@ write_regionname(const region * r, const faction * f, xmlChar * buffer, size_t s
|
|||
return buffer;
|
||||
}
|
||||
|
||||
const xmlChar *
|
||||
const char *
|
||||
regionname(const region * r, const faction * f)
|
||||
{
|
||||
static xmlChar buf[65];
|
||||
static char buf[65];
|
||||
return write_regionname(r, f, buf, sizeof(buf));
|
||||
}
|
||||
|
||||
|
@ -209,7 +209,7 @@ a_agedirection(attrib *a)
|
|||
|
||||
typedef struct dir_lookup {
|
||||
char * name;
|
||||
const xmlChar * oldname;
|
||||
const char * oldname;
|
||||
struct dir_lookup * next;
|
||||
} dir_lookup;
|
||||
|
||||
|
@ -223,7 +223,7 @@ register_special_direction(const char * name)
|
|||
|
||||
for (lang=locales;lang;lang=nextlocale(lang)) {
|
||||
tnode * tokens = get_translations(lang, UT_SPECDIR);
|
||||
const xmlChar * token = LOC(lang, name);
|
||||
const char * token = LOC(lang, name);
|
||||
|
||||
if (token) {
|
||||
variant var;
|
||||
|
@ -261,7 +261,7 @@ a_readdirection(attrib *a, FILE *f)
|
|||
cstring_i(d->desc);
|
||||
cstring_i(lbuf);
|
||||
for (;dl;dl=dl->next) {
|
||||
if (strcmp(lbuf, (const char *)dl->oldname)==0) {
|
||||
if (strcmp(lbuf, dl->oldname)==0) {
|
||||
d->keyword=strdup(dl->name);
|
||||
break;
|
||||
}
|
||||
|
@ -297,12 +297,12 @@ attrib_type at_direction = {
|
|||
};
|
||||
|
||||
region *
|
||||
find_special_direction(const region *r, const xmlChar *token, const struct locale * lang)
|
||||
find_special_direction(const region *r, const char *token, const struct locale * lang)
|
||||
{
|
||||
attrib *a;
|
||||
spec_direction *d;
|
||||
|
||||
if (xstrlen(token)==0) return NULL;
|
||||
if (strlen(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);
|
||||
|
||||
|
@ -774,15 +774,15 @@ r_demand(const region * r, const luxury_type * ltype)
|
|||
}
|
||||
|
||||
void
|
||||
rsetname(struct region * r, const xmlChar * name)
|
||||
rsetname(struct region * r, const char * name)
|
||||
{
|
||||
if (r->land) {
|
||||
free(r->land->name);
|
||||
r->land->name = xstrdup(name);
|
||||
r->land->name = strdup(name);
|
||||
}
|
||||
}
|
||||
|
||||
const xmlChar *
|
||||
const char *
|
||||
rname(const region * r, const struct locale * lang) {
|
||||
if (r->land) {
|
||||
return r->land->name;
|
||||
|
@ -889,7 +889,7 @@ free_region(region * r)
|
|||
/** creates a name for a region
|
||||
* TODO: Make this XML-configurable and allow non-ascii characters again.
|
||||
*/
|
||||
static xmlChar *
|
||||
static char *
|
||||
makename(void)
|
||||
{
|
||||
int s, v, k, e, p = 0, x = 0;
|
||||
|
@ -932,7 +932,7 @@ makename(void)
|
|||
}
|
||||
name[p] = '\0';
|
||||
name[0] = (char) toupper(name[0]);
|
||||
return (xmlChar*)name;
|
||||
return name;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -62,7 +62,7 @@ struct rawmaterial;
|
|||
struct donation;
|
||||
|
||||
typedef struct land_region {
|
||||
xmlChar *name;
|
||||
char *name;
|
||||
/* TODO: demand kann nach Konvertierung entfernt werden. */
|
||||
struct demand {
|
||||
struct demand * next;
|
||||
|
@ -97,7 +97,7 @@ typedef struct region {
|
|||
and lastregion */
|
||||
short x, y;
|
||||
struct plane *planep;
|
||||
xmlChar *display;
|
||||
char *display;
|
||||
unsigned int flags;
|
||||
unsigned short age;
|
||||
struct message_list *msgs;
|
||||
|
@ -165,7 +165,7 @@ void runhash(struct region * r);
|
|||
void free_regionlist(region_list *rl);
|
||||
void add_regionlist(region_list **rl, struct region *r);
|
||||
|
||||
extern struct region * find_special_direction(const struct region *r, const xmlChar *token, const struct locale * lang);
|
||||
extern struct region * find_special_direction(const struct region *r, const char *token, const struct locale * lang);
|
||||
extern void register_special_direction(const char * name);
|
||||
extern struct spec_direction * special_direction(const region * from, const region * to);
|
||||
extern struct attrib *create_special_direction(struct region *r, struct region *rt,
|
||||
|
@ -212,16 +212,16 @@ extern boolean r_isforest(const struct region * r);
|
|||
#define rterrain(r) (oldterrain((r)->terrain))
|
||||
#define rsetterrain(r, t) ((r)->terrain = newterrain(t))
|
||||
|
||||
extern const xmlChar * rname(const struct region * r, const struct locale * lang);
|
||||
extern void rsetname(struct region * r, const xmlChar * name);
|
||||
extern const char * rname(const struct region * r, const struct locale * lang);
|
||||
extern void rsetname(struct region * r, const char * name);
|
||||
|
||||
#define rplane(r) getplane(r)
|
||||
|
||||
extern void r_setdemand(struct region * r, const struct luxury_type * ltype, int value);
|
||||
extern int r_demand(const struct region * r, const struct luxury_type * ltype);
|
||||
|
||||
extern const xmlChar * regionname(const struct region * r, const struct faction * f);
|
||||
extern const xmlChar * write_regionname(const struct region * r, const struct faction * f, xmlChar * buffer, size_t size);
|
||||
extern const char * regionname(const struct region * r, const struct faction * f);
|
||||
extern const char * write_regionname(const struct region * r, const struct faction * f, char * buffer, size_t size);
|
||||
|
||||
extern void * resolve_region(variant data);
|
||||
extern struct region * new_region(short x, short y);
|
||||
|
|
|
@ -107,7 +107,7 @@ groupid(const struct group * g, const struct faction * f)
|
|||
return buf;
|
||||
}
|
||||
|
||||
const xmlChar *
|
||||
const char *
|
||||
report_kampfstatus(const unit * u, const struct locale * lang)
|
||||
{
|
||||
static char fsbuf[64];
|
||||
|
@ -116,13 +116,13 @@ report_kampfstatus(const unit * u, const struct locale * lang)
|
|||
"status_rear", "status_defensive",
|
||||
"status_avoid", "status_flee" };
|
||||
|
||||
xstrlcpy(fsbuf, LOC(lang, azstatus[u->status]), sizeof(fsbuf));
|
||||
strlcpy(fsbuf, LOC(lang, azstatus[u->status]), sizeof(fsbuf));
|
||||
if (fval(u, UFL_NOAID)) {
|
||||
strcat(fsbuf, ", ");
|
||||
xstrcat(fsbuf, LOC(lang, "status_noaid"));
|
||||
strcat(fsbuf, LOC(lang, "status_noaid"));
|
||||
}
|
||||
|
||||
return (xmlChar *)fsbuf;
|
||||
return fsbuf;
|
||||
}
|
||||
|
||||
const char *
|
||||
|
@ -1296,6 +1296,7 @@ write_reports(faction * f, time_t ltime)
|
|||
int backup = 1, maxbackup = 128;
|
||||
boolean gotit = false;
|
||||
struct report_context ctx;
|
||||
const char * encoding = "UTF-8";
|
||||
|
||||
ctx.f = f;
|
||||
ctx.report_time = time(NULL);
|
||||
|
@ -1318,7 +1319,7 @@ write_reports(faction * f, time_t ltime)
|
|||
if (f->options & rtype->flag) {
|
||||
char filename[MAX_PATH];
|
||||
sprintf(filename, "%s/%d-%s.%s", reportpath(), turn, factionid(f), rtype->extension);
|
||||
if (rtype->write(filename, &ctx)==0) {
|
||||
if (rtype->write(filename, &ctx, encoding)==0) {
|
||||
gotit = true;
|
||||
}
|
||||
}
|
||||
|
@ -1409,40 +1410,6 @@ write_script(FILE * F, const faction * f)
|
|||
fputc('\n', F);
|
||||
}
|
||||
|
||||
#undef GLOBAL_REPORT
|
||||
#ifdef GLOBAL_REPORT
|
||||
static void
|
||||
global_report(const char * filename)
|
||||
{
|
||||
FILE * F = fopen(filename, "w");
|
||||
region * r;
|
||||
faction * f;
|
||||
faction * monsters = findfaction(MONSTER_FACTION);
|
||||
faction_list * addresses = NULL;
|
||||
struct seen_region ** seen;
|
||||
|
||||
if (!monsters) return;
|
||||
if (!F) return;
|
||||
|
||||
/* list of all addresses */
|
||||
for (f=factions;f;f=f->next) {
|
||||
faction_list * flist = calloc(1, sizeof(faction_list));
|
||||
flist->data = f;
|
||||
flist->next = addresses;
|
||||
addresses = flist;
|
||||
}
|
||||
|
||||
seen = seen_init();
|
||||
for (r = regions; r; r = r->next) {
|
||||
add_seen(seen, r, see_unit, true);
|
||||
}
|
||||
report_computer(F, monsters, seen, addresses, time(NULL));
|
||||
freelist(addresses);
|
||||
seen_done(seen);
|
||||
fclose(F);
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
init_reports(void)
|
||||
{
|
||||
|
|
|
@ -93,7 +93,7 @@ typedef struct report_context {
|
|||
time_t report_time;
|
||||
} report_context;
|
||||
|
||||
typedef int (*report_fun)(const char * filename, report_context * ctx);
|
||||
typedef int (*report_fun)(const char * filename, report_context * ctx, const char * charset);
|
||||
extern void register_reporttype(const char * extension, report_fun write, int flag);
|
||||
|
||||
extern void report_item(const struct unit * owner, const struct item * i, const struct faction * viewer, const char ** name, const char ** basename, int * number, boolean singular);
|
||||
|
@ -101,8 +101,8 @@ extern void report_building(FILE *F, const struct region * r, const struct build
|
|||
extern int bufunit(const struct faction * f, const struct unit * u, int indent, int mode, char * buf, size_t size);
|
||||
|
||||
extern const char * reportpath(void);
|
||||
extern const xmlChar * trailinto(const struct region * r, const struct locale * lang);
|
||||
extern const xmlChar * report_kampfstatus(const struct unit * u, const struct locale * lang);
|
||||
extern const char * trailinto(const struct region * r, const struct locale * lang);
|
||||
extern const char * report_kampfstatus(const struct unit * u, const struct locale * lang);
|
||||
|
||||
extern void reports_init(void);
|
||||
|
||||
|
|
|
@ -87,6 +87,8 @@
|
|||
const char * xmlfile = "eressea.xml";
|
||||
const char * g_datadir;
|
||||
int firstx = 0, firsty = 0;
|
||||
const char * enc_gamedata = NULL;
|
||||
const char * enc_orderfile = NULL;
|
||||
|
||||
/* local symbols */
|
||||
static region * current_region;
|
||||
|
@ -169,9 +171,6 @@ cfopen(const char *filename, const char *mode)
|
|||
|
||||
#define rid(F) ri36(F)
|
||||
|
||||
static int nextc;
|
||||
#define rc(F) (nextc = getc(F))
|
||||
|
||||
#undef CONVERT_DBLINK
|
||||
#ifdef CONVERT_DBLINK
|
||||
|
||||
|
@ -252,31 +251,31 @@ rds(FILE * F, void **ds)
|
|||
{
|
||||
static char buffer[DISPLAYSIZE + 1]; /*Platz für null-char nicht vergessen!*/
|
||||
char *s = &buffer[0];
|
||||
|
||||
while (nextc != '"') {
|
||||
if (nextc == EOF) {
|
||||
int c = getc(F);
|
||||
while (c != '"') {
|
||||
if (c == EOF) {
|
||||
*s = 0;
|
||||
fprintf(stderr, "Die Datei bricht vorzeitig ab.\n");
|
||||
abort();
|
||||
}
|
||||
rc(F);
|
||||
c = getc(F);
|
||||
}
|
||||
|
||||
rc(F);
|
||||
c = getc(F);
|
||||
|
||||
while (nextc != '"') {
|
||||
if (nextc == EOF) {
|
||||
while (c != '"') {
|
||||
if (c == EOF) {
|
||||
*s = 0;
|
||||
fprintf(stderr, "Die Datei bricht vorzeitig ab.\n");
|
||||
abort();
|
||||
}
|
||||
if (s - buffer < DISPLAYSIZE) {
|
||||
*s++ = (char)nextc;
|
||||
*s++ = (char)c;
|
||||
}
|
||||
rc(F);
|
||||
c = getc(F);
|
||||
}
|
||||
|
||||
rc(F);
|
||||
c = getc(F);
|
||||
*s = 0;
|
||||
if (ds) {
|
||||
*ds = realloc(*ds, sizeof(char) * (strlen(buffer) + 1));
|
||||
|
@ -284,29 +283,93 @@ rds(FILE * F, void **ds)
|
|||
}
|
||||
}
|
||||
|
||||
static int
|
||||
xrs(FILE * F, char *dest, size_t size, int encoding)
|
||||
{
|
||||
char buffer[4096];
|
||||
char * begin = dest;
|
||||
char * s = begin;
|
||||
boolean quote = false;
|
||||
size_t maxs = size;
|
||||
|
||||
for (;;) {
|
||||
int c = getc(F);
|
||||
|
||||
if (c=='"') {
|
||||
if (quote) {
|
||||
c = getc(F);
|
||||
if (isspace(c)) break;
|
||||
} else if (s==begin) {
|
||||
quote = true;
|
||||
continue;
|
||||
}
|
||||
} else if (isspace(c) && !quote) {
|
||||
break;
|
||||
}
|
||||
|
||||
if ((c & 0x80) && encoding!=XML_CHAR_ENCODING_NONE && encoding!=XML_CHAR_ENCODING_UTF8) {
|
||||
if (begin!=buffer) {
|
||||
size_t cp = s-begin;
|
||||
maxs = min(sizeof(buffer), maxs);
|
||||
if (cp>maxs) cp = maxs;
|
||||
memcpy(buffer, begin, cp);
|
||||
begin = buffer;
|
||||
s = begin + cp;
|
||||
}
|
||||
}
|
||||
*s++ = (char)c;
|
||||
}
|
||||
*s = 0;
|
||||
if (begin==buffer) {
|
||||
// convert
|
||||
const char * inbuf = begin;
|
||||
char * outbuf = dest;
|
||||
int inbytes = (int)(s-begin)+1;
|
||||
int outbytes = (int)size;
|
||||
|
||||
assert(encoding==XML_CHAR_ENCODING_8859_1);
|
||||
return isolat1ToUTF8((xmlChar *)outbuf, &outbytes, (const xmlChar *)inbuf, &inbytes);
|
||||
}
|
||||
return (int)(s-begin);
|
||||
}
|
||||
|
||||
static void
|
||||
xrds(FILE * F, void **ds, int encoding)
|
||||
{
|
||||
static char buffer[DISPLAYSIZE + 1]; /*Platz für null-char nicht vergessen!*/
|
||||
int len = xrs(F, buffer, sizeof(buffer), encoding);
|
||||
|
||||
if (len>=0) {
|
||||
if (ds) {
|
||||
*ds = realloc(*ds, sizeof(char) * (len + 1));
|
||||
strcpy(*ds, buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define rcf(F) (getc(F));
|
||||
void
|
||||
rsf(FILE * F, char *s, size_t len)
|
||||
{
|
||||
char * begin = s;
|
||||
int nextc;
|
||||
int c;
|
||||
do {
|
||||
nextc = rcf(F);
|
||||
if (nextc == EOF) {
|
||||
c = getc(F);;
|
||||
if (c == EOF) {
|
||||
puts("Die Datei bricht vorzeitig ab.");
|
||||
abort();
|
||||
}
|
||||
} while (nextc != '"');
|
||||
} while (c != '"');
|
||||
|
||||
for (;;) {
|
||||
nextc = rcf(F);
|
||||
if (nextc == '"') break;
|
||||
else if (nextc == EOF) {
|
||||
c = getc(F);
|
||||
if (c == '"') break;
|
||||
else if (c == EOF) {
|
||||
puts("Die Datei bricht vorzeitig ab.");
|
||||
abort();
|
||||
}
|
||||
if (s-begin<(int)len-1)
|
||||
*s++ = (char)nextc;
|
||||
*s++ = (char)c;
|
||||
}
|
||||
*s = 0;
|
||||
}
|
||||
|
@ -315,18 +378,19 @@ static void
|
|||
rs(FILE * F, char *s)
|
||||
{
|
||||
boolean apos = false;
|
||||
while (isspace(nextc)) rc(F);
|
||||
if (nextc=='"') {
|
||||
apos=true;
|
||||
rc(F);
|
||||
int c = getc(F);
|
||||
while (isspace(c)) c = getc(F);
|
||||
if (c=='"') {
|
||||
apos = true;
|
||||
c = getc(F);
|
||||
}
|
||||
for (;;) {
|
||||
if (nextc=='"') {
|
||||
rc(F);
|
||||
if (c=='"') {
|
||||
c = getc(F);
|
||||
break;
|
||||
} else if (!apos && isspace(nextc)) break;
|
||||
*s++ = (char)nextc;
|
||||
rc(F);
|
||||
} else if (!apos && isspace(c)) break;
|
||||
*s++ = (char)c;
|
||||
c = getc(F);
|
||||
}
|
||||
*s = 0;
|
||||
}
|
||||
|
@ -338,20 +402,21 @@ ri(FILE * F)
|
|||
{
|
||||
int i = 0, vz = 1;
|
||||
|
||||
while (!xisdigit(nextc)) {
|
||||
if (nextc == EOF) {
|
||||
int c = getc(F);
|
||||
while (!xisdigit(c)) {
|
||||
if (c == EOF) {
|
||||
puts("Die Datei bricht vorzeitig ab.");
|
||||
abort();
|
||||
}
|
||||
rc(F);
|
||||
c = getc(F);
|
||||
}
|
||||
|
||||
while (xisdigit(nextc)) {
|
||||
if (nextc == '-')
|
||||
while (xisdigit(c)) {
|
||||
if (c == '-')
|
||||
vz = -1;
|
||||
else
|
||||
i = 10 * i + (nextc - '0');
|
||||
rc(F);
|
||||
i = 10 * i + (c - '0');
|
||||
c = getc(F);
|
||||
}
|
||||
|
||||
return i * vz;
|
||||
|
@ -362,13 +427,13 @@ ri36(FILE * F)
|
|||
{
|
||||
char buf[16];
|
||||
int i = 0;
|
||||
rc(F);
|
||||
while (!isalnum(nextc)) rc(F);
|
||||
while (isalnum(nextc)) {
|
||||
int c = getc(F);
|
||||
while (!isalnum(c)) c = getc(F);
|
||||
while (isalnum(c)) {
|
||||
if (i+1<sizeof(buf)) {
|
||||
buf[i++]=(char)nextc;
|
||||
buf[i++]=(char)c;
|
||||
}
|
||||
rc(F);
|
||||
c = getc(F);
|
||||
}
|
||||
buf[i]=0;
|
||||
i = atoi36(buf);
|
||||
|
@ -448,7 +513,7 @@ unitorders(FILE * F, int enc, struct faction * f)
|
|||
ordp = &u->orders;
|
||||
|
||||
for (;;) {
|
||||
const xmlChar * s;
|
||||
const char * s;
|
||||
/* Erst wenn wir sicher sind, dass kein Befehl
|
||||
* eingegeben wurde, checken wir, ob nun eine neue
|
||||
* Einheit oder ein neuer Spieler drankommt */
|
||||
|
@ -494,7 +559,7 @@ factionorders(void)
|
|||
f = findfaction(fid);
|
||||
|
||||
if (f!=NULL) {
|
||||
const xmlChar * pass = getstrtoken();
|
||||
const char * pass = getstrtoken();
|
||||
if (quiet==0) {
|
||||
printf(" %4s;", factionid(f));
|
||||
fflush(stdout);
|
||||
|
@ -527,7 +592,7 @@ version(void)
|
|||
/* ------------------------------------------------------------- */
|
||||
|
||||
static param_t
|
||||
igetparam (const xmlChar *s, const struct locale *lang)
|
||||
igetparam (const char *s, const struct locale *lang)
|
||||
{
|
||||
return findparam (igetstrtoken (s), lang);
|
||||
}
|
||||
|
@ -536,7 +601,7 @@ int
|
|||
readorders(const char *filename, const char * encoding)
|
||||
{
|
||||
FILE * F = NULL;
|
||||
const xmlChar *b;
|
||||
const char *b;
|
||||
int nfactions=0;
|
||||
struct faction *f = NULL;
|
||||
int enc = xmlParseCharEncoding(encoding);
|
||||
|
@ -554,7 +619,7 @@ readorders(const char *filename, const char * encoding)
|
|||
while (b) {
|
||||
const struct locale * lang = f?f->locale:default_locale;
|
||||
int p;
|
||||
const xmlChar * s;
|
||||
const char * s;
|
||||
|
||||
switch (igetparam(b, lang)) {
|
||||
case P_LOCALE:
|
||||
|
@ -716,7 +781,7 @@ read_alliances(FILE * F)
|
|||
char aname[128];
|
||||
rss(F, aname, sizeof(aname));
|
||||
makealliance(atoi36(pbuf), aname);
|
||||
rs(F, pbuf);
|
||||
rss(F, pbuf, sizeof(pbuf));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -860,7 +925,7 @@ fwriteorder(FILE * F, const struct order * ord, const struct locale * lang)
|
|||
}
|
||||
|
||||
unit *
|
||||
readunit(FILE * F)
|
||||
readunit(FILE * F, int encoding)
|
||||
{
|
||||
skill_t sk;
|
||||
unit * u;
|
||||
|
@ -887,10 +952,10 @@ readunit(FILE * F)
|
|||
faction * f = findfaction(n);
|
||||
if (f!=u->faction) u_setfaction(u, f);
|
||||
}
|
||||
rds(F, &u->name);
|
||||
if (lomem) rds(F, 0);
|
||||
xrds(F, &u->name, encoding);
|
||||
if (lomem) rds(F, NULL);
|
||||
else {
|
||||
rds(F, &u->display);
|
||||
xrds(F, &u->display, encoding);
|
||||
}
|
||||
number = ri(F);
|
||||
u->age = (short)ri(F);
|
||||
|
@ -922,10 +987,10 @@ readunit(FILE * F)
|
|||
else u->irace = u->race;
|
||||
}
|
||||
if (u->race->describe) {
|
||||
const xmlChar * rcdisp = u->race->describe(u, u->faction->locale);
|
||||
const char * rcdisp = u->race->describe(u, u->faction->locale);
|
||||
if (u->display && rcdisp) {
|
||||
/* see if the data file contains old descriptions */
|
||||
if (xstrcmp(rcdisp, u->display)==0) {
|
||||
if (strcmp(rcdisp, u->display)==0) {
|
||||
free(u->display);
|
||||
u->display = NULL;
|
||||
}
|
||||
|
@ -980,11 +1045,11 @@ readunit(FILE * F)
|
|||
}
|
||||
/* Persistente Befehle einlesen */
|
||||
free_orders(&u->orders);
|
||||
freadstr(F, obuf, sizeof(obuf));
|
||||
freadstr(F, encoding, obuf, sizeof(obuf));
|
||||
p = n = 0;
|
||||
orderp = &u->orders;
|
||||
while (obuf[0]) {
|
||||
order * ord = parse_order((const xmlChar *)obuf, u->faction->locale);
|
||||
order * ord = parse_order(obuf, u->faction->locale);
|
||||
if (ord!=NULL) {
|
||||
if (++n<MAXORDERS) {
|
||||
if (!is_persistent(ord) || ++p<MAXPERSISTENT) {
|
||||
|
@ -999,12 +1064,12 @@ readunit(FILE * F)
|
|||
}
|
||||
if (ord!=NULL) free_order(ord);
|
||||
}
|
||||
freadstr(F, obuf, sizeof(obuf));
|
||||
freadstr(F, encoding, obuf, sizeof(obuf));
|
||||
}
|
||||
if (global.data_version<NOLASTORDER_VERSION) {
|
||||
order * ord;
|
||||
freadstr(F, obuf, sizeof(obuf));
|
||||
ord = parse_order((const xmlChar *)obuf, u->faction->locale);
|
||||
freadstr(F, encoding, obuf, sizeof(obuf));
|
||||
ord = parse_order(obuf, u->faction->locale);
|
||||
if (ord!=NULL) {
|
||||
#ifdef LASTORDER
|
||||
set_order(&u->lastorder, ord);
|
||||
|
@ -1157,7 +1222,7 @@ writeunit(FILE * F, const unit * u)
|
|||
}
|
||||
|
||||
region *
|
||||
readregion(FILE * F, short x, short y)
|
||||
readregion(FILE * F, int encoding, short x, short y)
|
||||
{
|
||||
region * r = findregion(x, y);
|
||||
const terrain_type * terrain;
|
||||
|
@ -1179,8 +1244,8 @@ readregion(FILE * F, short x, short y)
|
|||
}
|
||||
r->land = 0;
|
||||
}
|
||||
if (lomem) rds(F, 0);
|
||||
else rds(F, &r->display);
|
||||
if (lomem) rds(F, NULL);
|
||||
else xrds(F, &r->display, encoding);
|
||||
|
||||
if (global.data_version < TERRAIN_VERSION) {
|
||||
int ter = ri(F);
|
||||
|
@ -1190,7 +1255,7 @@ readregion(FILE * F, short x, short y)
|
|||
terrain = newterrain((terrain_t)ter);
|
||||
} else {
|
||||
char name[64];
|
||||
rs(F, name);
|
||||
rss(F, name, sizeof(name));
|
||||
terrain = get_terrain(name);
|
||||
if (terrain==NULL) {
|
||||
log_error(("Unknown terrain '%s'\n", name));
|
||||
|
@ -1207,7 +1272,7 @@ readregion(FILE * F, short x, short y)
|
|||
|
||||
if (fval(r->terrain, LAND_REGION)) {
|
||||
r->land = calloc(1, sizeof(land_region));
|
||||
rds(F, &r->land->name);
|
||||
xrds(F, &r->land->name, encoding);
|
||||
}
|
||||
if (r->land) {
|
||||
int i;
|
||||
|
@ -1400,7 +1465,7 @@ addally(const faction * f, ally ** sfp, int aid, int state)
|
|||
* faction may not already exist, however.
|
||||
*/
|
||||
faction *
|
||||
readfaction(FILE * F)
|
||||
readfaction(FILE * F, int encoding)
|
||||
{
|
||||
ally **sfp;
|
||||
int planes;
|
||||
|
@ -1429,8 +1494,8 @@ readfaction(FILE * F)
|
|||
}
|
||||
}
|
||||
|
||||
rds(F, &f->name);
|
||||
rds(F, &f->banner);
|
||||
xrds(F, &f->name, encoding);
|
||||
xrds(F, &f->banner, encoding);
|
||||
|
||||
if (quiet==0) printf(" - Lese Partei %s (%s)\n", f->name, factionid(f));
|
||||
|
||||
|
@ -1607,7 +1672,7 @@ writefaction(FILE * F, const faction * f)
|
|||
}
|
||||
|
||||
int
|
||||
readgame(const char * filename, int backup)
|
||||
readgame(const char * filename, int backup, const char * encoding)
|
||||
{
|
||||
int i, n, p;
|
||||
faction *f, **fp;
|
||||
|
@ -1619,6 +1684,7 @@ readgame(const char * filename, int backup)
|
|||
int rmax = maxregions;
|
||||
char path[MAX_PATH];
|
||||
char token[32];
|
||||
int enc = xmlParseCharEncoding(encoding);
|
||||
|
||||
sprintf(path, "%s/%s", datapath(), filename);
|
||||
log_printf("- reading game data from %s\n", filename);
|
||||
|
@ -1629,8 +1695,6 @@ readgame(const char * filename, int backup)
|
|||
return -1;
|
||||
}
|
||||
|
||||
rc(F);
|
||||
|
||||
/* globale Variablen */
|
||||
|
||||
global.data_version = ri(F);
|
||||
|
@ -1668,7 +1732,7 @@ readgame(const char * filename, int backup)
|
|||
while(--n >= 0) {
|
||||
plane *pl = calloc(1, sizeof(plane));
|
||||
pl->id = ri(F);
|
||||
rds(F, &pl->name);
|
||||
xrds(F, &pl->name, enc);
|
||||
pl->minx = (short)ri(F);
|
||||
pl->maxx = (short)ri(F);
|
||||
pl->miny = (short)ri(F);
|
||||
|
@ -1703,7 +1767,7 @@ readgame(const char * filename, int backup)
|
|||
/* fflush (stdout); */
|
||||
|
||||
while (--n >= 0) {
|
||||
faction * f = readfaction(F);
|
||||
faction * f = readfaction(F, enc);
|
||||
|
||||
*fp = f;
|
||||
fp = &f->next;
|
||||
|
@ -1761,7 +1825,7 @@ readgame(const char * filename, int backup)
|
|||
}
|
||||
--rmax;
|
||||
|
||||
r = readregion(F, x, y);
|
||||
r = readregion(F, enc, x, y);
|
||||
|
||||
/* Burgen */
|
||||
p = ri(F);
|
||||
|
@ -1774,9 +1838,9 @@ readgame(const char * filename, int backup)
|
|||
*bp = b;
|
||||
bp = &b->next;
|
||||
bhash(b);
|
||||
rds(F, &b->name);
|
||||
xrds(F, &b->name, enc);
|
||||
if (lomem) rds(F, 0);
|
||||
else rds(F, &b->display);
|
||||
else xrds(F, &b->display, enc);
|
||||
b->size = ri(F);
|
||||
if (global.data_version < TYPES_VERSION) {
|
||||
assert(!"data format is no longer supported");
|
||||
|
@ -1801,9 +1865,9 @@ readgame(const char * filename, int backup)
|
|||
*shp = sh;
|
||||
shp = &sh->next;
|
||||
shash(sh);
|
||||
rds(F, &sh->name);
|
||||
if (lomem) rds(F, 0);
|
||||
else rds(F, &sh->display);
|
||||
xrds(F, &sh->name, enc);
|
||||
if (lomem) rds(F, NULL);
|
||||
else xrds(F, &sh->display, enc);
|
||||
|
||||
rss(F, token, sizeof(token));
|
||||
sh->type = st_find(token);
|
||||
|
@ -1829,7 +1893,7 @@ readgame(const char * filename, int backup)
|
|||
up = &r->units;
|
||||
|
||||
while (--p >= 0) {
|
||||
unit * u = readunit(F);
|
||||
unit * u = readunit(F, enc);
|
||||
sc_mage * mage;
|
||||
|
||||
assert(u->region==NULL);
|
||||
|
|
|
@ -36,7 +36,7 @@ double version(void);
|
|||
FILE * cfopen(const char *filename, const char *mode);
|
||||
int readorders(const char *filename, const char * encoding);
|
||||
int creategame(void);
|
||||
extern int readgame(const char * filename, int backup);
|
||||
extern int readgame(const char * filename, int backup, const char * encoding);
|
||||
int writegame(const char *filename, int quiet);
|
||||
|
||||
extern void rsf(FILE * F, char *s, size_t len);
|
||||
|
@ -47,6 +47,8 @@ extern int data_version;
|
|||
extern int maxregions;
|
||||
extern int firstx, firsty;
|
||||
extern const char *xmlfile;
|
||||
extern const char * enc_gamedata;
|
||||
extern const char * enc_orderfile;
|
||||
|
||||
extern void init_locales(void);
|
||||
extern int lastturn(void);
|
||||
|
@ -57,13 +59,13 @@ extern void write_items(FILE *f, struct item *it);
|
|||
extern const char * datapath(void);
|
||||
|
||||
extern void writeunit(FILE * stream, const struct unit * u);
|
||||
extern struct unit * readunit(FILE * stream);
|
||||
extern struct unit * readunit(FILE * stream, int encoding);
|
||||
|
||||
extern void writeregion(FILE * stream, const struct region * r);
|
||||
extern struct region * readregion(FILE * stream, short x, short y);
|
||||
extern struct region * readregion(FILE * stream, int encoding, short x, short y);
|
||||
|
||||
extern void writefaction(FILE * stream, const struct faction * f);
|
||||
extern struct faction * readfaction(FILE * stream);
|
||||
extern struct faction * readfaction(FILE * stream, int encoding);
|
||||
|
||||
extern void fwriteorder(FILE * F, const struct order * ord, const struct locale * lang);
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ ship_typelist *shiptypes = NULL;
|
|||
static local_names * snames;
|
||||
|
||||
const ship_type *
|
||||
findshiptype(const xmlChar * name, const struct locale * lang)
|
||||
findshiptype(const char * name, const struct locale * lang)
|
||||
{
|
||||
local_names * sn = snames;
|
||||
variant var;
|
||||
|
@ -57,7 +57,7 @@ findshiptype(const xmlChar * name, const struct locale * lang)
|
|||
sn->lang = lang;
|
||||
while (stl) {
|
||||
variant var;
|
||||
const xmlChar * n = locale_string(lang, stl->type->name[0]);
|
||||
const char * n = locale_string(lang, stl->type->name[0]);
|
||||
var.v = (void*)stl->type;
|
||||
addtoken(&sn->names, n, var);
|
||||
stl = stl->next;
|
||||
|
@ -166,7 +166,7 @@ captain(ship *sh, region *r)
|
|||
ship *
|
||||
new_ship(const ship_type * stype, const struct locale * lang, region * r)
|
||||
{
|
||||
static xmlChar buffer[7 + IDSIZE + 1];
|
||||
static char buffer[7 + IDSIZE + 1];
|
||||
ship *sh = (ship *) calloc(1, sizeof(ship));
|
||||
|
||||
sh->no = newcontainerid();
|
||||
|
@ -174,8 +174,8 @@ new_ship(const ship_type * stype, const struct locale * lang, region * r)
|
|||
sh->type = stype;
|
||||
sh->region = r;
|
||||
|
||||
sprintf((char*)buffer, "%s %s", LOC(lang, stype->name[0]), shipid(sh));
|
||||
sh->name = xstrdup(buffer);
|
||||
sprintf(buffer, "%s %s", LOC(lang, stype->name[0]), shipid(sh));
|
||||
sh->name = strdup(buffer);
|
||||
shash(sh);
|
||||
addlist(&r->ships, sh);
|
||||
return sh;
|
||||
|
@ -198,22 +198,22 @@ destroy_ship(ship * sh)
|
|||
handle_event(sh->attribs, "destroy", sh);
|
||||
}
|
||||
|
||||
const xmlChar *
|
||||
write_shipname(const ship * sh, xmlChar * ibuf, size_t size)
|
||||
const char *
|
||||
write_shipname(const ship * sh, char * ibuf, size_t size)
|
||||
{
|
||||
snprintf((char*)ibuf, size, "%s (%s)", sh->name, itoa36(sh->no));
|
||||
snprintf(ibuf, size, "%s (%s)", sh->name, itoa36(sh->no));
|
||||
ibuf[size-1] = 0;
|
||||
return ibuf;
|
||||
}
|
||||
|
||||
const xmlChar *
|
||||
const char *
|
||||
shipname(const ship * sh)
|
||||
{
|
||||
typedef char name[OBJECTIDSIZE + 1];
|
||||
static name idbuf[8];
|
||||
static int nextbuf = 0;
|
||||
char *ibuf = idbuf[(++nextbuf) % 8];
|
||||
return write_shipname(sh, (xmlChar*)ibuf, sizeof(name));
|
||||
return write_shipname(sh, ibuf, sizeof(name));
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
@ -70,8 +70,8 @@ typedef struct ship {
|
|||
struct ship *nexthash;
|
||||
int no;
|
||||
struct region *region;
|
||||
xmlChar *name;
|
||||
xmlChar *display;
|
||||
char *name;
|
||||
char *display;
|
||||
struct attrib * attribs;
|
||||
int size;
|
||||
int damage; /* damage in 100th of a point of size */
|
||||
|
@ -87,12 +87,12 @@ extern int shipcapacity(const struct ship * sh);
|
|||
extern void getshipweight(const struct ship * sh, int *weight, int *cabins);
|
||||
|
||||
extern ship *new_ship(const struct ship_type * stype, const struct locale * lang, struct region * r);
|
||||
extern const xmlChar *shipname(const struct ship * sh);
|
||||
extern const xmlChar *write_shipname(const struct ship * sh, xmlChar * buffer, size_t size);
|
||||
extern const char *shipname(const struct ship * sh);
|
||||
extern const char *write_shipname(const struct ship * sh, char * buffer, size_t size);
|
||||
extern struct ship *findship(int n);
|
||||
extern struct ship *findshipr(const struct region *r, int n);
|
||||
|
||||
extern const struct ship_type * findshiptype(const xmlChar *s, const struct locale * lang);
|
||||
extern const struct ship_type * findshiptype(const char *s, const struct locale * lang);
|
||||
|
||||
extern void register_ships(void);
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ const char *skillnames[MAXSKILLS] =
|
|||
|
||||
static boolean skill_enabled[MAXSKILLS];
|
||||
|
||||
const xmlChar *
|
||||
const char *
|
||||
skillname(skill_t sk, const struct locale * lang)
|
||||
{
|
||||
if (skill_enabled[sk]) {
|
||||
|
|
|
@ -46,7 +46,7 @@ extern void skill_init(void);
|
|||
extern void skill_done(void);
|
||||
extern struct attrib * make_skillmod(skill_t sk, unsigned int flags, skillmod_fun special, double multiplier, int bonus);
|
||||
|
||||
extern const xmlChar * skillname(skill_t, const struct locale *);
|
||||
extern const char * skillname(skill_t, const struct locale *);
|
||||
extern skill_t sk_find(const char * name);
|
||||
extern void enable_skill(const char * name, boolean value);
|
||||
extern int level_days(int level);
|
||||
|
|
|
@ -98,7 +98,7 @@ init_spellnames(const struct locale * lang, magic_t mtype)
|
|||
for (slist=spells;slist!=NULL;slist=slist->next) {
|
||||
spell * sp = slist->data;
|
||||
if (sp->magietyp==mtype) {
|
||||
const xmlChar * n = spell_name(sp, lang);
|
||||
const char * n = spell_name(sp, lang);
|
||||
variant token;
|
||||
token.v = sp;
|
||||
addtoken(&sn->names, n, token);
|
||||
|
@ -120,7 +120,7 @@ get_spellnames(const struct locale * lang, magic_t mtype)
|
|||
}
|
||||
|
||||
static spell *
|
||||
get_spellfromtoken_i(const xmlChar *name, const struct locale * lang, magic_t mtype)
|
||||
get_spellfromtoken_i(const char *name, const struct locale * lang, magic_t mtype)
|
||||
{
|
||||
variant token = { 0 };
|
||||
spell_names * sn;
|
||||
|
@ -143,7 +143,7 @@ get_spellfromtoken_i(const xmlChar *name, const struct locale * lang, magic_t mt
|
|||
}
|
||||
|
||||
spell *
|
||||
get_spellfromtoken(unit *u, const xmlChar *name, const struct locale * lang)
|
||||
get_spellfromtoken(unit *u, const char *name, const struct locale * lang)
|
||||
{
|
||||
sc_mage * m = get_mage(u);
|
||||
spell * sp;
|
||||
|
|
|
@ -44,7 +44,7 @@ extern "C" {
|
|||
extern void register_spell(struct spell * sp);
|
||||
extern struct spell * find_spell(magic_t mtype, const char * name);
|
||||
extern struct spell * find_spellbyid(magic_t mtype, spellid_t i);
|
||||
extern struct spell *get_spellfromtoken(struct unit *u, const xmlChar *s, const struct locale * lang);
|
||||
extern struct spell *get_spellfromtoken(struct unit *u, const char *s, const struct locale * lang);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -324,7 +324,7 @@ attrib_type at_private = {
|
|||
a_readstring
|
||||
};
|
||||
|
||||
const xmlChar *
|
||||
const char *
|
||||
u_description(const unit * u, const struct locale * lang)
|
||||
{
|
||||
if (u->display && u->display[0]) {
|
||||
|
@ -335,15 +335,15 @@ u_description(const unit * u, const struct locale * lang)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
const xmlChar *
|
||||
const char *
|
||||
uprivate(const unit * u) {
|
||||
attrib * a = a_find(u->attribs, &at_private);
|
||||
if (!a) return NULL;
|
||||
return (const xmlChar*)a->data.v;
|
||||
return a->data.v;
|
||||
}
|
||||
|
||||
void
|
||||
usetprivate(unit * u, const xmlChar * str) {
|
||||
usetprivate(unit * u, const char * str) {
|
||||
attrib * a = a_find(u->attribs, &at_private);
|
||||
|
||||
if(str == NULL) {
|
||||
|
@ -1273,16 +1273,16 @@ name_unit(unit *u)
|
|||
{
|
||||
free(u->name);
|
||||
if (u->race->generate_name) {
|
||||
const xmlChar * gen_name = u->race->generate_name(u);
|
||||
const char * gen_name = u->race->generate_name(u);
|
||||
if (gen_name) {
|
||||
u->name = xstrdup(gen_name);
|
||||
u->name = strdup(gen_name);
|
||||
} else {
|
||||
u->name = xstrdup(racename(u->faction->locale, u, u->race));
|
||||
u->name = strdup(racename(u->faction->locale, u, u->race));
|
||||
}
|
||||
} else {
|
||||
xmlChar name[16];
|
||||
sprintf((char*)name, "%s %s", LOC(u->faction->locale, "unitdefault"), itoa36(u->no));
|
||||
u->name = xstrdup(name);
|
||||
char name[16];
|
||||
sprintf(name, "%s %s", LOC(u->faction->locale, "unitdefault"), itoa36(u->no));
|
||||
u->name = strdup(name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1292,7 +1292,7 @@ name_unit(unit *u)
|
|||
* @param creator: unit to inherit stealth, group, building, ship, etc. from
|
||||
*/
|
||||
unit *
|
||||
create_unit(region * r, faction * f, int number, const struct race *urace, int id, const xmlChar * dname, unit *creator)
|
||||
create_unit(region * r, faction * f, int number, const struct race *urace, int id, const char * dname, unit *creator)
|
||||
{
|
||||
unit * u = calloc(1, sizeof(unit));
|
||||
order * deford = default_order(f->locale);
|
||||
|
@ -1328,7 +1328,7 @@ create_unit(region * r, faction * f, int number, const struct race *urace, int i
|
|||
if (!dname) {
|
||||
name_unit(u);
|
||||
} else {
|
||||
u->name = xstrdup(dname);
|
||||
u->name = strdup(dname);
|
||||
}
|
||||
if (count_unit(u)) f->no_units++;
|
||||
|
||||
|
|
|
@ -82,8 +82,8 @@ typedef struct unit {
|
|||
struct region *region;
|
||||
int no;
|
||||
int hp;
|
||||
xmlChar *name;
|
||||
xmlChar *display;
|
||||
char *name;
|
||||
char *display;
|
||||
struct faction *faction;
|
||||
struct building *building;
|
||||
struct ship *ship;
|
||||
|
@ -155,8 +155,8 @@ void usettarget(struct unit * u, const struct unit * b);
|
|||
|
||||
extern const struct race * urace(const struct unit * u);
|
||||
|
||||
const xmlChar* uprivate(const struct unit * u);
|
||||
void usetprivate(struct unit * u, const xmlChar * c);
|
||||
const char * uprivate(const struct unit * u);
|
||||
void usetprivate(struct unit * u, const char * c);
|
||||
|
||||
const struct potion_type * ugetpotionuse(const struct unit * u); /* benutzt u einein trank? */
|
||||
void usetpotionuse(struct unit * u, const struct potion_type * p); /* u benutzt trank p (es darf halt nur einer pro runde) */
|
||||
|
@ -167,7 +167,7 @@ void usetcontact(struct unit * u, const struct unit * c);
|
|||
struct unit * findnewunit (const struct region * r, const struct faction *f, int alias);
|
||||
|
||||
extern struct unit * udestroy;
|
||||
extern const xmlChar * u_description(const unit * u, const struct locale * lang);
|
||||
extern const char * u_description(const unit * u, const struct locale * lang);
|
||||
extern struct skill * add_skill(struct unit * u, skill_t id);
|
||||
extern void remove_skill(struct unit *u, skill_t sk);
|
||||
extern struct skill * get_skill(const struct unit * u, skill_t id);
|
||||
|
@ -215,7 +215,7 @@ extern int invisible(const struct unit *target, const struct unit * viewer);
|
|||
extern void stripunit(struct unit * u);
|
||||
|
||||
extern void name_unit(struct unit *u);
|
||||
extern struct unit * create_unit(struct region * r1, struct faction * f, int number, const struct race * rc, int id, const xmlChar * dname, struct unit *creator);
|
||||
extern struct unit * create_unit(struct region * r1, struct faction * f, int number, const struct race * rc, int id, const char * dname, struct unit *creator);
|
||||
|
||||
extern struct attrib_type at_creator;
|
||||
#ifdef __cplusplus
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -238,7 +238,7 @@ read_newfactions(const char * filename)
|
|||
if (nf->race==NULL) {
|
||||
/* if the script didn't supply the race as a token, then it gives us a
|
||||
* race in the default locale (which means that itis a UTF8 string) */
|
||||
nf->race = findrace((const xmlChar*)race, default_locale);
|
||||
nf->race = findrace(race, default_locale);
|
||||
}
|
||||
nf->lang = find_locale(lang);
|
||||
nf->bonus = bonus;
|
||||
|
|
|
@ -150,7 +150,7 @@ gm_create(const tnode * tnext, void * data, struct order * ord)
|
|||
i = getint();
|
||||
|
||||
if (i>0) {
|
||||
const xmlChar * iname = getstrtoken();
|
||||
const char * iname = getstrtoken();
|
||||
const item_type * itype = finditemtype(iname, u->faction->locale);
|
||||
if (itype==NULL) {
|
||||
mistake(u, ord, "Unbekannter Gegenstand.", 0);
|
||||
|
@ -215,7 +215,7 @@ gm_terraform(const tnode * tnext, void * data, struct order * ord)
|
|||
const struct plane * p = rplane(u->region);
|
||||
short x = rel_to_abs(p, u->faction, (short)getint(), 0);
|
||||
short y = rel_to_abs(p, u->faction, (short)getint(), 1);
|
||||
const xmlChar * c = getstrtoken();
|
||||
const char * c = getstrtoken();
|
||||
region * r = findregion(x, y);
|
||||
variant token;
|
||||
tnode * tokens = get_translations(u->faction->locale, UT_TERRAINS);
|
||||
|
@ -274,7 +274,7 @@ gm_messageplane(const tnode * tnext, void * data, struct order * ord)
|
|||
{
|
||||
unit * u = (unit*)data;
|
||||
const struct plane * p = rplane(u->region);
|
||||
const xmlChar * zmsg = getstrtoken();
|
||||
const char * zmsg = getstrtoken();
|
||||
if (p==NULL) {
|
||||
mistake(u, ord, "In diese Ebene kann keine Nachricht gesandt werden.", 0);
|
||||
} else {
|
||||
|
@ -310,7 +310,7 @@ gm_messagefaction(const tnode * tnext, void * data, struct order * ord)
|
|||
unit * u = (unit*)data;
|
||||
int n = getid();
|
||||
faction * f = findfaction(n);
|
||||
const xmlChar * msg = getstrtoken();
|
||||
const char * msg = getstrtoken();
|
||||
plane * p = rplane(u->region);
|
||||
attrib * permissions = a_find(u->faction->attribs, &at_permissions);
|
||||
if (!permissions || !has_permission(permissions, atoi36("gmmsgr"))) {
|
||||
|
@ -341,7 +341,7 @@ gm_messageregion(const tnode * tnext, void * data, struct order * ord)
|
|||
const struct plane * p = rplane(u->region);
|
||||
short x = rel_to_abs(p, u->faction, (short)getint(), 0);
|
||||
short y = rel_to_abs(p, u->faction, (short)getint(), 1);
|
||||
const xmlChar * msg = getstrtoken();
|
||||
const char * msg = getstrtoken();
|
||||
region * r = findregion(x, y);
|
||||
|
||||
if (r==NULL || p!=rplane(r)) {
|
||||
|
@ -368,7 +368,7 @@ gm_killunit(const tnode * tnext, void * data, struct order * ord)
|
|||
unit * u = (unit*)data;
|
||||
const struct plane * p = rplane(u->region);
|
||||
unit * target = findunit(getid());
|
||||
const xmlChar * msg = getstrtoken();
|
||||
const char * msg = getstrtoken();
|
||||
region * r = target->region;
|
||||
|
||||
if (r==NULL || p!=rplane(r)) {
|
||||
|
@ -398,7 +398,7 @@ gm_killfaction(const tnode * tnext, void * data, struct order * ord)
|
|||
unit * u = (unit*)data;
|
||||
int n = getid();
|
||||
faction * f = findfaction(n);
|
||||
const xmlChar * msg = getstrtoken();
|
||||
const char * msg = getstrtoken();
|
||||
plane * p = rplane(u->region);
|
||||
attrib * permissions = a_find(u->faction->attribs, &at_permissions);
|
||||
if (!permissions || !has_permission(permissions, atoi36("gmkill"))) {
|
||||
|
@ -432,7 +432,7 @@ gm_messageunit(const tnode * tnext, void * data, struct order * ord)
|
|||
unit * u = (unit*)data;
|
||||
const struct plane * p = rplane(u->region);
|
||||
unit * target = findunit(getid());
|
||||
const xmlChar * msg = getstrtoken();
|
||||
const char * msg = getstrtoken();
|
||||
region * r;
|
||||
|
||||
if (target == NULL) {
|
||||
|
@ -570,22 +570,22 @@ init_gmcmd(void)
|
|||
{
|
||||
at_register(&at_gmcreate);
|
||||
at_register(&at_permissions);
|
||||
add_command(&g_root, &g_keys, (const xmlChar *)"gm", NULL);
|
||||
add_command(&g_keys, NULL, (const xmlChar *)"terraform", &gm_terraform);
|
||||
add_command(&g_keys, NULL, (const xmlChar *)"create", &gm_create);
|
||||
add_command(&g_keys, NULL, (const xmlChar *)"gate", &gm_gate);
|
||||
add_command(&g_keys, NULL, (const xmlChar *)"give", &gm_give);
|
||||
add_command(&g_keys, NULL, (const xmlChar *)"take", &gm_take);
|
||||
add_command(&g_keys, NULL, (const xmlChar *)"teleport", &gm_teleport);
|
||||
add_command(&g_keys, NULL, (const xmlChar *)"skill", &gm_skill);
|
||||
add_command(&g_keys, &g_tell, (const xmlChar *)"tell", NULL);
|
||||
add_command(&g_tell, NULL, (const xmlChar *)"region", &gm_messageregion);
|
||||
add_command(&g_tell, NULL, (const xmlChar *)"unit", &gm_messageunit);
|
||||
add_command(&g_tell, NULL, (const xmlChar *)"plane", &gm_messageplane);
|
||||
add_command(&g_tell, NULL, (const xmlChar *)"faction", &gm_messagefaction);
|
||||
add_command(&g_keys, &g_kill, (const xmlChar *)"kill", NULL);
|
||||
add_command(&g_kill, NULL, (const xmlChar *)"unit", &gm_killunit);
|
||||
add_command(&g_kill, NULL, (const xmlChar *)"faction", &gm_killfaction);
|
||||
add_command(&g_root, &g_keys, "gm", NULL);
|
||||
add_command(&g_keys, NULL, "terraform", &gm_terraform);
|
||||
add_command(&g_keys, NULL, "create", &gm_create);
|
||||
add_command(&g_keys, NULL, "gate", &gm_gate);
|
||||
add_command(&g_keys, NULL, "give", &gm_give);
|
||||
add_command(&g_keys, NULL, "take", &gm_take);
|
||||
add_command(&g_keys, NULL, "teleport", &gm_teleport);
|
||||
add_command(&g_keys, NULL, "skill", &gm_skill);
|
||||
add_command(&g_keys, &g_tell, "tell", NULL);
|
||||
add_command(&g_tell, NULL, "region", &gm_messageregion);
|
||||
add_command(&g_tell, NULL, "unit", &gm_messageunit);
|
||||
add_command(&g_tell, NULL, "plane", &gm_messageplane);
|
||||
add_command(&g_tell, NULL, "faction", &gm_messagefaction);
|
||||
add_command(&g_keys, &g_kill, "kill", NULL);
|
||||
add_command(&g_kill, NULL, "unit", &gm_killunit);
|
||||
add_command(&g_kill, NULL, "faction", &gm_killfaction);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -681,8 +681,8 @@ gm_addfaction(const char * email, plane * p, region * r)
|
|||
|
||||
/* GM faction */
|
||||
a_add(&f->attribs, make_key(atoi36("quest")));
|
||||
f->banner = (xmlChar*)strdup("quest faction");
|
||||
f->name = (xmlChar*)strdup("quest faction");
|
||||
f->banner = strdup("quest faction");
|
||||
f->name = strdup("quest faction");
|
||||
f->passw = strdup(itoa36(rng_int()));
|
||||
f->override = strdup(itoa36(rng_int()));
|
||||
if (set_email(&f->email, email)!=0) {
|
||||
|
@ -724,7 +724,7 @@ gm_addfaction(const char * email, plane * p, region * r)
|
|||
a_add((attrib**)&a->data.v, make_atgmcreate(olditemtype[i]));
|
||||
}
|
||||
/* one initial unit */
|
||||
u = create_unit(r, f, 1, new_race[RC_TEMPLATE], 1, (const xmlChar*)"quest master", NULL);
|
||||
u = create_unit(r, f, 1, new_race[RC_TEMPLATE], 1, "quest master", NULL);
|
||||
u->irace = new_race[RC_GNOME];
|
||||
|
||||
return f;
|
||||
|
|
|
@ -76,7 +76,7 @@ xe_givepotion(unit *u, struct order *ord)
|
|||
static void
|
||||
xe_giveballon(unit *u, struct order *ord)
|
||||
{
|
||||
unit *u2 =getunitg(u->region, u->faction);
|
||||
unit *u2 = getunitg(u->region, u->faction);
|
||||
ship *sh;
|
||||
|
||||
if(!u2) {
|
||||
|
@ -87,7 +87,7 @@ xe_giveballon(unit *u, struct order *ord)
|
|||
sh = new_ship(st_find("balloon"), u2->faction->locale, u2->region);
|
||||
sh->size = 5;
|
||||
free(sh->name);
|
||||
sh->name = xstrdup(BAD_CAST "Xontormia-Ballon");
|
||||
sh->name = strdup("Xontormia-Ballon");
|
||||
leave(u2->region, u2);
|
||||
u2->ship = sh;
|
||||
fset(u2, UFL_OWNER);
|
||||
|
|
|
@ -1577,7 +1577,7 @@ sp_undeadhero(fighter * fi, int level, double power, spell * sp)
|
|||
|
||||
/* new units gets some stats from old unit */
|
||||
free(u->display);
|
||||
u->display = xstrdup(du->display);
|
||||
u->display = strdup(du->display);
|
||||
setstatus(u, du->status);
|
||||
setguard(u, GUARD_NONE);
|
||||
|
||||
|
|
|
@ -545,7 +545,7 @@ sp_summon_familiar(castorder *co)
|
|||
int dh, dh1;
|
||||
direction_t d;
|
||||
message * msg;
|
||||
xmlChar zText[NAMESIZE];
|
||||
char zText[NAMESIZE];
|
||||
size_t size;
|
||||
|
||||
if (get_familiar(mage) != NULL ) {
|
||||
|
@ -581,7 +581,7 @@ sp_summon_familiar(castorder *co)
|
|||
}
|
||||
|
||||
msg = msg_message("familiar_name", "unit", mage);
|
||||
nr_render(msg, mage->faction->locale, (char *)zText, sizeof(zText), mage->faction);
|
||||
nr_render(msg, mage->faction->locale, zText, sizeof(zText), mage->faction);
|
||||
msg_release(msg);
|
||||
familiar = create_unit(target_region, mage->faction, 1, rc, 0, zText, mage);
|
||||
setstatus(familiar, ST_FLEE);
|
||||
|
@ -602,12 +602,12 @@ sp_summon_familiar(castorder *co)
|
|||
dh1 = 1;
|
||||
} else {
|
||||
if (dh == 0) {
|
||||
size -= strlcat((char*)zText, (const char*)LOC(mage->faction->locale, "list_and"), size);
|
||||
size -= strlcat(zText, (const char*)LOC(mage->faction->locale, "list_and"), size);
|
||||
} else {
|
||||
size -= strlcat((char*)zText, (const char*)", ", size);
|
||||
size -= strlcat(zText, (const char*)", ", size);
|
||||
}
|
||||
}
|
||||
size -= strlcat((char*)zText, (const char*)skillname(sk, mage->faction->locale), size);
|
||||
size -= strlcat(zText, (const char*)skillname(sk, mage->faction->locale), size);
|
||||
}
|
||||
}
|
||||
ADDMSG(&mage->faction->msgs, msg_message("familiar_describe",
|
||||
|
@ -636,7 +636,7 @@ sp_destroy_magic(castorder *co)
|
|||
double force = co->force;
|
||||
spellparameter *pa = co->par;
|
||||
curse * c = NULL;
|
||||
xmlChar ts[80];
|
||||
char ts[80];
|
||||
attrib **ap;
|
||||
int obj;
|
||||
int succ;
|
||||
|
@ -4349,7 +4349,7 @@ sp_pump(castorder *co)
|
|||
ADDMSG(&mage->faction->msgs, msg_message("pump_effect", "mage unit tregion", mage, target, rt));
|
||||
}
|
||||
|
||||
u = create_unit(rt, mage->faction, RS_FARVISION, new_race[RC_SPELL], 0, (const xmlChar*)"spell/pump", NULL);
|
||||
u = create_unit(rt, mage->faction, RS_FARVISION, new_race[RC_SPELL], 0, "spell/pump", NULL);
|
||||
u->age = 2;
|
||||
set_level(u, SK_OBSERVATION, eff_skill(target, SK_OBSERVATION, u->region));
|
||||
|
||||
|
@ -4766,7 +4766,7 @@ sp_icastle(castorder *co)
|
|||
double power = co->force;
|
||||
spellparameter *pa = co->par;
|
||||
icastle_data * data;
|
||||
const xmlChar * bname;
|
||||
const char * bname;
|
||||
message * msg;
|
||||
|
||||
if ((type=findbuildingtype(pa->param[0]->data.xs, mage->faction->locale)) == NULL) {
|
||||
|
@ -4790,7 +4790,7 @@ sp_icastle(castorder *co)
|
|||
bname = LOC(mage->faction->locale, buildingtype(type, b, 0));
|
||||
}
|
||||
free(b->name);
|
||||
b->name = xstrdup(bname);
|
||||
b->name = strdup(bname);
|
||||
|
||||
/* TODO: Auf timeout und action_destroy umstellen */
|
||||
a = a_add(&b->attribs, a_new(&at_icastle));
|
||||
|
@ -5031,7 +5031,7 @@ sp_clonecopy(castorder *co)
|
|||
}
|
||||
|
||||
snprintf(name, sizeof(name), (const char*)LOC(mage->faction->locale, "clone_of"), unitname(mage));
|
||||
clone = create_unit(target_region, mage->faction, 1, new_race[RC_CLONE], 0, (const xmlChar *)name, mage);
|
||||
clone = create_unit(target_region, mage->faction, 1, new_race[RC_CLONE], 0, name, mage);
|
||||
setstatus(clone, ST_FLEE);
|
||||
fset(clone, UFL_LOCKED);
|
||||
|
||||
|
@ -5077,7 +5077,7 @@ sp_dreamreading(castorder *co)
|
|||
return 0;
|
||||
}
|
||||
|
||||
u2 = create_unit(u->region,mage->faction, RS_FARVISION, new_race[RC_SPELL], 0, (const xmlChar*)"spell/dreamreading", NULL);
|
||||
u2 = create_unit(u->region,mage->faction, RS_FARVISION, new_race[RC_SPELL], 0, "spell/dreamreading", NULL);
|
||||
set_number(u2, 1);
|
||||
u2->age = 2; /* Nur für diese Runde. */
|
||||
set_level(u2, SK_OBSERVATION, eff_skill(u, SK_OBSERVATION, u2->region));
|
||||
|
@ -5944,7 +5944,7 @@ sp_viewreality(castorder *co)
|
|||
|
||||
/* Irgendwann mal auf Curses u/o Attribut umstellen. */
|
||||
for (rl2=rl; rl2; rl2=rl2->next) {
|
||||
u = create_unit(rl2->data, mage->faction, RS_FARVISION, new_race[RC_SPELL], 0, (const xmlChar*)"spell/viewreality", NULL);
|
||||
u = create_unit(rl2->data, mage->faction, RS_FARVISION, new_race[RC_SPELL], 0, "spell/viewreality", NULL);
|
||||
set_level(u, SK_OBSERVATION, co->level/2);
|
||||
u->age = 2;
|
||||
}
|
||||
|
@ -6607,7 +6607,7 @@ sp_q_antimagie(castorder *co)
|
|||
int cast_level = co->level;
|
||||
double force = co->force;
|
||||
spellparameter *pa = co->par;
|
||||
const xmlChar *ts = NULL;
|
||||
const char *ts = NULL;
|
||||
|
||||
obj = pa->param[0]->typ;
|
||||
|
||||
|
@ -6622,21 +6622,21 @@ sp_q_antimagie(castorder *co)
|
|||
{
|
||||
unit *u = pa->param[0]->data.u;
|
||||
ap = &u->attribs;
|
||||
ts = (const xmlChar *) unitid(u);
|
||||
ts = unitid(u);
|
||||
break;
|
||||
}
|
||||
case SPP_BUILDING:
|
||||
{
|
||||
building *b = pa->param[0]->data.b;
|
||||
ap = &b->attribs;
|
||||
ts =(const xmlChar *) buildingid(b);
|
||||
ts = buildingid(b);
|
||||
break;
|
||||
}
|
||||
case SPP_SHIP:
|
||||
{
|
||||
ship *sh = pa->param[0]->data.sh;
|
||||
ap = &sh->attribs;
|
||||
ts =(const xmlChar *) shipid(sh);
|
||||
ts = shipid(sh);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -6688,7 +6688,7 @@ sp_break_curse(castorder *co)
|
|||
int cast_level = co->level;
|
||||
double force = co->force;
|
||||
spellparameter *pa = co->par;
|
||||
const xmlChar *ts = NULL;
|
||||
const char *ts = NULL;
|
||||
|
||||
if (pa->length < 2) {
|
||||
/* Das Zielobjekt wurde vergessen */
|
||||
|
@ -6715,21 +6715,21 @@ sp_break_curse(castorder *co)
|
|||
{
|
||||
unit *u = pa->param[0]->data.u;
|
||||
ap = &u->attribs;
|
||||
ts = (const xmlChar *)unitid(u);
|
||||
ts = unitid(u);
|
||||
break;
|
||||
}
|
||||
case SPP_BUILDING:
|
||||
{
|
||||
building *b = pa->param[0]->data.b;
|
||||
ap = &b->attribs;
|
||||
ts = (const xmlChar *)buildingid(b);
|
||||
ts = buildingid(b);
|
||||
break;
|
||||
}
|
||||
case SPP_SHIP:
|
||||
{
|
||||
ship *sh = pa->param[0]->data.sh;
|
||||
ap = &sh->attribs;
|
||||
ts = (const xmlChar *)shipid(sh);
|
||||
ts = shipid(sh);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -6856,7 +6856,7 @@ sp_wdwpyramid(castorder *co)
|
|||
typedef struct spelldata {
|
||||
spellid_t id;
|
||||
const char *sname;
|
||||
const xmlChar *info;
|
||||
const char *info;
|
||||
const char *syntax;
|
||||
const char *parameter;
|
||||
magic_t magietyp;
|
||||
|
|
|
@ -81,8 +81,7 @@ static void
|
|||
unitmessage_write(const trigger * t, FILE * F)
|
||||
{
|
||||
unitmessage_data * td = (unitmessage_data*)t->data.v;
|
||||
fprintf(F, "%s ", itoa36(td->target->no));
|
||||
fwritestr(F, td->string);
|
||||
fprintf(F, "%s %s", itoa36(td->target->no), td->string);
|
||||
fprintf(F, " %d %d ", td->type, td->level);
|
||||
}
|
||||
|
||||
|
@ -98,7 +97,7 @@ unitmessage_read(trigger * t, FILE * F)
|
|||
td->target = findunit(var.i);
|
||||
if (td->target==NULL) ur_add(var, (void**)&td->target, resolve_unit);
|
||||
|
||||
freadstr(F, zText, sizeof(zText));
|
||||
fscanf(F, "%s", zText);
|
||||
fscanf(F, "%d %d ", &td->type, &td->level);
|
||||
td->string = strdup(zText);
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ eatwhite(const char * ptr, size_t * total_size)
|
|||
while (*ptr) {
|
||||
wint_t ucs;
|
||||
size_t size = 0;
|
||||
ret = unicode_utf8_to_ucs4(&ucs, (const xmlChar*)ptr, &size);
|
||||
ret = unicode_utf8_to_ucs4(&ucs, ptr, &size);
|
||||
if (ret!=0) break;
|
||||
if (!iswspace(ucs)) break;
|
||||
*total_size += size;
|
||||
|
@ -40,7 +40,7 @@ eatwhite(const char * ptr, size_t * total_size)
|
|||
return ret;
|
||||
}
|
||||
|
||||
const xmlChar *
|
||||
const char *
|
||||
getbuf(FILE * F, int encoding)
|
||||
{
|
||||
boolean cont = false;
|
||||
|
@ -100,7 +100,7 @@ getbuf(FILE * F, int encoding)
|
|||
}
|
||||
}
|
||||
|
||||
ret = unicode_utf8_to_ucs4(&ucs, (const xmlChar *)bp, &size);
|
||||
ret = unicode_utf8_to_ucs4(&ucs, bp, &size);
|
||||
|
||||
if (ret!=0) {
|
||||
unicode_warning(bp);
|
||||
|
@ -159,5 +159,5 @@ getbuf(FILE * F, int encoding)
|
|||
}
|
||||
*cp=0;
|
||||
} while (cont || cp==fbuf);
|
||||
return (const xmlChar*)fbuf;
|
||||
return fbuf;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
const xmlChar * getbuf(FILE *, int encoding);
|
||||
const char * getbuf(FILE *, int encoding);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ debug_language(const char * log)
|
|||
s_logfile = strdup(log);
|
||||
}
|
||||
|
||||
const xmlChar *
|
||||
const char *
|
||||
locale_getstring(const locale * lang, const char * key)
|
||||
{
|
||||
unsigned int hkey = hashstring(key);
|
||||
|
@ -102,7 +102,7 @@ locale_getstring(const locale * lang, const char * key)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
const xmlChar *
|
||||
const char *
|
||||
locale_string(const locale * lang, const char * key)
|
||||
{
|
||||
if (key!=NULL) {
|
||||
|
@ -111,7 +111,7 @@ locale_string(const locale * lang, const char * key)
|
|||
struct locale_str * find;
|
||||
|
||||
if (key == NULL || *key==0) return NULL;
|
||||
if (lang == NULL) return BAD_CAST key;
|
||||
if (lang == NULL) return key;
|
||||
find = lang->strings[id];
|
||||
while (find) {
|
||||
if (find->hashkey == hkey) {
|
||||
|
@ -125,7 +125,7 @@ locale_string(const locale * lang, const char * key)
|
|||
find = find->nexthash;
|
||||
}
|
||||
if (!find) {
|
||||
const xmlChar * s = BAD_CAST key;
|
||||
const char * s = key;
|
||||
log_warning(("missing translation for \"%s\" in locale %s\n", key, lang->name));
|
||||
if (lang!=default_locale) {
|
||||
s = locale_string(default_locale, key);
|
||||
|
@ -146,7 +146,7 @@ locale_string(const locale * lang, const char * key)
|
|||
}
|
||||
|
||||
void
|
||||
locale_setstring(locale * lang, const char * key, const xmlChar * value)
|
||||
locale_setstring(locale * lang, const char * key, const char * value)
|
||||
{
|
||||
unsigned int hkey = hashstring(key);
|
||||
unsigned int id = hkey & (SMAXHASH-1);
|
||||
|
@ -163,13 +163,13 @@ locale_setstring(locale * lang, const char * key, const xmlChar * value)
|
|||
lang->strings[id] = find;
|
||||
find->hashkey = hkey;
|
||||
find->key = strdup(key);
|
||||
find->str = xmlStrdup(value);
|
||||
find->str = strdup(value);
|
||||
}
|
||||
else {
|
||||
if (xmlStrcmp(find->str, value)!=0) {
|
||||
if (strcmp(find->str, value)!=0) {
|
||||
log_error(("Duplicate key %s for '%s' and '%s'\n", key, value, find->str));
|
||||
}
|
||||
assert(!xmlStrcmp(find->str, value) || !"duplicate string for key");
|
||||
assert(!strcmp(find->str, value) || !"duplicate string for key");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,9 +24,9 @@ extern struct locale * find_locale(const char * name);
|
|||
extern struct locale * make_locale(const char * key);
|
||||
|
||||
/** operations on locales: **/
|
||||
extern void locale_setstring(struct locale * lang, const char * key, const xmlChar * value);
|
||||
extern const xmlChar * locale_getstring(const struct locale * lang, const char * key);
|
||||
extern const xmlChar * locale_string(const struct locale * lang, const char * key); /* does fallback */
|
||||
extern void locale_setstring(struct locale * lang, const char * key, const char * value);
|
||||
extern const char * locale_getstring(const struct locale * lang, const char * key);
|
||||
extern const char * locale_string(const struct locale * lang, const char * key); /* does fallback */
|
||||
extern unsigned int locale_hashkey(const struct locale * lang);
|
||||
extern const char * locale_name(const struct locale * lang);
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
typedef struct locale_str {
|
||||
unsigned int hashkey;
|
||||
struct locale_str * nexthash;
|
||||
xmlChar * str;
|
||||
char * str;
|
||||
char * key;
|
||||
} locale_str;
|
||||
|
||||
|
|
|
@ -12,15 +12,15 @@
|
|||
#define MAXTOKENSIZE 8192
|
||||
|
||||
typedef struct parser_state {
|
||||
const xmlChar *current_token;
|
||||
xmlChar * current_cmd;
|
||||
const char *current_token;
|
||||
char * current_cmd;
|
||||
struct parser_state * next;
|
||||
} parser_state;
|
||||
|
||||
static parser_state * state;
|
||||
|
||||
static int
|
||||
eatwhitespace_c(const xmlChar ** str)
|
||||
eatwhitespace_c(const char ** str)
|
||||
{
|
||||
int ret;
|
||||
wint_t ucs;
|
||||
|
@ -28,8 +28,8 @@ eatwhitespace_c(const xmlChar ** str)
|
|||
|
||||
/* skip over potential whitespace */
|
||||
for (;;) {
|
||||
xmlChar utf8_character = (*str)[0];
|
||||
if (utf8_character <= 0x7F) {
|
||||
unsigned char utf8_character = (*(unsigned char**)str)[0];
|
||||
if (~utf8_character & 0x80) {
|
||||
if (!iswspace(utf8_character)) break;
|
||||
++*str;
|
||||
} else {
|
||||
|
@ -46,14 +46,14 @@ eatwhitespace_c(const xmlChar ** str)
|
|||
}
|
||||
|
||||
void
|
||||
init_tokens_str(const xmlChar * initstr, xmlChar * cmd)
|
||||
init_tokens_str(const char * initstr, char * cmd)
|
||||
{
|
||||
if (state==NULL) {
|
||||
state = malloc(sizeof(parser_state));
|
||||
}
|
||||
else if (state->current_cmd) free(state->current_cmd);
|
||||
state->current_cmd = cmd;
|
||||
state->current_token = (const xmlChar *)initstr;
|
||||
state->current_token = initstr;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -92,8 +92,8 @@ skip_token(void)
|
|||
wint_t ucs;
|
||||
size_t len;
|
||||
|
||||
xmlChar utf8_character = state->current_token[0];
|
||||
if (utf8_character <= 0x7F) {
|
||||
unsigned char utf8_character = (unsigned char)state->current_token[0];
|
||||
if (~utf8_character & 0x80) {
|
||||
ucs = utf8_character;
|
||||
++state->current_token;
|
||||
} else {
|
||||
|
@ -121,14 +121,14 @@ skip_token(void)
|
|||
}
|
||||
}
|
||||
|
||||
const xmlChar *
|
||||
parse_token(const xmlChar ** str)
|
||||
const char *
|
||||
parse_token(const char ** str)
|
||||
{
|
||||
static xmlChar lbuf[MAXTOKENSIZE];
|
||||
xmlChar * cursor = lbuf;
|
||||
static char lbuf[MAXTOKENSIZE];
|
||||
char * cursor = lbuf;
|
||||
char quotechar = 0;
|
||||
boolean escape = false;
|
||||
const xmlChar * ctoken = *str;
|
||||
const char * ctoken = *str;
|
||||
|
||||
assert(ctoken);
|
||||
|
||||
|
@ -138,8 +138,8 @@ parse_token(const xmlChar ** str)
|
|||
size_t len;
|
||||
boolean copy = false;
|
||||
|
||||
xmlChar utf8_character = *ctoken;
|
||||
if (utf8_character <= 0x7F) {
|
||||
unsigned char utf8_character = *(unsigned char *)ctoken;
|
||||
if (~utf8_character & 0x80) {
|
||||
ucs = utf8_character;
|
||||
len = 1;
|
||||
} else {
|
||||
|
@ -185,8 +185,8 @@ parse_token(const xmlChar ** str)
|
|||
return lbuf;
|
||||
}
|
||||
|
||||
const xmlChar *
|
||||
const char *
|
||||
getstrtoken(void)
|
||||
{
|
||||
return parse_token((const xmlChar**)&state->current_token);
|
||||
return parse_token((const char **)&state->current_token);
|
||||
}
|
||||
|
|
|
@ -14,13 +14,13 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern void init_tokens_str(const xmlChar * initstr, xmlChar * cmd); /* initialize token parsing, take ownership of cmd */
|
||||
extern void init_tokens_str(const char * initstr, char * cmd); /* initialize token parsing, take ownership of cmd */
|
||||
extern void skip_token(void);
|
||||
extern const xmlChar * parse_token(const xmlChar ** str);
|
||||
extern const char * parse_token(const char ** str);
|
||||
extern void parser_pushstate(void);
|
||||
extern void parser_popstate(void);
|
||||
extern boolean parser_end(void);
|
||||
extern const xmlChar *getstrtoken(void);
|
||||
extern const char *getstrtoken(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ typedef struct tref {
|
|||
#define SHARED 2 /* at least two words share the node */
|
||||
|
||||
void
|
||||
addtoken(tnode * root, const xmlChar * str, variant id)
|
||||
addtoken(tnode * root, const char * str, variant id)
|
||||
{
|
||||
static struct replace {
|
||||
wint_t ucs;
|
||||
|
@ -116,9 +116,9 @@ addtoken(tnode * root, const xmlChar * str, variant id)
|
|||
addtoken(next->node, str+len, id);
|
||||
while (replace[i].str[0]) {
|
||||
if (lcs==replace[i].ucs) {
|
||||
xmlChar zText[1024];
|
||||
char zText[1024];
|
||||
memcpy(zText, replace[i].str, 3);
|
||||
strcpy((char*)zText+2, (const char*)str+len);
|
||||
strcpy(zText+2, (const char*)str+len);
|
||||
addtoken(root, zText, id);
|
||||
break;
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ addtoken(tnode * root, const xmlChar * str, variant id)
|
|||
}
|
||||
|
||||
int
|
||||
findtoken(const tnode * tk, const xmlChar * str, variant* result)
|
||||
findtoken(const tnode * tk, const char * str, variant* result)
|
||||
{
|
||||
if (!str || *str==0) return E_TOK_NOMATCH;
|
||||
|
||||
|
|
|
@ -32,8 +32,8 @@ typedef struct tnode {
|
|||
variant id;
|
||||
} tnode;
|
||||
|
||||
int findtoken(const struct tnode * tk, const xmlChar * str, variant* result);
|
||||
void addtoken(struct tnode * root, const xmlChar* str, variant id);
|
||||
int findtoken(const struct tnode * tk, const char * str, variant* result);
|
||||
void addtoken(struct tnode * root, const char * str, variant id);
|
||||
|
||||
typedef struct local_names {
|
||||
struct local_names * next;
|
||||
|
|
|
@ -14,19 +14,19 @@
|
|||
#include <errno.h>
|
||||
|
||||
int
|
||||
unicode_utf8_strcasecmp(const xmlChar * a, const xmlChar * b)
|
||||
unicode_utf8_strcasecmp(const char * a, const char * b)
|
||||
{
|
||||
while (*a && *b) {
|
||||
int ret;
|
||||
size_t size;
|
||||
wint_t ucsa = *a, ucsb = *b;
|
||||
|
||||
if (ucsa>0x7F) {
|
||||
if (ucsa & 0x80) {
|
||||
ret = unicode_utf8_to_ucs4(&ucsa, a, &size);
|
||||
if (ret!=0) return -1;
|
||||
a += size;
|
||||
} else ++a;
|
||||
if (ucsb>0x7F) {
|
||||
if (ucsb & 0x80) {
|
||||
ret = unicode_utf8_to_ucs4(&ucsb, b, &size);
|
||||
if (ret!=0) return -1;
|
||||
b += size;
|
||||
|
@ -46,14 +46,14 @@ unicode_utf8_strcasecmp(const xmlChar * a, const xmlChar * b)
|
|||
|
||||
/* Convert a UTF-8 encoded character to UCS-4. */
|
||||
int
|
||||
unicode_utf8_to_ucs4(wint_t *ucs4_character, const xmlChar *utf8_string,
|
||||
unicode_utf8_to_ucs4(wint_t *ucs4_character, const char *utf8_string,
|
||||
size_t *length)
|
||||
{
|
||||
xmlChar utf8_character = utf8_string[0];
|
||||
unsigned char utf8_character = (unsigned char)utf8_string[0];
|
||||
|
||||
/* Is the character in the ASCII range? If so, just copy it to the
|
||||
output. */
|
||||
if (utf8_character <= 0x7F)
|
||||
if (~utf8_character & 0x80)
|
||||
{
|
||||
*ucs4_character = utf8_character;
|
||||
*length = 1;
|
||||
|
|
|
@ -21,8 +21,8 @@ extern "C" {
|
|||
|
||||
#include <wchar.h>
|
||||
#define USE_UNICODE
|
||||
extern int unicode_utf8_to_ucs4(wint_t *ucs4_character, const xmlChar *utf8_string, size_t *length);
|
||||
extern int unicode_utf8_strcasecmp(const xmlChar * a, const xmlChar * b);
|
||||
extern int unicode_utf8_to_ucs4(wint_t *ucs4_character, const char *utf8_string, size_t *length);
|
||||
extern int unicode_utf8_strcasecmp(const char * a, const char * b);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -26,10 +26,10 @@ int
|
|||
xml_ivalue(xmlNodePtr node, const char * name, int dflt)
|
||||
{
|
||||
int i = dflt;
|
||||
xmlChar * property = xmlGetProp(node, BAD_CAST name);
|
||||
if (property!=NULL) {
|
||||
i = atoi((const char*)property);
|
||||
xmlFree(property);
|
||||
xmlChar * propValue = xmlGetProp(node, BAD_CAST name);
|
||||
if (propValue!=NULL) {
|
||||
i = atoi((const char*)propValue);
|
||||
xmlFree(propValue);
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
@ -38,21 +38,21 @@ boolean
|
|||
xml_bvalue(xmlNodePtr node, const char * name, boolean dflt)
|
||||
{
|
||||
boolean result = dflt;
|
||||
xmlChar * property = xmlGetProp(node, BAD_CAST name);
|
||||
if (property!=NULL) {
|
||||
if (strcmp((const char*)property, "no")==0) result = false;
|
||||
else if (strcmp((const char*)property, "yes")==0) result = true;
|
||||
else if (strcmp((const char*)property, "false")==0) result = true;
|
||||
else if (strcmp((const char*)property, "true")==0) result = true;
|
||||
else if (strcmp((const char*)property, "1")==0) {
|
||||
xmlChar * propValue = xmlGetProp(node, BAD_CAST name);
|
||||
if (propValue!=NULL) {
|
||||
if (strcmp((const char*)propValue, "no")==0) result = false;
|
||||
else if (strcmp((const char*)propValue, "yes")==0) result = true;
|
||||
else if (strcmp((const char*)propValue, "false")==0) result = true;
|
||||
else if (strcmp((const char*)propValue, "true")==0) result = true;
|
||||
else if (strcmp((const char*)propValue, "1")==0) {
|
||||
log_warning(("boolean value is '1': %s::%s\n", node->name, name));
|
||||
result = true;
|
||||
}
|
||||
else if (strcmp((const char*)property, "0")==0) {
|
||||
else if (strcmp((const char*)propValue, "0")==0) {
|
||||
log_warning(("boolean value is '0': %s::%s\n", node->name, name));
|
||||
result = false;
|
||||
}
|
||||
xmlFree(property);
|
||||
xmlFree(propValue);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -61,10 +61,10 @@ double
|
|||
xml_fvalue(xmlNodePtr node, const char * name, double dflt)
|
||||
{
|
||||
double result = dflt;
|
||||
xmlChar * property = xmlGetProp(node, BAD_CAST name);
|
||||
if (property!=NULL) {
|
||||
result = atof((const char*)property);
|
||||
xmlFree(property);
|
||||
xmlChar * propValue = xmlGetProp(node, BAD_CAST name);
|
||||
if (propValue!=NULL) {
|
||||
result = atof((const char*)propValue);
|
||||
xmlFree(propValue);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
10
src/config.h
10
src/config.h
|
@ -261,15 +261,5 @@ extern char * strdup(const char *s);
|
|||
# define INLINE_FUNCTION
|
||||
#endif
|
||||
|
||||
#include <libxml/xmlstring.h>
|
||||
|
||||
#define xstrlen(a) strlen((const char*)(a))
|
||||
#define xstrcmp(a, b) strcmp((const char*)(a), (const char *)(b))
|
||||
#define xstrcat(a, b) (xmlChar *)strcat((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)
|
||||
#define xstrlcat(a, b, s) strlcat((char*)(a), (const char *)(b), s)
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1293,14 +1293,16 @@ curses_readline(lua_State * L, const char * prompt)
|
|||
}
|
||||
|
||||
static dictionary * inifile;
|
||||
|
||||
static void
|
||||
load_inifile(const char * filename)
|
||||
{
|
||||
dictionary * d = iniparser_new(filename);
|
||||
if (d) {
|
||||
g_basedir = iniparser_getstr(d, "common:base");
|
||||
g_resourcedir = iniparser_getstr(d, "common:res");
|
||||
xmlfile = iniparser_getstr(d, "common:xml");
|
||||
g_basedir = iniparser_getstring(d, "common:base", g_basedir);
|
||||
g_resourcedir = iniparser_getstring(d, "common:res", g_resourcedir);
|
||||
xmlfile = iniparser_getstring(d, "common:xml", xmlfile);
|
||||
enc_gamedata = iniparser_getstring(d, "common:gamedata_encoding", enc_gamedata);
|
||||
}
|
||||
inifile = d;
|
||||
}
|
||||
|
@ -1333,7 +1335,7 @@ gmmain(int argc, char *argv[])
|
|||
if (turn>first_turn) {
|
||||
char datafile[12];
|
||||
sprintf(datafile, "%u", turn);
|
||||
readgame(datafile, 0);
|
||||
readgame(datafile, 0, enc_gamedata);
|
||||
}
|
||||
|
||||
run_mapper();
|
||||
|
|
|
@ -88,7 +88,7 @@ static void
|
|||
building_setinfo(building& b, const char * info)
|
||||
{
|
||||
free(b.display);
|
||||
b.display = (xmlChar*)strdup(info);
|
||||
b.display = strdup(info);
|
||||
}
|
||||
|
||||
static const char *
|
||||
|
@ -101,7 +101,7 @@ static void
|
|||
building_setname(building& b, const char * name)
|
||||
{
|
||||
free(b.name);
|
||||
b.name = (xmlChar*)strdup(name);
|
||||
b.name = strdup(name);
|
||||
}
|
||||
|
||||
static region *
|
||||
|
|
|
@ -103,7 +103,7 @@ static void
|
|||
lua_setstring(const char * lname, const char * key, const char * str)
|
||||
{
|
||||
struct locale * lang = find_locale(lname);
|
||||
locale_setstring(lang, key, (const xmlChar*)str);
|
||||
locale_setstring(lang, key, str);
|
||||
}
|
||||
|
||||
static const char *
|
||||
|
|
|
@ -37,9 +37,9 @@ using namespace luabind;
|
|||
static faction *
|
||||
add_faction(const char * email, const char * racename, const char * lang)
|
||||
{
|
||||
const race * frace = findrace((const xmlChar*)racename, default_locale);
|
||||
if (frace==NULL) frace = findrace((const xmlChar*)racename, find_locale("de"));
|
||||
if (frace==NULL) frace = findrace((const xmlChar*)racename, find_locale("en"));
|
||||
const race * frace = findrace(racename, default_locale);
|
||||
if (frace==NULL) frace = findrace(racename, find_locale("de"));
|
||||
if (frace==NULL) frace = findrace(racename, find_locale("en"));
|
||||
if (frace==NULL) return NULL;
|
||||
locale * loc = find_locale(lang);
|
||||
faction * f = addfaction(email, NULL, frace, loc, 0);
|
||||
|
@ -176,7 +176,7 @@ faction_additem(faction& f, const char * iname, int number)
|
|||
static void
|
||||
faction_addnotice(faction& f, const char * str)
|
||||
{
|
||||
const xmlChar * loc = LOC(f.locale, str);
|
||||
const char * loc = LOC(f.locale, str);
|
||||
ADDMSG(&f.msgs, msg_message("msg_event", "string", loc));
|
||||
}
|
||||
|
||||
|
@ -217,7 +217,7 @@ void
|
|||
faction_set_banner(faction& f, const char * banner)
|
||||
{
|
||||
free(f.banner);
|
||||
f.banner = BAD_CAST strdup(banner);
|
||||
f.banner = strdup(banner);
|
||||
}
|
||||
|
||||
const char *
|
||||
|
|
|
@ -90,13 +90,13 @@ lua_writereports(void)
|
|||
static void
|
||||
message_unit(unit& sender, unit& target, const char * str)
|
||||
{
|
||||
deliverMail(target.faction, sender.region, &sender, (const xmlChar *)str, &target);
|
||||
deliverMail(target.faction, sender.region, &sender, str, &target);
|
||||
}
|
||||
|
||||
static void
|
||||
message_faction(unit& sender, faction& target, const char * str)
|
||||
{
|
||||
deliverMail(&target, sender.region, &sender, (const xmlChar *)str, NULL);
|
||||
deliverMail(&target, sender.region, &sender, str, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -106,9 +106,9 @@ message_region(unit& sender, const char * str)
|
|||
}
|
||||
|
||||
static int
|
||||
read_game(const char * filename)
|
||||
read_game(const char * filename, const char * encoding)
|
||||
{
|
||||
int rv = readgame(filename, false);
|
||||
int rv = readgame(filename, false, encoding);
|
||||
printf(" - Korrekturen Runde %d\n", turn);
|
||||
korrektur();
|
||||
return rv;
|
||||
|
|
|
@ -51,7 +51,7 @@ region_ships(const region& r) {
|
|||
|
||||
static void
|
||||
region_setname(region& r, const char * name) {
|
||||
if (r.land) rsetname((&r), (const xmlChar *)name);
|
||||
if (r.land) rsetname((&r), name);
|
||||
}
|
||||
|
||||
static const char *
|
||||
|
@ -94,7 +94,7 @@ static void
|
|||
region_setinfo(region& r, const char * info)
|
||||
{
|
||||
free(r.display);
|
||||
r.display = xstrdup(info);
|
||||
r.display = strdup(info);
|
||||
}
|
||||
|
||||
static const char *
|
||||
|
@ -112,7 +112,7 @@ region_plane(const region& r)
|
|||
static void
|
||||
region_addnotice(region& r, const char * str)
|
||||
{
|
||||
addmessage(&r, NULL, (const xmlChar *)str, MSG_MESSAGE, ML_IMPORTANT);
|
||||
addmessage(&r, NULL, str, MSG_MESSAGE, ML_IMPORTANT);
|
||||
}
|
||||
|
||||
static std::ostream&
|
||||
|
|
|
@ -380,7 +380,7 @@ static void
|
|||
unit_setname(unit& u, const char * name)
|
||||
{
|
||||
free(u.name);
|
||||
u.name = xstrdup(name);
|
||||
u.name = strdup(name);
|
||||
}
|
||||
|
||||
static const char *
|
||||
|
@ -393,7 +393,7 @@ static void
|
|||
unit_setinfo(unit& u, const char * info)
|
||||
{
|
||||
free(u.display);
|
||||
u.display = xstrdup(info);
|
||||
u.display = strdup(info);
|
||||
}
|
||||
|
||||
static bool
|
||||
|
@ -479,7 +479,7 @@ unit_setmagic(unit& u, const char * type)
|
|||
static void
|
||||
unit_addorder(unit& u, const char * str)
|
||||
{
|
||||
order * ord = parse_order((const xmlChar *)str, u.faction->locale);
|
||||
order * ord = parse_order(str, u.faction->locale);
|
||||
addlist(&u.orders, ord);
|
||||
u.faction->lastorders = turn;
|
||||
}
|
||||
|
@ -569,7 +569,7 @@ unit_capacity(const struct unit& u)
|
|||
static void
|
||||
unit_addnotice(unit& u, const char * str)
|
||||
{
|
||||
addmessage(u.region, u.faction, (const xmlChar*)str, MSG_MESSAGE, ML_IMPORTANT);
|
||||
addmessage(u.region, u.faction, str, MSG_MESSAGE, ML_IMPORTANT);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -601,25 +601,20 @@ load_inifile(const char * filename)
|
|||
{
|
||||
dictionary * d = iniparser_new(filename);
|
||||
if (d) {
|
||||
const char * str;
|
||||
|
||||
str = iniparser_getstr(d, "common:base");
|
||||
if (str) g_basedir = str;
|
||||
str = iniparser_getstr(d, "common:res");
|
||||
if (str) g_resourcedir = str;
|
||||
str = iniparser_getstr(d, "common:xml");
|
||||
if (str) xmlfile = str;
|
||||
str = iniparser_getstr(d, "common:scripts");
|
||||
if (str) script_path = str;
|
||||
g_basedir = iniparser_getstring(d, "common:base", g_basedir);
|
||||
g_resourcedir = iniparser_getstring(d, "common:res", g_resourcedir);
|
||||
xmlfile = iniparser_getstring(d, "common:xml", xmlfile);
|
||||
script_path = iniparser_getstring(d, "common:scripts", script_path);
|
||||
lomem = iniparser_getint(d, "common:lomem", lomem)?1:0;
|
||||
|
||||
enc_gamedata = iniparser_getstring(d, "common:gamedata_encoding", enc_gamedata);
|
||||
enc_orderfile = iniparser_getstring(d, "common:orderfile_encoding", enc_orderfile);
|
||||
|
||||
quiet = iniparser_getint(d, "eressea:verbose", 0)?0:1;
|
||||
battledebug = iniparser_getint(d, "eressea:debug", battledebug)?1:0;
|
||||
|
||||
str = iniparser_getstr(d, "eressea:run");
|
||||
if (str) luafile = str;
|
||||
str = iniparser_getstr(d, "eressea:report");
|
||||
if (str) g_reportdir = str;
|
||||
luafile = iniparser_getstring(d, "eressea:run", luafile);
|
||||
g_reportdir = iniparser_getstring(d, "eressea:report", g_reportdir);
|
||||
}
|
||||
inifile = d;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
-- the locales that this gameworld supports.
|
||||
local locales = { "de", "en" }
|
||||
enc_orders = "UTF-8"
|
||||
enc_game = "ISO-8859-1"
|
||||
|
||||
function loadscript(name)
|
||||
local script = scriptpath .. "/" .. name
|
||||
|
@ -54,7 +56,7 @@ function process(orders)
|
|||
equipment_setitem("new_faction", "money", "4200");
|
||||
|
||||
file = "" .. get_turn()
|
||||
if read_game(file)~=0 then
|
||||
if read_game(file, enc_game)~=0 then
|
||||
print("could not read game")
|
||||
return -1
|
||||
end
|
||||
|
@ -64,7 +66,7 @@ function process(orders)
|
|||
loadscript("eressea/multis.lua")
|
||||
|
||||
-- run the turn:
|
||||
if read_orders(orders) ~= 0 then
|
||||
if read_orders(orders, enc_orders) ~= 0 then
|
||||
print("could not read " .. orders)
|
||||
return -1
|
||||
end
|
||||
|
|
|
@ -411,11 +411,11 @@ function test_moving()
|
|||
end
|
||||
end
|
||||
|
||||
-- test_movement()
|
||||
test_movement()
|
||||
-- test_fail()
|
||||
-- test_handler()
|
||||
-- test_parser()
|
||||
test_monsters()
|
||||
-- test_monsters()
|
||||
-- test_combat()
|
||||
-- test_rewards()
|
||||
-- test_give()
|
||||
|
@ -425,7 +425,7 @@ test_monsters()
|
|||
-- write_game("../testg.txt")
|
||||
-- read_game("../testg.txt")
|
||||
|
||||
if 0==1 then
|
||||
if 1==1 then
|
||||
run_scripts()
|
||||
process_orders()
|
||||
write_reports()
|
||||
|
|
Loading…
Add table
Reference in a new issue