ObjectManagerManager / SMAPIDedicatedServerMod

Dedicated (headless) server mod for Stardew Valley, powered by SMAPI. Turns the host into an automated bot.
MIT License
84 stars 16 forks source link

Crop saver is buggy #8

Closed ObjectManagerManager closed 1 year ago

ObjectManagerManager commented 1 year ago

Multiple-harvest crops are supposed to die after the first harvest once they've been out of season at some point. However, as it stands, if they've already been harvested once before going out of season, they become infinitely harvestable, even once out-of-season.

The issue is that when they're harvested, their growth stage changes, and the crop saver detects it as a "new crop" at the end of the day. It then copies its compatible seasons into the crop data dictionary. But since the crop saver has already detected this crop in the past, it's already updated its compatible seasons to support all seasons. It then gets confused, convinced that the crop's original compatible seasons consisted of all seasons.

The solution is to implement more sophisticated logic to determine when two crops are "different". If the phase, sprite row, life, or forage properties change, then the crop must be different. However, if the growth stage day changes, the crops are only different if they aren't "one harvest different" from each other. That is, if the growth stage days are different and it is not true that one of the two crops is harvestable (final phase; non-positive growth stage day or not fully grown) while the other has been harvested (final phase; fully grown; positive growth stage day), then the crops can be considered different. Otherwise, having different growth stage days should not mean the crops are different.