diff --git a/src/kernel/save.c b/src/kernel/save.c index 1c55db3ea..ed64b7bfd 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -122,10 +122,11 @@ char *rns(FILE * f, char *c, size_t size) return c; } -struct order *read_order(const char *s, const struct locale *lang) { - assert(s); +struct order *read_order(const char *in, const struct locale *lang) { + assert(in); assert(lang); - if (s[0]) { + if (in[0]) { + const char *s = in; keyword_t kwd; char token[64]; const char *stok; @@ -152,7 +153,7 @@ struct order *read_order(const char *s, const struct locale *lang) { /* Nun wird der Befehl erzeut und eingehÃĪngt */ kwd = get_keyword(stok, lang); if (kwd != NOKEYWORD) { - return create_order(kwd, lang, s); + return parse_order(in, lang); } } return NULL; diff --git a/src/kernel/save.test.c b/src/kernel/save.test.c index f70d6ff07..15600393a 100644 --- a/src/kernel/save.test.c +++ b/src/kernel/save.test.c @@ -469,6 +469,29 @@ static void test_read_order(CuTest *tc) { CuAssertStrEquals(tc, "move NORTH", get_command(ord, cmd, sizeof(cmd))); free_order(ord); + ord = read_order("MAKE TEMP foo", lang); + CuAssertPtrNotNull(tc, ord); + CuAssertTrue(tc, !ord->_noerror); + CuAssertTrue(tc, !ord->_persistent); + CuAssertIntEquals(tc, K_MAKETEMP, getkeyword(ord)); + CuAssertStrEquals(tc, "maketemp foo", get_command(ord, cmd, sizeof(cmd))); + free_order(ord); + + ord = read_order("MAKETEMP foo", lang); + CuAssertPtrNotNull(tc, ord); + CuAssertTrue(tc, !ord->_noerror); + CuAssertTrue(tc, !ord->_persistent); + CuAssertIntEquals(tc, K_MAKETEMP, getkeyword(ord)); + CuAssertStrEquals(tc, "maketemp foo", get_command(ord, cmd, sizeof(cmd))); + free_order(ord); + + CuAssertPtrEquals(tc, NULL, read_order("HODOR HODOR HODOR", lang)); + CuAssertPtrEquals(tc, NULL, read_order("FACTION abcd", lang)); + CuAssertPtrEquals(tc, NULL, read_order("UNIT abcd", lang)); + CuAssertPtrEquals(tc, NULL, read_order("ERESSEA abcd", lang)); + CuAssertPtrEquals(tc, NULL, read_order("REGION 2,3", lang)); + CuAssertPtrEquals(tc, NULL, read_order("NEXT", lang)); + test_cleanup(); }