From 39a284b4235e7c7a8e5f4049128b19f094b8643a Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 18 Aug 2016 19:46:29 +0200 Subject: [PATCH 1/8] quick and dirty .bat file to run drmemory on the server. --- tests/drmemory.bat | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 tests/drmemory.bat diff --git a/tests/drmemory.bat b/tests/drmemory.bat new file mode 100644 index 000000000..64fe7fba5 --- /dev/null +++ b/tests/drmemory.bat @@ -0,0 +1,6 @@ +cd c:\users\enno\documents\eressea\git\tests + +"C:\Program Files (x86)\Dr. Memory\bin64\drmemory.exe" ..\build-vs14\eressea\Debug\eressea.exe -t184 test-turn.lua + +deltree reports +del datum htpasswd parteien parteien.full passwd score turn From 9e901b47b6796cbee1def5e3bbe6cf0b0413c8c1 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 18 Aug 2016 20:07:16 +0200 Subject: [PATCH 2/8] I'm getting reports of leaks for umlaut.c based structures and configuration? This is not actually solving those, though. clean up report directory, fix .bat file. --- src/eressea.c | 2 ++ tests/drmemory.bat | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/eressea.c b/src/eressea.c index 2b137cb0a..18c98cad6 100755 --- a/src/eressea.c +++ b/src/eressea.c @@ -49,6 +49,8 @@ void game_done(void) calendar_cleanup(); #endif free_functions(); + free_config(); + free_locales(); curses_done(); kernel_done(); } diff --git a/tests/drmemory.bat b/tests/drmemory.bat index 64fe7fba5..1d07081aa 100644 --- a/tests/drmemory.bat +++ b/tests/drmemory.bat @@ -2,5 +2,6 @@ cd c:\users\enno\documents\eressea\git\tests "C:\Program Files (x86)\Dr. Memory\bin64\drmemory.exe" ..\build-vs14\eressea\Debug\eressea.exe -t184 test-turn.lua -deltree reports +del reports del datum htpasswd parteien parteien.full passwd score turn +pause From 1ef8049668773b316344eacd91ae407808dbd383 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 19 Aug 2016 18:22:38 +0200 Subject: [PATCH 3/8] adding Solthar's test to show that the bug exists --- scripts/tests/e2/movement.lua | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/scripts/tests/e2/movement.lua b/scripts/tests/e2/movement.lua index 7e20e41ca..706ed9ad2 100644 --- a/scripts/tests/e2/movement.lua +++ b/scripts/tests/e2/movement.lua @@ -8,6 +8,31 @@ function setup() eressea.settings.set("NewbieImmunity", "0") end + function test_piracy() + local r = region.create(0, 0, "plain") + local r2 = region.create(1, 0, "plain") + local r3 = region.create(-1, 0, "ocean") + local f = faction.create("pirate@eressea.de", "human", "de") + local f2 = faction.create("elf@eressea.de", "human", "de") + local u1 = unit.create(f, r2, 1) + local u2 = unit.create(f2, r3, 1) + + u1.ship = ship.create(r2, "longboat") + u2.ship = ship.create(r3, "longboat") + u1:set_skill("sailing", 10) + u2:set_skill("sailing", 10) + + u1:clear_orders() + u1:add_order("PIRATERIE") + u2:clear_orders() + u2:add_order("NACH o") + + process_orders() + +-- write_reports() + assert_equal(r2, u1.region) -- should pass, but fails!!! +end + function test_dolphin_on_land() local r1 = region.create(0, 0, "plain") local r2 = region.create(1, 0, "plain") From 1c4c0602f9daad46bd19c79f038455790fb583a8 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 20 Aug 2016 11:06:46 +0200 Subject: [PATCH 4/8] reactivate disabled piracy test, watch it fail --- src/piracy.test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/piracy.test.c b/src/piracy.test.c index 005ce5857..a06333974 100644 --- a/src/piracy.test.c +++ b/src/piracy.test.c @@ -226,7 +226,7 @@ CuSuite *get_piracy_suite(void) SUITE_ADD_TEST(suite, test_piracy_cmd_errors); SUITE_ADD_TEST(suite, test_piracy_cmd); SUITE_ADD_TEST(suite, test_piracy_cmd_walking); - DISABLE_TEST(suite, test_piracy_cmd_land_to_land); + SUITE_ADD_TEST(suite, test_piracy_cmd_land_to_land); SUITE_ADD_TEST(suite, test_piracy_cmd_swimmer); return suite; } From c755de1cd50a0e9d4ef1ab7d864fd360dd585555 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 20 Aug 2016 17:25:04 +0200 Subject: [PATCH 5/8] fix the bug (move_on_land must die). disable broken test (setup_pirate is incomprehensible gibberish). --- src/move.c | 1 + src/piracy.c | 2 +- src/piracy.test.c | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/move.c b/src/move.c index 6c5950c1f..b393777a0 100644 --- a/src/move.c +++ b/src/move.c @@ -2272,6 +2272,7 @@ static void travel(unit * u, region_list ** routep) } } +// FIXME: move_on_land argument is unused, kill it void move_cmd(unit * u, order * ord, bool move_on_land) { region_list *route = NULL; diff --git a/src/piracy.c b/src/piracy.c index 05a744cb9..7c7597691 100644 --- a/src/piracy.c +++ b/src/piracy.c @@ -206,7 +206,7 @@ void piracy_cmd(unit * u, order *ord) /* Bewegung ausführen */ init_order(u->thisorder); - move_cmd(u, ord, true); + move_cmd(u, ord, false); } void age_piracy(region *r) { diff --git a/src/piracy.test.c b/src/piracy.test.c index a06333974..005ce5857 100644 --- a/src/piracy.test.c +++ b/src/piracy.test.c @@ -226,7 +226,7 @@ CuSuite *get_piracy_suite(void) SUITE_ADD_TEST(suite, test_piracy_cmd_errors); SUITE_ADD_TEST(suite, test_piracy_cmd); SUITE_ADD_TEST(suite, test_piracy_cmd_walking); - SUITE_ADD_TEST(suite, test_piracy_cmd_land_to_land); + DISABLE_TEST(suite, test_piracy_cmd_land_to_land); SUITE_ADD_TEST(suite, test_piracy_cmd_swimmer); return suite; } From 860078cfc98c40430b9066b3b9995477792f30fd Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 20 Aug 2016 19:10:53 +0200 Subject: [PATCH 6/8] fix piracy_cmd_land_to_land --- src/piracy.test.c | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/src/piracy.test.c b/src/piracy.test.c index 005ce5857..1c266fd47 100644 --- a/src/piracy.test.c +++ b/src/piracy.test.c @@ -178,22 +178,39 @@ static void test_piracy_cmd_walking(CuTest * tc) { } static void test_piracy_cmd_land_to_land(CuTest * tc) { - unit *pirate, *victim; + unit *u; order *ord; region *r; + faction *f; + int target; + const terrain_type *t_plain; + const ship_type *stype; test_cleanup(); - setup_pirate(&pirate, 0, 0, "boat", &ord, &victim, SEA_REGION, "boat"); - set_level(pirate, SK_SAILING, pirate->ship->type->sumskill); - r = pirate->region; + setup_piracy(); + t_plain = get_or_create_terrain("plain"); + stype = test_create_shiptype("boat"); - piracy_cmd(pirate, ord); - CuAssertPtrEquals(tc, 0, pirate->thisorder); - CuAssertTrue(tc, pirate->region == r); - /* TODO check message - CuAssertPtrNotNullMsg(tc, "successful PIRACY movement", test_find_messagetype(pirate->faction->msgs, "travel")); - */ + // create a target: + r = test_create_region(0, 0, t_plain); + f = test_create_faction(0); + u = test_create_unit(f, r); + u->ship = test_create_ship(r, stype); + target = f->no; + + // create a pirate: + r = test_create_region(1, 0, t_plain); + f = test_create_faction(0); + u = test_create_unit(f, r); + u->ship = test_create_ship(r, stype); + set_level(u, SK_SAILING, u->ship->type->sumskill); + ord = create_order(K_PIRACY, f->locale, "%s", itoa36(target)); + + piracy_cmd(u, ord); + CuAssertPtrEquals(tc, 0, u->thisorder); + CuAssertPtrEquals(tc, r, u->region); + // TODO check message free_order(ord); test_cleanup(); @@ -226,7 +243,7 @@ CuSuite *get_piracy_suite(void) SUITE_ADD_TEST(suite, test_piracy_cmd_errors); SUITE_ADD_TEST(suite, test_piracy_cmd); SUITE_ADD_TEST(suite, test_piracy_cmd_walking); - DISABLE_TEST(suite, test_piracy_cmd_land_to_land); + SUITE_ADD_TEST(suite, test_piracy_cmd_land_to_land); SUITE_ADD_TEST(suite, test_piracy_cmd_swimmer); return suite; } From 6c17cf9d17c1ae278136448ab005fe0703531021 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 20 Aug 2016 19:24:18 +0200 Subject: [PATCH 7/8] remove move_on_land from sail() --- src/move.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/move.c b/src/move.c index b393777a0..fdc2dc64f 100644 --- a/src/move.c +++ b/src/move.c @@ -1786,8 +1786,7 @@ bool can_takeoff(const ship * sh, const region * from, const region * to) return true; } -static void -sail(unit * u, order * ord, bool move_on_land, region_list ** routep) +static void sail(unit * u, order * ord, region_list ** routep) { region *starting_point = u->region; region *current_point, *last_point; @@ -1909,12 +1908,10 @@ sail(unit * u, order * ord, bool move_on_land, region_list ** routep) } // storms_enabled if (!fval(tthis, SEA_REGION)) { if (!fval(tnext, SEA_REGION)) { - if (!move_on_land) { - /* check that you're not traveling from one land region to another. */ - ADDMSG(&u->faction->msgs, msg_message("shipnoshore", - "ship region", sh, next_point)); - break; - } + /* check that you're not traveling from one land region to another. */ + ADDMSG(&u->faction->msgs, msg_message("shipnoshore", + "ship region", sh, next_point)); + break; } else { if (!can_takeoff(sh, current_point, next_point)) { @@ -2024,9 +2021,7 @@ sail(unit * u, order * ord, bool move_on_land, region_list ** routep) * transferiert wurden, kann der aktuelle Befehl gelöscht werden. */ cycle_route(ord, u, step); set_order(&u->thisorder, NULL); - if (!move_on_land) { - set_coast(sh, last_point, current_point); - } + set_coast(sh, last_point, current_point); if (is_cursed(sh->attribs, C_SHIP_FLYING, 0)) { ADDMSG(&f->msgs, msg_message("shipfly", "ship from to", sh, @@ -2279,7 +2274,7 @@ void move_cmd(unit * u, order * ord, bool move_on_land) assert(u->number); if (u->ship && u == ship_owner(u->ship)) { - sail(u, ord, move_on_land, &route); + sail(u, ord, &route); } else { travel(u, &route); From 9a6d4a174a454f45181eacb51cf79e478026024e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 20 Aug 2016 19:25:44 +0200 Subject: [PATCH 8/8] remove move_on_land argument from move_cmd --- src/move.c | 9 ++++----- src/move.h | 2 +- src/piracy.c | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/move.c b/src/move.c index fdc2dc64f..09f3c2b3f 100644 --- a/src/move.c +++ b/src/move.c @@ -2267,8 +2267,7 @@ static void travel(unit * u, region_list ** routep) } } -// FIXME: move_on_land argument is unused, kill it -void move_cmd(unit * u, order * ord, bool move_on_land) +void move_cmd(unit * u, order * ord) { region_list *route = NULL; @@ -2392,7 +2391,7 @@ int follow_ship(unit * u, order * ord) init_tokens_str(command); getstrtoken(); /* NACH ausführen */ - move_cmd(u, ord, false); + move_cmd(u, ord); return 1; /* true -> Einheitenliste von vorne durchgehen */ } @@ -2559,13 +2558,13 @@ void movement(void) if (ships) { if (u->ship && ship_owner(u->ship) == u) { init_order(u->thisorder); - move_cmd(u, u->thisorder, false); + move_cmd(u, u->thisorder); } } else { if (!u->ship || ship_owner(u->ship) != u) { init_order(u->thisorder); - move_cmd(u, u->thisorder, false); + move_cmd(u, u->thisorder); } } } diff --git a/src/move.h b/src/move.h index 9c5893629..70dddbb0b 100644 --- a/src/move.h +++ b/src/move.h @@ -74,7 +74,7 @@ extern "C" { bool move_blocked(const struct unit *u, const struct region *src, const struct region *dest); bool can_takeoff(const struct ship * sh, const struct region * from, const struct region * to); - void move_cmd(struct unit * u, struct order * ord, bool move_on_land); + void move_cmd(struct unit * u, struct order * ord); int follow_ship(struct unit * u, struct order * ord); #define SA_HARBOUR 1 diff --git a/src/piracy.c b/src/piracy.c index 7c7597691..1a556f92f 100644 --- a/src/piracy.c +++ b/src/piracy.c @@ -206,7 +206,7 @@ void piracy_cmd(unit * u, order *ord) /* Bewegung ausführen */ init_order(u->thisorder); - move_cmd(u, ord, false); + move_cmd(u, ord); } void age_piracy(region *r) {