From e2391665b94017cc0b58618a6d3e3bf414ab3ab2 Mon Sep 17 00:00:00 2001 From: jadebenn Date: Sat, 16 Dec 2023 19:35:16 -0600 Subject: [PATCH] imagination costs that equal your capacity no longer abort qbs (#1338) --- dGame/dComponents/RebuildComponent.cpp | 9 ++++----- dGame/dComponents/RebuildComponent.h | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/dGame/dComponents/RebuildComponent.cpp b/dGame/dComponents/RebuildComponent.cpp index 5359dee0..bcdf4f70 100644 --- a/dGame/dComponents/RebuildComponent.cpp +++ b/dGame/dComponents/RebuildComponent.cpp @@ -197,18 +197,17 @@ void RebuildComponent::Update(float deltaTime) { DestroyableComponent* destComp = builder->GetComponent(); if (!destComp) break; - int newImagination = destComp->GetImagination(); - ++m_DrainedImagination; - --newImagination; + const int32_t imaginationCostRemaining = m_TakeImagination - m_DrainedImagination; + + const int32_t newImagination = destComp->GetImagination() - 1; destComp->SetImagination(newImagination); Game::entityManager->SerializeEntity(builder); - if (newImagination <= 0) { + if (newImagination <= 0 && imaginationCostRemaining > 0) { CancelRebuild(builder, eQuickBuildFailReason::OUT_OF_IMAGINATION, true); break; } - } if (m_Timer >= m_CompleteTime && m_DrainedImagination >= m_TakeImagination) { diff --git a/dGame/dComponents/RebuildComponent.h b/dGame/dComponents/RebuildComponent.h index bb097edd..b67747aa 100644 --- a/dGame/dComponents/RebuildComponent.h +++ b/dGame/dComponents/RebuildComponent.h @@ -285,7 +285,7 @@ private: float m_CompleteTime = 0; /** - * The imagination that's deducted when compeleting the rebuild + * The imagination that's deducted when completing the rebuild */ int m_TakeImagination = 0;