addendum bug 2389: insects mail not sail a ship into a glacier, but can be passengers.

This commit is contained in:
Enno Rehling 2017-12-17 14:50:11 +01:00
parent 404691c5db
commit 683e3c566d
3 changed files with 35 additions and 8 deletions

View File

@ -12,7 +12,7 @@ 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()
@ -21,10 +21,24 @@ function test_move_to_glacier()
assert_equal(r, u.region)
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)

View File

@ -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 {

View File

@ -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);