Unicode WIP:

- bugfixes ongoing
This commit is contained in:
Enno Rehling 2007-08-12 13:02:24 +00:00
parent d4d6776b50
commit dbfb50625e
11 changed files with 81 additions and 30 deletions

View file

@ -129,7 +129,11 @@ bt_find(const char* name)
}
}
while (btl && strcmp(btl->type->_name, name)) btl = btl->next;
return btl?btl->type:NULL;
if (btl==NULL) {
log_error(("could not locate building type '%s'.\n", name));
return NULL;
}
return btl->type;
}
void

View file

@ -575,22 +575,22 @@ unitorders(FILE * F, int enc, struct faction * f)
s = getbuf(F, enc);
if (s==NULL) break;
init_tokens_str(s, NULL);
s = getstrtoken();
if (findkeyword(s, u->faction->locale) == NOKEYWORD) {
boolean quit = false;
switch (findparam(s, u->faction->locale)) {
case P_UNIT:
case P_REGION:
case P_FACTION:
case P_NEXT:
case P_GAMENAME:
quit = true;
}
if (quit) break;
}
if (s[0]) {
const char * stok = s;
stok = parse_token(&stok);
if (stok) {
boolean quit = false;
switch (findparam(stok, u->faction->locale)) {
case P_UNIT:
case P_REGION:
case P_FACTION:
case P_NEXT:
case P_GAMENAME:
quit = true;
}
if (quit) break;
}
/* Nun wird der Befehl erzeut und eingehängt */
*ordp = parse_order(s, u->faction->locale);
if (*ordp) ordp = &(*ordp)->next;
@ -816,7 +816,12 @@ read_items(FILE *F, item **ilist)
itype = it_find(ibuf);
assert(itype!=NULL);
if (itype!=NULL) {
i_change(ilist, itype, ri(F));
int i = ri(F);
if (i<=0) {
log_error(("data contains an entry with %d %s\n", i, itype->rtype->_name[1]));
} else {
i_change(ilist, itype, i);
}
}
}
}
@ -890,8 +895,11 @@ void
write_items(FILE *F, item *ilist)
{
item * itm;
for (itm=ilist;itm;itm=itm->next) if (itm->number) {
fprintf(F, "%s %i ", resourcename(itm->type->rtype, 0), itm->number);
for (itm=ilist;itm;itm=itm->next) {
assert(itm->number>=0);
if (itm->number) {
fprintf(F, "%s %i ", resourcename(itm->type->rtype, 0), itm->number);
}
}
fputs("end ", F);
}

View file

@ -63,7 +63,9 @@ xml_readtext(xmlNodePtr node, struct locale ** lang, xmlChar **text)
xmlChar * propValue = xmlGetProp(node, BAD_CAST "locale");
assert(propValue!=NULL);
*lang = find_locale((const char*)propValue);
#ifdef MAKE_LOCALES
if (*lang==NULL) *lang = make_locale((const char*)propValue);
#endif
xmlFree(propValue);
*text = xmlNodeListGetString(node->doc, node->children, 1);
@ -1825,8 +1827,10 @@ parse_messages(xmlDocPtr doc)
xmlChar * propText;
xml_readtext(node, &lang, &propText);
xml_cleanup_string(propText);
nrt_register(mtype, lang, (const char *)propText, 0, (const char*)propSection);
if (lang) {
xml_cleanup_string(propText);
nrt_register(mtype, lang, (const char *)propText, 0, (const char*)propSection);
}
xmlFree(propText);
}
@ -1871,8 +1875,10 @@ xml_readstrings(xmlXPathContextPtr xpath, xmlNodePtr * nodeTab, int nodeNr, bool
xml_readtext(textNode, &lang, &propText);
if (propText!=NULL) {
assert(strcmp(zName, (const char*)xml_cleanup_string(BAD_CAST zName))==0);
xml_cleanup_string(propText);
locale_setstring(lang, zName, (const char *)propText);
if (lang) {
xml_cleanup_string(propText);
locale_setstring(lang, zName, (const char *)propText);
}
xmlFree(propText);
} else {
log_warning(("string %s has no text in locale %s\n",

View file

@ -526,7 +526,7 @@ sp_mindblast(fighter * fi, int level, double power, spell * sp)
--force;
}
m = msg_message("sp_midblast_effect", "mage spell amount dead", mage, sp, k, killed);
m = msg_message("sp_mindblast_effect", "mage spell amount dead", mage, sp, k, killed);
message_all(b, m);
msg_release(m);
return level;

View file

@ -4768,15 +4768,21 @@ sp_icastle(castorder *co)
icastle_data * data;
const char * bname;
message * msg;
static const building_type * bt_illusion;
if (bt_illusion==NULL) bt_illusion = bt_find("illusioncastle");
if (bt_illusion==NULL) {
return 0;
}
if ((type=findbuildingtype(pa->param[0]->data.xs, mage->faction->locale)) == NULL) {
type = bt_find("castle");
}
b = new_building(bt_find("illusion"), r, mage->faction->locale);
b = new_building(bt_illusion, r, mage->faction->locale);
/* Größe festlegen. */
if (type == bt_find("illusion")) {
if (type == bt_illusion) {
b->size = (rng_int()%(int)((power*power)+1)*10);
} else if (type->maxsize == -1) {
b->size = ((rng_int()%(int)(power))+1)*5;

View file

@ -67,6 +67,26 @@ make_locale(const char * name)
return l;
}
/** creates a list of locales
* This function takes a comma-delimited list of locale-names and creates
* the locales using the make_locale function (useful for ini-files).
*/
void
make_locales(const char * str)
{
const char * tok = str;
while (*tok) {
char zText[32];
while (*tok && *tok !=',') ++tok;
strncpy(zText, str, tok-str);
zText[tok-str] = 0;
make_locale(zText);
if (*tok) {
str = ++tok;
}
}
}
static FILE * s_debug = NULL;
static char * s_logfile = NULL;

View file

@ -34,6 +34,7 @@ extern const char * mkname(const char * namespc, const char * key);
extern char * mkname_buf(const char * namespc, const char * key, char * buffer);
extern void debug_language(const char * log);
extern void make_locales(const char * str);
#define LOC(lang, s) locale_string(lang, s)

View file

@ -1308,6 +1308,9 @@ load_inifile(const char * filename)
str = iniparser_getstring(d, "common:gamedata_encoding", NULL);
if (str) enc_gamedata = xmlParseCharEncoding(str);
str = iniparser_getstring(d, "common:locales", "de");
make_locales(str);
}
inifile = d;
}

View file

@ -619,6 +619,9 @@ load_inifile(const char * filename)
luafile = iniparser_getstring(d, "eressea:run", luafile);
g_reportdir = iniparser_getstring(d, "eressea:report", g_reportdir);
str = iniparser_getstring(d, "common:locales", "de");
make_locales(str);
}
inifile = d;
}

View file

@ -35,11 +35,11 @@ function write_aliases()
local file
local faction
file = io.open(basepath .. "/aliases." .. locale, "w")
file = io.open(basepath .. "/aliases", "w")
for faction in factions() do
local unit
file:write("partei-" .. itoa36(faction.id) .. ": " .. faction.email .. "\n")
for unit in f.units do
for unit in faction.units do
file:write("einheit-" .. itoa36(unit.id) .. ": " .. faction.email .. "\n")
end
end

View file

@ -5,8 +5,8 @@ function use_ring_of_levitation(u, amount)
if u2.ship==u.ship then
local i = u2:get_item("mallornseed")
if i>0 then
u2:use_item("mallornseed", i)
u2:add_item("seed", i)
u2:use_pooled("mallornseed", i)
u2:use_pooled("seed", i)
mallorn = mallorn + i
end
end