fix bug where selecting the same layout for a shipyard discarded the current progress and buffers
This commit is contained in:
@@ -103,14 +103,25 @@ TEST_CASE("readBuildingConfig returns a shipyard's schematic and layout",
|
||||
|
||||
const BuildingId id = placeOperational(sim, cfg, BuildingType::Shipyard, QPoint(0, 0));
|
||||
SimulationTestAccess::buildings(sim).setRecipe(SimulationTestAccess::state(sim), id, schematic->id);
|
||||
SimulationTestAccess::buildings(sim).setShipLayout(SimulationTestAccess::state(sim), id, ShipLayoutConfig{});
|
||||
|
||||
// A real layout, not an empty one: applying an empty layout to a shipyard that has
|
||||
// none is a no-op (REQ-MAT-INPUT-BUFFER), so it would leave nothing to read back.
|
||||
ShipLayoutConfig layout;
|
||||
PlacedModule placed;
|
||||
placed.moduleId = "armor_plate";
|
||||
placed.position = QPoint(0, 0);
|
||||
placed.rotation = Rotation::East;
|
||||
layout.placedModules.push_back(placed);
|
||||
SimulationTestAccess::buildings(sim).setShipLayout(SimulationTestAccess::state(sim), id, layout);
|
||||
|
||||
const std::optional<BuildingConfig> config = readBuildingConfig(sim, id);
|
||||
REQUIRE(config.has_value());
|
||||
CHECK(config->type == BuildingType::Shipyard);
|
||||
REQUIRE(config->recipeId.has_value());
|
||||
CHECK(*config->recipeId == schematic->id);
|
||||
CHECK(config->shipLayout.has_value());
|
||||
REQUIRE(config->shipLayout.has_value());
|
||||
REQUIRE(config->shipLayout->placedModules.size() == 1);
|
||||
CHECK(config->shipLayout->placedModules[0].moduleId == "armor_plate");
|
||||
}
|
||||
|
||||
TEST_CASE("readBuildingConfig reads a queued construction site", "[blueprint]")
|
||||
|
||||
Reference in New Issue
Block a user