fix splitter filters being lost when rotating in place and add test
This commit is contained in:
@@ -1427,6 +1427,36 @@ TEST_CASE("BuildingSystem: rotateInPlace re-registers a belt tile with BeltSyste
|
||||
REQUIRE(belts.tryPutItem(QPoint(0, 0), makeItem("iron_ore")));
|
||||
}
|
||||
|
||||
TEST_CASE("BuildingSystem: rotateInPlace preserves the output filters of a splitter "
|
||||
"(REQ-BLD-SPLITTER)", "[building][rotate-in-place]")
|
||||
{
|
||||
PlacementFixture f;
|
||||
|
||||
const QPoint tile(5, 5);
|
||||
const BuildingId id = f.bs.place(BuildingType::Splitter, tile, Rotation::East, 0).value();
|
||||
|
||||
// Run until construction completes, so the splitter is registered with BeltSystem.
|
||||
Tick tick = 0;
|
||||
while (f.bs.getAllBuildings().empty() && tick < 100000)
|
||||
{
|
||||
runTicks(f.bs, f.belts, 1, tick);
|
||||
}
|
||||
REQUIRE(f.bs.getAllBuildings().size() == 1);
|
||||
|
||||
const std::vector<ItemType> filterA{ ItemType{"iron_ore"} };
|
||||
const std::vector<ItemType> filterB{ ItemType{"copper_ore"} };
|
||||
f.belts.setSplitterFilters(tile, filterA, filterB);
|
||||
|
||||
f.bs.rotateInPlace(id, Rotation::North);
|
||||
|
||||
// The tile is re-registered with BeltSystem carrying the filters it had before
|
||||
// the rotation — rotating must not reset a configured splitter to "accept all".
|
||||
const std::optional<BeltSystem::SplitterInfo> info = f.belts.getSplitterInfo(tile);
|
||||
REQUIRE(info.has_value());
|
||||
REQUIRE(info->filterA == filterA);
|
||||
REQUIRE(info->filterB == filterB);
|
||||
}
|
||||
|
||||
TEST_CASE("BuildingSystem: splitter filters configured on a construction site carry over "
|
||||
"to the built splitter (REQ-BLD-SITE-CONFIG)", "[building]")
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user