Fix writing Experience, blanking unused parts#13
Open
JohnVeness wants to merge 1 commit intohegyak:masterfrom
Open
Fix writing Experience, blanking unused parts#13JohnVeness wants to merge 1 commit intohegyak:masterfrom
JohnVeness wants to merge 1 commit intohegyak:masterfrom
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.
This pull request fixes the situation where the Exp level is lowered from, say, 17 to 12. The issue was that in that situation, the three bytes at 118, 119 and 11A (and the equivalent three bytes in the other area) were not blanked. When the experience is read from the figure, those three (non-zero) bytes are read and added to the experience level, making the experience level higher than the intended 12 in this example.
I have copied your coding style as much as possible in the commit, but actually it would seem safer and neater to me to always blank the seven experience bytes first, before writing those that are needed. This would eliminate having to blank the unused bytes in the "Else" sections, giving something like:
Or even better, given that the code above sets all seven bytes correctly anyway, including setting unused ones to zero, e.g. in sections like this:
then you could simply write all seven bytes as is, without needing any If statements at all, e.g. just:
Let me know if you would prefer a pull request of this simpler form. Or just implement it that way yourself!
Thanks.