Skip to content

Commit

Permalink
fix: Incorrect quality bonuses/penalties from beacon modules. (#424)
Browse files Browse the repository at this point in the history
As reported [on
Discord](https://discord.com/channels/560199483065892894/1210135763422027837/1343188155515539457),
speed modules in beacons mess up quality calculations.

This was a copy/paste and duplicated code issue; the erroneous method
was only called once, while the working one was called in seven
different places.
  • Loading branch information
shpaass authored Feb 24, 2025
2 parents 3b2d736 + ef1d174 commit 7f9664a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
17 changes: 2 additions & 15 deletions Yafc.Model/Model/ProductionTableContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public struct ModuleEffects {
public readonly float speedMod => MathF.Max(1f + speed, 0.2f);
public readonly float energyUsageMod => MathF.Max(1f + consumption, 0.2f);
public readonly float qualityMod => MathF.Max(quality, 0);
public void AddModules(ObjectWithQuality<Module> module, float count, AllowedEffects allowedEffects) {
public void AddModules(ObjectWithQuality<Module> module, float count, AllowedEffects allowedEffects = AllowedEffects.All) {
ModuleSpecification spec = module.target.moduleSpecification;
Quality quality = module.quality;
if (allowedEffects.HasFlags(AllowedEffects.Speed)) {
Expand All @@ -32,23 +32,10 @@ public void AddModules(ObjectWithQuality<Module> module, float count, AllowedEff
}

if (allowedEffects.HasFlags(AllowedEffects.Quality)) {
this.quality += spec.Consumption(quality) * count;
this.quality += spec.Quality(quality) * count;
}
}

public void AddModules(ObjectWithQuality<Module> module, float count) {
ModuleSpecification spec = module.target.moduleSpecification;
Quality quality = module.quality;
speed += spec.Speed(quality) * count;

if (spec.baseProductivity > 0f) {
productivity += spec.Productivity(quality) * count;
}

consumption += spec.Consumption(quality) * count;
this.quality += spec.Quality(quality) * count;
}

public readonly int GetModuleSoftLimit(ObjectWithQuality<Module> module, int hardLimit) {
ModuleSpecification spec = module.target.moduleSpecification;
Quality quality = module.quality;
Expand Down
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Date:
- Add related recipes to the Link Summary screen.
Fixes:
- (regression) Legacy summary pages could not be saved or loaded.
- Quality bonuses/penalties in beacons were not handled correctly.
----------------------------------------------------------------------------------------------------------------------
Version: 2.8.1
Date: February 20th 2025
Expand Down

0 comments on commit 7f9664a

Please sign in to comment.