Skip to content

Remember artillery and target positions across reloads per map - #8

Open
Crecket wants to merge 3 commits into
apollyon-sys:mainfrom
Crecket:upstream-pr/remember-positions
Open

Remember artillery and target positions across reloads per map#8
Crecket wants to merge 3 commits into
apollyon-sys:mainfrom
Crecket:upstream-pr/remember-positions

Conversation

@Crecket

@Crecket Crecket commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

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 localStorage key, 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.origin and S.target are written from six places (map drags, coordinate inputs, saved-target restore, undo, coordinate search), but all of them end in inputs(), 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 in init() 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:

js/core/core.js              |   3 ++
js/features/saved-targets.js | 116 +++
js/main.js                   |   6 +++
js/ui/inputs.js              |  13 +++

@apollyon-sys

Copy link
Copy Markdown
Owner

Nice QoL improvement overall

One small thing before merging: right now wardogs-map-points only stores one map's positions at a time, so switching maps overwrites the previous map's saved artillery/target positions

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

@Crecket

Crecket commented Aug 30, 2026

Copy link
Copy Markdown
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

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.

2 participants