forked from github/server
Bug 2525: fix default oder preservation.
This commit is contained in:
parent
c856228d5e
commit
ac9db0c87b
|
@ -22,7 +22,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
static void begin_orders(unit *u) {
|
static void begin_orders(unit *u) {
|
||||||
if (u->flags & UFL_ORDERS) {
|
if ((u->flags & UFL_ORDERS) == 0) {
|
||||||
order **ordp;
|
order **ordp;
|
||||||
/* alle wiederholbaren, langen befehle werden gesichert: */
|
/* alle wiederholbaren, langen befehle werden gesichert: */
|
||||||
u->flags |= UFL_ORDERS;
|
u->flags |= UFL_ORDERS;
|
||||||
|
|
|
@ -50,7 +50,7 @@ static void test_unit_orders(CuTest *tc) {
|
||||||
input in;
|
input in;
|
||||||
unit *u;
|
unit *u;
|
||||||
faction *f;
|
faction *f;
|
||||||
strlist *orders = NULL;
|
strlist *orders = NULL, *backup;
|
||||||
char buf[64];
|
char buf[64];
|
||||||
|
|
||||||
test_setup();
|
test_setup();
|
||||||
|
@ -66,15 +66,18 @@ static void test_unit_orders(CuTest *tc) {
|
||||||
addstrlist(&orders, buf);
|
addstrlist(&orders, buf);
|
||||||
snprintf(buf, sizeof(buf), "%s %s", keyword_name(K_MOVE, f->locale),
|
snprintf(buf, sizeof(buf), "%s %s", keyword_name(K_MOVE, f->locale),
|
||||||
LOC(f->locale, shortdirections[D_WEST]));
|
LOC(f->locale, shortdirections[D_WEST]));
|
||||||
|
backup = orders;
|
||||||
addstrlist(&orders, buf);
|
addstrlist(&orders, buf);
|
||||||
in.data = &orders;
|
in.data = &orders;
|
||||||
in.getbuf = getbuf_strings;
|
in.getbuf = getbuf_strings;
|
||||||
CuAssertIntEquals(tc, 0, read_orders(&in));
|
CuAssertIntEquals(tc, 0, read_orders(&in));
|
||||||
CuAssertPtrNotNull(tc, u->old_orders);
|
CuAssertPtrNotNull(tc, u->old_orders);
|
||||||
CuAssertPtrNotNull(tc, u->orders);
|
CuAssertPtrNotNull(tc, u->orders);
|
||||||
|
CuAssertPtrEquals(tc, NULL, orders);
|
||||||
CuAssertIntEquals(tc, K_MOVE, getkeyword(u->orders));
|
CuAssertIntEquals(tc, K_MOVE, getkeyword(u->orders));
|
||||||
CuAssertIntEquals(tc, K_ENTERTAIN, getkeyword(u->old_orders));
|
CuAssertIntEquals(tc, K_ENTERTAIN, getkeyword(u->old_orders));
|
||||||
CuAssertIntEquals(tc, UFL_ORDERS, u->flags & UFL_ORDERS);
|
CuAssertIntEquals(tc, UFL_ORDERS, u->flags & UFL_ORDERS);
|
||||||
|
freestrlist(backup);
|
||||||
test_teardown();
|
test_teardown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue