forked from github/server
Unicode WIP:
- bugfixes ongoing
This commit is contained in:
parent
d4d6776b50
commit
dbfb50625e
11 changed files with 81 additions and 30 deletions
|
@ -129,7 +129,11 @@ bt_find(const char* name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (btl && strcmp(btl->type->_name, name)) btl = btl->next;
|
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
|
void
|
||||||
|
|
|
@ -575,22 +575,22 @@ unitorders(FILE * F, int enc, struct faction * f)
|
||||||
s = getbuf(F, enc);
|
s = getbuf(F, enc);
|
||||||
if (s==NULL) break;
|
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]) {
|
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 */
|
/* Nun wird der Befehl erzeut und eingehängt */
|
||||||
*ordp = parse_order(s, u->faction->locale);
|
*ordp = parse_order(s, u->faction->locale);
|
||||||
if (*ordp) ordp = &(*ordp)->next;
|
if (*ordp) ordp = &(*ordp)->next;
|
||||||
|
@ -816,7 +816,12 @@ read_items(FILE *F, item **ilist)
|
||||||
itype = it_find(ibuf);
|
itype = it_find(ibuf);
|
||||||
assert(itype!=NULL);
|
assert(itype!=NULL);
|
||||||
if (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)
|
write_items(FILE *F, item *ilist)
|
||||||
{
|
{
|
||||||
item * itm;
|
item * itm;
|
||||||
for (itm=ilist;itm;itm=itm->next) if (itm->number) {
|
for (itm=ilist;itm;itm=itm->next) {
|
||||||
fprintf(F, "%s %i ", resourcename(itm->type->rtype, 0), itm->number);
|
assert(itm->number>=0);
|
||||||
|
if (itm->number) {
|
||||||
|
fprintf(F, "%s %i ", resourcename(itm->type->rtype, 0), itm->number);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fputs("end ", F);
|
fputs("end ", F);
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,9 @@ xml_readtext(xmlNodePtr node, struct locale ** lang, xmlChar **text)
|
||||||
xmlChar * propValue = xmlGetProp(node, BAD_CAST "locale");
|
xmlChar * propValue = xmlGetProp(node, BAD_CAST "locale");
|
||||||
assert(propValue!=NULL);
|
assert(propValue!=NULL);
|
||||||
*lang = find_locale((const char*)propValue);
|
*lang = find_locale((const char*)propValue);
|
||||||
|
#ifdef MAKE_LOCALES
|
||||||
if (*lang==NULL) *lang = make_locale((const char*)propValue);
|
if (*lang==NULL) *lang = make_locale((const char*)propValue);
|
||||||
|
#endif
|
||||||
xmlFree(propValue);
|
xmlFree(propValue);
|
||||||
|
|
||||||
*text = xmlNodeListGetString(node->doc, node->children, 1);
|
*text = xmlNodeListGetString(node->doc, node->children, 1);
|
||||||
|
@ -1825,8 +1827,10 @@ parse_messages(xmlDocPtr doc)
|
||||||
xmlChar * propText;
|
xmlChar * propText;
|
||||||
|
|
||||||
xml_readtext(node, &lang, &propText);
|
xml_readtext(node, &lang, &propText);
|
||||||
xml_cleanup_string(propText);
|
if (lang) {
|
||||||
nrt_register(mtype, lang, (const char *)propText, 0, (const char*)propSection);
|
xml_cleanup_string(propText);
|
||||||
|
nrt_register(mtype, lang, (const char *)propText, 0, (const char*)propSection);
|
||||||
|
}
|
||||||
xmlFree(propText);
|
xmlFree(propText);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1871,8 +1875,10 @@ xml_readstrings(xmlXPathContextPtr xpath, xmlNodePtr * nodeTab, int nodeNr, bool
|
||||||
xml_readtext(textNode, &lang, &propText);
|
xml_readtext(textNode, &lang, &propText);
|
||||||
if (propText!=NULL) {
|
if (propText!=NULL) {
|
||||||
assert(strcmp(zName, (const char*)xml_cleanup_string(BAD_CAST zName))==0);
|
assert(strcmp(zName, (const char*)xml_cleanup_string(BAD_CAST zName))==0);
|
||||||
xml_cleanup_string(propText);
|
if (lang) {
|
||||||
locale_setstring(lang, zName, (const char *)propText);
|
xml_cleanup_string(propText);
|
||||||
|
locale_setstring(lang, zName, (const char *)propText);
|
||||||
|
}
|
||||||
xmlFree(propText);
|
xmlFree(propText);
|
||||||
} else {
|
} else {
|
||||||
log_warning(("string %s has no text in locale %s\n",
|
log_warning(("string %s has no text in locale %s\n",
|
||||||
|
|
|
@ -526,7 +526,7 @@ sp_mindblast(fighter * fi, int level, double power, spell * sp)
|
||||||
--force;
|
--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);
|
message_all(b, m);
|
||||||
msg_release(m);
|
msg_release(m);
|
||||||
return level;
|
return level;
|
||||||
|
|
|
@ -4768,15 +4768,21 @@ sp_icastle(castorder *co)
|
||||||
icastle_data * data;
|
icastle_data * data;
|
||||||
const char * bname;
|
const char * bname;
|
||||||
message * msg;
|
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) {
|
if ((type=findbuildingtype(pa->param[0]->data.xs, mage->faction->locale)) == NULL) {
|
||||||
type = bt_find("castle");
|
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. */
|
/* Größe festlegen. */
|
||||||
if (type == bt_find("illusion")) {
|
if (type == bt_illusion) {
|
||||||
b->size = (rng_int()%(int)((power*power)+1)*10);
|
b->size = (rng_int()%(int)((power*power)+1)*10);
|
||||||
} else if (type->maxsize == -1) {
|
} else if (type->maxsize == -1) {
|
||||||
b->size = ((rng_int()%(int)(power))+1)*5;
|
b->size = ((rng_int()%(int)(power))+1)*5;
|
||||||
|
|
|
@ -67,6 +67,26 @@ make_locale(const char * name)
|
||||||
return l;
|
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 FILE * s_debug = NULL;
|
||||||
static char * s_logfile = NULL;
|
static char * s_logfile = NULL;
|
||||||
|
|
||||||
|
|
|
@ -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 char * mkname_buf(const char * namespc, const char * key, char * buffer);
|
||||||
|
|
||||||
extern void debug_language(const char * log);
|
extern void debug_language(const char * log);
|
||||||
|
extern void make_locales(const char * str);
|
||||||
|
|
||||||
#define LOC(lang, s) locale_string(lang, s)
|
#define LOC(lang, s) locale_string(lang, s)
|
||||||
|
|
||||||
|
|
|
@ -1308,6 +1308,9 @@ load_inifile(const char * filename)
|
||||||
|
|
||||||
str = iniparser_getstring(d, "common:gamedata_encoding", NULL);
|
str = iniparser_getstring(d, "common:gamedata_encoding", NULL);
|
||||||
if (str) enc_gamedata = xmlParseCharEncoding(str);
|
if (str) enc_gamedata = xmlParseCharEncoding(str);
|
||||||
|
|
||||||
|
str = iniparser_getstring(d, "common:locales", "de");
|
||||||
|
make_locales(str);
|
||||||
}
|
}
|
||||||
inifile = d;
|
inifile = d;
|
||||||
}
|
}
|
||||||
|
|
|
@ -619,6 +619,9 @@ load_inifile(const char * filename)
|
||||||
|
|
||||||
luafile = iniparser_getstring(d, "eressea:run", luafile);
|
luafile = iniparser_getstring(d, "eressea:run", luafile);
|
||||||
g_reportdir = iniparser_getstring(d, "eressea:report", g_reportdir);
|
g_reportdir = iniparser_getstring(d, "eressea:report", g_reportdir);
|
||||||
|
|
||||||
|
str = iniparser_getstring(d, "common:locales", "de");
|
||||||
|
make_locales(str);
|
||||||
}
|
}
|
||||||
inifile = d;
|
inifile = d;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,11 +35,11 @@ function write_aliases()
|
||||||
local file
|
local file
|
||||||
local faction
|
local faction
|
||||||
|
|
||||||
file = io.open(basepath .. "/aliases." .. locale, "w")
|
file = io.open(basepath .. "/aliases", "w")
|
||||||
for faction in factions() do
|
for faction in factions() do
|
||||||
local unit
|
local unit
|
||||||
file:write("partei-" .. itoa36(faction.id) .. ": " .. faction.email .. "\n")
|
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")
|
file:write("einheit-" .. itoa36(unit.id) .. ": " .. faction.email .. "\n")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,8 +5,8 @@ function use_ring_of_levitation(u, amount)
|
||||||
if u2.ship==u.ship then
|
if u2.ship==u.ship then
|
||||||
local i = u2:get_item("mallornseed")
|
local i = u2:get_item("mallornseed")
|
||||||
if i>0 then
|
if i>0 then
|
||||||
u2:use_item("mallornseed", i)
|
u2:use_pooled("mallornseed", i)
|
||||||
u2:add_item("seed", i)
|
u2:use_pooled("seed", i)
|
||||||
mallorn = mallorn + i
|
mallorn = mallorn + i
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue