diff --git a/src/laws.c b/src/laws.c index 3aa9f8130..15c5404b4 100755 --- a/src/laws.c +++ b/src/laws.c @@ -2461,8 +2461,10 @@ static void reshow(unit * u, struct order *ord, const char *s, param_t p) break; } else { - if (display_item(u->faction, u, itype)) - break; + if (!display_item(u->faction, u, itype)) + cmistake(u, ord, 36, MSG_EVENT); + + break; } } /* try for a spell */ diff --git a/src/laws.test.c b/src/laws.test.c index 3c0be9b6a..e829eff27 100644 --- a/src/laws.test.c +++ b/src/laws.test.c @@ -1199,6 +1199,50 @@ static void test_mail_region_no_msg(CuTest *tc) { test_cleanup(); } +static void test_show_without_item(CuTest *tc) +{ + region *r; + faction *f; + unit *u; + order *ord; + item_type *itype; + item *i; + struct locale *loc; + + test_cleanup(); + + loc = get_or_create_locale("de"); + + r = test_create_region(0, 0, test_create_terrain("testregion", LAND_REGION)); + f = test_create_faction(test_create_race("human")); + u = test_create_unit(f, r); + + ord = create_order(K_RESHOW, u->faction->locale, "testname"); + + itype = it_get_or_create(rt_get_or_create("testitem")); + i = i_new(itype, 1); + + reshow_cmd(u, ord); + CuAssertTrue(tc, test_find_messagetype(u->faction->msgs, "error21") != NULL); + test_clear_messages(u->faction); + + locale_setstring(loc, "testitem", "testname"); + locale_setstring(loc, "iteminfo::testitem", "testdescription"); + reshow_cmd(u, ord); + CuAssertTrue(tc, test_find_messagetype(u->faction->msgs, "error21") == NULL); + CuAssertTrue(tc, test_find_messagetype(u->faction->msgs, "error36") != NULL); + test_clear_messages(u->faction); + + i_add(&(u->items), i); + reshow_cmd(u, ord); + CuAssertTrue(tc, test_find_messagetype(u->faction->msgs, "error21") == NULL); + CuAssertTrue(tc, test_find_messagetype(u->faction->msgs, "error36") == NULL); + test_clear_messages(u->faction); + + free_order(ord); + test_cleanup(); +} + CuSuite *get_laws_suite(void) { CuSuite *suite = CuSuiteNew(); @@ -1255,6 +1299,7 @@ CuSuite *get_laws_suite(void) SUITE_ADD_TEST(suite, test_name_region); SUITE_ADD_TEST(suite, test_name_building); SUITE_ADD_TEST(suite, test_name_ship); + SUITE_ADD_TEST(suite, test_show_without_item); return suite; } diff --git a/src/spells/flyingship.c b/src/spells/flyingship.c index da57ddd93..e8574db2b 100644 --- a/src/spells/flyingship.c +++ b/src/spells/flyingship.c @@ -37,14 +37,21 @@ int sp_flying_ship(castorder * co) { ship *sh; unit *u; - region *r = co_get_region(co); - unit *mage = co->magician.u; - int cast_level = co->level; - double power = co->force; - spellparameter *pa = co->par; + region *r; + unit *mage; + int cast_level; + double power; + spellparameter *pa; message *m = NULL; int cno; + assert(co); + r = co_get_region(co); + mage = co->magician.u; + cast_level = co->level; + power = co->force; + pa = co->par; + /* wenn kein Ziel gefunden, Zauber abbrechen */ if (pa->param[0]->flag == TARGET_NOTFOUND) return 0;