fix bug where selecting the same ship again in a shipyard clears the layout and resets the progress

This commit is contained in:
2026-07-09 21:05:01 +02:00
parent 4986c1bac8
commit 88bc4f2170
2 changed files with 44 additions and 0 deletions

View File

@@ -419,6 +419,12 @@ void BuildingSystem::setRecipe(BuildingId id, const std::string& recipeId)
{
if (site.id == id)
{
// No-op if the recipe is unchanged, so a redundant selection does
// not wipe an already-configured ship layout.
if (site.recipeId == recipeId)
{
return;
}
site.recipeId = recipeId;
site.shipLayout = std::nullopt;
return;
@@ -430,6 +436,12 @@ void BuildingSystem::setRecipe(BuildingId id, const std::string& recipeId)
{
if (building.id == id)
{
// No-op if the recipe is unchanged, so a redundant selection does
// not wipe an already-configured ship layout or reset buffers.
if (building.recipeId == recipeId)
{
return;
}
building.recipeId = recipeId;
building.shipLayout = std::nullopt;
building.inputBuffer.counts.clear();