From d7c2fc2b04545bb60c566812f0138a83c8813f6f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 11 Dec 2014 23:24:00 +0100 Subject: [PATCH] remove the R_UNIT resource. https://bugs.eressea.de/view.php?id=1945 assert that only items can be reserved. --- src/give.c | 2 +- src/kernel/item.c | 6 +----- src/kernel/item.h | 1 - src/kernel/item.test.c | 15 --------------- src/kernel/pool.c | 2 +- src/tests.test.c | 4 ---- 6 files changed, 3 insertions(+), 27 deletions(-) diff --git a/src/give.c b/src/give.c index 8887018ba..c2ddfdf6c 100644 --- a/src/give.c +++ b/src/give.c @@ -516,7 +516,7 @@ void give_unit(unit * u, unit * u2, order * ord) cmistake(u, ord, 156, MSG_COMMERCE); return; } - add_give(u, u2, 1, 1, get_resourcetype(R_UNIT), ord, 0); +// TODO: add_give(u, u2, 1, 1, get_resourcetype(R_UNIT), ord, 0); u_setfaction(u, u2->faction); u2->faction->newbies += n; } diff --git a/src/kernel/item.c b/src/kernel/item.c index f0baa0c78..42f58fa22 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -604,7 +604,7 @@ static const char *resourcenames[MAX_RESOURCES] = { "aurafocus", "sphereofinv", "magicbag", "magicherbbag", "dreameye", "p2", "seed", "mallornseed", "money", "aura", "permaura", - "hp", "unit", "peasant" + "hp", "peasant" }; const resource_type *get_resourcetype(resource_t type) { @@ -971,10 +971,6 @@ void init_resources(void) rtype = rt_get_or_create(resourcenames[R_AURA]); rtype->uchange = res_changeaura; - // R_UNIT - rtype = rt_get_or_create(resourcenames[R_UNIT]); - rtype->uchange = res_changeperson; - /* alte typen registrieren: */ init_oldpotions(); } diff --git a/src/kernel/item.h b/src/kernel/item.h index 790911ba6..d0986e41f 100644 --- a/src/kernel/item.h +++ b/src/kernel/item.h @@ -297,7 +297,6 @@ extern "C" { R_AURA, /* Aura */ R_PERMAURA, /* Permanente Aura */ R_LIFE, - R_UNIT, R_PEASANT, MAX_RESOURCES, /* do not use outside item.c ! */ diff --git a/src/kernel/item.test.c b/src/kernel/item.test.c index a99749ec7..5afc55b32 100644 --- a/src/kernel/item.test.c +++ b/src/kernel/item.test.c @@ -64,20 +64,6 @@ void test_change_item(CuTest * tc) test_uchange(tc, u, get_resourcetype(R_IRON)); } -void test_change_person(CuTest * tc) -{ - unit * u; - - test_cleanup(); - - register_resources(); - init_resources(); - test_create_world(); - - u = test_create_unit(0, 0); - test_uchange(tc, u, get_resourcetype(R_UNIT)); -} - void test_resource_type(CuTest * tc) { struct item_type *itype; @@ -136,7 +122,6 @@ CuSuite *get_item_suite(void) SUITE_ADD_TEST(suite, test_resourcename_no_appearance); SUITE_ADD_TEST(suite, test_resourcename_with_appearance); SUITE_ADD_TEST(suite, test_change_item); - SUITE_ADD_TEST(suite, test_change_person); SUITE_ADD_TEST(suite, test_resource_type); SUITE_ADD_TEST(suite, test_finditemtype); SUITE_ADD_TEST(suite, test_findresourcetype); diff --git a/src/kernel/pool.c b/src/kernel/pool.c index 552818871..f524616f6 100644 --- a/src/kernel/pool.c +++ b/src/kernel/pool.c @@ -128,7 +128,7 @@ int change_reservation(unit * u, const resource_type * rtype, int value) int set_resvalue(unit * u, const resource_type * rtype, int value) { reservation *res, **rp = &u->reservations; - + assert(rtype->itype); while (*rp && (*rp)->type != rtype) rp = &(*rp)->next; res = *rp; diff --git a/src/tests.test.c b/src/tests.test.c index d18775c56..7e36b193e 100644 --- a/src/tests.test.c +++ b/src/tests.test.c @@ -20,8 +20,6 @@ static void test_resources(CuTest *tc) { CuAssertPtrEquals(tc, rt_find("aura"), (void *)get_resourcetype(R_AURA)); CuAssertPtrNotNull(tc, rt_find("permaura")); CuAssertPtrEquals(tc, rt_find("permaura"), (void *)get_resourcetype(R_PERMAURA)); - CuAssertPtrNotNull(tc, rt_find("unit")); - CuAssertPtrEquals(tc, rt_find("unit"), (void *)get_resourcetype(R_UNIT)); CuAssertPtrEquals(tc, 0, rt_find("stone")); rtype = rt_get_or_create("stone"); @@ -55,7 +53,6 @@ static void test_recreate_world(CuTest * tc) CuAssertPtrNotNull(tc, get_resourcetype(R_AURA)); CuAssertPtrNotNull(tc, get_resourcetype(R_PERMAURA)); CuAssertPtrNotNull(tc, get_resourcetype(R_PEASANT)); - CuAssertPtrNotNull(tc, get_resourcetype(R_UNIT)); test_cleanup(); CuAssertPtrEquals(tc, 0, get_locale("de")); @@ -67,7 +64,6 @@ static void test_recreate_world(CuTest * tc) CuAssertPtrNotNull(tc, get_resourcetype(R_AURA)); CuAssertPtrNotNull(tc, get_resourcetype(R_PERMAURA)); CuAssertPtrNotNull(tc, get_resourcetype(R_PEASANT)); - CuAssertPtrNotNull(tc, get_resourcetype(R_UNIT)); CuAssertPtrEquals(tc, 0, findregion(0, 0)); }