From d2fbdec8311a85fa8325fd85af79d6e854de44b8 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 20 Apr 2015 15:07:10 +0200 Subject: [PATCH] re-enable disabled tests for E2, add test for FOLLOW. --- scripts/tests/e2/init.lua | 6 +++--- scripts/tests/e2/movement.lua | 15 +++++++++++++++ src/kernel/order.c | 1 + src/move.c | 5 +++-- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/scripts/tests/e2/init.lua b/scripts/tests/e2/init.lua index 427a7884d..bec715853 100644 --- a/scripts/tests/e2/init.lua +++ b/scripts/tests/e2/init.lua @@ -1,4 +1,4 @@ --- require 'tests.e2.shiplanding' --- require 'tests.e2.e2features' --- require 'tests.e2.movement' +require 'tests.e2.shiplanding' +require 'tests.e2.e2features' +require 'tests.e2.movement' require 'tests.e2.guard' diff --git a/scripts/tests/e2/movement.lua b/scripts/tests/e2/movement.lua index c97fccac7..e0c433761 100644 --- a/scripts/tests/e2/movement.lua +++ b/scripts/tests/e2/movement.lua @@ -44,3 +44,18 @@ function test_dolphin_in_ocean() process_orders() assert_equal(r2, u1.region) end + +function test_follow() + local r1 = region.create(0, 0, "plain") + local r2 = region.create(1, 0, "plain") + local f = faction.create("test@example.com", "human", "de") + local u1 = unit.create(f, r1, 1) + local u2 = unit.create(f, r1, 1) + u1:clear_orders() + u2:clear_orders() + u1:add_order("NACH O") + u2:add_order("FOLGE EINHEIT " .. itoa36(u1.id)) + process_orders() + assert_equal(u1.region, r2) + assert_equal(u2.region, r2) +end diff --git a/src/kernel/order.c b/src/kernel/order.c index 70114125d..fc29932fc 100644 --- a/src/kernel/order.c +++ b/src/kernel/order.c @@ -305,6 +305,7 @@ order *create_order(keyword_t kwd, const struct locale * lang, switch (*params) { case 's': s = va_arg(marker, const char *); + assert(s); bytes = (int)strlcpy(bufp, s, size); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); diff --git a/src/move.c b/src/move.c index 25ee31d9a..54864b89e 100644 --- a/src/move.c +++ b/src/move.c @@ -2313,10 +2313,11 @@ static void travel(unit * u, region_list ** routep) if (uf->region == r) { order *follow_order; const struct locale *lang = u->faction->locale; - + const char *s = LOC(uf->faction->locale, parameters[P_UNIT]); /* construct an order */ + assert(s || !"missing translation for UNIT keyword"); follow_order = create_order(K_FOLLOW, lang, "%s %i", - LOC(uf->faction->locale, parameters[P_UNIT]), ut->no); + s, ut->no); route_end = reroute(uf, route_begin, route_end); travel_i(uf, route_begin, route_end, follow_order, TRAVEL_FOLLOWING,