forked from github/server
Merge pull request #522 from ennorehling/feature/bug-2221
logging and fixing of live data for bug 2221
This commit is contained in:
commit
c31f543718
|
@ -2,6 +2,29 @@ require "lunit"
|
||||||
|
|
||||||
module("tests.e2.e2features", package.seeall, lunit.testcase )
|
module("tests.e2.e2features", package.seeall, lunit.testcase )
|
||||||
|
|
||||||
|
function test_build_harbour()
|
||||||
|
-- try to reproduce mantis bug 2221
|
||||||
|
local r = region.create(0, 0, "plain")
|
||||||
|
local f = faction.create("harbour@eressea.de", "human", "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 function one_unit(r, f)
|
||||||
local u = unit.create(f, r, 1)
|
local u = unit.create(f, r, 1)
|
||||||
u:add_item("money", u.number * 100)
|
u:add_item("money", u.number * 100)
|
||||||
|
|
|
@ -848,6 +848,7 @@ build_building(unit * u, const building_type * btype, int id, int want, order *
|
||||||
}
|
}
|
||||||
|
|
||||||
b->size += built;
|
b->size += built;
|
||||||
|
assert(b->type->maxsize <= 0 || b->size <= b->type->maxsize);
|
||||||
fset(b, BLD_EXPANDED);
|
fset(b, BLD_EXPANDED);
|
||||||
|
|
||||||
update_lighthouse(b);
|
update_lighthouse(b);
|
||||||
|
|
|
@ -1676,6 +1676,11 @@ int read_game(gamedata *data) {
|
||||||
if (b->type == bt_lighthouse) {
|
if (b->type == bt_lighthouse) {
|
||||||
r->flags |= RF_LIGHTHOUSE;
|
r->flags |= RF_LIGHTHOUSE;
|
||||||
}
|
}
|
||||||
|
// repairs, bug 2221:
|
||||||
|
if (b->type->maxsize>0 && b->size>b->type->maxsize) {
|
||||||
|
log_error("building too big: %s (%s size %d of %d), fixing.", buildingname(b), b->type->_name, b->size, b->type->maxsize);
|
||||||
|
b->size = b->type->maxsize;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* Schiffe */
|
/* Schiffe */
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue