github issue #658

MACHE 1 EISEN use 1 iron even with savings.
This commit is contained in:
Enno Rehling 2017-02-18 11:19:42 +01:00
parent 0a3e3de5a3
commit aee68fbd0f
2 changed files with 7 additions and 0 deletions

View File

@ -1036,6 +1036,8 @@ static void allocate_resource(unit * u, const resource_type * rtype, int want)
static int required(int want, variant save)
{
int req = (int)(want * save.sa[0] / save.sa[1]);
int r = want * save.sa[0] % save.sa[1];
if (r>0) ++req;
return req;
}

View File

@ -405,6 +405,11 @@ static void test_make_item(CuTest *tc) {
CuAssertIntEquals(tc, 21, get_item(u, itype));
CuAssertIntEquals(tc, 284, u->region->resources->amount); /* 60% saving = 6 stones make 10 stones */
make_item(u, itype, 1);
split_allocations(u->region);
CuAssertIntEquals(tc, 22, get_item(u, itype));
CuAssertIntEquals(tc, 283, u->region->resources->amount); /* no free lunches */
rdata->modifiers[0].flags = RMF_REQUIREDBUILDING;
rdata->modifiers[0].race = NULL;
rdata->modifiers[0].btype = bt_get_or_create("mine");