From 3c2754071dfcc23cf9c7d9e6ff4a6213f3c69745 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 17 Jul 2017 14:01:08 +0200 Subject: [PATCH] this test fails when btype->maxsize isn't used as a limit for building. --- res/core/common/buildings.xml | 2 +- scripts/tests/e2/buildings.lua | 34 ++++++++++++++++++--------------- scripts/tests/e2/e2features.lua | 23 ---------------------- src/kernel/build.c | 3 ++- 4 files changed, 22 insertions(+), 40 deletions(-) diff --git a/res/core/common/buildings.xml b/res/core/common/buildings.xml index a799ce309..b73ab01aa 100644 --- a/res/core/common/buildings.xml +++ b/res/core/common/buildings.xml @@ -129,7 +129,7 @@ - + diff --git a/scripts/tests/e2/buildings.lua b/scripts/tests/e2/buildings.lua index 07b774d9c..02298bd97 100644 --- a/scripts/tests/e2/buildings.lua +++ b/scripts/tests/e2/buildings.lua @@ -52,22 +52,26 @@ function test_build_castle_stages() assert_equal(250, b.size) end -function test_build_maxsize() - local r = region.create(0,0, "plain") - local f = faction.create("human") - local u = unit.create(f, r, 100) - local b = building.create(r, "harbour") - - b.size = 20 - u:add_item("stone", 1000) - u:add_item("log", 1000) - u:add_item("money", 10000) - - u:set_skill("building", 100) +function test_build_harbour() +-- try to reproduce mantis bug 2221 + local r = region.create(0, 0, "plain") + local f = faction.create("human", "harbour@eressea.de", "de") + local u = unit.create(f, r) + size = 30 + u.number = 20 + u:set_skill("building", 3) + u:add_item("money", size*250) + u:add_item("stone", size*5) + u:add_item("log", size*5) u:clear_orders() - u:add_order("MACHE BURG " .. itoa36(b.id)) + u:add_order("MACHE HAFEN") process_orders() - assert_equal(25, b.size) -- build no more than max + assert_not_nil(u.building) + assert_equal("harbour", u.building.type) + assert_equal(20, u.building.size) process_orders() - assert_equal(25, b.size) -- stop at max + assert_equal(25, u.building.size) + process_orders() + assert_equal(25, u.building.size) end + diff --git a/scripts/tests/e2/e2features.lua b/scripts/tests/e2/e2features.lua index ffe3266e3..7e143c0cc 100644 --- a/scripts/tests/e2/e2features.lua +++ b/scripts/tests/e2/e2features.lua @@ -62,29 +62,6 @@ function test_dwarf_bonus() assert_equal(70, r:get_resource("iron")) end -function test_build_harbour() --- try to reproduce mantis bug 2221 - local r = region.create(0, 0, "plain") - local f = faction.create("human", "harbour@eressea.de", "de") - local u = unit.create(f, r) - size = 30 - u.number = 20 - u:set_skill("building", 3) - u:add_item("money", size*250) - u:add_item("stone", size*5) - u:add_item("log", size*5) - u:clear_orders() - u:add_order("MACHE HAFEN") - process_orders() - assert_not_nil(u.building) - assert_equal("harbour", u.building.type) - assert_equal(20, u.building.size) - process_orders() - assert_equal(25, u.building.size) - process_orders() - assert_equal(25, u.building.size) -end - local function one_unit(r, f) local u = unit.create(f, r, 1) u:add_item("money", u.number * 100) diff --git a/src/kernel/build.c b/src/kernel/build.c index 57c172905..a6e8edc77 100644 --- a/src/kernel/build.c +++ b/src/kernel/build.c @@ -717,8 +717,9 @@ build_building(unit * u, const building_type * btype, int id, int want, order * b = u->building; } - if (b) + if (b) { btype = b->type; + } if (fval(btype, BTF_UNIQUE) && buildingtype_exists(r, btype, false)) { /* only one of these per region */