forked from github/server
Merge branch 'master' of github.com:eressea/server
Conflicts: s/cron/previews.sh
This commit is contained in:
commit
60e2e23414
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
"keywords": {
|
"keywords": {
|
||||||
"en" : {
|
"en" : {
|
||||||
|
"grow": [ "GROW", "BREED", "PLANT" ],
|
||||||
"combat": [ "COMBAT", "FIGHT" ]
|
"combat": [ "COMBAT", "FIGHT" ]
|
||||||
},
|
},
|
||||||
"de": {
|
"de": {
|
||||||
|
@ -51,7 +52,7 @@
|
||||||
"cast": ["ZAUBERE", "ZAUBERN"],
|
"cast": ["ZAUBERE", "ZAUBERN"],
|
||||||
"show": ["ZEIGE", "ZEIGEN"],
|
"show": ["ZEIGE", "ZEIGEN"],
|
||||||
"destroy": ["ZERSTÖRE", "ZERSTÖREN"],
|
"destroy": ["ZERSTÖRE", "ZERSTÖREN"],
|
||||||
"grow": ["ZÜCHTE", "ZÜCHTEN"],
|
"grow": ["ZÜCHTE", "PFLANZE", "ZÜCHTEN", "PFLANZEN"],
|
||||||
"default": "DEFAULT",
|
"default": "DEFAULT",
|
||||||
"origin": "URSPRUNG",
|
"origin": "URSPRUNG",
|
||||||
"email": "EMAIL",
|
"email": "EMAIL",
|
||||||
|
@ -59,7 +60,6 @@
|
||||||
"group": "GRUPPE",
|
"group": "GRUPPE",
|
||||||
"sort": ["SORTIERE", "SORTIEREN"],
|
"sort": ["SORTIERE", "SORTIEREN"],
|
||||||
"prefix": "PRÄFIX",
|
"prefix": "PRÄFIX",
|
||||||
"plant": ["PFLANZE", "PFLANZEN"],
|
|
||||||
"alliance": "ALLIANZ",
|
"alliance": "ALLIANZ",
|
||||||
"claim": ["BEANSPRUCHE", "BEANSPRUCHEN"],
|
"claim": ["BEANSPRUCHE", "BEANSPRUCHEN"],
|
||||||
"promote": ["BEFÖRDERE", "BEFÖRDERUNG"],
|
"promote": ["BEFÖRDERE", "BEFÖRDERUNG"],
|
||||||
|
|
|
@ -1496,9 +1496,6 @@
|
||||||
<string name="pay">
|
<string name="pay">
|
||||||
<text locale="en">PAY</text>
|
<text locale="en">PAY</text>
|
||||||
</string>
|
</string>
|
||||||
<string name="plant">
|
|
||||||
<text locale="en">PLANT</text>
|
|
||||||
</string>
|
|
||||||
<string name="piracy">
|
<string name="piracy">
|
||||||
<text locale="en">PIRACY</text>
|
<text locale="en">PIRACY</text>
|
||||||
</string>
|
</string>
|
||||||
|
@ -1568,9 +1565,6 @@
|
||||||
<string name="destroy">
|
<string name="destroy">
|
||||||
<text locale="en">DESTROY</text>
|
<text locale="en">DESTROY</text>
|
||||||
</string>
|
</string>
|
||||||
<string name="grow">
|
|
||||||
<text locale="en">GROW</text>
|
|
||||||
</string>
|
|
||||||
<string name="loot">
|
<string name="loot">
|
||||||
<text locale="en">loot</text>
|
<text locale="en">loot</text>
|
||||||
</string>
|
</string>
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
[ -z $ERESSEA ] && ERESSEA=$HOME/eressea
|
[ -z ${ERESSEA} ] && ERESSEA=~/eressea
|
||||||
|
branch="master"
|
||||||
branch=master
|
if [ -e ${ERESSEA}/build/.preview ]; then
|
||||||
if [ ! -n "$1" ]; then
|
branch=`cat ${ERESSEA}/build/.preview`
|
||||||
branch="$1"
|
|
||||||
fi
|
fi
|
||||||
SRC=$ERESSEA/git
|
SRC=${ERESSEA}/git
|
||||||
$SRC/s/preview build $branch
|
${SRC}/s/preview build ${branch}
|
||||||
$SRC/s/preview version
|
${SRC}/s/preview version
|
||||||
for game in 2 3 4 ; do
|
for game in 2 3 4 ; do
|
||||||
$SRC/s/preview -g $game run && \
|
${SRC}/s/preview -g ${game} run && \
|
||||||
$SRC/s/preview -g $game send
|
${SRC}/s/preview -g ${game} send
|
||||||
done
|
done
|
||||||
|
|
|
@ -2,3 +2,4 @@ require 'tests.e3.castles'
|
||||||
require 'tests.e3.stealth'
|
require 'tests.e3.stealth'
|
||||||
require 'tests.e3.spells'
|
require 'tests.e3.spells'
|
||||||
require 'tests.e3.rules'
|
require 'tests.e3.rules'
|
||||||
|
require 'tests.e3.parser'
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
require 'lunit'
|
||||||
|
|
||||||
|
module('tests.e3.parser', package.seeall, lunit.testcase)
|
||||||
|
|
||||||
|
function setup()
|
||||||
|
eressea.game.reset()
|
||||||
|
end
|
||||||
|
|
||||||
|
function test_set_status_en()
|
||||||
|
local r = region.create(0, 0, "plain")
|
||||||
|
local f = faction.create("bug_1882@eressea.de", "human", "en")
|
||||||
|
local u = unit.create(f, r, 1)
|
||||||
|
u.status = 1
|
||||||
|
u:clear_orders()
|
||||||
|
u:add_order("COMBAT AGGRESSIVE")
|
||||||
|
process_orders()
|
||||||
|
assert_equal(u.status, 0)
|
||||||
|
u.status = 1
|
||||||
|
u:add_order("FIGHT AGGRESSIVE")
|
||||||
|
process_orders()
|
||||||
|
assert_equal(u.status, 0)
|
||||||
|
end
|
||||||
|
|
||||||
|
function test_set_status_de()
|
||||||
|
local r = region.create(0, 0, "plain")
|
||||||
|
local f = faction.create("bug_1882@eressea.de", "human", "de")
|
||||||
|
local u = unit.create(f, r, 1)
|
||||||
|
u.status = 1
|
||||||
|
u:clear_orders()
|
||||||
|
u:add_order("KAEMPFE AGGRESSIV")
|
||||||
|
process_orders()
|
||||||
|
assert_equal(u.status, 0)
|
||||||
|
end
|
||||||
|
|
||||||
|
function test_breed_horses()
|
||||||
|
local r = region.create(0, 0, "plain")
|
||||||
|
local f = faction.create("bug_1886@eressea.de", "human", "en")
|
||||||
|
local u = unit.create(f, r, 1)
|
||||||
|
local b = building.create(r, "stables")
|
||||||
|
b.size = 10
|
||||||
|
u.building = b
|
||||||
|
u:add_item("horse", 2)
|
||||||
|
u:add_item("money", 2000)
|
||||||
|
u:set_skill("training", 100) -- 100% chance to duplicate each horse
|
||||||
|
u:clear_orders()
|
||||||
|
u:add_order("GROW horses")
|
||||||
|
process_orders()
|
||||||
|
assert_equal(4, u:get_item("horse"))
|
||||||
|
u:clear_orders()
|
||||||
|
u:add_order("BREED horses")
|
||||||
|
process_orders()
|
||||||
|
assert_equal(8, u:get_item("horse"))
|
||||||
|
u:clear_orders()
|
||||||
|
u:add_order("PLANT horses")
|
||||||
|
process_orders()
|
||||||
|
assert_equal(16, u:get_item("horse"))
|
||||||
|
end
|
|
@ -54,10 +54,6 @@ function disable_test_bug_1738_build_castle_e3()
|
||||||
-- 33/4 makes 8 points, resulting size is 258.
|
-- 33/4 makes 8 points, resulting size is 258.
|
||||||
|
|
||||||
process_orders()
|
process_orders()
|
||||||
--[[
|
|
||||||
init_reports()
|
|
||||||
write_report(f)
|
|
||||||
]]--
|
|
||||||
-- resulting size should be 250 because unit 2
|
-- resulting size should be 250 because unit 2
|
||||||
-- does not have the needed minimum skill.
|
-- does not have the needed minimum skill.
|
||||||
assert_equal(c.size, 250)
|
assert_equal(c.size, 250)
|
||||||
|
@ -302,13 +298,11 @@ function test_ship_capacity()
|
||||||
process_orders()
|
process_orders()
|
||||||
if r2~=u1.region then
|
if r2~=u1.region then
|
||||||
print(get_turn(), u1, u1.faction)
|
print(get_turn(), u1, u1.faction)
|
||||||
write_reports()
|
|
||||||
end
|
end
|
||||||
assert_equal(r2, u1.region)
|
assert_equal(r2, u1.region)
|
||||||
assert_not_equal(r2.id, u2.region.id)
|
assert_not_equal(r2.id, u2.region.id)
|
||||||
if r2~=u3.region then
|
if r2~=u3.region then
|
||||||
print(get_turn(), u3, u3.faction)
|
print(get_turn(), u3, u3.faction)
|
||||||
write_reports()
|
|
||||||
end
|
end
|
||||||
assert_equal(r2, u3.region)
|
assert_equal(r2, u3.region)
|
||||||
assert_not_equal(r2.id, u4.region.id)
|
assert_not_equal(r2.id, u4.region.id)
|
||||||
|
@ -375,8 +369,6 @@ function test_region_owner_cannot_leave_castle()
|
||||||
u:clear_orders()
|
u:clear_orders()
|
||||||
u:add_order("BETRETE BURG " .. itoa36(b2.id))
|
u:add_order("BETRETE BURG " .. itoa36(b2.id))
|
||||||
process_orders()
|
process_orders()
|
||||||
init_reports()
|
|
||||||
write_report(u.faction)
|
|
||||||
assert_equal(b1, u.building, "region owner has left the building") -- region owners may not leave
|
assert_equal(b1, u.building, "region owner has left the building") -- region owners may not leave
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@ int config_parse(const char *json)
|
||||||
if (conf) {
|
if (conf) {
|
||||||
json_config(conf);
|
json_config(conf);
|
||||||
cJSON_Delete(conf);
|
cJSON_Delete(conf);
|
||||||
|
init_locales();
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
int line;
|
int line;
|
||||||
|
|
|
@ -193,7 +193,7 @@ static int tolua_translate(lua_State * L)
|
||||||
const char *lang = tolua_tostring(L, 2, 0);
|
const char *lang = tolua_tostring(L, 2, 0);
|
||||||
struct locale *loc = lang ? get_locale(lang) : default_locale;
|
struct locale *loc = lang ? get_locale(lang) : default_locale;
|
||||||
if (loc) {
|
if (loc) {
|
||||||
str = locale_string(loc, str);
|
str = LOC(loc, str);
|
||||||
tolua_pushstring(L, str);
|
tolua_pushstring(L, str);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
#define VERSION_MAJOR 3
|
#define VERSION_MAJOR 3
|
||||||
#define VERSION_MINOR 4
|
#define VERSION_MINOR 5
|
||||||
#define VERSION_BUILD 695
|
#define VERSION_BUILD 696
|
||||||
|
|
|
@ -92,7 +92,7 @@ static const char *crtag(const char *key)
|
||||||
static const struct locale *lang = NULL;
|
static const struct locale *lang = NULL;
|
||||||
if (!lang)
|
if (!lang)
|
||||||
lang = get_locale(TAG_LOCALE);
|
lang = get_locale(TAG_LOCALE);
|
||||||
return locale_string(lang, key);
|
return LOC(lang, key);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#define crtag(x) (x)
|
#define crtag(x) (x)
|
||||||
|
@ -274,7 +274,7 @@ cr_output_curses(FILE * F, const faction * viewer, const void *obj, objtype_t ty
|
||||||
fputs("EFFECTS\n", F);
|
fputs("EFFECTS\n", F);
|
||||||
}
|
}
|
||||||
fprintf(F, "\"%d %s\"\n", data->value, translate(key,
|
fprintf(F, "\"%d %s\"\n", data->value, translate(key,
|
||||||
locale_string(default_locale, key)));
|
LOC(default_locale, key)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
a = a->next;
|
a = a->next;
|
||||||
|
@ -331,7 +331,7 @@ static int cr_resource(variant var, char *buffer, const void *userdata)
|
||||||
if (r) {
|
if (r) {
|
||||||
const char *key = resourcename(r, 0);
|
const char *key = resourcename(r, 0);
|
||||||
sprintf(buffer, "\"%s\"",
|
sprintf(buffer, "\"%s\"",
|
||||||
translate(key, locale_string(report->locale, key)));
|
translate(key, LOC(report->locale, key)));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -343,7 +343,7 @@ static int cr_race(variant var, char *buffer, const void *userdata)
|
||||||
const struct race *rc = (const race *)var.v;
|
const struct race *rc = (const race *)var.v;
|
||||||
const char *key = rc_name_s(rc, NAME_SINGULAR);
|
const char *key = rc_name_s(rc, NAME_SINGULAR);
|
||||||
sprintf(buffer, "\"%s\"",
|
sprintf(buffer, "\"%s\"",
|
||||||
translate(key, locale_string(report->locale, key)));
|
translate(key, LOC(report->locale, key)));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -649,7 +649,7 @@ const faction * f, const region * r)
|
||||||
if (sh->display && sh->display[0])
|
if (sh->display && sh->display[0])
|
||||||
fprintf(F, "\"%s\";Beschr\n", sh->display);
|
fprintf(F, "\"%s\";Beschr\n", sh->display);
|
||||||
fprintf(F, "\"%s\";Typ\n", translate(sh->type->_name,
|
fprintf(F, "\"%s\";Typ\n", translate(sh->type->_name,
|
||||||
locale_string(f->locale, sh->type->_name)));
|
LOC(f->locale, sh->type->_name)));
|
||||||
fprintf(F, "%d;Groesse\n", sh->size);
|
fprintf(F, "%d;Groesse\n", sh->size);
|
||||||
if (sh->damage) {
|
if (sh->damage) {
|
||||||
int percent =
|
int percent =
|
||||||
|
@ -839,20 +839,20 @@ static void cr_output_unit(FILE * F, const region * r, const faction * f,
|
||||||
if (u->faction == f && fval(u_race(u), RCF_SHAPESHIFTANY)) {
|
if (u->faction == f && fval(u_race(u), RCF_SHAPESHIFTANY)) {
|
||||||
const char *zRace = rc_name_s(u_race(u), NAME_PLURAL);
|
const char *zRace = rc_name_s(u_race(u), NAME_PLURAL);
|
||||||
fprintf(F, "\"%s\";wahrerTyp\n",
|
fprintf(F, "\"%s\";wahrerTyp\n",
|
||||||
translate(zRace, locale_string(f->locale, zRace)));
|
translate(zRace, LOC(f->locale, zRace)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const race *irace = u_irace(u);
|
const race *irace = u_irace(u);
|
||||||
const char *zRace = rc_name_s(irace, NAME_PLURAL);
|
const char *zRace = rc_name_s(irace, NAME_PLURAL);
|
||||||
fprintf(F, "\"%s\";Typ\n",
|
fprintf(F, "\"%s\";Typ\n",
|
||||||
translate(zRace, locale_string(f->locale, zRace)));
|
translate(zRace, LOC(f->locale, zRace)));
|
||||||
if (u->faction == f && irace != u_race(u)) {
|
if (u->faction == f && irace != u_race(u)) {
|
||||||
assert(skill_enabled(SK_STEALTH)
|
assert(skill_enabled(SK_STEALTH)
|
||||||
|| !"we're resetting this on load, so.. ircase should never be used");
|
|| !"we're resetting this on load, so.. ircase should never be used");
|
||||||
zRace = rc_name_s(u_race(u), NAME_PLURAL);
|
zRace = rc_name_s(u_race(u), NAME_PLURAL);
|
||||||
fprintf(F, "\"%s\";wahrerTyp\n",
|
fprintf(F, "\"%s\";wahrerTyp\n",
|
||||||
translate(zRace, locale_string(f->locale, zRace)));
|
translate(zRace, LOC(f->locale, zRace)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -902,7 +902,7 @@ static void cr_output_unit(FILE * F, const region * r, const faction * f,
|
||||||
c = hp_status(u);
|
c = hp_status(u);
|
||||||
if (c && *c && (u->faction == f || omniscient(f))) {
|
if (c && *c && (u->faction == f || omniscient(f))) {
|
||||||
fprintf(F, "\"%s\";hp\n", translate(c,
|
fprintf(F, "\"%s\";hp\n", translate(c,
|
||||||
locale_string(u->faction->locale, c)));
|
LOC(u->faction->locale, c)));
|
||||||
}
|
}
|
||||||
if (fval(u, UFL_HERO)) {
|
if (fval(u, UFL_HERO)) {
|
||||||
fputs("1;hero\n", F);
|
fputs("1;hero\n", F);
|
||||||
|
@ -998,8 +998,7 @@ static void cr_output_unit(FILE * F, const region * r, const faction * f,
|
||||||
pr = 1;
|
pr = 1;
|
||||||
fputs("GEGENSTAENDE\n", F);
|
fputs("GEGENSTAENDE\n", F);
|
||||||
}
|
}
|
||||||
fprintf(F, "%d;%s\n", in, translate(ic, locale_string(f->locale,
|
fprintf(F, "%d;%s\n", in, translate(ic, LOC(f->locale, ic)));
|
||||||
ic)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cr_output_curses(F, f, u, TYP_UNIT);
|
cr_output_curses(F, f, u, TYP_UNIT);
|
||||||
|
@ -1294,8 +1293,7 @@ static void cr_output_region(FILE * F, report_context * ctx, seen_region * sr)
|
||||||
}
|
}
|
||||||
tname = terrain_name(r);
|
tname = terrain_name(r);
|
||||||
|
|
||||||
fprintf(F, "\"%s\";Terrain\n", translate(tname, locale_string(f->locale,
|
fprintf(F, "\"%s\";Terrain\n", translate(tname, LOC(f->locale, tname)));
|
||||||
tname)));
|
|
||||||
if (sr->mode != see_unit)
|
if (sr->mode != see_unit)
|
||||||
fprintf(F, "\"%s\";visibility\n", visibility[sr->mode]);
|
fprintf(F, "\"%s\";visibility\n", visibility[sr->mode]);
|
||||||
if (sr->mode == see_neighbour) {
|
if (sr->mode == see_neighbour) {
|
||||||
|
@ -1359,12 +1357,12 @@ static void cr_output_region(FILE * F, report_context * ctx, seen_region * sr)
|
||||||
if (lux) {
|
if (lux) {
|
||||||
const char *ch = resourcename(lux->rtype, 0);
|
const char *ch = resourcename(lux->rtype, 0);
|
||||||
fprintf(F, "%d;%s\n", 1, translate(ch,
|
fprintf(F, "%d;%s\n", 1, translate(ch,
|
||||||
locale_string(f->locale, ch)));
|
LOC(f->locale, ch)));
|
||||||
}
|
}
|
||||||
if (herb) {
|
if (herb) {
|
||||||
const char *ch = resourcename(herb->rtype, 0);
|
const char *ch = resourcename(herb->rtype, 0);
|
||||||
fprintf(F, "%d;%s\n", 1, translate(ch,
|
fprintf(F, "%d;%s\n", 1, translate(ch,
|
||||||
locale_string(f->locale, ch)));
|
LOC(f->locale, ch)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1376,7 +1374,7 @@ static void cr_output_region(FILE * F, report_context * ctx, seen_region * sr)
|
||||||
fprintf(F, "%d;%s\n", (dmd->value
|
fprintf(F, "%d;%s\n", (dmd->value
|
||||||
? dmd->value * dmd->type->price
|
? dmd->value * dmd->type->price
|
||||||
: -dmd->type->price),
|
: -dmd->type->price),
|
||||||
translate(ch, locale_string(f->locale, ch)));
|
translate(ch, LOC(f->locale, ch)));
|
||||||
dmd = dmd->next;
|
dmd = dmd->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1491,7 +1489,7 @@ report_computer(const char *filename, report_context * ctx, const char *charset)
|
||||||
faction *f = ctx->f;
|
faction *f = ctx->f;
|
||||||
const char *prefix;
|
const char *prefix;
|
||||||
region *r;
|
region *r;
|
||||||
const char *mailto = locale_string(f->locale, "mailto");
|
const char *mailto = LOC(f->locale, "mailto");
|
||||||
const attrib *a;
|
const attrib *a;
|
||||||
seen_region *sr = NULL;
|
seen_region *sr = NULL;
|
||||||
#if SCORE_MODULE
|
#if SCORE_MODULE
|
||||||
|
@ -1530,7 +1528,7 @@ report_computer(const char *filename, report_context * ctx, const char *charset)
|
||||||
fprintf(F, "%d.%d.%d;Build\n", VERSION_MAJOR, VERSION_MINOR, VERSION_BUILD);
|
fprintf(F, "%d.%d.%d;Build\n", VERSION_MAJOR, VERSION_MINOR, VERSION_BUILD);
|
||||||
if (mailto != NULL) {
|
if (mailto != NULL) {
|
||||||
fprintf(F, "\"%s\";mailto\n", mailto);
|
fprintf(F, "\"%s\";mailto\n", mailto);
|
||||||
fprintf(F, "\"%s\";mailcmd\n", locale_string(f->locale, "mailcmd"));
|
fprintf(F, "\"%s\";mailcmd\n", LOC(f->locale, "mailcmd"));
|
||||||
}
|
}
|
||||||
|
|
||||||
show_alliances_cr(F, f);
|
show_alliances_cr(F, f);
|
||||||
|
@ -1651,8 +1649,7 @@ report_computer(const char *filename, report_context * ctx, const char *charset)
|
||||||
continue;
|
continue;
|
||||||
ch = resourcename(ptype->itype->rtype, 0);
|
ch = resourcename(ptype->itype->rtype, 0);
|
||||||
fprintf(F, "TRANK %d\n", hashstring(ch));
|
fprintf(F, "TRANK %d\n", hashstring(ch));
|
||||||
fprintf(F, "\"%s\";Name\n", translate(ch, locale_string(f->locale,
|
fprintf(F, "\"%s\";Name\n", translate(ch, LOC(f->locale, ch)));
|
||||||
ch)));
|
|
||||||
fprintf(F, "%d;Stufe\n", ptype->level);
|
fprintf(F, "%d;Stufe\n", ptype->level);
|
||||||
|
|
||||||
if (description == NULL) {
|
if (description == NULL) {
|
||||||
|
@ -1669,8 +1666,7 @@ report_computer(const char *filename, report_context * ctx, const char *charset)
|
||||||
|
|
||||||
while (m->number) {
|
while (m->number) {
|
||||||
ch = resourcename(m->rtype, 0);
|
ch = resourcename(m->rtype, 0);
|
||||||
fprintf(F, "\"%s\"\n", translate(ch, locale_string(f->locale,
|
fprintf(F, "\"%s\"\n", translate(ch, LOC(f->locale, ch)));
|
||||||
ch)));
|
|
||||||
m++;
|
m++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ void init_directions(struct locale *lang) {
|
||||||
register_special_direction(lang, "vortex");
|
register_special_direction(lang, "vortex");
|
||||||
|
|
||||||
for (i = 0; dirs[i].direction != NODIRECTION; ++i) {
|
for (i = 0; dirs[i].direction != NODIRECTION; ++i) {
|
||||||
const char *str = locale_string(lang, dirs[i].name);
|
const char *str = locale_string(lang, dirs[i].name, false);
|
||||||
if (str) {
|
if (str) {
|
||||||
variant token;
|
variant token;
|
||||||
token.i = dirs[i].direction;
|
token.i = dirs[i].direction;
|
||||||
|
|
|
@ -3270,7 +3270,6 @@ void produce(struct region *r)
|
||||||
sabotage_cmd(u, u->thisorder);
|
sabotage_cmd(u, u->thisorder);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case K_PLANT:
|
|
||||||
case K_BREED:
|
case K_BREED:
|
||||||
breed_cmd(u, u->thisorder);
|
breed_cmd(u, u->thisorder);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -305,7 +305,7 @@ const building_type *findbuildingtype(const char *name,
|
||||||
for (qi = 0, ql = buildingtypes; ql; ql_advance(&ql, &qi, 1)) {
|
for (qi = 0, ql = buildingtypes; ql; ql_advance(&ql, &qi, 1)) {
|
||||||
building_type *btype = (building_type *)ql_get(ql, qi);
|
building_type *btype = (building_type *)ql_get(ql, qi);
|
||||||
|
|
||||||
const char *n = locale_string(lang, btype->_name);
|
const char *n = LOC(lang, btype->_name);
|
||||||
type.v = (void *)btype;
|
type.v = (void *)btype;
|
||||||
addtoken(&bn->names, n, type);
|
addtoken(&bn->names, n, type);
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,7 +144,7 @@ bool ExpensiveMigrants(void)
|
||||||
gamecookie = global.cookie;
|
gamecookie = global.cookie;
|
||||||
value = get_param_int(global.parameters, "study.expensivemigrants", 0);
|
value = get_param_int(global.parameters, "study.expensivemigrants", 0);
|
||||||
}
|
}
|
||||||
return value;
|
return value!=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Specifies automatic alliance modes.
|
/** Specifies automatic alliance modes.
|
||||||
|
@ -932,12 +932,12 @@ void init_terrains_translation(const struct locale *lang) {
|
||||||
variant var;
|
variant var;
|
||||||
const char *name;
|
const char *name;
|
||||||
var.v = (void *)terrain;
|
var.v = (void *)terrain;
|
||||||
name = LOC(lang, terrain->_name);
|
name = locale_string(lang, terrain->_name, false);
|
||||||
if (name) {
|
if (name) {
|
||||||
addtoken(tokens, name, var);
|
addtoken(tokens, name, var);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log_error("no translation for terrain %s in locale %s", terrain->_name, locale_name(lang));
|
log_debug("no translation for terrain %s in locale %s", terrain->_name, locale_name(lang));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -951,12 +951,12 @@ void init_options_translation(const struct locale * lang) {
|
||||||
variant var;
|
variant var;
|
||||||
var.i = i;
|
var.i = i;
|
||||||
if (options[i]) {
|
if (options[i]) {
|
||||||
const char *name = LOC(lang, options[i]);
|
const char *name = locale_string(lang, options[i], false);
|
||||||
if (name) {
|
if (name) {
|
||||||
addtoken(tokens, name, var);
|
addtoken(tokens, name, var);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log_error("no translation for OPTION %s in locale %s", options[i], locale_name(lang));
|
log_debug("no translation for OPTION %s in locale %s", options[i], locale_name(lang));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1006,9 +1006,9 @@ void init_locale(struct locale *lang)
|
||||||
for (rc = races; rc; rc = rc->next) {
|
for (rc = races; rc; rc = rc->next) {
|
||||||
const char *name;
|
const char *name;
|
||||||
var.v = (void *)rc;
|
var.v = (void *)rc;
|
||||||
name = LOC(lang, rc_name_s(rc, NAME_PLURAL));
|
name = locale_string(lang, rc_name_s(rc, NAME_PLURAL), false);
|
||||||
if (name) addtoken(tokens, name, var);
|
if (name) addtoken(tokens, name, var);
|
||||||
name = LOC(lang, rc_name_s(rc, NAME_SINGULAR));
|
name = locale_string(lang, rc_name_s(rc, NAME_SINGULAR), false);
|
||||||
if (name) addtoken(tokens, name, var);
|
if (name) addtoken(tokens, name, var);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1122,8 +1122,15 @@ void set_param(struct param **p, const char *key, const char *data)
|
||||||
while (*p != NULL) {
|
while (*p != NULL) {
|
||||||
int cmp = strcmp((*p)->name, key);
|
int cmp = strcmp((*p)->name, key);
|
||||||
if (cmp == 0) {
|
if (cmp == 0) {
|
||||||
free((*p)->data);
|
par = *p;
|
||||||
(*p)->data = _strdup(data);
|
free(par->data);
|
||||||
|
if (data) {
|
||||||
|
par->data = _strdup(data);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
*p = par->next;
|
||||||
|
free(par);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (cmp > 0) {
|
else if (cmp > 0) {
|
||||||
|
@ -1686,7 +1693,7 @@ order *default_order(const struct locale *lang)
|
||||||
assert(i < MAXLOCALES);
|
assert(i < MAXLOCALES);
|
||||||
result = defaults[i];
|
result = defaults[i];
|
||||||
if (!result && usedefault) {
|
if (!result && usedefault) {
|
||||||
const char * str = locale_string(lang, "defaultorder");
|
const char * str = LOC(lang, "defaultorder");
|
||||||
if (str) {
|
if (str) {
|
||||||
result = defaults[i] = parse_order(str, lang);
|
result = defaults[i] = parse_order(str, lang);
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,6 +71,8 @@ static void test_get_set_param(CuTest * tc)
|
||||||
set_param(&par, "bar", "foo");
|
set_param(&par, "bar", "foo");
|
||||||
CuAssertStrEquals(tc, "bar", get_param(par, "foo"));
|
CuAssertStrEquals(tc, "bar", get_param(par, "foo"));
|
||||||
CuAssertStrEquals(tc, "foo", get_param(par, "bar"));
|
CuAssertStrEquals(tc, "foo", get_param(par, "bar"));
|
||||||
|
set_param(&par, "bar", NULL);
|
||||||
|
CuAssertPtrEquals(tc, NULL, (void *)get_param(par, "bar"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_param_int(CuTest * tc)
|
static void test_param_int(CuTest * tc)
|
||||||
|
|
|
@ -1045,7 +1045,7 @@ static int add_resourcename_cb(const void * match, const void * key, size_t keyl
|
||||||
cb_get_kv(match, &rtype, sizeof(rtype));
|
cb_get_kv(match, &rtype, sizeof(rtype));
|
||||||
for (i = 0; i != 2; ++i) {
|
for (i = 0; i != 2; ++i) {
|
||||||
char buffer[128];
|
char buffer[128];
|
||||||
const char * name = locale_string(lang, resourcename(rtype, (i==0) ? 0 : NMF_PLURAL));
|
const char * name = LOC(lang, resourcename(rtype, (i == 0) ? 0 : NMF_PLURAL));
|
||||||
|
|
||||||
if (name && transliterate(buffer, sizeof(buffer), name)) {
|
if (name && transliterate(buffer, sizeof(buffer), name)) {
|
||||||
size_t len = strlen(buffer);
|
size_t len = strlen(buffer);
|
||||||
|
@ -1096,7 +1096,7 @@ static int add_itemname_cb(const void * match, const void * key, size_t keylen,
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i != 2; ++i) {
|
for (i = 0; i != 2; ++i) {
|
||||||
char buffer[128];
|
char buffer[128];
|
||||||
const char * name = locale_string(lang, resourcename(rtype, (i == 0) ? 0 : NMF_PLURAL));
|
const char * name = LOC(lang, resourcename(rtype, (i == 0) ? 0 : NMF_PLURAL));
|
||||||
|
|
||||||
if (name && transliterate(buffer, sizeof(buffer), name)) {
|
if (name && transliterate(buffer, sizeof(buffer), name)) {
|
||||||
size_t len = strlen(buffer);
|
size_t len = strlen(buffer);
|
||||||
|
|
|
@ -373,8 +373,8 @@ static void test_skills(CuTest * tc)
|
||||||
CuAssertIntEquals(tc, SK_CROSSBOW, get_skill("kreuz", lang));
|
CuAssertIntEquals(tc, SK_CROSSBOW, get_skill("kreuz", lang));
|
||||||
CuAssertIntEquals(tc, SK_ALCHEMY, get_skill("alchemie", lang));
|
CuAssertIntEquals(tc, SK_ALCHEMY, get_skill("alchemie", lang));
|
||||||
|
|
||||||
CuAssertStrEquals(tc, "ALCHEMIE", locale_string(lang, "skill::alchemy"));
|
CuAssertStrEquals(tc, "ALCHEMIE", LOC(lang, "skill::alchemy"));
|
||||||
CuAssertStrEquals(tc, "ARMBRUST", locale_string(lang, "skill::crossbow"));
|
CuAssertStrEquals(tc, "ARMBRUST", LOC(lang, "skill::crossbow"));
|
||||||
|
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
@ -396,8 +396,8 @@ static void test_keywords(CuTest * tc)
|
||||||
CuAssertIntEquals(tc, K_STUDY, get_keyword("lerne", lang));
|
CuAssertIntEquals(tc, K_STUDY, get_keyword("lerne", lang));
|
||||||
CuAssertIntEquals(tc, K_MOVE, get_keyword("nach", lang));
|
CuAssertIntEquals(tc, K_MOVE, get_keyword("nach", lang));
|
||||||
|
|
||||||
CuAssertStrEquals(tc, "LERNEN", locale_string(lang, "keyword::study"));
|
CuAssertStrEquals(tc, "LERNEN", LOC(lang, "keyword::study"));
|
||||||
CuAssertStrEquals(tc, "NACH", locale_string(lang, "keyword::move"));
|
CuAssertStrEquals(tc, "NACH", LOC(lang, "keyword::move"));
|
||||||
|
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
@ -413,10 +413,10 @@ static void test_strings(CuTest * tc)
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
lang = get_or_create_locale("de");
|
lang = get_or_create_locale("de");
|
||||||
CuAssertPtrNotNull(tc, lang);
|
CuAssertPtrNotNull(tc, lang);
|
||||||
CuAssertPtrEquals(tc, NULL, (void *)locale_string(lang, "move"));
|
CuAssertPtrEquals(tc, NULL, (void *)LOC(lang, "move"));
|
||||||
json_config(json);
|
json_config(json);
|
||||||
CuAssertStrEquals(tc, "NACH", locale_string(lang, "move"));
|
CuAssertStrEquals(tc, "NACH", LOC(lang, "move"));
|
||||||
CuAssertStrEquals(tc, "LERNEN", locale_string(lang, "study"));
|
CuAssertStrEquals(tc, "LERNEN", LOC(lang, "study"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_infinitive_from_config(CuTest *tc) {
|
static void test_infinitive_from_config(CuTest *tc) {
|
||||||
|
|
|
@ -388,8 +388,6 @@ order *parse_order(const char *s, const struct locale * lang)
|
||||||
bool is_repeated(const order * ord)
|
bool is_repeated(const order * ord)
|
||||||
{
|
{
|
||||||
keyword_t kwd = ORD_KEYWORD(ord);
|
keyword_t kwd = ORD_KEYWORD(ord);
|
||||||
int result = 0;
|
|
||||||
|
|
||||||
switch (kwd) {
|
switch (kwd) {
|
||||||
case K_CAST:
|
case K_CAST:
|
||||||
case K_BUY:
|
case K_BUY:
|
||||||
|
@ -408,17 +406,15 @@ bool is_repeated(const order * ord)
|
||||||
case K_TEACH:
|
case K_TEACH:
|
||||||
case K_BREED:
|
case K_BREED:
|
||||||
case K_PIRACY:
|
case K_PIRACY:
|
||||||
case K_PLANT:
|
|
||||||
case K_MAKE:
|
case K_MAKE:
|
||||||
case K_LOOT:
|
case K_LOOT:
|
||||||
case K_DESTROY:
|
case K_DESTROY:
|
||||||
result = 1;
|
return true;
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
result = 0;
|
break;
|
||||||
}
|
}
|
||||||
return result;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -432,7 +428,6 @@ bool is_repeated(const order * ord)
|
||||||
bool is_exclusive(const order * ord)
|
bool is_exclusive(const order * ord)
|
||||||
{
|
{
|
||||||
keyword_t kwd = ORD_KEYWORD(ord);
|
keyword_t kwd = ORD_KEYWORD(ord);
|
||||||
int result = 0;
|
|
||||||
|
|
||||||
switch (kwd) {
|
switch (kwd) {
|
||||||
case K_MOVE:
|
case K_MOVE:
|
||||||
|
@ -450,17 +445,15 @@ bool is_exclusive(const order * ord)
|
||||||
case K_TEACH:
|
case K_TEACH:
|
||||||
case K_BREED:
|
case K_BREED:
|
||||||
case K_PIRACY:
|
case K_PIRACY:
|
||||||
case K_PLANT:
|
|
||||||
case K_MAKE:
|
case K_MAKE:
|
||||||
case K_LOOT:
|
case K_LOOT:
|
||||||
case K_DESTROY:
|
case K_DESTROY:
|
||||||
result = 1;
|
return true;
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
result = 0;
|
break;
|
||||||
}
|
}
|
||||||
return result;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -474,7 +467,6 @@ bool is_exclusive(const order * ord)
|
||||||
bool is_long(const order * ord)
|
bool is_long(const order * ord)
|
||||||
{
|
{
|
||||||
keyword_t kwd = ORD_KEYWORD(ord);
|
keyword_t kwd = ORD_KEYWORD(ord);
|
||||||
bool result = false;
|
|
||||||
|
|
||||||
switch (kwd) {
|
switch (kwd) {
|
||||||
case K_CAST:
|
case K_CAST:
|
||||||
|
@ -495,16 +487,15 @@ bool is_long(const order * ord)
|
||||||
case K_TEACH:
|
case K_TEACH:
|
||||||
case K_BREED:
|
case K_BREED:
|
||||||
case K_PIRACY:
|
case K_PIRACY:
|
||||||
case K_PLANT:
|
|
||||||
case K_MAKE:
|
case K_MAKE:
|
||||||
case K_LOOT:
|
case K_LOOT:
|
||||||
case K_DESTROY:
|
case K_DESTROY:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
result = false;
|
break;
|
||||||
}
|
}
|
||||||
return result;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -532,7 +523,6 @@ bool is_persistent(const order * ord)
|
||||||
default:
|
default:
|
||||||
return persist || is_repeated(ord);
|
return persist || is_repeated(ord);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char *write_order(const order * ord, char *buffer, size_t size)
|
char *write_order(const order * ord, char *buffer, size_t size)
|
||||||
|
|
|
@ -168,8 +168,9 @@ static unit *unitorders(FILE * F, int enc, struct faction *f)
|
||||||
|
|
||||||
if (s[0]) {
|
if (s[0]) {
|
||||||
if (s[0] != '@') {
|
if (s[0] != '@') {
|
||||||
|
char token[128];
|
||||||
const char *stok = s;
|
const char *stok = s;
|
||||||
stok = parse_token_depr(&stok);
|
stok = parse_token(&stok, token, sizeof(token));
|
||||||
|
|
||||||
if (stok) {
|
if (stok) {
|
||||||
bool quit = false;
|
bool quit = false;
|
||||||
|
@ -192,7 +193,6 @@ static unit *unitorders(FILE * F, int enc, struct faction *f)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
/* TODO: syntax error message */
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (quit) {
|
if (quit) {
|
||||||
|
@ -1568,7 +1568,7 @@ int readgame(const char *filename, int backup)
|
||||||
sh->type = st_find(name);
|
sh->type = st_find(name);
|
||||||
if (sh->type == NULL) {
|
if (sh->type == NULL) {
|
||||||
/* old datafiles */
|
/* old datafiles */
|
||||||
sh->type = st_find((const char *)locale_string(default_locale, name));
|
sh->type = st_find((const char *)LOC(default_locale, name));
|
||||||
}
|
}
|
||||||
assert(sh->type || !"ship_type not registered!");
|
assert(sh->type || !"ship_type not registered!");
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ const ship_type *findshiptype(const char *name, const struct locale *lang)
|
||||||
for (qi = 0, ql = shiptypes; ql; ql_advance(&ql, &qi, 1)) {
|
for (qi = 0, ql = shiptypes; ql; ql_advance(&ql, &qi, 1)) {
|
||||||
ship_type *stype = (ship_type *)ql_get(ql, qi);
|
ship_type *stype = (ship_type *)ql_get(ql, qi);
|
||||||
variant var2;
|
variant var2;
|
||||||
const char *n = locale_string(lang, stype->_name);
|
const char *n = LOC(lang, stype->_name);
|
||||||
var2.v = (void *)stype;
|
var2.v = (void *)stype;
|
||||||
addtoken(&sn->names, n, var2);
|
addtoken(&sn->names, n, var2);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1883,7 +1883,7 @@ char *write_unitname(const unit * u, char *buffer, size_t size)
|
||||||
} else {
|
} else {
|
||||||
const struct locale * lang = u->faction ? u->faction->locale : default_locale;
|
const struct locale * lang = u->faction ? u->faction->locale : default_locale;
|
||||||
const char * name = rc_name_s(u->_race, u->number == 1 ? NAME_SINGULAR : NAME_PLURAL);
|
const char * name = rc_name_s(u->_race, u->number == 1 ? NAME_SINGULAR : NAME_PLURAL);
|
||||||
slprintf(buffer, size, "%s (%s)", locale_string(lang, name), itoa36(u->no));
|
slprintf(buffer, size, "%s (%s)", LOC(lang, name), itoa36(u->no));
|
||||||
}
|
}
|
||||||
buffer[size - 1] = 0;
|
buffer[size - 1] = 0;
|
||||||
return buffer;
|
return buffer;
|
||||||
|
@ -1902,8 +1902,8 @@ bool unit_name_equals_race(const unit *u) {
|
||||||
rc_name(u->_race, NAME_SINGULAR, sing, sizeof(sing));
|
rc_name(u->_race, NAME_SINGULAR, sing, sizeof(sing));
|
||||||
rc_name(u->_race, NAME_PLURAL, plur, sizeof(plur));
|
rc_name(u->_race, NAME_PLURAL, plur, sizeof(plur));
|
||||||
if (strcmp(u->name, sing) == 0 || strcmp(u->name, plur) == 0 ||
|
if (strcmp(u->name, sing) == 0 || strcmp(u->name, plur) == 0 ||
|
||||||
strcmp(u->name, locale_string(lang, sing)) == 0 ||
|
strcmp(u->name, LOC(lang, sing)) == 0 ||
|
||||||
strcmp(u->name, locale_string(lang, plur)) == 0) {
|
strcmp(u->name, LOC(lang, plur)) == 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,7 +138,6 @@ const char *keywords[MAXKEYWORDS] = {
|
||||||
"group",
|
"group",
|
||||||
"sort",
|
"sort",
|
||||||
"prefix",
|
"prefix",
|
||||||
"plant",
|
|
||||||
"alliance",
|
"alliance",
|
||||||
"claim",
|
"claim",
|
||||||
"promote",
|
"promote",
|
||||||
|
|
|
@ -64,7 +64,6 @@ typedef enum {
|
||||||
K_GROUP,
|
K_GROUP,
|
||||||
K_SORT,
|
K_SORT,
|
||||||
K_PREFIX,
|
K_PREFIX,
|
||||||
K_PLANT,
|
|
||||||
K_ALLIANCE,
|
K_ALLIANCE,
|
||||||
K_CLAIM,
|
K_CLAIM,
|
||||||
K_PROMOTION,
|
K_PROMOTION,
|
||||||
|
|
10
src/laws.c
10
src/laws.c
|
@ -968,7 +968,7 @@ static bool CheckOverload(void)
|
||||||
if (value < 0) {
|
if (value < 0) {
|
||||||
value = get_param_int(global.parameters, "rules.check_overload", 0);
|
value = get_param_int(global.parameters, "rules.check_overload", 0);
|
||||||
}
|
}
|
||||||
return value;
|
return value!=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int enter_ship(unit * u, struct order *ord, int id, bool report)
|
int enter_ship(unit * u, struct order *ord, int id, bool report)
|
||||||
|
@ -1411,11 +1411,11 @@ static void init_prefixnames(void)
|
||||||
for (key = 0; race_prefixes[key]; ++key) {
|
for (key = 0; race_prefixes[key]; ++key) {
|
||||||
variant var;
|
variant var;
|
||||||
const char *pname =
|
const char *pname =
|
||||||
locale_string(lang, mkname("prefix", race_prefixes[key]));
|
LOC(lang, mkname("prefix", race_prefixes[key]));
|
||||||
if (findtoken(in->names, pname, &var) == E_TOK_NOMATCH || var.i != key) {
|
if (findtoken(in->names, pname, &var) == E_TOK_NOMATCH || var.i != key) {
|
||||||
var.i = key;
|
var.i = key;
|
||||||
addtoken(&in->names, pname, var);
|
addtoken(&in->names, pname, var);
|
||||||
addtoken(&in->names, locale_string(lang, mkname("prefix",
|
addtoken(&in->names, LOC(lang, mkname("prefix",
|
||||||
race_prefixes[key])), var);
|
race_prefixes[key])), var);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2209,7 +2209,7 @@ static bool display_item(faction * f, unit * u, const item_type * itype)
|
||||||
info = locale_getstring(f->locale, key);
|
info = locale_getstring(f->locale, key);
|
||||||
|
|
||||||
if (info == NULL) {
|
if (info == NULL) {
|
||||||
info = locale_string(f->locale, mkname("iteminfo", "no_info"));
|
info = LOC(f->locale, mkname("iteminfo", "no_info"));
|
||||||
}
|
}
|
||||||
ADDMSG(&f->msgs, msg_message("displayitem", "weight item description",
|
ADDMSG(&f->msgs, msg_message("displayitem", "weight item description",
|
||||||
itype->weight, itype->rtype, info));
|
itype->weight, itype->rtype, info));
|
||||||
|
@ -2261,7 +2261,7 @@ static bool display_race(faction * f, unit * u, const race * rc)
|
||||||
key = mkname("raceinfo", rc->_name);
|
key = mkname("raceinfo", rc->_name);
|
||||||
info = locale_getstring(f->locale, key);
|
info = locale_getstring(f->locale, key);
|
||||||
if (info == NULL) {
|
if (info == NULL) {
|
||||||
info = locale_string(f->locale, mkname("raceinfo", "no_info"));
|
info = LOC(f->locale, mkname("raceinfo", "no_info"));
|
||||||
}
|
}
|
||||||
|
|
||||||
bytes = (int)strlcpy(bufp, info, size);
|
bytes = (int)strlcpy(bufp, info, size);
|
||||||
|
|
|
@ -104,9 +104,9 @@ bool check_leuchtturm(region * r, faction * f)
|
||||||
{
|
{
|
||||||
attrib *a;
|
attrib *a;
|
||||||
|
|
||||||
if (!fval(r->terrain, SEA_REGION))
|
if (!fval(r->terrain, SEA_REGION)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
for (a = a_find(r->attribs, &at_lighthouse); a && a->type == &at_lighthouse;
|
for (a = a_find(r->attribs, &at_lighthouse); a && a->type == &at_lighthouse;
|
||||||
a = a->next) {
|
a = a->next) {
|
||||||
building *b = (building *)a->data.v;
|
building *b = (building *)a->data.v;
|
||||||
|
@ -141,7 +141,7 @@ bool check_leuchtturm(region * r, faction * f)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* E3A rule: no perception req'd */
|
/* E3A rule: no perception req'd */
|
||||||
return maxd;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1025,7 +1025,7 @@ static void describe(FILE * F, const seen_region * sr, faction * f)
|
||||||
|
|
||||||
if (r->land->ownership) {
|
if (r->land->ownership) {
|
||||||
const char *str =
|
const char *str =
|
||||||
locale_string(f->locale, mkname("morale", itoa10(r->land->morale)));
|
LOC(f->locale, mkname("morale", itoa10(r->land->morale)));
|
||||||
bytes = _snprintf(bufp, size, " %s", str);
|
bytes = _snprintf(bufp, size, " %s", str);
|
||||||
if (wrptr(&bufp, &size, bytes) != 0)
|
if (wrptr(&bufp, &size, bytes) != 0)
|
||||||
WARN_STATIC_BUFFER();
|
WARN_STATIC_BUFFER();
|
||||||
|
@ -1701,7 +1701,7 @@ show_allies(const faction * f, const ally * allies, char *buf, size_t size)
|
||||||
if (wrptr(&bufp, &size, bytes) != 0)
|
if (wrptr(&bufp, &size, bytes) != 0)
|
||||||
WARN_STATIC_BUFFER();
|
WARN_STATIC_BUFFER();
|
||||||
if ((mode & HELP_ALL) == HELP_ALL) {
|
if ((mode & HELP_ALL) == HELP_ALL) {
|
||||||
bytes = (int)strlcpy(bufp, locale_string(f->locale, parameters[P_ANY]), size);
|
bytes = (int)strlcpy(bufp, LOC(f->locale, parameters[P_ANY]), size);
|
||||||
if (wrptr(&bufp, &size, bytes) != 0)
|
if (wrptr(&bufp, &size, bytes) != 0)
|
||||||
WARN_STATIC_BUFFER();
|
WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
|
@ -1736,7 +1736,7 @@ show_allies(const faction * f, const ally * allies, char *buf, size_t size)
|
||||||
if (wrptr(&bufp, &size, bytes) != 0)
|
if (wrptr(&bufp, &size, bytes) != 0)
|
||||||
WARN_STATIC_BUFFER();
|
WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
bytes = (int)strlcpy(bufp, locale_string(f->locale, parameters[p]), size);
|
bytes = (int)strlcpy(bufp, LOC(f->locale, parameters[p]), size);
|
||||||
if (wrptr(&bufp, &size, bytes) != 0)
|
if (wrptr(&bufp, &size, bytes) != 0)
|
||||||
WARN_STATIC_BUFFER();
|
WARN_STATIC_BUFFER();
|
||||||
hh = 1;
|
hh = 1;
|
||||||
|
|
|
@ -150,7 +150,7 @@ const char **name, const char **basename, int *number, bool singular)
|
||||||
if (owner && owner->faction == viewer) {
|
if (owner && owner->faction == viewer) {
|
||||||
if (name)
|
if (name)
|
||||||
*name =
|
*name =
|
||||||
locale_string(viewer->locale, resourcename(i->type->rtype,
|
LOC(viewer->locale, resourcename(i->type->rtype,
|
||||||
((i->number != 1 && !singular) ? GR_PLURAL : 0)));
|
((i->number != 1 && !singular) ? GR_PLURAL : 0)));
|
||||||
if (basename)
|
if (basename)
|
||||||
*basename = resourcename(i->type->rtype, 0);
|
*basename = resourcename(i->type->rtype, 0);
|
||||||
|
@ -163,19 +163,19 @@ const char **name, const char **basename, int *number, bool singular)
|
||||||
*number = 1;
|
*number = 1;
|
||||||
if (pp > 50000 && dragonrace(u_race(owner))) {
|
if (pp > 50000 && dragonrace(u_race(owner))) {
|
||||||
if (name)
|
if (name)
|
||||||
*name = locale_string(viewer->locale, "dragonhoard");
|
*name = LOC(viewer->locale, "dragonhoard");
|
||||||
if (basename)
|
if (basename)
|
||||||
*basename = "dragonhoard";
|
*basename = "dragonhoard";
|
||||||
}
|
}
|
||||||
else if (pp > 5000) {
|
else if (pp > 5000) {
|
||||||
if (name)
|
if (name)
|
||||||
*name = locale_string(viewer->locale, "moneychest");
|
*name = LOC(viewer->locale, "moneychest");
|
||||||
if (basename)
|
if (basename)
|
||||||
*basename = "moneychest";
|
*basename = "moneychest";
|
||||||
}
|
}
|
||||||
else if (pp > 500) {
|
else if (pp > 500) {
|
||||||
if (name)
|
if (name)
|
||||||
*name = locale_string(viewer->locale, "moneybag");
|
*name = LOC(viewer->locale, "moneybag");
|
||||||
if (basename)
|
if (basename)
|
||||||
*basename = "moneybag";
|
*basename = "moneybag";
|
||||||
}
|
}
|
||||||
|
@ -191,7 +191,7 @@ const char **name, const char **basename, int *number, bool singular)
|
||||||
else {
|
else {
|
||||||
if (name)
|
if (name)
|
||||||
*name =
|
*name =
|
||||||
locale_string(viewer->locale, resourcename(i->type->rtype,
|
LOC(viewer->locale, resourcename(i->type->rtype,
|
||||||
NMF_APPEARANCE | ((i->number != 1 && !singular) ? GR_PLURAL : 0)));
|
NMF_APPEARANCE | ((i->number != 1 && !singular) ? GR_PLURAL : 0)));
|
||||||
if (basename)
|
if (basename)
|
||||||
*basename = resourcename(i->type->rtype, NMF_APPEARANCE);
|
*basename = resourcename(i->type->rtype, NMF_APPEARANCE);
|
||||||
|
@ -584,7 +584,7 @@ size_t size)
|
||||||
|
|
||||||
if (u->number && (u->faction == f || telepath_see || isbattle)) {
|
if (u->number && (u->faction == f || telepath_see || isbattle)) {
|
||||||
const char *c = hp_status(u);
|
const char *c = hp_status(u);
|
||||||
c = c ? locale_string(f->locale, c) : 0;
|
c = c ? LOC(f->locale, c) : 0;
|
||||||
bytes = (int)strlcpy(bufp, ", ", size);
|
bytes = (int)strlcpy(bufp, ", ", size);
|
||||||
if (wrptr(&bufp, &size, bytes) != 0)
|
if (wrptr(&bufp, &size, bytes) != 0)
|
||||||
WARN_STATIC_BUFFER();
|
WARN_STATIC_BUFFER();
|
||||||
|
@ -1956,7 +1956,7 @@ const char *trailinto(const region * r, const struct locale *lang)
|
||||||
if (r) {
|
if (r) {
|
||||||
const char *tname = terrain_name(r);
|
const char *tname = terrain_name(r);
|
||||||
strcat(strcpy(ref, tname), "_trail");
|
strcat(strcpy(ref, tname), "_trail");
|
||||||
s = locale_string(lang, ref);
|
s = LOC(lang, ref);
|
||||||
if (s && *s) {
|
if (s && *s) {
|
||||||
if (strstr(s, "%s"))
|
if (strstr(s, "%s"))
|
||||||
return s;
|
return s;
|
||||||
|
@ -2003,7 +2003,7 @@ static void eval_localize(struct opstack **stack, const void *userdata)
|
||||||
const struct faction *f = (const struct faction *)userdata;
|
const struct faction *f = (const struct faction *)userdata;
|
||||||
const struct locale *lang = f ? f->locale : default_locale;
|
const struct locale *lang = f ? f->locale : default_locale;
|
||||||
const char *c = (const char *)opop_v(stack);
|
const char *c = (const char *)opop_v(stack);
|
||||||
c = locale_string(lang, c);
|
c = LOC(lang, c);
|
||||||
opush_v(stack, strcpy(balloc(strlen(c) + 1), c));
|
opush_v(stack, strcpy(balloc(strlen(c) + 1), c));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ void init_skills(const struct locale *lang) {
|
||||||
const char *skillname(skill_t sk, const struct locale *lang)
|
const char *skillname(skill_t sk, const struct locale *lang)
|
||||||
{
|
{
|
||||||
if (skill_disabled[sk]) return 0;
|
if (skill_disabled[sk]) return 0;
|
||||||
return locale_string(lang, mkname("skill", skillnames[sk]));
|
return LOC(lang, mkname("skill", skillnames[sk]));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -123,7 +123,7 @@ const char *locale_getstring(const locale * lang, const char *key)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *locale_string(const locale * lang, const char *key)
|
const char *locale_string(const locale * lang, const char *key, bool warn)
|
||||||
{
|
{
|
||||||
assert(lang);
|
assert(lang);
|
||||||
assert(key);
|
assert(key);
|
||||||
|
@ -150,9 +150,11 @@ const char *locale_string(const locale * lang, const char *key)
|
||||||
if (find) {
|
if (find) {
|
||||||
return find->str;
|
return find->str;
|
||||||
}
|
}
|
||||||
log_error("missing translation for \"%s\" in locale %s\n", key, lang->name);
|
if (warn) {
|
||||||
|
log_warning("missing translation for \"%s\" in locale %s\n", key, lang->name);
|
||||||
|
}
|
||||||
if (lang->fallback) {
|
if (lang->fallback) {
|
||||||
return locale_string(lang->fallback, key);
|
return locale_string(lang->fallback, key, warn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -262,7 +264,7 @@ void init_translations(const struct locale *lang, int ut, const char * (*string_
|
||||||
tokens = get_translations(lang, ut);
|
tokens = get_translations(lang, ut);
|
||||||
for (i = 0; i != maxstrings; ++i) {
|
for (i = 0; i != maxstrings; ++i) {
|
||||||
const char * s = string_cb(i);
|
const char * s = string_cb(i);
|
||||||
const char * key = s ? locale_string(lang, s) : 0;
|
const char * key = s ? locale_string(lang, s, false) : 0;
|
||||||
key = key ? key : s;
|
key = key ? key : s;
|
||||||
if (key) {
|
if (key) {
|
||||||
struct critbit_tree ** cb = (struct critbit_tree **)tokens;
|
struct critbit_tree ** cb = (struct critbit_tree **)tokens;
|
||||||
|
|
|
@ -18,6 +18,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
#ifndef MY_LOCALE_H
|
#ifndef MY_LOCALE_H
|
||||||
#define MY_LOCALE_H
|
#define MY_LOCALE_H
|
||||||
|
|
||||||
|
#include <platform.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
@ -39,7 +42,7 @@ extern "C" {
|
||||||
const char *value);
|
const char *value);
|
||||||
extern const char *locale_getstring(const struct locale *lang,
|
extern const char *locale_getstring(const struct locale *lang,
|
||||||
const char *key);
|
const char *key);
|
||||||
extern const char *locale_string(const struct locale *lang, const char *key); /* does fallback */
|
extern const char *locale_string(const struct locale *lang, const char *key, bool warn); /* does fallback */
|
||||||
extern unsigned int locale_index(const struct locale *lang);
|
extern unsigned int locale_index(const struct locale *lang);
|
||||||
extern const char *locale_name(const struct locale *lang);
|
extern const char *locale_name(const struct locale *lang);
|
||||||
|
|
||||||
|
@ -48,7 +51,7 @@ extern "C" {
|
||||||
|
|
||||||
extern void make_locales(const char *str);
|
extern void make_locales(const char *str);
|
||||||
|
|
||||||
#define LOC(lang, s) (lang?locale_string(lang, s):s)
|
#define LOC(lang, s) (lang?locale_string(lang, s, true):s)
|
||||||
|
|
||||||
extern struct locale *default_locale;
|
extern struct locale *default_locale;
|
||||||
extern struct locale *locales;
|
extern struct locale *locales;
|
||||||
|
|
|
@ -28,7 +28,7 @@ static dir_lookup *dir_name_lookup;
|
||||||
|
|
||||||
void register_special_direction(struct locale *lang, const char *name)
|
void register_special_direction(struct locale *lang, const char *name)
|
||||||
{
|
{
|
||||||
const char *token = LOC(lang, name);
|
const char *token = locale_string(lang, name, false);
|
||||||
|
|
||||||
if (token) {
|
if (token) {
|
||||||
void **tokens = get_translations(lang, UT_SPECDIR);
|
void **tokens = get_translations(lang, UT_SPECDIR);
|
||||||
|
@ -47,7 +47,7 @@ void register_special_direction(struct locale *lang, const char *name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log_error("no translation for spec_direction '%s' in locale '%s'\n", name, locale_name(lang));
|
log_debug("no translation for spec_direction '%s' in locale '%s'\n", name, locale_name(lang));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue