Skip to content

Commit

Permalink
BUG owner of a building can't enter ship
Browse files Browse the repository at this point in the history
If owner of a building want to enter a ship or other building,
he must first leave the bulding.
Commands are "leave" and "enter <ship/tower> <ID>".
For buildings was that OK but not for ships.
The building owner was inside the region after that commans
and not in the ship.
  • Loading branch information
TomBraun02 committed Jul 3, 2014
1 parent 6639fbb commit 918ab39
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
22 changes: 22 additions & 0 deletions scripts/tests/e3a.lua
Expand Up @@ -710,3 +710,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")

This comment has been minimized.

Copy link
@ennorehling

ennorehling Jul 5, 2014

This assert seems strange: the id of the building must not be equal to the id of the ship that the unit is in? ships are not buildings, and comparing their ids makes no sense at all.
I think you mean to say something else (that the unit is not in a building?)

This comment has been minimized.

Copy link
@TomBraun

TomBraun Jul 5, 2014

Owner

The assert work's but the check is wrong :)
correct is:
assert_not_equal(b1.id, u1.building.id, "BUG owner of the building can not go into a ship")

end
3 changes: 2 additions & 1 deletion src/laws.c
Expand Up @@ -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)
Expand Down

0 comments on commit 918ab39

Please sign in to comment.