Fix zones not recovering after heightmap edit in Risk mode#1327
Merged
Conversation
✅ Deploy Preview for afmg ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Co-authored-by: Azgaar <26469650+Azgaar@users.noreply.github.com>
Azgaar
reviewed
Feb 18, 2026
Azgaar
reviewed
Feb 18, 2026
Azgaar
requested changes
Feb 18, 2026
Copilot
AI
changed the title
[WIP] Fix zones not recovering after heightmap edit
Fix zones not recovering after heightmap edit in Risk mode
Feb 18, 2026
Co-authored-by: Azgaar <26469650+Azgaar@users.noreply.github.com>
Co-authored-by: Azgaar <26469650+Azgaar@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes Risk-mode heightmap editing so zones survive significant reGraph() changes by persisting zone membership via the data model instead of broken SVG DOM selection logic.
Changes:
- Backup zones using
pack.zones[*].cells -> grid cell idsbeforereGraph() - Restore zones by mapping saved grid cell ids back onto new pack cells after
reGraph() - Remove prior (non-functional) SVG DOM-based backup/restore logic
Co-authored-by: Azgaar <26469650+Azgaar@users.noreply.github.com>
Co-authored-by: Azgaar <26469650+Azgaar@users.noreply.github.com>
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.
Description
Zones were lost after heightmap editing in Risk mode due to incorrect DOM selector. Code attempted to backup/restore zones via
zones.selectAll("g"), but zones render as<path>elements, causing the logic to never execute.Changes:
pack.zonesarray operationsreGraph(): store zone→gridCells mapping in localzoneGridCellsMap(Map) - avoids mutating zone objectsreGraph(): creategridToPackMapfor O(1) lookups, restore zones usingflatMapResult: Zones now persist correctly through significant graph changes (coastline modifications, etc.)
Performance Optimization:
filterandincludesflatMapfor efficient zone restorationData Safety:
zone.gridCellspropertyCode Quality:
Screenshots
Zones displayed before heightmap edit:

Zones successfully restored after heightmap edit:

Type of change
Versioning
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.