diff --git a/game/eressea.ini b/eressea.ini
similarity index 84%
rename from game/eressea.ini
rename to eressea.ini
index e1b51607c..b9829c357 100644
--- a/game/eressea.ini
+++ b/eressea.ini
@@ -1,6 +1,5 @@
[eressea]
base = .
-load = setup.lua
report = reports
verbose = 0
lomem = 0
@@ -9,7 +8,6 @@ memcheck = 0
locales = de,en
[config]
-game = arda
source_dir = ..
maxnmrs = 10
diff --git a/game/setup.lua b/game/setup.lua
deleted file mode 100644
index 4ff2a0304..000000000
--- a/game/setup.lua
+++ /dev/null
@@ -1,15 +0,0 @@
-local srcpath = config.source_dir
-local respath = srcpath .. '/res'
-local paths = {
- 'scripts/?.lua',
- 'core/scripts/?.lua',
- 'lunit/?.lua'
-}
-
-for idx, path in pairs(paths) do
- package.path = srcpath .. '/' .. path .. ';' .. package.path
-end
-
-read_xml(respath..'/config-arda.xml', respath..'/catalog-arda.xml')
-
-require "init"
diff --git a/se/eressea.vpj b/se/eressea.vpj
index f131f3443..04265cc1e 100644
--- a/se/eressea.vpj
+++ b/se/eressea.vpj
@@ -262,6 +262,7 @@
+
@@ -291,6 +292,7 @@
+
@@ -415,6 +417,7 @@
+
@@ -442,6 +445,7 @@
+
diff --git a/se/tests.vpj b/se/tests.vpj
index 9e0430161..ebc226afc 100644
--- a/se/tests.vpj
+++ b/se/tests.vpj
@@ -246,6 +246,7 @@
+
@@ -268,7 +269,8 @@
+ Filters="*.h;*.H;*.hh;*.hpp;*.hxx;*.inc;*.sh;*.cpy;*.if">
+
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 275e1e4d9..7aa105eca 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -58,6 +58,8 @@ ENDIF()
set (ERESSEA_SRC
eressea.c
+ direction.c
+ keyword.c
json.c
creation.c
creport.c
@@ -141,6 +143,7 @@ set(TESTS_SRC
test_eressea.c
tests.c
tests_test.c
+ direction_test.c
json_test.c
economy_test.c
market_test.c
diff --git a/src/attributes/iceberg.h b/src/attributes/iceberg.h
index b9c423d85..4702f5620 100644
--- a/src/attributes/iceberg.h
+++ b/src/attributes/iceberg.h
@@ -18,6 +18,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#ifndef H_ATTRIBUTE_ICEBERG
#define H_ATTRIBUTE_ICEBERG
+
+#include "direction.h"
+
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/src/bind_process.c b/src/bind_process.c
index 00a501a6b..14fbf628c 100755
--- a/src/bind_process.c
+++ b/src/bind_process.c
@@ -15,6 +15,7 @@
#include "laws.h"
#include "market.h"
#include "study.h"
+#include "keyword.h"
#define PROC_LAND_REGION 0x0001
#define PROC_LONG_ORDER 0x0002
@@ -144,151 +145,152 @@ void process_name(void) {
}
void process_group(void) {
- process_cmd(K_GROUP, group_cmd, 0);
+ process_cmd(K_GROUP, group_cmd, 0);
}
void process_origin(void) {
- process_cmd(K_URSPRUNG, origin_cmd, 0);
+ process_cmd(K_URSPRUNG, origin_cmd, 0);
}
void process_quit(void) {
- process_cmd(K_QUIT, quit_cmd, 0);
- quit();
+ process_cmd(K_QUIT, quit_cmd, 0);
+ quit();
}
void process_study(void) {
- process_cmd(K_TEACH, teach_cmd, PROC_LONG_ORDER);
- process_cmd(K_STUDY, learn_cmd, PROC_LONG_ORDER);
+ process_cmd(K_TEACH, teach_cmd, PROC_LONG_ORDER);
+ process_cmd(K_STUDY, learn_cmd, PROC_LONG_ORDER);
}
void process_movement(void) {
- region * r;
+ region *r;
- movement();
- for (r=regions; r; r=r->next) {
- if (r->ships) {
- sinkships(r);
+ movement();
+ for (r = regions; r; r = r->next) {
+ if (r->ships) {
+ sinkships(r);
+ }
}
- }
}
void process_use(void) {
- process_cmd(K_USE, use_cmd, 0);
+ process_cmd(K_USE, use_cmd, 0);
}
void process_leave(void) {
- process_cmd(K_LEAVE, leave_cmd, 0);
+ process_cmd(K_LEAVE, leave_cmd, 0);
}
void process_promote(void) {
- process_cmd(K_PROMOTION, promotion_cmd, 0);
+ process_cmd(K_PROMOTION, promotion_cmd, 0);
}
void process_renumber(void) {
- process_cmd(K_NUMBER, renumber_cmd, 0);
- renumber_factions();
+ process_cmd(K_NUMBER, renumber_cmd, 0);
+ renumber_factions();
}
void process_restack(void) {
- restack_units();
+ restack_units();
}
void process_setspells(void) {
- process_cmd(K_COMBATSPELL, combatspell_cmd, 0);
+ process_cmd(K_COMBATSPELL, combatspell_cmd, 0);
}
void process_sethelp(void) {
- process_cmd(K_ALLY, ally_cmd, 0);
+ process_cmd(K_ALLY, ally_cmd, 0);
}
void process_contact(void) {
- process_cmd(K_CONTACT, contact_cmd, 0);
+ process_cmd(K_CONTACT, contact_cmd, 0);
}
void process_magic(void) {
- magic();
+ magic();
}
void process_give_control(void) {
- process_cmd(K_CONTACT, give_control_cmd, 0);
+ process_cmd(K_CONTACT, give_control_cmd, 0);
}
void process_guard_on(void) {
- process_cmd(K_GUARD, guard_on_cmd, PROC_LAND_REGION);
+ process_cmd(K_GUARD, guard_on_cmd, PROC_LAND_REGION);
}
void process_explain(void) {
- process_cmd(K_RESHOW, reshow_cmd, 0);
+ process_cmd(K_RESHOW, reshow_cmd, 0);
}
void process_reserve(void) {
- process_cmd(K_RESERVE, reserve_cmd, 0);
+ process_cmd(K_RESERVE, reserve_cmd, 0);
}
void process_claim(void) {
- process_cmd(K_CLAIM, claim_cmd, 0);
+ process_cmd(K_CLAIM, claim_cmd, 0);
}
void process_follow(void) {
- struct region *r;
- for (r = regions; r; r = r->next) {
- unit * u;
- for (u=r->units; u; u=u->next) {
- follow_unit(u);
+ struct region *r;
+ for (r = regions; r; r = r->next) {
+ unit *u;
+ for (u = r->units; u; u = u->next) {
+ follow_unit(u);
+ }
}
- }
}
void process_messages(void) {
- process_cmd(K_MAIL, mail_cmd, 0);
+ process_cmd(K_MAIL, mail_cmd, 0);
}
void process_guard_off(void) {
- process_cmd(K_GUARD, guard_off_cmd, PROC_LAND_REGION);
+ process_cmd(K_GUARD, guard_off_cmd, PROC_LAND_REGION);
}
void process_regeneration(void) {
- monthly_healing();
- regenerate_aura();
+ monthly_healing();
+ regenerate_aura();
}
void process_enter(int final) {
- region * r;
- for (r=regions; r; r=r->next) {
- do_enter(r, final);
- }
+ region *r;
+ for (r = regions; r; r = r->next) {
+ do_enter(r, final);
+ }
}
void process_maintenance(void) {
- region * r;
- for (r=regions; r; r=r->next) {
- unit * u;
- for (u=r->units; u; u=u->next) {
- order * ord;
- for (ord=u->orders; ord; ord=ord->next) {
- keyword_t kwd = get_keyword(ord);
- if (kwd==K_PAY) {
- pay_cmd(u, ord);
+ region *r;
+ for (r = regions; r; r = r->next) {
+ unit *u;
+ for (u = r->units; u; u = u->next) {
+ order *ord;
+ for (ord = u->orders; ord; ord = ord->next) {
+ keyword_t kwd = get_keyword(ord);
+ if (kwd == K_PAY) {
+ pay_cmd(u, ord);
+ }
+ }
}
- }
+ maintain_buildings(r, 0);
}
- maintain_buildings(r, 0);
- }
}
void process_alliance(void) {
- alliance_cmd();
+ alliance_cmd();
}
void process_idle(void) {
- region * r;
- for (r=regions; r; r=r->next) {
- auto_work(r);
- }
+ region *r;
+ for (r = regions; r; r = r->next) {
+ auto_work(r);
+ }
}
void process_set_default(void) {
- if (!global.disabled[K_DEFAULT]) {
- defaultorders();
- }
+ if (!keyword_disabled(K_DEFAULT)) {
+ defaultorders();
+ }
}
+
diff --git a/src/direction.c b/src/direction.c
new file mode 100644
index 000000000..95ad70926
--- /dev/null
+++ b/src/direction.c
@@ -0,0 +1,58 @@
+#include
+#include
+#include "direction.h"
+
+#include "util/language.h"
+#include "util/umlaut.h"
+
+void init_direction(const struct locale *lang, direction_t dir, const char *str) {
+ void **tokens = get_translations(lang, UT_DIRECTIONS);
+ variant token;
+ token.i = dir;
+ addtoken(tokens, str, token);
+}
+
+void init_directions(const struct locale *lang) {
+ /* mit dieser routine kann man mehrere namen für eine direction geben,
+ * das ist für die hexes ideal. */
+ const struct {
+ const char *name;
+ direction_t direction;
+ } dirs[] = {
+ { "dir_ne", D_NORTHEAST },
+ { "dir_nw", D_NORTHWEST },
+ { "dir_se", D_SOUTHEAST },
+ { "dir_sw", D_SOUTHWEST },
+ { "dir_east", D_EAST },
+ { "dir_west", D_WEST },
+ { "northeast", D_NORTHEAST },
+ { "northwest", D_NORTHWEST },
+ { "southeast", D_SOUTHEAST },
+ { "southwest", D_SOUTHWEST },
+ { "east", D_EAST },
+ { "west", D_WEST },
+ { "PAUSE", D_PAUSE },
+ { NULL, NODIRECTION }
+ };
+ int i;
+ void **tokens = get_translations(lang, UT_DIRECTIONS);
+
+ for (i = 0; dirs[i].direction != NODIRECTION; ++i) {
+ variant token;
+ const char *str = locale_string(lang, dirs[i].name);
+ token.i = dirs[i].direction;
+ addtoken(tokens, str, token);
+ }
+}
+
+direction_t finddirection(const char *s, const struct locale *lang)
+{
+ void **tokens = get_translations(lang, UT_DIRECTIONS);
+ variant token;
+
+ if (findtoken(*tokens, s, &token) == E_TOK_SUCCESS) {
+ return (direction_t)token.i;
+ }
+ return NODIRECTION;
+}
+
diff --git a/src/direction.h b/src/direction.h
new file mode 100644
index 000000000..6919ecd44
--- /dev/null
+++ b/src/direction.h
@@ -0,0 +1,30 @@
+#ifndef H_DIRECTION_H
+#define H_DIRECTION_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+struct locale;
+
+typedef enum {
+ D_NORTHWEST,
+ D_NORTHEAST,
+ D_EAST,
+ D_SOUTHEAST,
+ D_SOUTHWEST,
+ D_WEST,
+ MAXDIRECTIONS,
+ D_PAUSE,
+ D_SPECIAL,
+ NODIRECTION = -1
+} direction_t;
+
+direction_t finddirection(const char *s, const struct locale *);
+void init_directions(const struct locale *lang);
+void init_direction(const struct locale *lang, direction_t dir, const char *str);
+
+#ifdef __cplusplus
+#endif
+#endif
diff --git a/src/direction_test.c b/src/direction_test.c
new file mode 100644
index 000000000..409568fee
--- /dev/null
+++ b/src/direction_test.c
@@ -0,0 +1,54 @@
+#include
+#include "kernel/types.h"
+#include "direction.h"
+#include "util/language.h"
+#include "tests.h"
+
+#include
+
+void test_init_directions(CuTest *tc) {
+ struct locale *lang;
+
+ test_cleanup();
+ lang = make_locale("en");
+ locale_setstring(lang, "dir_nw", "NW");
+ init_directions(lang);
+ CuAssertIntEquals(tc, D_NORTHWEST, finddirection("nw", lang));
+ test_cleanup();
+}
+
+void test_init_direction(CuTest *tc) {
+ struct locale *lang;
+ test_cleanup();
+
+ lang = make_locale("de");
+ init_direction(lang, D_NORTHWEST, "NW");
+ init_direction(lang, D_EAST, "OST");
+ CuAssertIntEquals(tc, D_NORTHWEST, finddirection("nw", lang));
+ CuAssertIntEquals(tc, D_EAST, finddirection("ost", lang));
+ CuAssertIntEquals(tc, NODIRECTION, finddirection("east", lang));
+ test_cleanup();
+}
+
+void test_finddirection_default(CuTest *tc) {
+ struct locale *lang;
+ test_cleanup();
+ lang = make_locale("en");
+ CuAssertIntEquals(tc, NODIRECTION, finddirection("potato", lang));
+ CuAssertIntEquals(tc, D_SOUTHWEST, finddirection("southwest", lang));
+ CuAssertIntEquals(tc, D_SOUTHEAST, finddirection("southeast", lang));
+ CuAssertIntEquals(tc, D_NORTHWEST, finddirection("northwest", lang));
+ CuAssertIntEquals(tc, D_NORTHEAST, finddirection("northeast", lang));
+ CuAssertIntEquals(tc, D_WEST, finddirection("west", lang));
+ CuAssertIntEquals(tc, D_EAST, finddirection("east", lang));
+}
+
+CuSuite *get_direction_suite(void)
+{
+ CuSuite *suite = CuSuiteNew();
+ SUITE_ADD_TEST(suite, test_init_direction);
+ SUITE_ADD_TEST(suite, test_init_directions);
+ SUITE_ADD_TEST(suite, test_finddirection_default);
+ return suite;
+}
+
diff --git a/src/economy.c b/src/economy.c
index 6d015106b..b83d64f79 100644
--- a/src/economy.c
+++ b/src/economy.c
@@ -21,7 +21,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include
#include "economy.h"
-/* gamecode includes */
+#include "direction.h"
#include "give.h"
#include "laws.h"
#include "randenc.h"
diff --git a/src/kernel/ally_test.c b/src/kernel/ally_test.c
index c7b8500ad..7a3155159 100644
--- a/src/kernel/ally_test.c
+++ b/src/kernel/ally_test.c
@@ -25,3 +25,4 @@ CuSuite *get_ally_suite(void)
SUITE_ADD_TEST(suite, test_ally);
return suite;
}
+
diff --git a/src/kernel/build.c b/src/kernel/build.c
index 118e7f21a..eb19505be 100644
--- a/src/kernel/build.c
+++ b/src/kernel/build.c
@@ -24,6 +24,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "alchemy.h"
#include "alliance.h"
#include "connection.h"
+#include "direction.h"
#include "building.h"
#include "curse.h"
#include "faction.h"
@@ -93,7 +94,7 @@ ship *getship(const struct region * r)
static void destroy_road(unit * u, int nmax, struct order *ord)
{
- direction_t d = getdirection(u->faction->locale);
+ direction_t d = finddirection(getstrtoken(), u->faction->locale);
unit *u2;
region *r = u->region;
short n = (short)nmax;
diff --git a/src/kernel/build.h b/src/kernel/build.h
index 1e7b7d623..3f469e665 100644
--- a/src/kernel/build.h
+++ b/src/kernel/build.h
@@ -20,6 +20,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#define H_KRNL_BUILD
#include "types.h"
+#include "direction.h"
#ifdef __cplusplus
extern "C" {
diff --git a/src/kernel/config.c b/src/kernel/config.c
index 8fec38181..d28ba1f81 100644
--- a/src/kernel/config.c
+++ b/src/kernel/config.c
@@ -32,6 +32,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "building.h"
#include "calendar.h"
#include "curse.h"
+#include "direction.h"
#include "faction.h"
#include "group.h"
#include "item.h"
@@ -55,7 +56,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include
#include
#include
-#include
#include
#include
#include
@@ -80,6 +80,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
/* external libraries */
#include
+#include
/* libc includes */
#include
@@ -386,69 +387,6 @@ const char *parameters[MAXPARAMS] = {
"ALLIANZ"
};
-const char *keywords[MAXKEYWORDS] = {
- "//",
- "BANNER",
- "ARBEITEN",
- "ATTACKIEREN",
- "BEKLAUEN",
- "BELAGERE",
- "BENENNEN",
- "BENUTZEN",
- "BESCHREIBEN",
- "BETRETEN",
- "BEWACHEN",
- "BOTSCHAFT",
- "ENDE",
- "FAHREN",
- "NUMMER",
- "FOLGEN",
- "FORSCHEN",
- "GIB",
- "HELFEN",
- "KAEMPFEN",
- "KAMPFZAUBER",
- "KAUFEN",
- "KONTAKTIEREN",
- "LEHREN",
- "LERNEN",
- "MACHEN",
- "NACH",
- "PASSWORT",
- "REKRUTIEREN",
- "RESERVIEREN",
- "ROUTE",
- "SABOTIEREN",
- "OPTION",
- "SPIONIEREN",
- "STIRB",
- "TARNEN",
- "TRANSPORTIEREN",
- "TREIBEN",
- "UNTERHALTEN",
- "VERKAUFEN",
- "VERLASSEN",
- "VERGESSEN",
- "ZAUBERE",
- "ZEIGEN",
- "ZERSTOEREN",
- "ZUECHTEN",
- "DEFAULT",
- "URSPRUNG",
- "EMAIL",
- "PIRATERIE",
- "GRUPPE",
- "SORTIEREN",
- "GM",
- "INFO",
- "PRAEFIX",
- "PFLANZEN",
- "ALLIANZ",
- "BEANSPRUCHEN",
- "PROMOTION",
- "BEZAHLEN",
-};
-
const char *report_options[MAX_MSG] = {
"Kampf",
"Ereignisse",
@@ -1346,34 +1284,6 @@ skill_t findskill(const char *s, const struct locale * lang)
return result;
}
-keyword_t findkeyword(const char *s, const struct locale * lang)
-{
- keyword_t result = NOKEYWORD;
- char buffer[64];
-
- assert(lang);
- assert(s);
- while (*s == '@') ++s;
-
- if (*s) {
- char * str = transliterate(buffer, sizeof(buffer)-sizeof(int), s);
-
- if (str) {
- int i;
- const void * match;
- void **tokens = get_translations(lang, UT_KEYWORDS);
- critbit_tree *cb = (critbit_tree *)*tokens;
- assert(cb);
- if (cb_find_prefix(cb, str, strlen(str), &match, 1, 0)) {
- cb_get_kv(match, &i, sizeof(int));
- result = (keyword_t)i;
- return global.disabled[result] ? NOKEYWORD : result;
- }
- }
- }
- return NOKEYWORD;
-}
-
param_t findparam(const char *s, const struct locale * lang)
{
param_t result = NOPARAM;
@@ -1906,57 +1816,7 @@ void *gc_add(void *p)
return p;
}
-static void init_directions(void ** root, const struct locale *lang)
-{
- /* mit dieser routine kann man mehrere namen für eine direction geben,
- * das ist für die hexes ideal. */
- const struct {
- const char *name;
- int direction;
- } dirs[] = {
- {
- "dir_ne", D_NORTHEAST}, {
- "dir_nw", D_NORTHWEST}, {
- "dir_se", D_SOUTHEAST}, {
- "dir_sw", D_SOUTHWEST}, {
- "dir_east", D_EAST}, {
- "dir_west", D_WEST}, {
- "northeast", D_NORTHEAST}, {
- "northwest", D_NORTHWEST}, {
- "southeast", D_SOUTHEAST}, {
- "southwest", D_SOUTHWEST}, {
- "east", D_EAST}, {
- "west", D_WEST}, {
- "PAUSE", D_PAUSE}, {
- NULL, NODIRECTION}
- };
- int i;
- void **tokens = get_translations(lang, UT_DIRECTIONS);
-
- for (i = 0; dirs[i].direction != NODIRECTION; ++i) {
- variant token;
- token.i = dirs[i].direction;
- addtoken(tokens, LOC(lang, dirs[i].name), token);
- }
-}
-
-direction_t finddirection(const char *s, const struct locale *lang)
-{
- void **tokens = get_translations(lang, UT_DIRECTIONS);
- variant token;
-
- if (findtoken(*tokens, s, &token) == E_TOK_SUCCESS) {
- return (direction_t) token.i;
- }
- return NODIRECTION;
-}
-
-direction_t getdirection(const struct locale * lang)
-{
- return finddirection(getstrtoken(), lang);
-}
-
-static void init_translations(const struct locale *lang, int ut, const char * (*string_cb)(int i), int maxstrings)
+void init_translations(const struct locale *lang, int ut, const char * (*string_cb)(int i), int maxstrings)
{
char buffer[256];
void **tokens;
@@ -1986,12 +1846,6 @@ static void init_translations(const struct locale *lang, int ut, const char * (*
}
}
-static const char * keyword_key(int i)
-{
- assert(i=0);
- return keywords[i];
-}
-
static const char * parameter_key(int i)
{
assert(i=0);
@@ -2034,8 +1888,7 @@ static void init_locale(const struct locale *lang)
free(sstr);
}
- tokens = get_translations(lang, UT_DIRECTIONS);
- init_directions(tokens, lang);
+ init_directions(lang);
tokens = get_translations(lang, UT_RACES);
for (rc = races; rc; rc = rc->next) {
@@ -2046,7 +1899,7 @@ static void init_locale(const struct locale *lang)
init_translations(lang, UT_PARAMS, parameter_key, MAXPARAMS);
init_translations(lang, UT_SKILLS, skill_key, MAXSKILLS);
- init_translations(lang, UT_KEYWORDS, keyword_key, MAXKEYWORDS);
+// init_translations(lang, UT_KEYWORDS, keyword_key, MAXKEYWORDS);
tokens = get_translations(lang, UT_OPTIONS);
for (i = 0; i != MAXOPTIONS; ++i) {
@@ -2434,7 +2287,7 @@ void guard(unit * u, unsigned int mask)
int besieged(const unit * u)
{
/* belagert kann man in schiffen und burgen werden */
- return (u && !global.disabled[K_BESIEGE]
+ return (u && !keyword_disabled(K_BESIEGE)
&& u->building && u->building->besieged
&& u->building->besieged >= u->building->size * SIEGEFACTOR);
}
diff --git a/src/kernel/config.h b/src/kernel/config.h
index 8ee6f7aa6..7f03776ae 100644
--- a/src/kernel/config.h
+++ b/src/kernel/config.h
@@ -100,7 +100,6 @@ extern "C" {
/* ----------------- Befehle ----------------------------------- */
- extern const char *keywords[MAXKEYWORDS];
extern const char *parameters[MAXPARAMS];
/** report options **/
@@ -108,8 +107,8 @@ extern "C" {
extern const char *options[MAXOPTIONS];
/* ------------------------------------------------------------- */
-
- extern int shipspeed(const struct ship *sh, const struct unit *u);
+ void init_translations(const struct locale *lang, int ut, const char * (*string_cb)(int i), int maxstrings);
+ int shipspeed(const struct ship *sh, const struct unit *u);
#define i2b(i) ((bool)((i)?(true):(false)))
@@ -130,23 +129,22 @@ extern "C" {
extern int verbosity;
/* parteinummern */
- extern bool faction_id_is_unused(int);
+ bool faction_id_is_unused(int);
/* leuchtturm */
- extern bool check_leuchtturm(struct region *r, struct faction *f);
- extern void update_lighthouse(struct building *lh);
- extern int lighthouse_range(const struct building *b,
+ bool check_leuchtturm(struct region *r, struct faction *f);
+ void update_lighthouse(struct building *lh);
+ int lighthouse_range(const struct building *b,
const struct faction *f);
/* skills */
- extern int skill_limit(struct faction *f, skill_t sk);
- extern int count_skill(struct faction *f, skill_t sk);
+ int skill_limit(struct faction *f, skill_t sk);
+ int count_skill(struct faction *f, skill_t sk);
/* direction, geography */
extern const char *directions[];
- extern direction_t finddirection(const char *s, const struct locale *);
- extern int findoption(const char *s, const struct locale *lang);
+ int findoption(const char *s, const struct locale *lang);
/* special units */
void make_undead_unit(struct unit *);
@@ -159,20 +157,16 @@ extern "C" {
unsigned int getuint(void);
int getint(void);
- direction_t getdirection(const struct locale *);
+ const char *igetstrtoken(const char *s);
- extern const char *igetstrtoken(const char *s);
-
- extern skill_t findskill(const char *s, const struct locale *lang);
-
- extern keyword_t findkeyword(const char *s, const struct locale *lang);
+ skill_t findskill(const char *s, const struct locale *lang);
param_t findparam(const char *s, const struct locale *lang);
param_t findparam_ex(const char *s, const struct locale * lang);
bool isparam(const char *s, const struct locale * lang, param_t param);
param_t getparam(const struct locale *lang);
- extern int getid(void);
+ int getid(void);
#define unitid(x) itoa36((x)->no)
#define getshipid() getid()
@@ -183,39 +177,40 @@ extern "C" {
#define factionid(x) itoa36((x)->no)
#define curseid(x) itoa36((x)->no)
- extern bool cansee(const struct faction *f, const struct region *r,
+ bool cansee(const struct faction *f, const struct region *r,
const struct unit *u, int modifier);
bool cansee_durchgezogen(const struct faction *f, const struct region *r,
const struct unit *u, int modifier);
- extern bool cansee_unit(const struct unit *u, const struct unit *target,
+ bool cansee_unit(const struct unit *u, const struct unit *target,
int modifier);
bool seefaction(const struct faction *f, const struct region *r,
const struct unit *u, int modifier);
- extern int effskill(const struct unit *u, skill_t sk);
+ int effskill(const struct unit *u, skill_t sk);
- extern int lovar(double xpct_x2);
+ int lovar(double xpct_x2);
/* returns a value between [0..xpct_2], generated with two dice */
int distribute(int old, int new_value, int n);
+ void init_locales(void);
int newunitid(void);
int forbiddenid(int id);
int newcontainerid(void);
- extern struct unit *createunit(struct region *r, struct faction *f,
+ struct unit *createunit(struct region *r, struct faction *f,
int number, const struct race *rc);
- extern void create_unitid(struct unit *u, int id);
+ void create_unitid(struct unit *u, int id);
extern bool getunitpeasants;
- extern struct unit *getunitg(const struct region *r, const struct faction *f);
- extern struct unit *getunit(const struct region *r, const struct faction *f);
+ struct unit *getunitg(const struct region *r, const struct faction *f);
+ struct unit *getunit(const struct region *r, const struct faction *f);
- extern int read_unitid(const struct faction *f, const struct region *r);
+ int read_unitid(const struct faction *f, const struct region *r);
- extern int alliedunit(const struct unit *u, const struct faction *f2,
+ int alliedunit(const struct unit *u, const struct faction *f2,
int mode);
- extern int alliedfaction(const struct plane *pl, const struct faction *f,
+ int alliedfaction(const struct plane *pl, const struct faction *f,
const struct faction *f2, int mode);
- extern int alliedgroup(const struct plane *pl, const struct faction *f,
+ int alliedgroup(const struct plane *pl, const struct faction *f,
const struct faction *f2, const struct ally *sf, int mode);
struct faction *findfaction(int n);
@@ -227,12 +222,12 @@ extern "C" {
struct unit *findunitr(const struct region *r, int n);
struct region *findunitregion(const struct unit *su);
- 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 char *unitname(const struct unit *u);
- extern char *write_unitname(const struct unit *u, char *buffer, size_t size);
+ char *estring(const char *s);
+ char *estring_i(char *s);
+ char *cstring(const char *s);
+ char *cstring_i(char *s);
+ const char *unitname(const struct unit *u);
+ char *write_unitname(const struct unit *u, char *buffer, size_t size);
typedef int (*cmp_building_cb) (const struct building * b,
const struct building * a);
@@ -252,9 +247,9 @@ extern "C" {
#define HARVEST_WORK 0x00
#define HARVEST_TAXES 0x01
int rule_blessed_harvest(void);
- extern int rule_give(void);
- extern int rule_alliance_limit(void);
- extern int rule_faction_limit(void);
+ int rule_give(void);
+ int rule_alliance_limit(void);
+ int rule_faction_limit(void);
#define COUNT_MONSTERS 0x01
#define COUNT_MIGRANTS 0x02
@@ -275,8 +270,6 @@ extern "C" {
int ispresent(const struct faction *f, const struct region *r);
int check_option(struct faction *f, int option);
- extern void parse_kwd(keyword_t kword, int (*dofun) (struct unit *,
- struct order *), bool thisorder);
/* Anzahl Personen in einer Einheit festlegen. NUR (!) mit dieser Routine,
* sonst großes Unglück. Durch asserts an ein paar Stellen abgesichert. */
@@ -290,8 +283,8 @@ extern "C" {
void changeblockchaos(void);
/* intervall, in dem die regionen der partei zu finden sind */
- extern struct region *firstregion(struct faction *f);
- extern struct region *lastregion(struct faction *f);
+ struct region *firstregion(struct faction *f);
+ struct region *lastregion(struct faction *f);
void fhash(struct faction *f);
void funhash(struct faction *f);
@@ -335,32 +328,32 @@ extern "C" {
/* Verhindert Abbau von Resourcen mit RTF_LIMITED */
#define GUARD_ALL 0xFFFF
- extern void setstatus(struct unit *u, int status);
+ void setstatus(struct unit *u, int status);
/* !< sets combatstatus of a unit */
- extern void setguard(struct unit *u, unsigned int flags);
+ void setguard(struct unit *u, unsigned int flags);
/* !< setzt die guard-flags der Einheit */
- extern unsigned int getguard(const struct unit *u);
+ unsigned int getguard(const struct unit *u);
/* liest die guard-flags der Einheit */
- extern void guard(struct unit *u, unsigned int mask);
+ void guard(struct unit *u, unsigned int mask);
/* Einheit setzt "BEWACHE", rassenspezifzisch.
* 'mask' kann einzelne flags zusätzlich und-maskieren.
*/
unsigned int guard_flags(const struct unit *u);
- extern bool hunger(int number, struct unit *u);
- extern int lifestyle(const struct unit *);
- extern int besieged(const struct unit *u);
- extern int maxworkingpeasants(const struct region *r);
- extern bool has_horses(const struct unit *u);
- extern int markets_module(void);
- extern int wage(const struct region *r, const struct faction *f,
+ bool hunger(int number, struct unit *u);
+ int lifestyle(const struct unit *);
+ int besieged(const struct unit *u);
+ int maxworkingpeasants(const struct region *r);
+ bool has_horses(const struct unit *u);
+ int markets_module(void);
+ int wage(const struct region *r, const struct faction *f,
const struct race *rc, int in_turn);
- extern int maintenance_cost(const struct unit *u);
- extern struct message *movement_error(struct unit *u, const char *token,
+ int maintenance_cost(const struct unit *u);
+ struct message *movement_error(struct unit *u, const char *token,
struct order *ord, int error_code);
- extern bool move_blocked(const struct unit *u, const struct region *src,
+ bool 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);
+ void add_income(struct unit *u, int type, int want, int qty);
/* movewhere error codes */
enum {
@@ -368,26 +361,26 @@ extern "C" {
E_MOVE_NOREGION, /* no region exists in this direction */
E_MOVE_BLOCKED /* cannot see this region, there is a blocking connection. */
};
- extern int movewhere(const struct unit *u, const char *token,
+ int movewhere(const struct unit *u, const char *token,
struct region *r, struct region **resultp);
- extern const char *datapath(void);
- extern void set_datapath(const char *path);
+ const char *datapath(void);
+ void set_datapath(const char *path);
- extern const char *basepath(void);
- extern void set_basepath(const char *);
+ const char *basepath(void);
+ void set_basepath(const char *);
void load_inifile(struct _dictionary_ *d);
- extern const char *reportpath(void);
- extern void set_reportpath(const char *);
+ const char *reportpath(void);
+ void set_reportpath(const char *);
- extern void kernel_init(void);
- extern void kernel_done(void);
+ void kernel_init(void);
+ void kernel_done(void);
extern const char *localenames[];
/** compatibility: **/
- extern race_t old_race(const struct race *);
+ race_t old_race(const struct race *);
extern const struct race *new_race[];
/* globale settings des Spieles */
@@ -395,7 +388,7 @@ extern "C" {
const char *gamename;
struct attrib *attribs;
unsigned int data_turn;
- bool disabled[MAXKEYWORDS];
+// bool disabled[MAXKEYWORDS];
struct param *parameters;
void *vm_state;
float producexpchance;
@@ -412,33 +405,33 @@ extern "C" {
} settings;
extern settings global;
- extern int produceexp(struct unit *u, skill_t sk, int n);
+ int produceexp(struct unit *u, skill_t sk, int n);
extern bool battledebug;
extern bool sqlpatch;
extern bool lomem; /* save memory */
- extern const char *dbrace(const struct race *rc);
+ const char *dbrace(const struct race *rc);
- extern void set_param(struct param **p, const char *name, const char *data);
- extern const char *get_param(const struct param *p, const char *name);
- extern int get_param_int(const struct param *p, const char *name, int def);
- extern float get_param_flt(const struct param *p, const char *name,
+ void set_param(struct param **p, const char *name, const char *data);
+ const char *get_param(const struct param *p, const char *name);
+ int get_param_int(const struct param *p, const char *name, int def);
+ float get_param_flt(const struct param *p, const char *name,
float def);
- extern bool ExpensiveMigrants(void);
- extern int NMRTimeout(void);
- extern int LongHunger(const struct unit *u);
- extern int SkillCap(skill_t sk);
- extern int NewbieImmunity(void);
- extern bool IsImmune(const struct faction *f);
- extern int AllianceAuto(void); /* flags that allied factions get automatically */
- extern int AllianceRestricted(void); /* flags restricted to allied factions */
- extern int HelpMask(void); /* flags restricted to allied factions */
- extern struct order *default_order(const struct locale *lang);
- extern int entertainmoney(const struct region *r);
+ bool ExpensiveMigrants(void);
+ int NMRTimeout(void);
+ int LongHunger(const struct unit *u);
+ int SkillCap(skill_t sk);
+ int NewbieImmunity(void);
+ bool IsImmune(const struct faction *f);
+ int AllianceAuto(void); /* flags that allied factions get automatically */
+ int AllianceRestricted(void); /* flags restricted to allied factions */
+ int HelpMask(void); /* flags restricted to allied factions */
+ struct order *default_order(const struct locale *lang);
+ int entertainmoney(const struct region *r);
- extern void plagues(struct region *r, bool ismagic);
+ void plagues(struct region *r, bool ismagic);
typedef struct helpmode {
const char *name;
int status;
@@ -456,7 +449,7 @@ extern "C" {
#define GIVE_DEFAULT (GIVE_SELF|GIVE_PEASANTS|GIVE_LUXURIES|GIVE_HERBS|GIVE_GOODS)
extern struct attrib_type at_guard;
- extern void free_gamedata(void);
+ void free_gamedata(void);
#ifdef __cplusplus
}
diff --git a/src/kernel/move.c b/src/kernel/move.c
index 4d919be16..30f37b64a 100644
--- a/src/kernel/move.c
+++ b/src/kernel/move.c
@@ -26,6 +26,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "building.h"
#include "calendar.h"
#include "curse.h"
+#include "direction.h"
#include "faction.h"
#include "item.h"
#include "magic.h"
diff --git a/src/kernel/order.c b/src/kernel/order.c
index f3b1053fc..b0419c93e 100644
--- a/src/kernel/order.c
+++ b/src/kernel/order.c
@@ -15,6 +15,7 @@
#include "order.h"
#include "skill.h"
+#include "keyword.h"
#include
#include
@@ -87,53 +88,50 @@ keyword_t get_keyword(const order * ord)
* This is the inverse function to the parse_order command. Note that
* keywords are expanded to their full length.
*/
-static char *get_command(const order * ord, char *sbuffer, size_t size)
-{
- char *bufp = sbuffer;
- const char *text = ORD_STRING(ord);
- keyword_t kwd = ORD_KEYWORD(ord);
- int bytes;
+static char* get_command(const order *ord, char *sbuffer, size_t size) {
+ char *bufp = sbuffer;
+ const char *text = ORD_STRING(ord);
+ keyword_t kwd = ORD_KEYWORD(ord);
+ int bytes;
- if (ord->_persistent) {
- if (size > 0) {
- *bufp++ = '@';
- --size;
- } else {
- WARN_STATIC_BUFFER();
- }
- }
- if (kwd != NOKEYWORD) {
- const struct locale *lang = ORD_LOCALE(ord);
- if (size > 0) {
- if (text)
- --size;
- bytes = (int)strlcpy(bufp, (const char *)LOC(lang, keywords[kwd]), size);
- if (wrptr(&bufp, &size, bytes) != 0)
- WARN_STATIC_BUFFER();
- if (text)
- *bufp++ = ' ';
- } else {
- WARN_STATIC_BUFFER();
- }
- }
- if (text) {
- bytes = (int)strlcpy(bufp, (const char *)text, size);
- if (wrptr(&bufp, &size, bytes) != 0) {
- WARN_STATIC_BUFFER();
- if (bufp - sbuffer >= 6) {
- bufp -= 6;
- while (bufp > sbuffer && (*bufp & 0x80) != 0) {
- ++size;
- --bufp;
+ if (ord->_persistent) {
+ if (size > 0) {
+ *bufp++ = '@';
+ --size;
+ } else {
+ WARN_STATIC_BUFFER();
}
- memcpy(bufp, "[...]", 6); /* TODO: make sure this only happens in eval_command */
- bufp += 6;
- }
}
- }
- if (size > 0)
- *bufp = 0;
- return sbuffer;
+ if (kwd != NOKEYWORD) {
+ const struct locale *lang = ORD_LOCALE(ord);
+ if (size > 0) {
+ const char *str = (const char *)LOC(lang, keywords[kwd]);
+ assert(str);
+ if (text) --size;
+ bytes = (int)strlcpy(bufp, str, size);
+ if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER();
+ if (text) *bufp++ = ' ';
+ } else {
+ WARN_STATIC_BUFFER();
+ }
+ }
+ if (text) {
+ bytes = (int)strlcpy(bufp, (const char *)text, size);
+ if (wrptr(&bufp, &size, bytes) != 0) {
+ WARN_STATIC_BUFFER();
+ if (bufp - sbuffer >= 6) {
+ bufp -= 6;
+ while (bufp > sbuffer && (*bufp & 0x80) != 0) {
+ ++size;
+ --bufp;
+ }
+ memcpy(bufp, "[...]", 6); /* TODO: make sure this only happens in eval_command */
+ bufp += 6;
+ }
+ }
+ }
+ if (size > 0) *bufp = 0;
+ return sbuffer;
}
char *getcommand(const order * ord)
diff --git a/src/kernel/order.h b/src/kernel/order.h
index d62f6b2ad..61f78bff9 100644
--- a/src/kernel/order.h
+++ b/src/kernel/order.h
@@ -16,6 +16,8 @@
extern "C" {
#endif
+#include "keyword.h"
+
/* Encapsulation of an order
*
* This structure contains one order given by a unit. These used to be
diff --git a/src/kernel/region.h b/src/kernel/region.h
index 593d1e3f9..d427dd5f2 100644
--- a/src/kernel/region.h
+++ b/src/kernel/region.h
@@ -24,6 +24,7 @@ extern "C" {
#include
#include "types.h"
+#include "direction.h"
/* FAST_CONNECT: regions are directly connected to neighbours, saves doing
a hash-access each time a neighbour is needed */
diff --git a/src/kernel/save.h b/src/kernel/save.h
index c3051a722..0b5f48e1c 100644
--- a/src/kernel/save.h
+++ b/src/kernel/save.h
@@ -42,7 +42,6 @@ extern "C" {
extern const char *game_name;
extern int enc_gamedata;
- extern void init_locales(void);
extern int current_turn(void);
extern void read_items(struct storage *store, struct item **it);
diff --git a/src/kernel/ship.h b/src/kernel/ship.h
index 983d770a9..7c9b2d1bf 100644
--- a/src/kernel/ship.h
+++ b/src/kernel/ship.h
@@ -23,6 +23,7 @@ extern "C" {
#endif
#include "types.h"
+#include "direction.h"
#define DAMAGE_SCALE 100 /* multiplier for sh->damage */
diff --git a/src/kernel/types.h b/src/kernel/types.h
index f023e435a..bb48c9fc5 100644
--- a/src/kernel/types.h
+++ b/src/kernel/types.h
@@ -73,73 +73,6 @@ typedef struct ursprung {
int x, y;
} ursprung;
-/* ----------------- Befehle ----------------------------------- */
-
-typedef enum {
- K_KOMMENTAR,
- K_BANNER,
- K_WORK,
- K_ATTACK,
- K_STEAL,
- K_BESIEGE,
- K_NAME,
- K_USE,
- K_DISPLAY,
- K_ENTER,
- K_GUARD,
- K_MAIL,
- K_END,
- K_DRIVE,
- K_NUMBER,
- K_FOLLOW,
- K_RESEARCH,
- K_GIVE,
- K_ALLY,
- K_STATUS,
- K_COMBATSPELL,
- K_BUY,
- K_CONTACT,
- K_TEACH,
- K_STUDY,
- K_MAKE,
- K_MOVE,
- K_PASSWORD,
- K_RECRUIT,
- K_RESERVE,
- K_ROUTE,
- K_SABOTAGE,
- K_SEND,
- K_SPY,
- K_QUIT,
- K_SETSTEALTH,
- K_TRANSPORT,
- K_TAX,
- K_ENTERTAIN,
- K_SELL,
- K_LEAVE,
- K_FORGET,
- K_CAST,
- K_RESHOW,
- K_DESTROY,
- K_BREED,
- K_DEFAULT,
- K_URSPRUNG,
- K_EMAIL,
- K_PIRACY,
- K_GROUP,
- K_SORT,
- K_GM, /* perform GM commands */
- K_INFO, /* set player-info */
- K_PREFIX,
- K_PLANT,
- K_ALLIANCE,
- K_CLAIM,
- K_PROMOTION,
- K_PAY,
- MAXKEYWORDS,
- NOKEYWORD = -1
-} keyword_t;
-
/* ------------------ Status von Einheiten --------------------- */
typedef unsigned char status_t;
@@ -354,20 +287,6 @@ typedef enum {
NORACE = -1
} race_t;
-/* Richtungen */
-typedef enum {
- D_NORTHWEST,
- D_NORTHEAST,
- D_EAST,
- D_SOUTHEAST,
- D_SOUTHWEST,
- D_WEST,
- MAXDIRECTIONS,
- D_PAUSE,
- D_SPECIAL,
- NODIRECTION = -1
-} direction_t;
-
typedef enum {
M_GRAY = 0, /* Gray */
M_ILLAUN = 1, /* Illaun */
diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c
index e2d5bd9c1..b2a9ec24c 100644
--- a/src/kernel/xmlreader.c
+++ b/src/kernel/xmlreader.c
@@ -2307,7 +2307,7 @@ static int parse_main(xmlDocPtr doc)
int k;
for (k = 0; k != MAXKEYWORDS; ++k) {
if (strcmp(keywords[k], (const char *)propName) == 0) {
- global.disabled[k] = 1;
+ enable_keyword(k, false);
break;
}
}
diff --git a/src/keyword.c b/src/keyword.c
new file mode 100644
index 000000000..98d22a3c9
--- /dev/null
+++ b/src/keyword.c
@@ -0,0 +1,119 @@
+#include
+#include
+#include "keyword.h"
+
+#include "util/language.h"
+#include "util/umlaut.h"
+
+#include
+
+#include
+#include
+
+static const char * keyword_key(int i)
+{
+ assert(i=0);
+ return keywords[i];
+}
+
+keyword_t findkeyword(const char *s, const struct locale *lang) {
+ keyword_t result = NOKEYWORD;
+ char buffer[64];
+
+ init_translations(lang, UT_KEYWORDS, keyword_key, MAXKEYWORDS);
+ assert(lang);
+ assert(s);
+ while (*s == '@') ++s;
+
+ if (*s) {
+ char *str = transliterate(buffer, sizeof(buffer) - sizeof(int), s);
+
+ if (str) {
+ int i;
+ const void *match;
+ void **tokens = get_translations(lang, UT_KEYWORDS);
+ critbit_tree *cb = (critbit_tree *)*tokens;
+ assert(cb);
+ if (cb_find_prefix(cb, str, strlen(str), &match, 1, 0)) {
+ cb_get_kv(match, &i, sizeof(int));
+ result = (keyword_t)i;
+ return keyword_disabled(result) ? NOKEYWORD : result;
+ }
+ }
+ }
+ return NOKEYWORD;
+}
+
+static bool disabled_kwd[MAXKEYWORDS];
+
+void enable_keyword(keyword_t kwd, bool enabled) {
+ assert(kwd
#include
-/* gamecode includes */
#include "economy.h"
#include "monster.h"
#include "randenc.h"
#include "spy.h"
#include "study.h"
#include "market.h"
+#include "keyword.h"
/* kernel includes */
#include
@@ -3855,7 +3855,7 @@ void defaultorders(void)
{
region *r;
- assert(!global.disabled[K_DEFAULT]);
+ assert(!keyword_disabled(K_DEFAULT));
for (r = regions; r; r = r->next) {
unit *u;
for (u = r->units; u; u = u->next) {
@@ -4162,7 +4162,7 @@ void
add_proc_order(int priority, keyword_t kword, int (*parser) (struct unit *,
struct order *), unsigned int flags, const char *name)
{
- if (!global.disabled[kword]) {
+ if (!keyword_disabled(kword)) {
processor *proc = add_proc(priority, name, PR_ORDER);
if (proc) {
proc->data.per_order.process = parser;
@@ -4516,7 +4516,7 @@ void init_processor(void)
add_proc_region(p, &do_battle, "Attackieren");
- if (!global.disabled[K_BESIEGE]) {
+ if (!keyword_disabled(K_BESIEGE)) {
p += 10;
add_proc_region(p, &do_siege, "Belagern");
}
@@ -4531,7 +4531,7 @@ void init_processor(void)
add_proc_region(p, &economics, "Zerstoeren, Geben, Rekrutieren, Vergessen");
p += 10;
- if (!global.disabled[K_PAY]) {
+ if (!keyword_disabled(K_PAY)) {
add_proc_order(p, K_PAY, &pay_cmd, 0, "Gebaeudeunterhalt (disable)");
}
add_proc_postregion(p, &maintain_buildings_1,
@@ -4540,7 +4540,7 @@ void init_processor(void)
p += 10; /* QUIT fuer sich alleine */
add_proc_global(p, quit, "Sterben");
- if (!global.disabled[K_CAST]) {
+ if (!keyword_disabled(K_CAST)) {
p += 10;
add_proc_global(p, &magic, "Zaubern");
}
@@ -4591,17 +4591,17 @@ void init_processor(void)
add_proc_global(p, &monthly_healing, "Regeneration (HP)");
add_proc_global(p, ®enerate_aura, "Regeneration (Aura)");
- if (!global.disabled[K_DEFAULT]) {
+ if (!keyword_disabled(K_DEFAULT)) {
add_proc_global(p, &defaultorders, "Defaults setzen");
}
add_proc_global(p, &demographics, "Nahrung, Seuchen, Wachstum, Wanderung");
- if (!global.disabled[K_SORT]) {
+ if (!keyword_disabled(K_SORT)) {
p += 10;
add_proc_global(p, restack_units, "Einheiten sortieren");
}
add_proc_order(p, K_PROMOTION, &promotion_cmd, 0, "Heldenbefoerderung");
- if (!global.disabled[K_NUMBER]) {
+ if (!keyword_disabled(K_NUMBER)) {
add_proc_order(p, K_NUMBER, &renumber_cmd, 0, "Neue Nummern (Einheiten)");
p += 10;
add_proc_global(p, &renumber_factions, "Neue Nummern");
@@ -4703,8 +4703,6 @@ int init_data(const char *filename, const char *catalog)
if (l)
return l;
- init_locales();
-
if (turn < 0) {
turn = first_turn;
}
diff --git a/src/spells/spells.c b/src/spells/spells.c
index 644ba60ec..08f0dce46 100644
--- a/src/spells/spells.c
+++ b/src/spells/spells.c
@@ -20,6 +20,7 @@
#include "spells.h"
#include "borders.h"
#include "buildingcurse.h"
+#include "direction.h"
#include "regioncurse.h"
#include "unitcurse.h"
#include "shipcurse.h"
diff --git a/src/test_eressea.c b/src/test_eressea.c
index c9d33ecde..404fead60 100644
--- a/src/test_eressea.c
+++ b/src/test_eressea.c
@@ -25,6 +25,7 @@ CuSuite *get_bsdstring_suite(void);
CuSuite *get_functions_suite(void);
CuSuite *get_umlaut_suite(void);
CuSuite *get_ally_suite(void);
+CuSuite *get_direction_suite(void);
int RunAllTests(void)
{
@@ -38,6 +39,7 @@ int RunAllTests(void)
CuSuiteAddSuite(suite, get_tests_suite());
CuSuiteAddSuite(suite, get_json_suite());
CuSuiteAddSuite(suite, get_jsonconf_suite());
+ CuSuiteAddSuite(suite, get_direction_suite());
/* util */
CuSuiteAddSuite(suite, get_base36_suite());
CuSuiteAddSuite(suite, get_bsdstring_suite());
diff --git a/src/util/language.c b/src/util/language.c
index a32204fa1..67c230c89 100644
--- a/src/util/language.c
+++ b/src/util/language.c
@@ -128,6 +128,7 @@ const char *locale_getstring(const locale * lang, const char *key)
const char *locale_string(const locale * lang, const char *key)
{
assert(lang);
+ assert(key);
if (key != NULL) {
unsigned int hkey = hashstring(key);
@@ -154,7 +155,7 @@ const char *locale_string(const locale * lang, const char *key)
if (lang->fallback) {
return locale_string(lang->fallback, key);
}
- return 0;
+ return key;
}
return find->str;
}
diff --git a/src/util/umlaut.h b/src/util/umlaut.h
index 42997b50f..a82d4567c 100644
--- a/src/util/umlaut.h
+++ b/src/util/umlaut.h
@@ -20,6 +20,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#define _UMLAUT_H
#include "variant.h"
+#include
#ifdef __cplusplus
extern "C" {