forked from github/server
Merge pull request #614 from ennorehling/master
fix bug 2261: bit manipulation error in STEALTH FACTION.
This commit is contained in:
commit
ada05ff55f
|
@ -295,11 +295,11 @@ int setstealth_cmd(unit * u, struct order *ord)
|
||||||
s = gettoken(token, sizeof(token));
|
s = gettoken(token, sizeof(token));
|
||||||
if (rule_stealth_anon()) {
|
if (rule_stealth_anon()) {
|
||||||
if (!s || *s == 0) {
|
if (!s || *s == 0) {
|
||||||
fset(u, UFL_ANON_FACTION);
|
u->flags |= UFL_ANON_FACTION;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (findparam(s, u->faction->locale) == P_NOT) {
|
else if (findparam(s, u->faction->locale) == P_NOT) {
|
||||||
u->flags |= ~UFL_ANON_FACTION;
|
u->flags &= ~UFL_ANON_FACTION;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -416,7 +416,7 @@ static void sink_ship(region * r, ship * sh, unit * saboteur)
|
||||||
/* slight optimization to avoid dereferencing u->faction each time */
|
/* slight optimization to avoid dereferencing u->faction each time */
|
||||||
if (f != u->faction) {
|
if (f != u->faction) {
|
||||||
f = u->faction;
|
f = u->faction;
|
||||||
f->flags |= ~FFL_SELECT;
|
f->flags &= ~FFL_SELECT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -146,6 +146,26 @@ static void test_sabotage_other_fail(CuTest *tc) {
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_setstealth_cmd(CuTest *tc) {
|
||||||
|
unit *u;
|
||||||
|
const struct locale *lang;
|
||||||
|
|
||||||
|
test_setup();
|
||||||
|
u = test_create_unit(test_create_faction(0), test_create_region(0,0,0));
|
||||||
|
lang = u->faction->locale;
|
||||||
|
u->flags = UFL_ANON_FACTION|UFL_SIEGE;
|
||||||
|
u->thisorder = create_order(K_SETSTEALTH, lang, "%s %s",
|
||||||
|
LOC(lang, parameters[P_FACTION]),
|
||||||
|
LOC(lang, parameters[P_NOT]));
|
||||||
|
setstealth_cmd(u, u->thisorder);
|
||||||
|
CuAssertIntEquals(tc, UFL_SIEGE, u->flags);
|
||||||
|
free_order(u->thisorder);
|
||||||
|
u->thisorder = create_order(K_SETSTEALTH, lang, "%s",
|
||||||
|
LOC(lang, parameters[P_FACTION]));
|
||||||
|
setstealth_cmd(u, u->thisorder);
|
||||||
|
CuAssertIntEquals(tc, UFL_SIEGE|UFL_ANON_FACTION, u->flags);
|
||||||
|
test_cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
static void test_sabotage_other_success(CuTest *tc) {
|
static void test_sabotage_other_success(CuTest *tc) {
|
||||||
unit *u, *u2;
|
unit *u, *u2;
|
||||||
|
@ -178,6 +198,7 @@ CuSuite *get_spy_suite(void)
|
||||||
SUITE_ADD_TEST(suite, test_simple_spy_message);
|
SUITE_ADD_TEST(suite, test_simple_spy_message);
|
||||||
SUITE_ADD_TEST(suite, test_all_spy_message);
|
SUITE_ADD_TEST(suite, test_all_spy_message);
|
||||||
SUITE_ADD_TEST(suite, test_sabotage_self);
|
SUITE_ADD_TEST(suite, test_sabotage_self);
|
||||||
|
SUITE_ADD_TEST(suite, test_setstealth_cmd);
|
||||||
SUITE_ADD_TEST(suite, test_sabotage_other_fail);
|
SUITE_ADD_TEST(suite, test_sabotage_other_fail);
|
||||||
SUITE_ADD_TEST(suite, test_sabotage_other_success);
|
SUITE_ADD_TEST(suite, test_sabotage_other_success);
|
||||||
return suite;
|
return suite;
|
||||||
|
|
Loading…
Reference in New Issue