Remember artillery and target positions across reloads per map - #8
Open
Crecket wants to merge 3 commits into
Open
Remember artillery and target positions across reloads per map#8Crecket wants to merge 3 commits into
Crecket wants to merge 3 commits into
Conversation
Owner
|
Nice QoL improvement overall One small thing before merging: right now Since the PR is described as remembering positions per map, could we store them keyed by map id instead? Other than that, the implementation looks good |
Contributor
Author
|
Yeah reasonable, I wasn't sure if I wanted to store it per map since swapping maps might make you wanna wipe it anyway for a next ingame round but then storing all of it right now would be weird to so I might aswell add a map specific key |
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.
Very basic change, probably mostly useful for development but I can imagine someone might open another tab or refresh a page etc and still retain where their targets/artillery positions are.
One
localStoragekey,wardogs-map-points:{ "map": "bakurani", "origin": { "x": 5.0, "y": 5.0 }, "target": { "x": 5.5, "y": 5.5 } }The map id is stored because the coordinates mean nothing on another map. A mismatch on load drops the stored points instead of placing the gun somewhere arbitrary.
S.originandS.targetare written from six places (map drags, coordinate inputs, saved-target restore, undo, coordinate search), but all of them end ininputs(), so the write hooks there once rather than at each site.inputs()runs on every frame of a drag, so the write is throttled by 300 ms.loadMapPoints()runs ininit()just before the existing bounds clamp, so restored points are clamped like any other. Reads are validated and both read and write are wrapped in try/catch.+138 lines, no deletions: