diff --git a/src/laws.c b/src/laws.c index 4cf2561cd..39eef515e 100644 --- a/src/laws.c +++ b/src/laws.c @@ -2490,6 +2490,7 @@ int status_cmd(unit * u, struct order *ord) break; case P_FLEE: unit_setstatus(u, ST_FLEE); + setguard(u, false); break; case P_CHICKEN: unit_setstatus(u, ST_CHICKEN); diff --git a/src/laws.test.c b/src/laws.test.c index eaf9f2538..cbd7e2c79 100644 --- a/src/laws.test.c +++ b/src/laws.test.c @@ -1577,7 +1577,24 @@ static void test_status_cmd(CuTest* tc) { test_teardown(); } -static void test_ally_cmd(CuTest* tc) { +static void test_status_flee_stops_guard(CuTest *tc) { + unit *u; + faction *f; + + guard_fixture fix; + + setup_guard(&fix, true); + u = fix.u; + f = fix.u->faction; + u->thisorder = create_order(K_STATUS, f->locale, param_name(P_FLEE, f->locale)); + status_cmd(u, u->thisorder); + CuAssertIntEquals(tc, ST_FLEE, u->status); + CuAssertTrue(tc, !is_guard(u)); + + test_teardown(); +} + +static void test_ally_cmd(CuTest *tc) { unit *u; faction * f; order *ord; @@ -3027,6 +3044,7 @@ CuSuite *get_laws_suite(void) SUITE_ADD_TEST(suite, test_findparam_ex); SUITE_ADD_TEST(suite, test_nmr_warnings); SUITE_ADD_TEST(suite, test_status_cmd); + SUITE_ADD_TEST(suite, test_status_flee_stops_guard); SUITE_ADD_TEST(suite, test_ally_cmd); SUITE_ADD_TEST(suite, test_name_cmd); SUITE_ADD_TEST(suite, test_name_foreign_cmd);