From 4bc881705659098ba1c4fb1a622038fdea469a81 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 29 Aug 2016 18:15:20 +0100 Subject: [PATCH] remove a TODO that was ill-advised. The reason that "resources" is a list is that it's built incrementally. --- res/core/messages.xml | 4 ++-- src/kernel/build.c | 1 - src/magic.c | 1 - src/reports.c | 9 ++++----- src/reports.test.c | 2 +- 5 files changed, 7 insertions(+), 10 deletions(-) diff --git a/res/core/messages.xml b/res/core/messages.xml index d0df6343b..4669ab8b1 100644 --- a/res/core/messages.xml +++ b/res/core/messages.xml @@ -776,7 +776,7 @@ - + "$unit($unit) in $region($region): '$order($command)' - Dafür braucht die Einheit $resources($required)." "$unit($unit) in $region($region): '$order($command)' - For this, the unit needs $resources($required)." @@ -2374,7 +2374,7 @@ - + "$unit($unit) in $region($region): '$order($command)' - Für diesen Zauber fehlen noch $resources($list)." "$unit($unit) in $region($region): '$order($command)' - Casting this spell requires an additional $resources($list)." diff --git a/src/kernel/build.c b/src/kernel/build.c index 5d8f955c5..a6e8ff3dc 100644 --- a/src/kernel/build.c +++ b/src/kernel/build.c @@ -640,7 +640,6 @@ message *msg_materials_required(unit * u, order * ord, if (multi <= 0 || multi == INT_MAX) multi = 1; for (c = 0; ctype && ctype->materials[c].number; ++c) { - // TODO: lots of alloc/dealloc calls here (make var_copy_resources take an array) resource *res = malloc(sizeof(resource)); res->number = multi * ctype->materials[c].number / ctype->reqsize; res->type = ctype->materials[c].rtype; diff --git a/src/magic.c b/src/magic.c index 9960f2cb2..d24612e06 100644 --- a/src/magic.c +++ b/src/magic.c @@ -993,7 +993,6 @@ cancast(unit * u, const spell * sp, int level, int range, struct order * ord) itemhave = get_pooled(u, rtype, GET_DEFAULT, itemanz); if (itemhave < itemanz) { - // TODO: lots of alloc/dealloc calls here (make var_copy_resources take an array) resource *res = malloc(sizeof(resource)); res->number = itemanz - itemhave; res->type = rtype; diff --git a/src/reports.c b/src/reports.c index a7a9f7ac0..ce17b9ad2 100644 --- a/src/reports.c +++ b/src/reports.c @@ -1688,7 +1688,7 @@ static variant var_copy_items(variant x) return x; } -static variant var_copy_resource_list(variant x) +static variant var_copy_resources(variant x) { resource *rsrc; resource *rdst = NULL, **rptr = &rdst; @@ -1705,7 +1705,7 @@ static variant var_copy_resource_list(variant x) return x; } -static void var_free_resource_list(variant x) +static void var_free_resources(variant x) { resource *rsrc = (resource *)x.v; while (rsrc) { @@ -2250,9 +2250,8 @@ void register_reports(void) register_argtype("int", NULL, NULL, VAR_INT); register_argtype("string", var_free_string, var_copy_string, VAR_VOIDPTR); register_argtype("order", var_free_order, var_copy_order, VAR_VOIDPTR); - register_argtype("resource_list", var_free_resource_list, var_copy_resource_list, VAR_VOIDPTR); - //register_argtype("resources", var_free_resources, var_copy_resources, VAR_VOIDPTR); - register_argtype("items", var_free_resource_list, var_copy_items, VAR_VOIDPTR); + register_argtype("resources", var_free_resources, var_copy_resources, VAR_VOIDPTR); + register_argtype("items", var_free_resources, var_copy_items, VAR_VOIDPTR); register_argtype("regions", var_free_regions, NULL, VAR_VOIDPTR); msg_log_create = &log_orders; diff --git a/src/reports.test.c b/src/reports.test.c index 8cf8f402c..f368e63e1 100644 --- a/src/reports.test.c +++ b/src/reports.test.c @@ -434,7 +434,7 @@ static void test_arg_resources(CuTest *tc) { res[1].next = NULL; register_reports(); - atype = find_argtype("resource_list"); + atype = find_argtype("resources"); CuAssertPtrNotNull(tc, atype); v2 = atype->copy(v1); free(v1.v);