diff --git a/src/economy.c b/src/economy.c index 70b48e9ce..ab1875eed 100644 --- a/src/economy.c +++ b/src/economy.c @@ -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; } diff --git a/src/economy.test.c b/src/economy.test.c index d9f9b82e8..fdc218844 100644 --- a/src/economy.test.c +++ b/src/economy.test.c @@ -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");