Fixed Coins leaking into SP - #26
Merged
Merged
Conversation
…leaned up load/unload.
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.
Fixes #25.
There was an issue where the coins data was not reset upon loading up a world. This was causing the locally stored data from a server session to persist if a player played on a MP world, leaves, then opens up a SP world where there was no prior currency data (eg. creating a new world).
This PR centralizes the unloading of everything on server start and loading data from scratch.
The data leak technically still happens if a player hops from one MP server to another, but it does not affect gameplay nor spawns in items in this case. Since coins are server-side authoritative, there is no risk of the coins being transferred there. When a player opens a vending machine for the first time on another server, it would immediately sync and override the local coin data.
I acknowledge this fix is not very clean, but it will fix the issue for now. The immediate next steps I'm working on are to change the coin sync code to decouple it from tradestate as much as possible and just sync the coin display amount via MUI2 synchandlers instead of sending/updating the coin amounts to the client. When that happens, this leak will stop happening altogether.
Tested on 186 in both SP and local MP with multiple players, to ensure read/write and integrity of saved coin data (to prevent another coin disappearance incident).