From ac9db0c87b780b9ac155f42ee7a9fddd8c148e0a Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 2 Dec 2018 15:53:21 +0100 Subject: [PATCH] Bug 2525: fix default oder preservation. --- src/orderfile.c | 2 +- src/orderfile.test.c | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/orderfile.c b/src/orderfile.c index 26ae34ae7..410fa094a 100644 --- a/src/orderfile.c +++ b/src/orderfile.c @@ -22,7 +22,7 @@ #include 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; diff --git a/src/orderfile.test.c b/src/orderfile.test.c index 9b43795ff..204e20d5d 100644 --- a/src/orderfile.test.c +++ b/src/orderfile.test.c @@ -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(); }