@@ -825,4 +825,39 @@ BOOST_FIXTURE_TEST_CASE(GoToNeighborHarbor, ShipReadyFixture<1>)
825825 BOOST_TEST_REQUIRE (ship.IsMoving ());
826826}
827827
828+ BOOST_FIXTURE_TEST_CASE (SinkShipLoosesCargo, ShipAndHarborsReadyFixture<1 >)
829+ {
830+ const GamePlayer& player = world.GetPlayer (curPlayer);
831+ noShip& ship = *player.GetShipByID (0 );
832+
833+ const auto & harbors = player.GetBuildingRegister ().GetHarbors ();
834+ BOOST_TEST_REQUIRE (harbors.size () >= 2u );
835+ nobHarborBuilding& harbor1 = *harbors.front ();
836+ nobHarborBuilding& harbor2 = **(++harbors.begin ());
837+
838+ // Transport something
839+ BOOST_TEST_REQUIRE (harbor1.OrderJob (Job::Woodcutter, harbor2, false ));
840+ BOOST_TEST_REQUIRE (harbor1.OrderWare (GoodType::Wood, harbor2));
841+ BOOST_TEST_REQUIRE (harbor1.OrderWare (GoodType::Wood, harbor2));
842+
843+ RTTR_EXEC_TILL (90 , ship.IsLoading ());
844+ RTTR_EXEC_TILL (200 , ship.IsMoving ());
845+ BOOST_TEST (ship.GetWares ().size () == 2u );
846+ BOOST_TEST (ship.GetFigures ().size () == 1u );
847+
848+ const auto shipPos = ship.GetPos ();
849+ BOOST_TEST_REQUIRE (player.GetNumShips () == 1u );
850+ BOOST_TEST_REQUIRE (world.GetFigures (shipPos).size () == 1u );
851+ BOOST_TEST_REQUIRE (dynamic_cast <noShip*>(&world.GetFigures (shipPos).front ()));
852+
853+ const auto numWood = player.GetInventory ()[GoodType::Wood];
854+ const auto numWoodcutters = player.GetInventory ()[Job::Woodcutter];
855+ ship.Sink ();
856+ RTTR_SKIP_GFS (1 ); // Handle delayed destruction
857+ BOOST_TEST (player.GetNumShips () == 0u );
858+ BOOST_TEST (world.GetFigures (shipPos).size () == 0u );
859+ BOOST_TEST (player.GetInventory ()[GoodType::Wood] == numWood - 2 );
860+ BOOST_TEST (player.GetInventory ()[Job::Woodcutter] == numWoodcutters - 1 );
861+ }
862+
828863BOOST_AUTO_TEST_SUITE_END ()
0 commit comments