Skip to content

Commit

Permalink
Fix VBV path of mass-unlocking parts not subtracting credit if the pa…
Browse files Browse the repository at this point in the history
…rt to unlock doesn't have a real ECM. Close #2029
  • Loading branch information
NathanKell committed Jun 25, 2023
1 parent 4d08ffb commit 0cbfe9a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
5 changes: 2 additions & 3 deletions Source/KerbalConstructionTime/VesselBuildValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,13 @@ private void ProcessPartAvailability(BuildListVessel blv)
double credit = UnlockSubsidyHandler.Instance.GetCreditAmount(partList);

double spentCredit = Math.Min(postCMQUnlockCost, credit);
double postCreditTotal = postCMQUnlockCost - spentCredit;
cmq.AddDeltaAuthorized(CurrencyRP0.Funds, spentCredit);

int partCount = purchasableParts.Count();
int partCount = partList.Count;
string mode = KCTGameStates.EditorShipEditingMode ? "save edits" : "build vessel";
var buttons = new DialogGUIButton[] {
new DialogGUIButton("Acknowledged", () => { _validationResult = ValidationResult.Fail; }),
new DialogGUIButton($"Unlock {partCount} part{(partCount > 1? "s":"")} for <sprite=\"CurrencySpriteAsset\" name=\"Funds\" tint=1>{postCreditTotal:N0} and {mode} (spending <sprite=\"CurrencySpriteAsset\" name=\"Funds\" tint=1>{spentCredit:N0} credit)", () =>
new DialogGUIButton($"Unlock {partCount} part{(partCount > 1? "s":"")} for <sprite=\"CurrencySpriteAsset\" name=\"Funds\" tint=1>{Math.Max(0d, -cmq.GetTotal(CurrencyRP0.Funds)):N0} and {mode} (spending <sprite=\"CurrencySpriteAsset\" name=\"Funds\" tint=1>{spentCredit:N0} credit)", () =>
{
if (cmq.CanAfford())
{
Expand Down
1 change: 1 addition & 0 deletions Source/UnlockSubsidyHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ private void AddPartToDicts(AvailablePart ap, Dictionary<string, double> ecmToCo
techs = new HashSet<string>();

techs.Add(ap.TechRequired);
ecmToTech[sanitizedName] = techs;
}
}

Expand Down

0 comments on commit 0cbfe9a

Please sign in to comment.