fix bug where items get already consumed right after being placed on a belt

This commit is contained in:
2026-04-20 22:14:55 +02:00
parent a924877e20
commit 35dd81748e
2 changed files with 32 additions and 23 deletions

View File

@@ -119,19 +119,13 @@ std::optional<Item> BeltSystem::tryTakeItem(Port port)
}
BeltTile& bt = it->second;
if (bt.front)
if (bt.front && bt.front->progress >= 1.0)
{
const Item taken = bt.front->item;
bt.front = bt.back;
bt.back = std::nullopt;
return taken;
}
if (bt.back)
{
const Item taken = bt.back->item;
bt.back = std::nullopt;
return taken;
}
return std::nullopt;
}
@@ -149,14 +143,10 @@ std::optional<ItemType> BeltSystem::peekItem(Port port) const
}
const BeltTile& bt = it->second;
if (bt.front)
if (bt.front && bt.front->progress >= 1.0)
{
return bt.front->item.type;
}
if (bt.back)
{
return bt.back->item.type;
}
return std::nullopt;
}