From 04b0dcf6e320df36bac4161c1d799bd240c450c3 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 28 Jun 2026 11:47:28 +0200 Subject: [PATCH 1/2] =?UTF-8?q?KAEMPFE=20FLIEHE=20l=C3=B6scht=20Bewachung?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/laws.test.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/laws.test.c b/src/laws.test.c index eaf9f2538..57d0f4628 100644 --- a/src/laws.test.c +++ b/src/laws.test.c @@ -1577,7 +1577,23 @@ 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; + + test_setup(); + u = test_create_unit(f = test_create_faction(), test_create_plain(0, 0)); + fset(u, UFL_GUARD); + u->status = ST_FIGHT; + 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 +3043,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); From b96c7988b06c49d27e5886300438d3b47bbe9ded Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 28 Jun 2026 12:01:22 +0200 Subject: [PATCH 2/2] =?UTF-8?q?KAEMPFE=20FLIEHE=20l=C3=B6st=20Bewachung=20?= =?UTF-8?q?auf.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/laws.c | 1 + src/laws.test.c | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) 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 57d0f4628..cbd7e2c79 100644 --- a/src/laws.test.c +++ b/src/laws.test.c @@ -1581,10 +1581,11 @@ static void test_status_flee_stops_guard(CuTest *tc) { unit *u; faction *f; - test_setup(); - u = test_create_unit(f = test_create_faction(), test_create_plain(0, 0)); - fset(u, UFL_GUARD); - u->status = ST_FIGHT; + 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);