Merge branch 'bug/#2144' of https://github.com/TurnerSE/server into TurnerSE-bug/#2144

This commit is contained in:
Enno Rehling 2015-11-07 18:53:19 +01:00
commit 9f94979b0d
3 changed files with 61 additions and 7 deletions

View file

@ -2461,8 +2461,10 @@ static void reshow(unit * u, struct order *ord, const char *s, param_t p)
break; break;
} }
else { else {
if (display_item(u->faction, u, itype)) if (!display_item(u->faction, u, itype))
break; cmistake(u, ord, 36, MSG_EVENT);
break;
} }
} }
/* try for a spell */ /* try for a spell */

View file

@ -1199,6 +1199,50 @@ static void test_mail_region_no_msg(CuTest *tc) {
test_cleanup(); 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 *get_laws_suite(void)
{ {
CuSuite *suite = CuSuiteNew(); 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_region);
SUITE_ADD_TEST(suite, test_name_building); SUITE_ADD_TEST(suite, test_name_building);
SUITE_ADD_TEST(suite, test_name_ship); SUITE_ADD_TEST(suite, test_name_ship);
SUITE_ADD_TEST(suite, test_show_without_item);
return suite; return suite;
} }

View file

@ -37,14 +37,21 @@ int sp_flying_ship(castorder * co)
{ {
ship *sh; ship *sh;
unit *u; unit *u;
region *r = co_get_region(co); region *r;
unit *mage = co->magician.u; unit *mage;
int cast_level = co->level; int cast_level;
double power = co->force; double power;
spellparameter *pa = co->par; spellparameter *pa;
message *m = NULL; message *m = NULL;
int cno; 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 */ /* wenn kein Ziel gefunden, Zauber abbrechen */
if (pa->param[0]->flag == TARGET_NOTFOUND) if (pa->param[0]->flag == TARGET_NOTFOUND)
return 0; return 0;