From 74ddb1f881ae0c1def9fef6a3eac7e1778ebe55c Mon Sep 17 00:00:00 2001 From: Gerd Wellenreuther Date: Thu, 7 Jun 2012 20:59:26 +0200 Subject: [PATCH] Bugfix 1922 entering of RF_BLOCKED regions with ships --- scripts/tests/common.lua | 44 ++++++++++++++++++++++++++++++++++++++++ src/kernel/move.c | 3 ++- 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/scripts/tests/common.lua b/scripts/tests/common.lua index 59b9b68e9..06fe05807 100644 --- a/scripts/tests/common.lua +++ b/scripts/tests/common.lua @@ -917,6 +917,50 @@ function test_parser() assert_not_equal(0, u:get_skill("melee")) end +function test_bug_1922() + -- see http://bugs.eressea.de/view.php?id=1922 + local r = region.create(0, 0, "ocean") + local r2 = region.create(1, 0, "plain") + r2:set_flag(2) -- region should not be accessible + + local f = faction.create("noreply@eressea.de", "human", "de") + local u = unit.create(f, r, 1) + + local s = _test_create_ship(r) + + settings.set("rules.ship.drifting","0") -- ships are not drifting + settings.set("rules.economy.food","4") -- does not need silver + + u.ship = s + u:clear_orders() + u:add_order("NACH O") + u:set_skill("sailing",120) -- supadupa captain able to drive a trireme + process_orders() + assert_not_equal(r2,u.region) -- unit should not reach r2. + +end + + +function test_bug_1922_by_foot() + -- see http://bugs.eressea.de/view.php?id=1922 + local r = region.create(0, 0, "plain") + local r2 = region.create(1, 0, "plain") + r2:set_flag(2) -- region should not be accessible + + local f = faction.create("noreply@eressea.de", "human", "de") + local u = unit.create(f, r, 1) + + settings.set("rules.economy.food","4") -- does not need silver + + u:clear_orders() + u:add_order("NACH O") + + process_orders() + assert_not_equal(r2,u.region) -- unit should not reach r2. + +end + + function test_bug_1814() -- see http://bugs.eressea.de/view.php?id=1814 local r = region.create(0, 0, "mountain") diff --git a/src/kernel/move.c b/src/kernel/move.c index 5c1f7b9fc..993125b43 100644 --- a/src/kernel/move.c +++ b/src/kernel/move.c @@ -704,6 +704,7 @@ static float damage_drift(void) static void drifting_ships(region * r) { direction_t d; + if (get_param_int(global.parameters, "rules.ship.drifting", 1)==0) return; if (fval(r->terrain, SEA_REGION)) { ship **shp = &r->ships; @@ -1718,7 +1719,7 @@ sail(unit * u, order * ord, boolean move_on_land, region_list ** routep) assert(sh == u->ship || !"ship has sunk, but we didn't notice it"); - if (fval(next_point->terrain, FORBIDDEN_REGION)) { + if (fval(next_point->terrain, FORBIDDEN_REGION)||fval(next_point,RF_BLOCKED)) { ADDMSG(&f->msgs, msg_message("sailforbidden", "ship region", sh, next_point)); break;