fix bug where splitter filters were not taken over to blueprint
This commit is contained in:
@@ -201,6 +201,16 @@ Blueprint BlueprintPanel::createBlueprintFromSelection() const
|
||||
bb.offset = e.building->anchor - center;
|
||||
bb.recipeId = e.building->recipeId;
|
||||
bb.shipLayout = e.building->shipLayout;
|
||||
if (e.building->type == BuildingType::Splitter)
|
||||
{
|
||||
const std::optional<BeltSystem::SplitterInfo> info =
|
||||
m_sim->belts().getSplitterInfo(e.building->anchor);
|
||||
if (info.has_value())
|
||||
{
|
||||
bb.splitterFilterA = info->filterA;
|
||||
bb.splitterFilterB = info->filterB;
|
||||
}
|
||||
}
|
||||
bp.buildings.push_back(bb);
|
||||
}
|
||||
return bp;
|
||||
|
||||
@@ -58,6 +58,19 @@
|
||||
namespace
|
||||
{
|
||||
|
||||
// Keep only the filter entries whose item type is currently unlocked
|
||||
// (REQ-LOCK-UI-BLUEPRINT). An empty result means "accept all".
|
||||
std::vector<ItemType> filterUnlockedItems(const std::vector<ItemType>& filter,
|
||||
const Simulation& sim)
|
||||
{
|
||||
std::vector<ItemType> result;
|
||||
for (const ItemType& item : filter)
|
||||
{
|
||||
if (sim.isItemUnlocked(item.id)) { result.push_back(item); }
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Rotation rotateClockwise(Rotation r)
|
||||
{
|
||||
switch (r)
|
||||
@@ -532,6 +545,18 @@ void GameWorldView::placeBlueprintAtTile(QPoint center)
|
||||
{
|
||||
m_sim->buildings().setShipLayout(id, *bb.shipLayout);
|
||||
}
|
||||
|
||||
if (bb.type == BuildingType::Splitter
|
||||
&& (!bb.splitterFilterA.empty() || !bb.splitterFilterB.empty()))
|
||||
{
|
||||
// The splitter is still a construction site, so the filters carry
|
||||
// over when it finishes building (REQ-UI-BLUEPRINT-PLACE). Locked
|
||||
// item types are dropped per REQ-LOCK-UI-BLUEPRINT.
|
||||
m_sim->buildings().setSiteSplitterFilters(
|
||||
id,
|
||||
filterUnlockedItems(bb.splitterFilterA, *m_sim),
|
||||
filterUnlockedItems(bb.splitterFilterB, *m_sim));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user