laen test does not work. trying to make setresource add the raw material to fix it

This commit is contained in:
Enno Rehling 2012-08-02 00:06:03 -07:00
parent 166d4ccc2c
commit 1fe075e82d
2 changed files with 16 additions and 15 deletions

View File

@ -573,16 +573,7 @@ local function _test_create_laen()
local r = region.create(0,0, "mountain")
local f1 = faction.create("noreply@eressea.de", "human", "de")
local u1 = unit.create(f1, r, 1)
-- TODO this is a stupid way to create a laen region
for i = 1, 10000 do
r = region.create(i,0, "mountain")
if r:get_resource("laen") > 2 then
break
end
end
assert(r:get_resource("laen")>2, "could not run test properly, please try again")
r:set_resource("laen", 3)
return r, u1
end

View File

@ -1016,6 +1016,16 @@ void region_setresource(region * r, const resource_type * rtype, int value)
rsetpeasants(r, value);
else if (rtype == rt_find("horse"))
rsethorses(r, value);
else {
int i;
for (i = 0; r->terrain->production[i].type; ++i) {
const terrain_production *production = r->terrain->production + i;
if (production->type==rtype) {
add_resource(r, 1, value, dice_rand(production->divisor), rtype);
break;
}
}
}
}
}