From a834c486d9119c69404d38ccd0e681a7219b5037 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 9 Apr 2016 19:05:28 +0200 Subject: [PATCH] fix a FIXME: setting default order through config, making test better. this feature is not in use, so all this work is really pointless. --- conf/e2/config.json | 1 + conf/e2/config.xml | 4 ---- conf/e3/config.json | 1 + conf/e3/config.xml | 4 ---- conf/e4/config.json | 1 + conf/e4/config.xml | 4 ---- res/eressea/strings.xml | 4 ---- src/kernel/config.c | 21 ++++++++------------- src/kernel/config.h | 1 - src/kernel/config.test.c | 3 ++- src/laws.test.c | 5 +---- 11 files changed, 14 insertions(+), 35 deletions(-) diff --git a/conf/e2/config.json b/conf/e2/config.json index fa8566eab..217cfffe9 100644 --- a/conf/e2/config.json +++ b/conf/e2/config.json @@ -11,6 +11,7 @@ "settings": { "game.id": 2, "game.name": "Eressea", + "orders.default": "work", "NewbieImmunity": 8, "modules.wormholes": true, "entertain.base": 0, diff --git a/conf/e2/config.xml b/conf/e2/config.xml index d1eac12d8..5516fd601 100644 --- a/conf/e2/config.xml +++ b/conf/e2/config.xml @@ -67,9 +67,5 @@ ERESSEA 2 BEFEHLE ERESSEA 2 ORDERS - - ARBEITEN - WORK - diff --git a/conf/e3/config.json b/conf/e3/config.json index a1fc05b74..c9a86c8da 100644 --- a/conf/e3/config.json +++ b/conf/e3/config.json @@ -27,6 +27,7 @@ "settings": { "game.id": 3, "game.name": "E3", + "orders.default": "work", "database.gameid": 7, "NewbieImmunity": 4, "modules.astralspace": false, diff --git a/conf/e3/config.xml b/conf/e3/config.xml index 0531f69d2..04af3858d 100644 --- a/conf/e3/config.xml +++ b/conf/e3/config.xml @@ -59,9 +59,5 @@ ERESSEA 3 BEFEHLE ERESSEA 3 ORDERS - - ARBEITEN - WORK - diff --git a/conf/e4/config.json b/conf/e4/config.json index 345558dff..7a73de86f 100644 --- a/conf/e4/config.json +++ b/conf/e4/config.json @@ -27,6 +27,7 @@ "settings": { "game.id": 4, "game.name": "Deveron", + "orders.default": "work", "database.gameid": 7, "NewbieImmunity": 4, "modules.astralspace": false, diff --git a/conf/e4/config.xml b/conf/e4/config.xml index ffa1c5df8..2def4f1a8 100644 --- a/conf/e4/config.xml +++ b/conf/e4/config.xml @@ -60,9 +60,5 @@ ERESSEA 4 BEFEHLE ERESSEA 4 ORDERS - - ARBEITEN - WORK - diff --git a/res/eressea/strings.xml b/res/eressea/strings.xml index 6b6cf8903..b7db0eb4b 100644 --- a/res/eressea/strings.xml +++ b/res/eressea/strings.xml @@ -284,10 +284,6 @@ getting it after the second turn, please make one of your units give the order OPTION COMPUTER. - - ARBEITEN - WORK - Tempel temple diff --git a/src/kernel/config.c b/src/kernel/config.c index cc769b2c9..597841c46 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -1003,29 +1003,24 @@ void kernel_init(void) } static order * defaults[MAXLOCALES]; -keyword_t default_keyword = NOKEYWORD; -void set_default_order(int kwd) { - default_keyword = (keyword_t)kwd; -} - -// TODO: outside of tests, default_keyword is never used, why is this here? -// see also test_long_order_hungry order *default_order(const struct locale *lang) { int i = locale_index(lang); order *result = 0; assert(i < MAXLOCALES); - if (default_keyword != NOKEYWORD) { - return create_order(default_keyword, lang, 0); - } - result = defaults[i]; if (!result) { - const char * str = LOC(lang, "defaultorder"); + const char * str; + keyword_t kwd = NOKEYWORD; + str = config_get("orders.default"); if (str) { - result = defaults[i] = parse_order(str, lang); + kwd = findkeyword(str); + } + if (kwd != NOKEYWORD) { + result = create_order(kwd, lang, NULL); + defaults[i] = result; } } return result ? copy_order(result) : 0; diff --git a/src/kernel/config.h b/src/kernel/config.h index dda7873aa..87d44492d 100644 --- a/src/kernel/config.h +++ b/src/kernel/config.h @@ -195,7 +195,6 @@ struct param; bool IsImmune(const struct faction *f); struct order *default_order(const struct locale *lang); - void set_default_order(int kwd); int entertainmoney(const struct region *r); void init_parameters(struct locale *lang); diff --git a/src/kernel/config.test.c b/src/kernel/config.test.c index 7cd495284..d5b46581c 100644 --- a/src/kernel/config.test.c +++ b/src/kernel/config.test.c @@ -180,7 +180,8 @@ static void test_default_order(CuTest *tc) { loc = test_create_locale(); ord = default_order(loc); CuAssertPtrEquals(tc, 0, ord); - locale_setstring(loc, "defaultorder", "work"); + + config_set("orders.default", "work"); ord = default_order(loc); CuAssertPtrNotNull(tc, ord); CuAssertIntEquals(tc, K_WORK, getkeyword(ord)); diff --git a/src/laws.test.c b/src/laws.test.c index 1b2136db7..94296400d 100644 --- a/src/laws.test.c +++ b/src/laws.test.c @@ -1003,8 +1003,6 @@ static void test_long_order_buy_cast(CuTest *tc) { } static void test_long_order_hungry(CuTest *tc) { - // FIXME: set_default_order is a test-only function, this is a bad test. - // see also default_order unit *u; test_cleanup(); config_set("hunger.long", "1"); @@ -1012,12 +1010,11 @@ static void test_long_order_hungry(CuTest *tc) { fset(u, UFL_HUNGER); unit_addorder(u, create_order(K_MOVE, u->faction->locale, 0)); unit_addorder(u, create_order(K_DESTROY, u->faction->locale, 0)); - set_default_order(K_WORK); + config_set("orders.default", "work"); update_long_order(u); CuAssertIntEquals(tc, K_WORK, getkeyword(u->thisorder)); CuAssertPtrNotNull(tc, u->orders); CuAssertPtrEquals(tc, 0, u->faction->msgs); - set_default_order(NOKEYWORD); test_cleanup(); }