-
-
Notifications
You must be signed in to change notification settings - Fork 25
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
[BUG] Loading Save Not Resetting $Data #255
Comments
So I noticed a few things while digging into the code. Not sure if it's related but I saw that in game-save.ts the GlobalGameSave has data there as well as achievements. That feels odd as I expected to find "global" instead of "data" (per the documentation in save-and-load.md. I tried changing that, but it didn't fix the problem, so I'm guessing more is at work here. |
So I did a lot more digging on this. What I've noticed is this situation only happens after you loaded a game. It would appear that load doesn't load a copy of the vm store from the save file but actually uses that vm from the save file. Which means any changes to the game after loading the file results to changes to the underlying save file. Obviously that's not great. I eventually found the culprit in the code. The loadSaveData is passing data.data as a reference. Simply needed to add deepCopy(). I'll upload a fix. That being said, I'm willing to bet the same issue appears in the other stores, but I wasn't as keen to modify those as there might be a reason behind it. |
Describe the bug
When you load a previous save, it does not reset the data object to previous state, it keeps current state.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
I'd expect the data.someNumber to be a 2
Screenshots
Browser
Chrome, latest version
The text was updated successfully, but these errors were encountered: