forked from github/server
Merge branch 'develop'
This commit is contained in:
commit
0d6abd3811
|
@ -1688,12 +1688,6 @@
|
|||
<string name="mallornseed_p">
|
||||
<text locale="de">Mallornsamen</text>
|
||||
</string>
|
||||
<string name="birthday_firework">
|
||||
<text locale="de">Feuerwerk</text>
|
||||
</string>
|
||||
<string name="birthday_firework_p">
|
||||
<text locale="de">Feuerwerke</text>
|
||||
</string>
|
||||
<string name="lebkuchenherz">
|
||||
<text locale="de">Lebkuchenherz mit der Aufschrift 'Erz und
|
||||
Stein, das ist fein'</text>
|
||||
|
|
|
@ -874,12 +874,6 @@
|
|||
<string name="mallornseed_p">
|
||||
<text locale="en">mallorn seeds</text>
|
||||
</string>
|
||||
<string name="birthday_firework">
|
||||
<text locale="en">firework</text>
|
||||
</string>
|
||||
<string name="birthday_firework_p">
|
||||
<text locale="en">fireworks</text>
|
||||
</string>
|
||||
<string name="lebkuchenherz">
|
||||
<text locale="en">gingerbread heart</text>
|
||||
</string>
|
||||
|
|
|
@ -881,12 +881,6 @@
|
|||
<string name="mallornseed_p">
|
||||
<text locale="fr">graines de mallorn</text>
|
||||
</string>
|
||||
<string name="birthday_firework">
|
||||
<text locale="fr">feu d'artifice</text>
|
||||
</string>
|
||||
<string name="birthday_firework_p">
|
||||
<text locale="fr">feux d'artifice</text>
|
||||
</string>
|
||||
<string name="lebkuchenherz">
|
||||
<text locale="fr">coeur de pain d'épices</text>
|
||||
</string>
|
||||
|
|
|
@ -750,38 +750,6 @@
|
|||
<text locale="de">"$unit($unit) hat Glück und findet einen Hort von $int($amount) $resource($item,$amount)."</text>
|
||||
<text locale="en">"$unit($unit) luckily finds a cache of $int($amount) $resource($item,$amount)."</text>
|
||||
</message>
|
||||
<message name="birthday_firework_noname_local" section="events">
|
||||
<type>
|
||||
<arg name="unit" type="unit"/>
|
||||
</type>
|
||||
<text locale="de">"$unit($unit) brennt ein großes Feuerwerk ab und Kaskaden bunter Sterne, leuchtende Wasserfälle aus Licht und strahlende Feuerdrachen erhellen den Himmel."</text>
|
||||
<text locale="en">"A large firework is visible all over the sky."</text>
|
||||
</message>
|
||||
<message name="birthday_firework_noname" section="events">
|
||||
<type>
|
||||
<arg name="unit" type="unit"/>
|
||||
<arg name="region" type="region"/>
|
||||
</type>
|
||||
<text locale="de">"In $region($region) wird ein großes Feuerwerk abgebrannt, welches noch hier zu bewundern ist. Kaskaden bunter Sterne, leuchtende Wasserfälle aus Licht und strahlende Feuerdrachen erhellen den Himmel."</text>
|
||||
<text locale="en">"A large firework, visible all over the sky, has been started in $region($region)."</text>
|
||||
</message>
|
||||
<message name="birthday_firework_local" section="events">
|
||||
<type>
|
||||
<arg name="unit" type="unit"/>
|
||||
<arg name="name" type="string"/>
|
||||
</type>
|
||||
<text locale="de">"Zur Feier des Geburtstags von ${name} brennt $unit($unit) ein großes Feuerwerk ab. Kaskaden bunter Sterne, leuchtende Wasserfälle aus Licht und strahlende Feuerdrachen erhellen den Himmel."</text>
|
||||
<text locale="en">"A large firework in honor of ${name} is visible all over the sky."</text>
|
||||
</message>
|
||||
<message name="birthday_firework" section="events">
|
||||
<type>
|
||||
<arg name="unit" type="unit"/>
|
||||
<arg name="region" type="region"/>
|
||||
<arg name="name" type="string"/>
|
||||
</type>
|
||||
<text locale="de">"Zur Feier des Geburtstags von ${name} wird in $region($region) ein großes Feuerwerk abgebrannt, welches noch hier zu bewundern ist. Kaskaden bunter Sterne, leuchtende Wasserfälle aus Licht und strahlende Feuerdrachen erhellen den Himmel."</text>
|
||||
<text locale="en">"A large firework in honor of ${name}, visible all over the sky, has been started in $region($region)."</text>
|
||||
</message>
|
||||
<message name="battle_critical" section="battle">
|
||||
<type>
|
||||
<arg name="unit" type="unit"/>
|
||||
|
@ -1682,7 +1650,7 @@
|
|||
<text locale="de">"$string"</text>
|
||||
<text locale="en">"$string"</text>
|
||||
</message>
|
||||
<message name="battle_army" section="battle">
|
||||
<message name="para_army_index" section="battle">
|
||||
<type>
|
||||
<arg name="index" type="int"/>
|
||||
<arg name="name" type="string"/>
|
||||
|
@ -7211,20 +7179,13 @@
|
|||
<text locale="en">"$unit($mage) casts $spell($spell), but nobody was in range."</text>
|
||||
</message>
|
||||
|
||||
<message name="after_battle" section="battle">
|
||||
<message name="para_after_battle" section="battle">
|
||||
<type>
|
||||
</type>
|
||||
<text locale="de">"Einheiten nach dem Kampf:"</text>
|
||||
<text locale="en">"Units after the battle:"</text>
|
||||
</message>
|
||||
|
||||
<message name="section_battle" section="battle">
|
||||
<type>
|
||||
</type>
|
||||
<text locale="de">""</text>
|
||||
<text locale="en">""</text>
|
||||
</message>
|
||||
|
||||
<message name="sp_wolfhowl_effect" section="battle">
|
||||
<type>
|
||||
<arg name="mage" type="unit"/>
|
||||
|
@ -7284,7 +7245,7 @@
|
|||
<text locale="en">"$unit($mage) causes the walls of $building($building) to glow in an eerie magic light."</text>
|
||||
</message>
|
||||
|
||||
<message name="lineup_battle" section="battle">
|
||||
<message name="para_lineup_battle" section="battle">
|
||||
<type>
|
||||
<arg name="turn" type="int"/>
|
||||
</type>
|
||||
|
@ -7628,7 +7589,7 @@
|
|||
<text locale="en">"$unit($unit) in $region($region): '$order($command)' - The $ship($ship) will now be faster."</text>
|
||||
</message>
|
||||
|
||||
<message name="aurapotion50" section="magic">
|
||||
<message name="aurapotion50_effect" section="magic">
|
||||
<type>
|
||||
<arg name="unit" type="unit"/>
|
||||
<arg name="region" type="region"/>
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -86,7 +86,7 @@ function test_aurapotion50()
|
|||
turn_begin()
|
||||
turn_process()
|
||||
assert_equal(0, u:get_item("aurapotion50"))
|
||||
assert_equal(1, f:count_msg_type('aurapotion50'))
|
||||
assert_equal(1, f:count_msg_type('aurapotion50_effect'))
|
||||
assert_equal(50, u.aura)
|
||||
turn_end()
|
||||
end
|
||||
|
|
16
src/battle.c
16
src/battle.c
|
@ -110,8 +110,6 @@ typedef enum combatmagic {
|
|||
static int missile_range[2] = { FIGHT_ROW, BEHIND_ROW };
|
||||
static int melee_range[2] = { FIGHT_ROW, FIGHT_ROW };
|
||||
|
||||
static message *msg_separator;
|
||||
|
||||
const troop no_troop = { 0, 0 };
|
||||
|
||||
#define FORMULA_ORIG 0
|
||||
|
@ -2888,9 +2886,7 @@ static void print_stats(battle * b)
|
|||
message *msg;
|
||||
char buf[1024];
|
||||
|
||||
battle_message_faction(b, f, msg_separator);
|
||||
|
||||
msg = msg_message("battle_army", "index name", army_index(s), sname);
|
||||
msg = msg_message("para_army_index", "index name", army_index(s), sname);
|
||||
battle_message_faction(b, f, msg);
|
||||
msg_release(msg);
|
||||
|
||||
|
@ -2959,8 +2955,6 @@ static void print_stats(battle * b)
|
|||
print_fighters(b, s);
|
||||
}
|
||||
|
||||
message_all(b, msg_separator);
|
||||
|
||||
/* Besten Taktiker ermitteln */
|
||||
|
||||
b->max_tactics = 0;
|
||||
|
@ -3501,12 +3495,11 @@ static int battle_report(battle * b)
|
|||
bool komma = false;
|
||||
|
||||
sbs_init(&sbs, buf, sizeof(buf));
|
||||
battle_message_faction(b, fac, msg_separator);
|
||||
|
||||
if (cont)
|
||||
m = msg_message("lineup_battle", "turn", b->turn);
|
||||
m = msg_message("para_lineup_battle", "turn", b->turn);
|
||||
else
|
||||
m = msg_message("after_battle", "");
|
||||
m = msg_message("para_after_battle", "");
|
||||
battle_message_faction(b, fac, m);
|
||||
msg_release(m);
|
||||
|
||||
|
@ -4008,9 +4001,6 @@ void do_battle(region * r)
|
|||
battle *b = NULL;
|
||||
bool fighting = false;
|
||||
ship *sh;
|
||||
if (msg_separator == NULL) {
|
||||
msg_separator = msg_message("section_battle", "");
|
||||
}
|
||||
|
||||
fighting = start_battle(r, &b);
|
||||
|
||||
|
|
|
@ -918,12 +918,6 @@ static void export_locale(const struct locale *lang, const char *name) {
|
|||
char fname[64];
|
||||
FILE * F;
|
||||
|
||||
sprintf(fname, "strings.%2s.po", name);
|
||||
F = fopen(fname, "wt");
|
||||
if (F) {
|
||||
export_strings(lang, F);
|
||||
fclose(F);
|
||||
}
|
||||
sprintf(fname, "messages.%2s.po", name);
|
||||
F = fopen(fname, "wt");
|
||||
if (F) {
|
||||
|
|
|
@ -512,14 +512,14 @@ static void report_crtypes(FILE * F, const struct locale *lang)
|
|||
for (i = 0; i != MTMAXHASH; ++i) {
|
||||
struct known_mtype *kmt;
|
||||
for (kmt = mtypehash[i]; kmt; kmt = kmt->nexthash) {
|
||||
const struct nrmessage_type *nrt = nrt_find(lang, kmt->mtype);
|
||||
const struct nrmessage_type *nrt = nrt_find(kmt->mtype);
|
||||
if (nrt) {
|
||||
char buffer[DISPLAYSIZE];
|
||||
int hash = (int)kmt->mtype->key;
|
||||
assert(hash > 0);
|
||||
fprintf(F, "MESSAGETYPE %d\n", hash);
|
||||
fputc('\"', F);
|
||||
fputs(str_escape(nrt_string(nrt), buffer, sizeof(buffer)), F);
|
||||
fputs(str_escape(nrt_string(nrt, lang), buffer, sizeof(buffer)), F);
|
||||
fputs("\";text\n", F);
|
||||
fprintf(F, "\"%s\";section\n", nrt_section(nrt));
|
||||
}
|
||||
|
|
|
@ -224,7 +224,7 @@ int amount, struct order *ord)
|
|||
|
||||
change_spellpoints(u, 50);
|
||||
|
||||
ADDMSG(&u->faction->msgs, msg_message("aurapotion50",
|
||||
ADDMSG(&u->faction->msgs, msg_message("aurapotion50_effect",
|
||||
"unit region command", u, u->region, ord));
|
||||
|
||||
use_pooled(u, itype->rtype, GET_DEFAULT, 1);
|
||||
|
|
|
@ -743,6 +743,10 @@ rp_messages(struct stream *out, message_list * msgs, faction * viewer, int inden
|
|||
k = 1;
|
||||
}
|
||||
nr_render(m->msg, viewer->locale, lbuf, sizeof(lbuf), viewer);
|
||||
/* Hack: some messages should start a new paragraph with a newline: */
|
||||
if (strncmp("para_", m->msg->type->name, 5) == 0) {
|
||||
newline(out);
|
||||
}
|
||||
paragraph(out, lbuf, indent, 2, 0);
|
||||
}
|
||||
m = m->next;
|
||||
|
|
|
@ -258,29 +258,6 @@ void po_write_msg(FILE *F, const char *id, const char *str, const char *ctxt) {
|
|||
fputs("\"\n\n", F);
|
||||
}
|
||||
|
||||
void export_strings(const struct locale * lang, FILE *F) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i != SMAXHASH; ++i) {
|
||||
const struct locale_str *find = lang->strings[i];
|
||||
while (find) {
|
||||
const char *dcolon = strstr(find->key, "::");
|
||||
if (dcolon) {
|
||||
size_t len = dcolon - find->key;
|
||||
char ctxname[16];
|
||||
assert(sizeof(ctxname) > len);
|
||||
memcpy(ctxname, find->key, len);
|
||||
ctxname[len] = '\0';
|
||||
po_write_msg(F, dcolon + 2, find->str, ctxname);
|
||||
}
|
||||
else {
|
||||
po_write_msg(F, find->key, find->str, NULL);
|
||||
}
|
||||
find = find->nexthash;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const char *locale_name(const locale * lang)
|
||||
{
|
||||
return lang ? lang->name : "(null)";
|
||||
|
|
|
@ -58,7 +58,6 @@ extern "C" {
|
|||
void make_locales(const char *str);
|
||||
|
||||
void locale_foreach(void(*callback)(const struct locale *lang, const char *name));
|
||||
void export_strings(const struct locale * lang, FILE *F);
|
||||
void po_write_msg(FILE *F, const char *id, const char *str, const char *ctxt);
|
||||
|
||||
#define LOC(lang, s) (lang?locale_string(lang, s, true):s)
|
||||
|
|
|
@ -30,38 +30,31 @@
|
|||
#define NRT_MAXHASH 1021
|
||||
static nrmessage_type *nrtypes[NRT_MAXHASH];
|
||||
|
||||
const char *nrt_string(const struct nrmessage_type *type)
|
||||
const char *nrt_string(const struct nrmessage_type *nrt, const struct locale *lang)
|
||||
{
|
||||
if (type->string) {
|
||||
return type->string;
|
||||
const char * str = locale_getstring(lang, nrt->mtype->name);
|
||||
if (!str) {
|
||||
str = locale_getstring(default_locale, nrt->mtype->name);
|
||||
}
|
||||
return locale_get(type->lang, type->mtype->name);
|
||||
assert(str);
|
||||
return str;
|
||||
}
|
||||
|
||||
nrmessage_type *nrt_find(const struct locale * lang,
|
||||
const struct message_type * mtype)
|
||||
nrmessage_type *nrt_find(const struct message_type * mtype)
|
||||
{
|
||||
nrmessage_type *found = NULL;
|
||||
unsigned int hash = mtype->key % NRT_MAXHASH;
|
||||
nrmessage_type *type = nrtypes[hash];
|
||||
while (type) {
|
||||
if (type->mtype == mtype) {
|
||||
if (found == NULL)
|
||||
if (found == NULL) {
|
||||
found = type;
|
||||
else if (type->lang == NULL)
|
||||
found = type;
|
||||
if (lang == type->lang) {
|
||||
found = type;
|
||||
break;
|
||||
}
|
||||
}
|
||||
type = type->next;
|
||||
}
|
||||
if (!found) {
|
||||
log_warning("could not find nr-type %s for locale %s\n", mtype->name, locale_name(lang));
|
||||
}
|
||||
if (lang && found && found->lang != lang) {
|
||||
log_warning("could not find nr-type %s for locale %s, using %s\n", mtype->name, locale_name(lang), locale_name(found->lang));
|
||||
log_warning("could not find nr-type %s\n", mtype->name);
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
@ -100,12 +93,11 @@ const nrsection *section_add(const char *name)
|
|||
}
|
||||
|
||||
void
|
||||
nrt_register(const struct message_type *mtype, const struct locale *lang,
|
||||
const char *string, int level, const char *section)
|
||||
nrt_register(const struct message_type *mtype, const char *section)
|
||||
{
|
||||
unsigned int hash = mtype->key % NRT_MAXHASH;
|
||||
nrmessage_type *nrt = nrtypes[hash];
|
||||
while (nrt && (nrt->lang != lang || nrt->mtype != mtype)) {
|
||||
while (nrt && nrt->mtype != mtype) {
|
||||
nrt = nrt->next;
|
||||
}
|
||||
if (nrt) {
|
||||
|
@ -117,10 +109,8 @@ const char *string, int level, const char *section)
|
|||
char zNames[256];
|
||||
char *c = zNames;
|
||||
nrt = malloc(sizeof(nrmessage_type));
|
||||
nrt->lang = lang;
|
||||
nrt->mtype = mtype;
|
||||
nrt->next = nrtypes[hash];
|
||||
nrt->level = level;
|
||||
if (section) {
|
||||
const nrsection *s = section_find(section);
|
||||
if (s == NULL) {
|
||||
|
@ -131,8 +121,6 @@ const char *string, int level, const char *section)
|
|||
else
|
||||
nrt->section = NULL;
|
||||
nrtypes[hash] = nrt;
|
||||
assert(string && *string);
|
||||
nrt->string = str_strdup(string);
|
||||
*c = '\0';
|
||||
for (i = 0; i != mtype->nparameters; ++i) {
|
||||
if (i != 0)
|
||||
|
@ -147,11 +135,11 @@ size_t
|
|||
nr_render(const struct message *msg, const struct locale *lang, char *buffer,
|
||||
size_t size, const void *userdata)
|
||||
{
|
||||
struct nrmessage_type *nrt = nrt_find(lang, msg->type);
|
||||
struct nrmessage_type *nrt = nrt_find(msg->type);
|
||||
|
||||
if (nrt) {
|
||||
const char *m =
|
||||
translate(nrt_string(nrt), userdata, nrt->vars, msg->parameters);
|
||||
translate(nrt_string(nrt, lang), userdata, nrt->vars, msg->parameters);
|
||||
if (m) {
|
||||
return str_strlcpy((char *)buffer, m, size);
|
||||
}
|
||||
|
@ -164,15 +152,9 @@ size_t size, const void *userdata)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int nr_level(const struct message *msg)
|
||||
{
|
||||
nrmessage_type *nrt = nrt_find(NULL, msg->type);
|
||||
return nrt ? nrt->level : 0;
|
||||
}
|
||||
|
||||
const char *nr_section(const struct message *msg)
|
||||
{
|
||||
nrmessage_type *nrt = nrt_find(default_locale, msg->type);
|
||||
nrmessage_type *nrt = nrt_find(msg->type);
|
||||
return nrt ? nrt->section : NULL;
|
||||
}
|
||||
|
||||
|
@ -187,19 +169,18 @@ void free_nrmesssages(void) {
|
|||
while (nrtypes[i]) {
|
||||
nrmessage_type *nr = nrtypes[i];
|
||||
nrtypes[i] = nr->next;
|
||||
free(nr->string);
|
||||
free(nr->vars);
|
||||
free(nr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void export_messages(const struct locale * lang, FILE *F, const char *context) {
|
||||
void export_messages(const struct locale * lang, FILE *F, const char *msgctxt) {
|
||||
int i;
|
||||
for (i = 0; i != NRT_MAXHASH; ++i) {
|
||||
nrmessage_type *nrt = nrtypes[i];
|
||||
while (nrt) {
|
||||
po_write_msg(F, nrt->mtype->name, nrt->string, context);
|
||||
po_write_msg(F, nrt->mtype->name, nrt_string(nrt, lang), msgctxt);
|
||||
nrt = nrt->next;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,20 +34,16 @@ extern "C" {
|
|||
|
||||
void free_nrmesssages(void);
|
||||
|
||||
void nrt_register(const struct message_type *mtype,
|
||||
const struct locale *lang, const char *script,
|
||||
int level, const char *section);
|
||||
struct nrmessage_type *nrt_find(const struct locale *,
|
||||
const struct message_type *);
|
||||
const char *nrt_string(const struct nrmessage_type *type);
|
||||
const char *nrt_section(const struct nrmessage_type *mt);
|
||||
void nrt_register(const struct message_type *mtype, const char *section);
|
||||
struct nrmessage_type *nrt_find(const struct message_type *);
|
||||
const char *nrt_string(const struct nrmessage_type *nrt, const struct locale *lang);
|
||||
const char *nrt_section(const struct nrmessage_type *nrt);
|
||||
|
||||
size_t nr_render(const struct message *msg, const struct locale *lang,
|
||||
char *buffer, size_t size, const void *userdata);
|
||||
int nr_level(const struct message *msg);
|
||||
const char *nr_section(const struct message *msg);
|
||||
|
||||
void export_messages(const struct locale * lang, FILE *F, const char *context);
|
||||
void export_messages(const struct locale * lang, FILE *F, const char *msgctxt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -7,11 +7,8 @@
|
|||
|
||||
typedef struct nrmessage_type {
|
||||
const struct message_type *mtype;
|
||||
const struct locale *lang;
|
||||
char *string;
|
||||
char *vars;
|
||||
struct nrmessage_type *next;
|
||||
int level;
|
||||
const char *section;
|
||||
} nrmessage_type;
|
||||
|
||||
|
|
|
@ -1368,6 +1368,8 @@ static int parse_messages(xmlDocPtr doc)
|
|||
if (propSection == NULL)
|
||||
propSection = BAD_CAST default_section;
|
||||
|
||||
nrt_register(mtype, (const char *)propSection);
|
||||
|
||||
/* strings */
|
||||
xpath->node = node;
|
||||
result = xmlXPathEvalExpression(BAD_CAST "text", xpath);
|
||||
|
@ -1380,8 +1382,7 @@ static int parse_messages(xmlDocPtr doc)
|
|||
xml_readtext(node, &lang, &propText);
|
||||
if (lang) {
|
||||
xml_cleanup_string(propText);
|
||||
nrt_register(mtype, lang, (const char *)propText, 0,
|
||||
(const char *)propSection);
|
||||
locale_setstring(lang, mtype->name, (const char *)propText);
|
||||
}
|
||||
xmlFree(propText);
|
||||
|
||||
|
|
Loading…
Reference in New Issue