From fc2b8f3471bd32341829be39fd28df071fb627e8 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 2 Jul 2015 11:42:18 +0200 Subject: [PATCH] bug 2080: long actions after DESTROY https://bugs.eressea.de/view.php?id=2080 we forgot to set the flags. also added a test for the future. --- scripts/tests/e2/movement.lua | 14 ++++++++++++++ src/economy.c | 3 +++ src/kernel/build.c | 3 +-- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/scripts/tests/e2/movement.lua b/scripts/tests/e2/movement.lua index ef62873d8..e05715590 100644 --- a/scripts/tests/e2/movement.lua +++ b/scripts/tests/e2/movement.lua @@ -84,3 +84,17 @@ function test_follow_ship() assert_equal(2, u1.region.x) assert_equal(2, u2.region.x) end + +function test_dont_move_after_destroy() + local r1 = region.create(0, 0, "plain") + local r2 = region.create(1, 0, "plain") + local f = faction.create("test@example.com", "human", "de") + local u = unit.create(f, r1, 1) + u.building = building.create(r1, "castle") + u:clear_orders() + u:add_order("NACH O") + u:add_order("ZERSTOERE " .. itoa36(u.building.id)) + process_orders() + assert_equal(r1, u.region) + assert_equal(nil, u.building) +end diff --git a/src/economy.c b/src/economy.c index ec83bbc4e..23ccb3fde 100644 --- a/src/economy.c +++ b/src/economy.c @@ -996,6 +996,9 @@ void economics(region * r) } } } + if (destroyed) { + fset(u, UFL_LONGACTION | UFL_NOTMOVING); + } } } diff --git a/src/kernel/build.c b/src/kernel/build.c index bca970fc4..ab8d520d1 100644 --- a/src/kernel/build.c +++ b/src/kernel/build.c @@ -164,8 +164,7 @@ int destroy_cmd(unit * u, struct order *ord) if (s && *s) { n = atoi((const char *)s); if (n <= 0) { - cmistake(u, ord, 288, MSG_PRODUCE); - return 0; + n = INT_MAX; } }