do not eject units from a ship when on the ocean.

This commit is contained in:
Enno Rehling 2015-01-05 22:09:08 +01:00
parent 73da256461
commit d968aa2ed5
2 changed files with 20 additions and 1 deletions

View File

@ -4280,7 +4280,7 @@ void force_leave(region *r) {
if (u->building) {
uo = building_owner(u->building);
}
if (u->ship) {
if (u->ship && r->land) {
uo = ship_owner(u->ship);
}
if (uo && !help_enter(uo, u)) {

View File

@ -271,6 +271,23 @@ static void test_force_leave_ships(CuTest *tc) {
test_cleanup();
}
static void test_force_leave_ships_on_ocean(CuTest *tc) {
region *r;
unit *u1, *u2;
ship *sh;
test_cleanup();
r = test_create_region(0, 0, test_create_terrain("ocean", SEA_REGION));
u1 = test_create_unit(test_create_faction(NULL), r);
u2 = test_create_unit(test_create_faction(NULL), r);
sh = test_create_ship(r, NULL);
u_set_ship(u1, sh);
u_set_ship(u2, sh);
ship_set_owner(u1);
force_leave(r);
CuAssertPtrEquals_Msg(tc, "no forcing out of ships on oceans", sh, u2->ship);
test_cleanup();
}
static void test_fishing_feeds_2_people(CuTest * tc)
{
const resource_type *rtype;
@ -696,5 +713,7 @@ CuSuite *get_laws_suite(void)
SUITE_ADD_TEST(suite, test_display_cmd);
SUITE_ADD_TEST(suite, test_force_leave_buildings);
SUITE_ADD_TEST(suite, test_force_leave_ships);
SUITE_ADD_TEST(suite, test_force_leave_ships_on_ocean);
return suite;
}