diff --git a/src/economy.c b/src/economy.c index 53f5ad4cd..0f1a7874e 100644 --- a/src/economy.c +++ b/src/economy.c @@ -703,7 +703,6 @@ message *check_give(const unit *u, const unit *u2, order * ord) { if (!can_give(u, u2, NULL, GIVE_ALLITEMS)) { return msg_feedback(u, ord, "feedback_give_forbidden", ""); } - return 0; } diff --git a/src/economy.test.c b/src/economy.test.c index 54741e97a..395f97a84 100644 --- a/src/economy.test.c +++ b/src/economy.test.c @@ -1,4 +1,5 @@ #include +#include #include #include "economy.h" @@ -117,27 +118,47 @@ static void test_steal_ocean(CuTest * tc) { struct give { struct unit *src, *dst; struct region *r; - struct faction *f; + struct faction *f1, *f2; }; static void setup_give(struct give *env) { terrain_type *ter = test_create_terrain("plain", LAND_REGION); - struct race * rc = test_create_race("human"); env->r = test_create_region(0, 0, ter); - env->f = test_create_faction(0); - env->src = test_create_unit(env->f, env->r); - env->dst = test_create_unit(env->f, env->r); + env->src = test_create_unit(env->f1, env->r); + env->dst = test_create_unit(env->f2, env->r); } static void test_give_okay(CuTest * tc) { struct give env; + struct race * rc; + test_cleanup(); + rc = test_create_race("human"); + env.f2 = env.f1 = test_create_faction(rc); setup_give(&env); + set_param(&global.parameters, "rules.give", "0"); CuAssertPtrEquals(tc, 0, check_give(env.src, env.dst, 0)); test_cleanup(); } +static void test_give_denied_by_rules(CuTest * tc) { + struct give env; + struct race * rc; + struct message *msg; + + test_cleanup(); + rc = test_create_race("human"); + env.f1 = test_create_faction(rc); + env.f2 = test_create_faction(rc); + setup_give(&env); + + set_param(&global.parameters, "rules.give", "0"); + CuAssertPtrNotNull(tc, msg=check_give(env.src, env.dst, 0)); + msg_release(msg); + test_cleanup(); +} + CuSuite *get_economy_suite(void) { CuSuite *suite = CuSuiteNew(); @@ -147,5 +168,6 @@ CuSuite *get_economy_suite(void) SUITE_ADD_TEST(suite, test_steal_ocean); SUITE_ADD_TEST(suite, test_steal_nosteal); SUITE_ADD_TEST(suite, test_give_okay); + SUITE_ADD_TEST(suite, test_give_denied_by_rules); return suite; } diff --git a/src/kernel/config.c b/src/kernel/config.c index 61f02a211..01fb7a7ee 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -2748,6 +2748,7 @@ void kernel_init(void) register_reports(); if (!mt_find("missing_message")) { mt_register(mt_new_va("missing_message", "name:string", 0)); + mt_register(mt_new_va("missing_feedback", "unit:unit", "region:region", "command:order", "name:string", 0)); } attrib_init(); translation_init(); diff --git a/src/util/language.c b/src/util/language.c index 601be6245..f5e98797b 100644 --- a/src/util/language.c +++ b/src/util/language.c @@ -189,8 +189,7 @@ void locale_setstring(locale * lang, const char *key, const char *value) const char *locale_name(const locale * lang) { - assert(lang); - return lang->name; + return lang ? lang->name : "(null)"; } char *mkname_buf(const char *space, const char *name, char *buffer)