From cde0ce07424e19db30c2d61ce6356cf58fa12ba8 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 3 Aug 2012 00:41:17 -0700 Subject: [PATCH] fix broken laen tests by hacking in another config setting --- scripts/tests/common.lua | 12 ++++++++---- src/kernel/resources.c | 11 ++++++++--- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/scripts/tests/common.lua b/scripts/tests/common.lua index f8f546e05..0521e66e4 100755 --- a/scripts/tests/common.lua +++ b/scripts/tests/common.lua @@ -570,10 +570,11 @@ function test_config() end local function _test_create_laen() + eressea.settings.set("rules.terraform.all", "1") local r = region.create(0,0, "mountain") local f1 = faction.create("noreply@eressea.de", "human", "de") local u1 = unit.create(f1, r, 1) - r:set_resource("laen", 3) + r:set_resource("laen", 50) return r, u1 end @@ -596,15 +597,18 @@ function test_laen2() u1:set_skill("mining", 15) u1:clear_orders() u1:add_order("MACHEN Laen") - + u1.name = "Laenmeister" + local b = building.create(r, "mine") b.size = 10 u1.building = b local laen = r:get_resource("laen") - process_orders() - assert_equal(2, u1:get_item("laen")) + process_orders() + init_reports() + write_report(u1.faction) assert_equal(laen - 2, r:get_resource("laen")) + assert_equal(2, u1:get_item("laen")) end function test_mine() diff --git a/src/kernel/resources.c b/src/kernel/resources.c index 4a3607d7b..5f3c14757 100644 --- a/src/kernel/resources.c +++ b/src/kernel/resources.c @@ -82,6 +82,10 @@ void terraform_resources(region * r) { int i; const terrain_type *terrain = r->terrain; + static int terraform_all = -1; + if (terraform_all<0) { + terraform_all = get_param_int(global.parameters, "rules.terraform.all", 0); + } if (terrain->production == NULL) return; @@ -94,10 +98,11 @@ void terraform_resources(region * r) if (rm->type->rtype == rtype) break; } - if (rm) + if (rm) { continue; - - if (chance(production->chance)) { + } + + if (terraform_all || chance(production->chance)) { add_resource(r, dice_rand(production->startlevel), dice_rand(production->base), dice_rand(production->divisor), production->type);