From f054bdf8cfd0f51790949df11719b709f1251df5 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 20 Jan 2019 16:51:04 +0100 Subject: [PATCH] BUG 2549 promote after recruit calculating max units before PROMOTE requires that all recruitment has finished. --- scripts/tests/common.lua | 18 ++++++++++++++++++ src/laws.c | 4 ++++ 2 files changed, 22 insertions(+) diff --git a/scripts/tests/common.lua b/scripts/tests/common.lua index 2aec0fc0f..70e1b61e4 100644 --- a/scripts/tests/common.lua +++ b/scripts/tests/common.lua @@ -1182,3 +1182,21 @@ function test_cartmaking() assert_equal(1, u:get_item('cart')) assert_equal(5, u:get_item('log')) end + +function test_promote_after_recruit() + local f = faction.create('human') + local r1 = region.create(0, 0, 'plain') + local r2 = region.create(1, 0, 'plain') + local u1 = unit.create(f, r1, 1) + u1.name = 'Xolgrim' + local u2 = unit.create(f, r2, 55) + u2:add_order('REKRUTIERE 1') + u1:add_order('BEFOERDERE') + u1:add_item('money', 57) + u2:add_item('money', 150) + local fl = u1.flags + process_orders() + assert_equal(56, u2.number) + assert_equal(fl + 128, u1.flags) -- UFL_HERO + assert_equal(0, u1:get_item('money')) +end diff --git a/src/laws.c b/src/laws.c index 421d1af31..68d90d6f8 100644 --- a/src/laws.c +++ b/src/laws.c @@ -3840,6 +3840,10 @@ void init_processor(void) add_proc_region(p, do_force_leave, "kick non-allies out of buildings/ships"); } add_proc_region(p, economics, "Zerstoeren, Geben, Rekrutieren, Vergessen"); + + /* all recruitment must be finished before we can calculate + * promotion cost of ability */ + p += 10; add_proc_order(p, K_PROMOTION, promotion_cmd, 0, "Heldenbefoerderung"); p += 10;