Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Priorities reset after save-load. #209

Open
wants to merge 2 commits into
base: 1.4
Choose a base branch
from

Conversation

Doomster14
Copy link

@Doomster14 Doomster14 commented Nov 11, 2023

Fix the following scenario:

  1. Save a game without the mod active.
  2. Activate the mod.
  3. Load the game twice.
  4. Change work priorities.
  5. Save.
  6. Load.
  7. Priorities are reset to default values and there are errors in the log:
    Exception in LookDictionary(label=Priorities): System.InvalidOperationException: Tried to add different values for the same key.

Also, fix the following scenario:

  1. Play any game with the mod active.
  2. Start a new game (without exiting the application).
  3. Save.
  4. Load.
  5. Probably harmless errors appear in the log:
    Could not resolve reference to object with loadID Thing_Human#

Supposedly, fixes #203 and fixes #208.

Games saved with the erroneous mod version may still give errors on load. Saving them anew should fix them.

PriorityManager class was relying on Scribe methods in ExposeData() for clearing out old priorities data.
But ExposeData() is not called when a new game is started or a game is loaded which was saved without the mod active.
So, new data was added to the old one.
If a non-modded save was loaded twice, pawn priorities lists were doubled, with the latest list being active.
When the game was subsequently saved and loaded, all data was saved, but only the oldest copy of priorities was restored.
Other copies yielded an error:
Exception in LookDictionary(label=Priorities): System.InvalidOperationException: Tried to add different values for the same key.
Attempts to load priorities data of non-existent pawns, inherited from other games, resulted in a probably harmless error:
Could not resolve reference to object with loadID Thing_Human#

Now, all static members of PriorityManager are initialized by constructor.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant