diff --git a/src/move.c b/src/move.c index 848574f70..cb4d935a8 100644 --- a/src/move.c +++ b/src/move.c @@ -808,7 +808,7 @@ static void drifting_ships(region * r) /* Kapitän bestimmen */ captain = ship_owner(sh); - if (effskill(captain, SK_SAILING, r) < sh->type->cptskill) + if (captain && effskill(captain, SK_SAILING, r) < sh->type->cptskill) captain = NULL; /* Kapitän da? Beschädigt? Genügend Matrosen? diff --git a/src/move.test.c b/src/move.test.c index dc16c1b25..2688178d0 100644 --- a/src/move.test.c +++ b/src/move.test.c @@ -324,6 +324,23 @@ static void test_ship_no_overload(CuTest *tc) { test_cleanup(); } +static void test_ship_empty(CuTest *tc) { + struct drift_fixture fix; + + test_cleanup(); + + setup_drift(&fix); + fix.u->ship = NULL; + ship_update_owner(fix.sh); + + movement(); + CuAssertPtrEquals(tc, fix.sh->region, findregion(0, 0)); + CuAssertIntEquals(tc, 2, ship_damage_percent(fix.sh)); + CuAssertPtrEquals(tc, 0, test_find_messagetype(fix.f->msgs, "ship_drift")); + + test_cleanup(); +} + static void test_ship_normal_overload(CuTest *tc) { struct drift_fixture fix; @@ -505,6 +522,7 @@ CuSuite *get_move_suite(void) SUITE_ADD_TEST(suite, test_ship_trails); SUITE_ADD_TEST(suite, test_age_trails); SUITE_ADD_TEST(suite, test_ship_no_overload); + SUITE_ADD_TEST(suite, test_ship_empty); SUITE_ADD_TEST(suite, test_ship_normal_overload); SUITE_ADD_TEST(suite, test_ship_no_real_overload); SUITE_ADD_TEST(suite, test_ship_big_overload);