From b5ed9e96dd4d6bfd92aee0c234d329b400e4c8d3 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 21 Aug 2016 06:59:43 +0200 Subject: [PATCH 1/3] re-enable disabled test (it passes, so what gives?) --- src/kernel/save.test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/kernel/save.test.c b/src/kernel/save.test.c index 89fdcfbb1..e88cf7b2b 100644 --- a/src/kernel/save.test.c +++ b/src/kernel/save.test.c @@ -316,7 +316,7 @@ CuSuite *get_save_suite(void) SUITE_ADD_TEST(suite, test_readwrite_dead_faction_createunit); SUITE_ADD_TEST(suite, test_readwrite_dead_faction_changefaction); SUITE_ADD_TEST(suite, test_readwrite_dead_faction_regionowner); - DISABLE_TEST(suite, test_readwrite_dead_faction_group); + SUITE_ADD_TEST(suite, test_readwrite_dead_faction_group); SUITE_ADD_TEST(suite, test_read_password); SUITE_ADD_TEST(suite, test_read_password_external); return suite; From 6cfdc50fdf28434489ebfc414a7b8b5a0b8fb210 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 21 Aug 2016 11:46:54 +0200 Subject: [PATCH 2/3] add unit tests for giving stuff to empty units. should only be allowed to give things to a new unit, not a recently deceased. https://bugs.eressea.de/view.php?id=2230 --- src/give.test.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/give.test.c b/src/give.test.c index f12397bce..e65c2861c 100644 --- a/src/give.test.c +++ b/src/give.test.c @@ -316,6 +316,34 @@ static void test_give_denied_by_rules(CuTest * tc) { test_cleanup(); } +static void test_give_dead_unit(CuTest * tc) { + struct give env; + struct message *msg; + + test_cleanup(); + env.f1 = test_create_faction(0); + env.f2 = test_create_faction(0); + setup_give(&env); + env.dst->number = 0; + freset(env.dst, UFL_ISNEW); + CuAssertPtrNotNull(tc, msg = check_give(env.src, env.dst, 0)); + msg_release(msg); + test_cleanup(); +} + +static void test_give_new_unit(CuTest * tc) { + struct give env; + + test_cleanup(); + env.f1 = test_create_faction(0); + env.f2 = test_create_faction(0); + setup_give(&env); + env.dst->number = 0; + fset(env.dst, UFL_ISNEW); + CuAssertPtrEquals(tc, 0, check_give(env.src, env.dst, 0)); + test_cleanup(); +} + static void test_give_invalid_target(CuTest *tc) { // bug https://bugs.eressea.de/view.php?id=1685 struct give env; @@ -357,5 +385,7 @@ CuSuite *get_give_suite(void) SUITE_ADD_TEST(suite, test_give_okay); SUITE_ADD_TEST(suite, test_give_denied_by_rules); SUITE_ADD_TEST(suite, test_give_invalid_target); + SUITE_ADD_TEST(suite, test_give_new_unit); + SUITE_ADD_TEST(suite, test_give_dead_unit); return suite; } From a5c7d9b61544100acab16acf65d74e7b157a6cd1 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 21 Aug 2016 11:58:53 +0200 Subject: [PATCH 3/3] fix giving items to dead units, https://bugs.eressea.de/view.php?id=2230 --- src/give.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/give.c b/src/give.c index 52b1cda34..80f4a1ab5 100644 --- a/src/give.c +++ b/src/give.c @@ -70,7 +70,11 @@ static void feedback_give_not_allowed(unit * u, order * ord) static bool can_give(const unit * u, const unit * u2, const item_type * itype, int mask) { if (u2) { - if (u->faction != u2->faction) { + if (u2->number==0 && !fval(u2, UFL_ISNEW)) { + // https://bugs.eressea.de/view.php?id=2230 + // cannot give anything to dead units + return false; + } else if (u->faction != u2->faction) { int rule = rule_give(); if (itype) { assert(mask == 0);