Merge pull request #750 from ennorehling/develop

bug 2389 part 2
This commit is contained in:
Enno Rehling 2017-12-17 14:51:30 +01:00 committed by GitHub
commit dab802031a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 8 deletions

View File

@ -12,19 +12,33 @@ end
function test_move_to_glacier() function test_move_to_glacier()
local r = region.create(0, 0, "plain") local r = region.create(0, 0, "plain")
local r2 = region.create(1, 0, "glacier") 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) local u = unit.create(f, r, 1)
u:clear_orders() u:clear_orders()
u:add_order("NACH OST") u:add_order("NACH OST")
process_orders() process_orders()
assert_equal(r, u.region) 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 r = region.create(0, 0, "ocean")
local r2 = region.create(1, 0, "glacier") 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 u1 = unit.create(f, r, 1, 'human')
local u2 = unit.create(f, r, 1, 'insect') local u2 = unit.create(f, r, 1, 'insect')
@ -39,7 +53,7 @@ end
function test_recruit_in_winter() function test_recruit_in_winter()
local r = region.create(0, 0, "plain") 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) local u = unit.create(f, r, 1)
u:add_item('money', 1000) u:add_item('money', 1000)
@ -60,7 +74,7 @@ end
function test_recruit_in_desert() function test_recruit_in_desert()
local r = region.create(0, 0, "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) local u = unit.create(f, r, 1)
u:add_item('money', 1000) u:add_item('money', 1000)

View File

@ -677,6 +677,15 @@ int check_ship_allowed(struct ship *sh, const region * r)
int c = 0; int c = 0;
const building_type *bt_harbour = bt_find("harbour"); 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)) { if (bt_harbour && buildingtype_exists(r, bt_harbour, true)) {
unit* harbourmaster = NULL; unit* harbourmaster = NULL;
harbourmaster = owner_buildingtyp(r, bt_harbour); 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); reason = check_ship_allowed(sh, next_point);
if (reason < 0) { if (reason < 0) {
/* for some reason or another, we aren't allowed in there.. */ /* 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)); ADDMSG(&f->msgs, msg_message("sailnolandingstorm", "ship region", sh, next_point));
} }
else { else {

View File

@ -90,7 +90,8 @@ extern "C" {
#define SA_HARBOUR 1 #define SA_HARBOUR 1
#define SA_COAST 0 #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); int check_ship_allowed(struct ship *sh, const struct region * r);
direction_t drift_target(struct ship *sh); direction_t drift_target(struct ship *sh);