fix splitter filters being lost when rotating in place
rotateInPlace re-implemented the belt-tile re-registration switch inline instead of calling reregisterBeltTile, and its splitter branch omitted the setSplitterFilters call the canonical version has. Since an operational splitter keeps its filters only in BeltSystem, removeTile discarded them and rotating a configured splitter silently reset it to "accept all". Replace the duplicated switch with a call to reregisterBeltTile, capturing the filters beforehand via getSplitterInfo — the same idiom deconstruct already uses. This removes the second copy of the switch that allowed the two to drift apart in the first place. Add a regression test; the existing [rotate-in-place] cases covered belt tiles only, which is why this went unnoticed. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GH8ZMRY3vhxxXcaUxBqxkk
This commit is contained in:
@@ -1719,29 +1719,25 @@ void BuildingSystem::rotateInPlace(BuildingId id, Rotation newRotation)
|
||||
// the new port set (REQ-MAT-INPUT-INTAKE).
|
||||
b.incomingItems.assign(b.inputPorts.size(), {});
|
||||
|
||||
// Re-register with BeltSystem (items on tile are discarded).
|
||||
if (b.type == BuildingType::Belt)
|
||||
// Re-register with BeltSystem (items on tile are discarded). A splitter's
|
||||
// filters live in BeltSystem and would be lost by removeTile, so capture
|
||||
// them first and hand them back to reregisterBeltTile (REQ-BLD-SPLITTER).
|
||||
if (isBeltSubsystemType(b.type))
|
||||
{
|
||||
std::vector<ItemType> splitterFilterA;
|
||||
std::vector<ItemType> splitterFilterB;
|
||||
if (b.type == BuildingType::Splitter)
|
||||
{
|
||||
if (const std::optional<BeltSystem::SplitterInfo> info =
|
||||
m_belts.getSplitterInfo(b.anchor))
|
||||
{
|
||||
splitterFilterA = info->filterA;
|
||||
splitterFilterB = info->filterB;
|
||||
}
|
||||
}
|
||||
|
||||
m_belts.removeTile(b.anchor);
|
||||
m_belts.placeBelt(b.anchor, newRotation);
|
||||
}
|
||||
else if (b.type == BuildingType::Splitter)
|
||||
{
|
||||
m_belts.removeTile(b.anchor);
|
||||
assert(mask.outputPorts.size() >= 2);
|
||||
m_belts.placeSplitter(b.anchor,
|
||||
mask.outputPorts[0].direction,
|
||||
mask.outputPorts[1].direction);
|
||||
}
|
||||
else if (b.type == BuildingType::TunnelEntry)
|
||||
{
|
||||
m_belts.removeTile(b.anchor);
|
||||
m_belts.placeTunnelEntry(b.anchor, newRotation, m_config.world.tunnelMaxDistance_tiles);
|
||||
}
|
||||
else if (b.type == BuildingType::TunnelExit)
|
||||
{
|
||||
m_belts.removeTile(b.anchor);
|
||||
m_belts.placeTunnelExit(b.anchor, newRotation);
|
||||
reregisterBeltTile(b, splitterFilterA, splitterFilterB);
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user