diff --git a/scripts/tests/e2/insects.lua b/scripts/tests/e2/insects.lua index bfd0a2065..1898e215c 100644 --- a/scripts/tests/e2/insects.lua +++ b/scripts/tests/e2/insects.lua @@ -12,19 +12,33 @@ end function test_move_to_glacier() local r = region.create(0, 0, "plain") local r2 = region.create(1, 0, "glacier") - local f = faction.create("insect", "insect@eressea.de", "de") + local f = faction.create("insect") local u = unit.create(f, r, 1) u:clear_orders() u:add_order("NACH OST") process_orders() assert_equal(r, u.region) -end +end -function test_sail_into_glacier() +function test_sail_to_glacier() local r = region.create(0, 0, "ocean") local r2 = region.create(1, 0, "glacier") - local f = faction.create("insect", "insect@eressea.de", "de") + local f = faction.create("insect") + local u1 = unit.create(f, r, 1, 'insect') + + u1.ship = ship.create(r, 'boat') + u1:set_skill("sailing", 10) + u1:clear_orders() + u1:add_order("NACH OST") + process_orders() + assert_equal(r, u1.region) +end + +function test_passenger_into_glacier() + local r = region.create(0, 0, "ocean") + local r2 = region.create(1, 0, "glacier") + local f = faction.create("insect") local u1 = unit.create(f, r, 1, 'human') local u2 = unit.create(f, r, 1, 'insect') @@ -39,7 +53,7 @@ end function test_recruit_in_winter() local r = region.create(0, 0, "plain") - local f = faction.create("insect", "insect@eressea.de", "de") + local f = faction.create("insect") local u = unit.create(f, r, 1) u:add_item('money', 1000) @@ -60,7 +74,7 @@ end function test_recruit_in_desert() local r = region.create(0, 0, "desert") - local f = faction.create("insect", "insect@eressea.de", "de") + local f = faction.create("insect") local u = unit.create(f, r, 1) u:add_item('money', 1000) diff --git a/src/move.c b/src/move.c index 1502f6243..99585ad09 100644 --- a/src/move.c +++ b/src/move.c @@ -677,6 +677,15 @@ int check_ship_allowed(struct ship *sh, const region * r) int c = 0; const building_type *bt_harbour = bt_find("harbour"); + if (sh->region && r_insectstalled(r)) { + /* insekten dürfen nicht hier rein. haben wir welche? */ + unit *u = ship_owner(sh); + + if (is_freezing(u)) { + return SA_NO_INSECT; + } + } + if (bt_harbour && buildingtype_exists(r, bt_harbour, true)) { unit* harbourmaster = NULL; harbourmaster = owner_buildingtyp(r, bt_harbour); @@ -1837,7 +1846,10 @@ static void sail(unit * u, order * ord, region_list ** routep, bool drifting) reason = check_ship_allowed(sh, next_point); if (reason < 0) { /* for some reason or another, we aren't allowed in there.. */ - if (check_leuchtturm(current_point, NULL)) { + if (reason == SA_NO_INSECT) { + ADDMSG(&f->msgs, msg_message("detectforbidden", "unit region", u, sh->region)); + } + else if (check_leuchtturm(current_point, NULL)) { ADDMSG(&f->msgs, msg_message("sailnolandingstorm", "ship region", sh, next_point)); } else { diff --git a/src/move.h b/src/move.h index d3a5d1e0d..535c76bb2 100644 --- a/src/move.h +++ b/src/move.h @@ -90,7 +90,8 @@ extern "C" { #define SA_HARBOUR 1 #define SA_COAST 0 -#define SA_NO_COAST -1 +#define SA_NO_INSECT -1 +#define SA_NO_COAST -2 int check_ship_allowed(struct ship *sh, const struct region * r); direction_t drift_target(struct ship *sh);