From f52e00d574f043e3254f2c1ffc1d8fe3e9544ec4 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 5 Jan 2015 22:09:08 +0100 Subject: [PATCH] do not eject units from a ship when on the ocean. --- src/laws.c | 2 +- src/laws.test.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/laws.c b/src/laws.c index 46f765b41..5d51eeba4 100755 --- a/src/laws.c +++ b/src/laws.c @@ -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)) { diff --git a/src/laws.test.c b/src/laws.test.c index ec1174a17..14e6bb6c7 100644 --- a/src/laws.test.c +++ b/src/laws.test.c @@ -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; }