diff --git a/scripts/tests/economy.lua b/scripts/tests/economy.lua index a1bfa3bb6..9289efa2b 100644 --- a/scripts/tests/economy.lua +++ b/scripts/tests/economy.lua @@ -11,6 +11,23 @@ function setup() eressea.settings.set("rules.encounters", "0") end +function test_bug_2361_forget_magic() + -- https://bugs.eressea.de/view.php?id=2361 + -- familiars cannot forget magic + local r = region.create(0, 0, "plain") + local f = faction.create("human") + local u = unit.create(f, r, 1) + u:clear_orders() + u:add_order("VERGESSE Magie") + u:set_skill('magic', 5) + u.race = 'unicorn' + process_orders() + assert_equal(5, u:get_skill('magic')) + u.race = 'human' + process_orders() + assert_equal(0, u:get_skill('magic')) +end + function test_mine_bonus() local r = region.create(0, 0, "mountain") r:set_resource("iron", 100) diff --git a/src/economy.c b/src/economy.c index 4122fa6a1..546f7876e 100644 --- a/src/economy.c +++ b/src/economy.c @@ -661,7 +661,12 @@ static int forget_cmd(unit * u, order * ord) init_order(ord); s = gettoken(token, sizeof(token)); - if ((sk = get_skill(s, u->faction->locale)) != NOSKILL) { + sk = get_skill(s, u->faction->locale); + if (sk != NOSKILL) { + if (sk == SK_MAGIC && (u_race(u)->flags & RCF_FAMILIAR)) { + /* some races cannot forget their innate magical abilities */ + return 0; + } ADDMSG(&u->faction->msgs, msg_message("forget", "unit skill", u, sk)); set_level(u, sk, 0); }