resource_limit.value is always zero, never initialized. kill it.

This commit is contained in:
Enno Rehling 2017-02-25 19:50:32 +01:00
parent 3a985108a6
commit 6031dff685
4 changed files with 3 additions and 5 deletions

2
clibs

@ -1 +1 @@
Subproject commit 27c8b3202b52766465743c3324fc0b52c5ba4b11 Subproject commit b91413316ce13044c555084a9f605983586107b4

View File

@ -1123,7 +1123,7 @@ attrib_allocation(const resource_type * rtype, region * r, allocation * alist)
allocation *al; allocation *al;
int nreq = 0; int nreq = 0;
resource_limit *rdata = get_resourcelimit(rtype); resource_limit *rdata = get_resourcelimit(rtype);
int avail = rdata->value; int avail = 0;
for (al = alist; al; al = al->next) { for (al = alist; al; al = al->next) {
nreq += required(al->want, al->save); nreq += required(al->want, al->save);
@ -1165,7 +1165,7 @@ static allocate_function get_allocator(const struct resource_type *rtype)
resource_limit *rdata = get_resourcelimit(rtype); resource_limit *rdata = get_resourcelimit(rtype);
if (rdata) { if (rdata) {
if (rdata->value > 0 || rdata->limit != NULL) { if (rdata->limit != NULL) {
return attrib_allocation; return attrib_allocation;
} }
return leveled_allocation; return leveled_allocation;

View File

@ -384,7 +384,6 @@ static void test_make_item(CuTest *tc) {
rtype->flags |= RTF_LIMITED; rtype->flags |= RTF_LIMITED;
rmt = rmt_create(rtype); rmt = rmt_create(rtype);
rdata = rtype->limit = calloc(1, sizeof(resource_limit)); rdata = rtype->limit = calloc(1, sizeof(resource_limit));
rdata->value = 0;
add_resource(u->region, 1, 300, 150, rtype); add_resource(u->region, 1, 300, 150, rtype);
u->region->resources->amount = 300; /* there are 300 stones at level 1 */ u->region->resources->amount = 300; /* there are 300 stones at level 1 */
set_level(u, SK_ALCHEMY, 10); set_level(u, SK_ALCHEMY, 10);

View File

@ -58,7 +58,6 @@ extern "C" {
typedef struct resource_limit { typedef struct resource_limit {
rlimit_limit limit; rlimit_limit limit;
rlimit_produce produce; rlimit_produce produce;
int value;
resource_mod *modifiers; resource_mod *modifiers;
} resource_limit; } resource_limit;