Bug 2525: fix default oder preservation.

This commit is contained in:
Enno Rehling 2018-12-02 15:53:21 +01:00
parent c856228d5e
commit ac9db0c87b
2 changed files with 5 additions and 2 deletions

View File

@ -22,7 +22,7 @@
#include <string.h>
static void begin_orders(unit *u) {
if (u->flags & UFL_ORDERS) {
if ((u->flags & UFL_ORDERS) == 0) {
order **ordp;
/* alle wiederholbaren, langen befehle werden gesichert: */
u->flags |= UFL_ORDERS;

View File

@ -50,7 +50,7 @@ static void test_unit_orders(CuTest *tc) {
input in;
unit *u;
faction *f;
strlist *orders = NULL;
strlist *orders = NULL, *backup;
char buf[64];
test_setup();
@ -66,15 +66,18 @@ static void test_unit_orders(CuTest *tc) {
addstrlist(&orders, buf);
snprintf(buf, sizeof(buf), "%s %s", keyword_name(K_MOVE, f->locale),
LOC(f->locale, shortdirections[D_WEST]));
backup = orders;
addstrlist(&orders, buf);
in.data = &orders;
in.getbuf = getbuf_strings;
CuAssertIntEquals(tc, 0, read_orders(&in));
CuAssertPtrNotNull(tc, u->old_orders);
CuAssertPtrNotNull(tc, u->orders);
CuAssertPtrEquals(tc, NULL, orders);
CuAssertIntEquals(tc, K_MOVE, getkeyword(u->orders));
CuAssertIntEquals(tc, K_ENTERTAIN, getkeyword(u->old_orders));
CuAssertIntEquals(tc, UFL_ORDERS, u->flags & UFL_ORDERS);
freestrlist(backup);
test_teardown();
}