diff --git a/res/e3a/races.xml b/res/e3a/races.xml index 2316b8aa5..197a2f1d1 100644 --- a/res/e3a/races.xml +++ b/res/e3a/races.xml @@ -192,7 +192,7 @@ - + @@ -218,7 +218,7 @@ - + @@ -239,7 +239,7 @@ - + @@ -260,7 +260,7 @@ - + @@ -283,7 +283,7 @@ - + @@ -306,7 +306,7 @@ - + @@ -328,7 +328,7 @@ - + @@ -400,7 +400,7 @@ - + @@ -425,7 +425,7 @@ - + @@ -448,7 +448,7 @@ - + @@ -471,7 +471,7 @@ - + @@ -493,7 +493,7 @@ - + @@ -520,7 +520,7 @@ - + @@ -543,7 +543,7 @@ - + @@ -565,7 +565,7 @@ - + @@ -589,7 +589,7 @@ - + @@ -651,11 +651,11 @@ - + - + @@ -678,11 +678,11 @@ - + - + @@ -694,7 +694,7 @@ - + @@ -710,7 +710,7 @@ - + @@ -830,7 +830,7 @@ - + diff --git a/res/eressea/races.xml b/res/eressea/races.xml index 71eacc458..106ff1cce 100644 --- a/res/eressea/races.xml +++ b/res/eressea/races.xml @@ -11,7 +11,7 @@ - + @@ -26,7 +26,7 @@ - + @@ -59,7 +59,7 @@ - + @@ -87,7 +87,7 @@ - + @@ -114,7 +114,7 @@ - + @@ -143,7 +143,7 @@ - + @@ -172,7 +172,7 @@ - + @@ -202,7 +202,7 @@ - + @@ -236,7 +236,7 @@ - + @@ -266,7 +266,7 @@ - + @@ -298,7 +298,7 @@ - + @@ -328,7 +328,7 @@ - + @@ -357,7 +357,7 @@ - + @@ -387,7 +387,7 @@ - + @@ -416,7 +416,7 @@ - + @@ -447,7 +447,7 @@ - + @@ -478,7 +478,7 @@ - + @@ -507,7 +507,7 @@ - + @@ -539,7 +539,7 @@ - + @@ -569,16 +569,16 @@ - + - + - + @@ -648,28 +648,28 @@ - + - + - + - + - + @@ -683,25 +683,25 @@ - + - + - + - + @@ -711,7 +711,7 @@ - + @@ -721,7 +721,7 @@ - + @@ -732,7 +732,7 @@ - + @@ -927,7 +927,7 @@ giveunit="yes" getitem="yes" recruitethereal="yes" equipment="yes"> - + @@ -964,7 +964,7 @@ giveunit="yes" getitem="yes" recruitethereal="yes" equipment="yes"> - + @@ -972,7 +972,7 @@ giveunit="yes" getitem="yes" recruitethereal="yes" equipment="yes"> - + @@ -986,7 +986,7 @@ giveunit="yes" getitem="yes" recruitethereal="yes" equipment="yes"> - + @@ -1003,7 +1003,7 @@ giveunit="yes" getitem="yes" recruitethereal="yes" equipment="yes"> - + @@ -1019,7 +1019,7 @@ giveunit="yes" getitem="yes" recruitethereal="yes" equipment="yes"> - + @@ -1034,7 +1034,7 @@ giveunit="yes" getitem="yes" recruitethereal="yes" equipment="yes"> - + @@ -1047,7 +1047,7 @@ giveunit="yes" getitem="yes" recruitethereal="yes" equipment="yes"> - + @@ -1061,7 +1061,7 @@ giveunit="yes" getitem="yes" recruitethereal="yes" equipment="yes"> - + @@ -1074,11 +1074,11 @@ giveunit="yes" getitem="yes" recruitethereal="yes" equipment="yes"> - + - + @@ -1205,7 +1205,7 @@ giveunit="yes" getitem="yes" recruitethereal="yes" equipment="yes"> - + diff --git a/scripts/tests/economy.lua b/scripts/tests/economy.lua index 271d245d6..1ed232502 100644 --- a/scripts/tests/economy.lua +++ b/scripts/tests/economy.lua @@ -214,6 +214,7 @@ function test_ironkeeper_guards_iron() local level = r:get_resourcelevel("iron") local u = unit.create(faction.create("human"), r) u:set_skill("mining", level) + u:set_skill("stealth", 1) -- does not help against ironkeeper local guard = unit.create(faction.create("mountainguard"), r, 1, "mountainguard") guard:add_order("BEWACHEN") u:add_order("MACHE EISEN") @@ -223,6 +224,23 @@ function test_ironkeeper_guards_iron() assert_equal(level, u:get_item("iron")) end +-- bug 2679 +function test_stealthy_iron_producer() + local r = region.create(0, 0, "plain") + r:set_resource("iron", 100) + local level = r:get_resourcelevel("iron") + local u = unit.create(faction.create("human"), r) + u:set_skill("stealth", 1) + u:set_skill("mining", level) + local guard = unit.create(faction.create("human"), r, 1, "human") + guard:add_order("BEWACHEN") + u:add_order("MACHE EISEN") + process_orders() + assert_equal(level, u:get_item("iron")) + process_orders() + assert_equal(2 * level, u:get_item("iron")) +end + function test_sawmill() local r = region.create(0, 0, "plain") r:set_resource("tree", 100) diff --git a/src/economy.c b/src/economy.c index f0e655b99..5f3bb8cbf 100644 --- a/src/economy.c +++ b/src/economy.c @@ -574,6 +574,12 @@ static void allocate_resource(unit * u, const resource_type * rtype, int want) int amount, skill, skill_mod = 0; variant save_mod; skill_t sk; + static const struct race *rc_mountainguard; + static int config; + + if (rc_changed(&config)) { + rc_mountainguard = rc_find("mountainguard"); + } /* momentan kann man keine ressourcen abbauen, wenn man dafuer * Materialverbrauch hat: */ @@ -605,14 +611,16 @@ static void allocate_resource(unit * u, const resource_type * rtype, int want) * Als magische Wesen 'sehen' Bergwaechter alles und werden durch * Belagerung nicht aufgehalten. (Ansonsten wie oben bei Elfen anpassen). */ - if (itype->rtype && (itype->rtype == get_resourcetype(R_IRON) || itype->rtype == rt_find("laen"))) { - unit *u2; - for (u2 = r->units; u2; u2 = u2->next) { - if (!fval(u2, UFL_ISNEW) && u2->number - && is_guard(u2) && !alliedunit(u2, u->faction, HELP_GUARD)) { - ADDMSG(&u->faction->msgs, - msg_feedback(u, u->thisorder, "region_guarded", "guard", u2)); - return; + if (rc_mountainguard) { + if (itype->rtype && (itype->rtype == get_resourcetype(R_IRON) || itype->rtype == rt_find("laen"))) { + unit *u2; + for (u2 = r->units; u2; u2 = u2->next) { + if (rc_mountainguard == u_race(u2) && !fval(u2, UFL_ISNEW) && u2->number > 0 + && is_guard(u2) && !alliedunit(u2, u->faction, HELP_GUARD)) { + ADDMSG(&u->faction->msgs, + msg_feedback(u, u->thisorder, "region_guarded", "guard", u2)); + return; + } } } }