From 783df8405587aa1f2b678813bb4ef0fac16cba2e Mon Sep 17 00:00:00 2001 From: TomBraun Date: Thu, 3 Jul 2014 15:30:59 +0200 Subject: [PATCH] BUG owner of a building can't enter ship If owner of a building want to enter a ship or other building, he must first leave the bulding. Commands are "leave" and "enter ". For buildings was that OK but not for ships. The building owner was inside the region after that commans and not in the ship. --- scripts/tests/e3a.lua | 22 ++++++++++++++++++++++ src/laws.c | 3 ++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/scripts/tests/e3a.lua b/scripts/tests/e3a.lua index e3f6ad725..de9902883 100644 --- a/scripts/tests/e3a.lua +++ b/scripts/tests/e3a.lua @@ -711,3 +711,25 @@ function test_golem_use_four_iron() assert_equal(4, u1:get_item("towershield")) end +function test_building_owner_can_enter_ship() + local r1 = region.create(1, 2, "plain") + local f1 = faction.create("noreply@tteessttiinngg.de", "human", "de") + local b1 = building.create(r1, "castle") + b1.size = 10 + local s1 = ship.create(r1, "cutter") + + local u1 = unit.create(f1, r1, 10) + u1.building = b1 + u1:add_item("money", u1.number * 100) + u1:clear_orders() + u1:add_order("VERLASSEN") + u1:add_order("BETRETE SCHIFF " .. itoa36(s1.id)) + + local u2 = unit.create(f1, r1, 10) + u2.ship = s1 + u2:add_item("money", u1.number * 100) + u2:clear_orders() + process_orders() + assert_equal(s1.id, u1.ship.id) + assert_not_equal(b1.id, u1.ship.id, "BUG owner of the building can not go into a ship") +end diff --git a/src/laws.c b/src/laws.c index 89dc41e08..49e02613c 100755 --- a/src/laws.c +++ b/src/laws.c @@ -1259,10 +1259,11 @@ int enter_ship(unit * u, struct order *ord, int id, int report) if (leave(u, false)) { u_set_ship(u, sh); fset(u, UFL_ENTER); + return 1; } else if (report) { cmistake(u, ord, 150, MSG_MOVE); } - return 1; + return 0; } int enter_building(unit * u, order * ord, int id, int report)