forked from github/server
add a test for default_order, so I can change it.
This commit is contained in:
parent
01ecc72f2d
commit
11ae7dd55e
|
@ -2332,7 +2332,7 @@ void do_attack(fighter * af)
|
|||
if (apr > 0) {
|
||||
/* Wenn die Waffe nachladen muss, oder es sich nicht um einen
|
||||
* Waffen-Angriff handelt, dann gilt der Speed nicht. */
|
||||
/* FIXME allow multiple AT_NATURAL attacks? */
|
||||
/* TODO: allow multiple AT_NATURAL attacks? */
|
||||
if (u_race(au)->attack[a].type != AT_STANDARD)
|
||||
continue;
|
||||
else {
|
||||
|
|
|
@ -1013,7 +1013,6 @@ void set_default_order(int kwd) {
|
|||
// see also test_long_order_hungry
|
||||
order *default_order(const struct locale *lang)
|
||||
{
|
||||
static int usedefault = 1;
|
||||
int i = locale_index(lang);
|
||||
order *result = 0;
|
||||
assert(i < MAXLOCALES);
|
||||
|
@ -1023,14 +1022,11 @@ order *default_order(const struct locale *lang)
|
|||
}
|
||||
|
||||
result = defaults[i];
|
||||
if (!result && usedefault) {
|
||||
if (!result) {
|
||||
const char * str = LOC(lang, "defaultorder");
|
||||
if (str) {
|
||||
result = defaults[i] = parse_order(str, lang);
|
||||
}
|
||||
else {
|
||||
usedefault = 0;
|
||||
}
|
||||
}
|
||||
return result ? copy_order(result) : 0;
|
||||
}
|
||||
|
|
|
@ -172,6 +172,22 @@ static void test_forbiddenid(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 1, forbiddenid(atoi36("t")));
|
||||
}
|
||||
|
||||
static void test_default_order(CuTest *tc) {
|
||||
order *ord;
|
||||
struct locale * loc;
|
||||
|
||||
test_cleanup();
|
||||
loc = test_create_locale();
|
||||
ord = default_order(loc);
|
||||
CuAssertPtrEquals(tc, 0, ord);
|
||||
locale_setstring(loc, "defaultorder", "work");
|
||||
ord = default_order(loc);
|
||||
CuAssertPtrNotNull(tc, ord);
|
||||
CuAssertIntEquals(tc, K_WORK, getkeyword(ord));
|
||||
CuAssertPtrEquals(tc, ord->data, default_order(loc)->data);
|
||||
test_cleanup();
|
||||
}
|
||||
|
||||
CuSuite *get_config_suite(void)
|
||||
{
|
||||
CuSuite *suite = CuSuiteNew();
|
||||
|
@ -181,5 +197,6 @@ CuSuite *get_config_suite(void)
|
|||
SUITE_ADD_TEST(suite, test_forbiddenid);
|
||||
SUITE_ADD_TEST(suite, test_getunit);
|
||||
SUITE_ADD_TEST(suite, test_read_unitid);
|
||||
SUITE_ADD_TEST(suite, test_default_order);
|
||||
return suite;
|
||||
}
|
||||
|
|
|
@ -511,7 +511,7 @@ static void json_prefixes(cJSON *json) {
|
|||
}
|
||||
|
||||
/** disable a feature.
|
||||
* features are identified by eone of:
|
||||
* features are identified by one of:
|
||||
* 1. the keyword for their orders,
|
||||
* 2. the name of the skill they use,
|
||||
* 3. a "module.enabled" flag in the settings
|
||||
|
@ -525,14 +525,12 @@ static void disable_feature(const char *str) {
|
|||
enable_skill(sk, false);
|
||||
return;
|
||||
}
|
||||
for (k = 0; k != MAXKEYWORDS; ++k) {
|
||||
// FIXME: this loop is slow as balls.
|
||||
if (strcmp(keywords[k], str) == 0) {
|
||||
k = findkeyword(str);
|
||||
if (k!=NOKEYWORD) {
|
||||
log_debug("disable keyword %s\n", str);
|
||||
enable_keyword(k, false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
_snprintf(name, sizeof(name), "%s.enabled", str);
|
||||
log_info("disable feature %s\n", name);
|
||||
config_set(name, "0");
|
||||
|
|
|
@ -101,6 +101,7 @@ struct locale * test_create_locale(void) {
|
|||
test_translate_param(loc, i, parameters[i]);
|
||||
}
|
||||
init_parameters(loc);
|
||||
init_keywords(loc);
|
||||
init_skills(loc);
|
||||
}
|
||||
return loc;
|
||||
|
|
Loading…
Reference in New Issue