Fix crop count inflation on non-farm locations#41
Open
ktiedt wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SVE Bug Report: Farm Computer Crop Count Inflation on Custom/Non-Farm Locations
Description
A bug in Stardew Valley Expanded's
HarmonyPatch_FarmComputerLocationsclass causes crop, ready-to-harvest, unwatered, and open hoe dirt counts to be inflated on every single location in the game (including vanilla NPC homes, cellars, and other mods' custom maps).Root Cause Analysis
Stardew Valley Expanded patches the base
GameLocationclass methods to aggregate crop statistics for custom SVE farm areas (like Grandpa's Shed Greenhouse).The patches are registered on:
GameLocation.getTotalCrops()GameLocation.getTotalCropsReadyForHarvest()GameLocation.getTotalUnwateredCrops()GameLocation.getTotalOpenHoeDirt()However, because these postfixes are applied to
GameLocation(which is the base class for all maps/locations) and lack a type-check for the mainFarm, the SVE postfixes run on every location in the game. Every time a location's crop count is queried, SVE adds the crop count ofCustom_GrandpasShedGreenhouse(144) to the result.Suggested Code Patch
To fix this, the Harmony patches in
StardewValleyExpanded.HarmonyPatch_FarmComputerLocationsmust verify that the method is executing on the mainFarminstance (or check the location name) before modifying__result.Before:
After (Proposed Fix):
This same type-check (
if (__instance is Farm)) should be added to the other three postfixes in the class:Farm_getTotalCropsReadyForHarvestFarm_getTotalUnwateredCropsFarm_getTotalOpenHoeDirt