diff --git a/res/core/weapons/mallorncrossbow.xml b/res/core/weapons/mallorncrossbow.xml
index 8d4a5027b..fb7be26c0 100644
--- a/res/core/weapons/mallorncrossbow.xml
+++ b/res/core/weapons/mallorncrossbow.xml
@@ -5,8 +5,8 @@
-
-
+
+
diff --git a/src/laws.c b/src/laws.c
index b29280bb4..ba5466fda 100755
--- a/src/laws.c
+++ b/src/laws.c
@@ -1992,7 +1992,7 @@ int mail_cmd(unit * u, struct order *ord)
}
s = getstrtoken();
- if (!s[0]) {
+ if (!s || !s[0]) {
cmistake(u, ord, 30, MSG_MESSAGE);
break;
}
@@ -2015,7 +2015,7 @@ int mail_cmd(unit * u, struct order *ord)
}
s = getstrtoken();
- if (!s[0]) {
+ if (!s || !s[0]) {
cmistake(u, ord, 30, MSG_MESSAGE);
break;
}
@@ -2047,7 +2047,7 @@ int mail_cmd(unit * u, struct order *ord)
s = getstrtoken();
- if (!s[0]) {
+ if (!s || !s[0]) {
cmistake(u, ord, 30, MSG_MESSAGE);
break;
}
@@ -2076,7 +2076,7 @@ int mail_cmd(unit * u, struct order *ord)
s = getstrtoken();
- if (!s[0]) {
+ if (!s || !s[0]) {
cmistake(u, ord, 30, MSG_MESSAGE);
break;
}
diff --git a/src/laws.test.c b/src/laws.test.c
index a824f4cab..431c03845 100644
--- a/src/laws.test.c
+++ b/src/laws.test.c
@@ -970,7 +970,7 @@ static void test_ally_cmd(CuTest *tc) {
test_cleanup();
}
-void test_nmr_warnings(CuTest *tc) {
+static void test_nmr_warnings(CuTest *tc) {
faction *f1, *f2;
test_cleanup();
set_param(&global.parameters, "nmr.timeout", "3");
@@ -989,6 +989,43 @@ void test_nmr_warnings(CuTest *tc) {
test_cleanup();
}
+static void test_mail_cmd(CuTest *tc) {
+ unit *u;
+ order *ord;
+ faction *f;
+ struct locale *lang;
+
+ test_cleanup();
+ f = test_create_faction(0);
+ f->locale = lang = get_or_create_locale("de");
+ locale_setstring(lang, parameters[P_UNIT], "EINHEIT");
+ init_parameters(lang);
+ u = test_create_unit(f, test_create_region(0, 0, 0));
+ ord = create_order(K_MAIL, u->faction->locale, "EINHEIT %s 'Hodor!'", itoa36(u->no));
+ mail_cmd(u, ord);
+ CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "unitmessage"));
+ test_cleanup();
+}
+
+static void test_mail_cmd_no_msg(CuTest *tc) {
+ unit *u;
+ order *ord;
+ faction *f;
+ struct locale *lang;
+
+ test_cleanup();
+ f = test_create_faction(0);
+ f->locale = lang = get_or_create_locale("de");
+ locale_setstring(lang, parameters[P_UNIT], "EINHEIT");
+ init_parameters(lang);
+ u = test_create_unit(f, test_create_region(0, 0, 0));
+ ord = create_order(K_MAIL, u->faction->locale, "EINHEIT %s", itoa36(u->no));
+ mail_cmd(u, ord);
+ CuAssertPtrEquals(tc, 0, test_find_messagetype(f->msgs, "unitmessage"));
+ CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error30"));
+ test_cleanup();
+}
+
CuSuite *get_laws_suite(void)
{
CuSuite *suite = CuSuiteNew();
@@ -1033,6 +1070,8 @@ CuSuite *get_laws_suite(void)
SUITE_ADD_TEST(suite, test_force_leave_ships);
SUITE_ADD_TEST(suite, test_force_leave_ships_on_ocean);
SUITE_ADD_TEST(suite, test_peasant_luck_effect);
+ SUITE_ADD_TEST(suite, test_mail_cmd);
+ SUITE_ADD_TEST(suite, test_mail_cmd_no_msg);
(void)test_luck_message; /* disabled, breaks on travis */
return suite;