forked from github/server
Merge pull request #543 from ennorehling/bug-2228-tunneling
Bug 2228: piracy between land regions
This commit is contained in:
commit
17c88fa48d
|
@ -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")
|
||||
|
|
|
@ -49,6 +49,8 @@ void game_done(void)
|
|||
calendar_cleanup();
|
||||
#endif
|
||||
free_functions();
|
||||
free_config();
|
||||
free_locales();
|
||||
curses_done();
|
||||
kernel_done();
|
||||
}
|
||||
|
|
17
src/move.c
17
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,13 +1908,11 @@ 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;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!can_takeoff(sh, current_point, next_point)) {
|
||||
/* Schiff kann nicht ablegen */
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
if (is_cursed(sh->attribs, C_SHIP_FLYING, 0)) {
|
||||
ADDMSG(&f->msgs, msg_message("shipfly", "ship from to", sh,
|
||||
|
@ -2272,13 +2267,13 @@ static void travel(unit * u, region_list ** routep)
|
|||
}
|
||||
}
|
||||
|
||||
void move_cmd(unit * u, order * ord, bool move_on_land)
|
||||
void move_cmd(unit * u, order * ord)
|
||||
{
|
||||
region_list *route = NULL;
|
||||
|
||||
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);
|
||||
|
@ -2396,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 */
|
||||
}
|
||||
|
||||
|
@ -2563,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
void age_piracy(region *r) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
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
|
||||
|
||||
del reports
|
||||
del datum htpasswd parteien parteien.full passwd score turn
|
||||
pause
|
Loading…
Reference in New Issue