forked from github/server
read_order must use parse_order (not create) to properly handle make temp.
This commit is contained in:
parent
8b39133dbf
commit
86e99a560c
2 changed files with 28 additions and 4 deletions
|
@ -122,10 +122,11 @@ char *rns(FILE * f, char *c, size_t size)
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct order *read_order(const char *s, const struct locale *lang) {
|
struct order *read_order(const char *in, const struct locale *lang) {
|
||||||
assert(s);
|
assert(in);
|
||||||
assert(lang);
|
assert(lang);
|
||||||
if (s[0]) {
|
if (in[0]) {
|
||||||
|
const char *s = in;
|
||||||
keyword_t kwd;
|
keyword_t kwd;
|
||||||
char token[64];
|
char token[64];
|
||||||
const char *stok;
|
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 */
|
/* Nun wird der Befehl erzeut und eingehängt */
|
||||||
kwd = get_keyword(stok, lang);
|
kwd = get_keyword(stok, lang);
|
||||||
if (kwd != NOKEYWORD) {
|
if (kwd != NOKEYWORD) {
|
||||||
return create_order(kwd, lang, s);
|
return parse_order(in, lang);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -469,6 +469,29 @@ static void test_read_order(CuTest *tc) {
|
||||||
CuAssertStrEquals(tc, "move NORTH", get_command(ord, cmd, sizeof(cmd)));
|
CuAssertStrEquals(tc, "move NORTH", get_command(ord, cmd, sizeof(cmd)));
|
||||||
free_order(ord);
|
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();
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue