From c276b5a43ca2e1471d9aa33d3451a30f42930342 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 28 Feb 2017 10:58:09 +0100 Subject: [PATCH] generate error, not crash. todo: fix items --- scripts/tests/e3/items.lua | 2 +- src/battle.c | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/tests/e3/items.lua b/scripts/tests/e3/items.lua index 9c6035bf7..b2100f5ed 100644 --- a/scripts/tests/e3/items.lua +++ b/scripts/tests/e3/items.lua @@ -26,7 +26,7 @@ function test_goblins() for k, v in ipairs(restricted) do u1:add_item(v, 1) u2:add_item(v, 1) - u2:add_item(v, 1) + u3:add_item(v, 1) end u1:add_order("ATTACKIERE " .. itoa36(u2.id)) diff --git a/src/battle.c b/src/battle.c index 9e2958242..fa5725c50 100644 --- a/src/battle.c +++ b/src/battle.c @@ -580,7 +580,12 @@ static bool i_canuse(const unit * u, const item_type * itype) if (itype->canuse) { result = itype->canuse(u, itype); } - assert(result==rc_can_use(u_race(u), itype)); + if (result!=rc_can_use(u_race(u), itype)) { + log_error("conversion error: %s should be %s to use %s", + u->_race->_name, + result ? "allowed" : "forbidden", + itype->rtype->_name); + } return result; }