From d9f800f444cdff79e65d8cff71a8e70120a0383e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 3 Nov 2018 18:25:22 +0100 Subject: [PATCH] =?UTF-8?q?Bug=202482:=20Untote=20k=C3=B6nnen=20ihre=20eig?= =?UTF-8?q?enen=20Gegenst=C3=A4nde=20reservieren.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/tests/e2/undead.lua | 27 +++++++++++++++++++++++++++ src/laws.c | 7 +++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/scripts/tests/e2/undead.lua b/scripts/tests/e2/undead.lua index e137ce3c2..4d8c9772b 100644 --- a/scripts/tests/e2/undead.lua +++ b/scripts/tests/e2/undead.lua @@ -6,6 +6,33 @@ function setup() eressea.free_game() end +function test_undead_reserve_self() + local r1 = region.create(0, 0, "plain") + local f1 = faction.create("human") + local u1 = unit.create(f1, r1, 1) + u1.race = "undead" + u1:clear_orders() + u1:add_item("log", 2) + u1:add_order("RESERVIERE 1 Holz") + u1:add_order("GIB 0 ALLES Holz") + process_orders() + assert_equal(1, u1:get_item("log")) +end + +function test_undead_reserve_other() + local r1 = region.create(0, 0, "plain") + local f1 = faction.create("human") + local u1 = unit.create(f1, r1, 1) + local u2 = unit.create(f1, r1, 1) + u2:add_item("log", 2) + u1.race = "undead" + u1:clear_orders() + u1:add_order("RESERVIERE 1 Holz") + process_orders() + assert_equal(0, u1:get_item("log")) + assert_equal(2, u2:get_item("log")) +end + function test_undead_give_item() local r1 = region.create(0, 0, "plain") local f1 = faction.create("human", "hodor@eressea.de", "de") diff --git a/src/laws.c b/src/laws.c index 775bd78a0..57c5adfc2 100644 --- a/src/laws.c +++ b/src/laws.c @@ -3379,7 +3379,7 @@ int pay_cmd(unit * u, struct order *ord) static int reserve_i(unit * u, struct order *ord, int flags) { char token[128]; - if (u->number > 0 && (u_race(u)->ec_flags & ECF_GETITEM)) { + if (u->number > 0) { int use, count, para; const item_type *itype; const char *s; @@ -3413,7 +3413,10 @@ static int reserve_i(unit * u, struct order *ord, int flags) } int reserve_cmd(unit * u, struct order *ord) { - return reserve_i(u, ord, GET_DEFAULT); + if ((u_race(u)->ec_flags & ECF_GETITEM)) { + return reserve_i(u, ord, GET_DEFAULT); + } + return 0; } int reserve_self(unit * u, struct order *ord) {