forked from github/server
fix a FIXME: setting default order through config, making test better.
this feature is not in use, so all this work is really pointless.
This commit is contained in:
parent
11ae7dd55e
commit
a834c486d9
|
@ -11,6 +11,7 @@
|
|||
"settings": {
|
||||
"game.id": 2,
|
||||
"game.name": "Eressea",
|
||||
"orders.default": "work",
|
||||
"NewbieImmunity": 8,
|
||||
"modules.wormholes": true,
|
||||
"entertain.base": 0,
|
||||
|
|
|
@ -67,9 +67,5 @@
|
|||
<text locale="de">ERESSEA 2 BEFEHLE</text>
|
||||
<text locale="en">ERESSEA 2 ORDERS</text>
|
||||
</string>
|
||||
<string name="defaultorder">
|
||||
<text locale="de">ARBEITEN</text>
|
||||
<text locale="en">WORK</text>
|
||||
</string>
|
||||
</strings>
|
||||
</eressea>
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
"settings": {
|
||||
"game.id": 3,
|
||||
"game.name": "E3",
|
||||
"orders.default": "work",
|
||||
"database.gameid": 7,
|
||||
"NewbieImmunity": 4,
|
||||
"modules.astralspace": false,
|
||||
|
|
|
@ -59,9 +59,5 @@
|
|||
<text locale="de">ERESSEA 3 BEFEHLE</text>
|
||||
<text locale="en">ERESSEA 3 ORDERS</text>
|
||||
</string>
|
||||
<string name="defaultorder">
|
||||
<text locale="de">ARBEITEN</text>
|
||||
<text locale="en">WORK</text>
|
||||
</string>
|
||||
</strings>
|
||||
</eressea>
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
"settings": {
|
||||
"game.id": 4,
|
||||
"game.name": "Deveron",
|
||||
"orders.default": "work",
|
||||
"database.gameid": 7,
|
||||
"NewbieImmunity": 4,
|
||||
"modules.astralspace": false,
|
||||
|
|
|
@ -60,9 +60,5 @@
|
|||
<text locale="de">ERESSEA 4 BEFEHLE</text>
|
||||
<text locale="en">ERESSEA 4 ORDERS</text>
|
||||
</string>
|
||||
<string name="defaultorder">
|
||||
<text locale="de">ARBEITEN</text>
|
||||
<text locale="en">WORK</text>
|
||||
</string>
|
||||
</strings>
|
||||
</eressea>
|
||||
|
|
|
@ -284,10 +284,6 @@
|
|||
getting it after the second turn, please make one of your units give the
|
||||
order OPTION COMPUTER.</text>
|
||||
</string>
|
||||
<string name="defaultorder">
|
||||
<text locale="de">ARBEITEN</text>
|
||||
<text locale="en">WORK</text>
|
||||
</string>
|
||||
<string name="temple">
|
||||
<text locale="de">Tempel</text>
|
||||
<text locale="en">temple</text>
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue