Spec Overrides: apply a NIL_SENT on a defaults-backed key as the registered default - #1250
Open
dfrisone wants to merge 2 commits into
Open
Spec Overrides: apply a NIL_SENT on a defaults-backed key as the registered default#1250dfrisone wants to merge 2 commits into
dfrisone wants to merge 2 commits into
Conversation
…istered default A stored key-removal marker (NIL_SENT) for a key with a registered default was skipped at every apply site, so whatever value sat live could never be cleared by an override restore. The class-resource bar's Custom fill mode writes resourceColored = nil, the override stores NIL_SENT for it, and after the Default Editing Mode view wrote the recorded default (true) live, the skip left it there forever: resourceColored takes precedence over classColored, so the spec's custom colour rendered as the class resource colour after any settings open/close round trip. Replace HasRegisteredDefault with ReadRegisteredDefault and substitute the registered default value for the marker at all five apply sites, which is the exact live state a logout/login produces (saved vars drop nils, the defaults merge refills). Existing poisoned stores heal on their next apply with no migration. WriteDefaultValues also gains the same table guards as its sibling sites. The swatches now store false instead of removing the key so new edits stay plain scalars.
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.
The bug
Reported on a Devourer spec-override profile: set the class-resource (soul) bar to a custom colour, close the EUI settings window, reopen it, and the bar is back to the class resource colour. The stored custom colour is still there, it just never gets applied again.
Narrowed with the reporter:
/reload, and merely reopening the menu is not enough on its own.Root cause
Three facts combine, and none is a bug on its own.
1. The Custom swatch expressed its state by key REMOVAL. The class-resource Fill Color swatches wrote:
resourceColoredwas the only key in that trio written as= nil, and at runtime a truthyresourceColoredtakes precedence overclassColoredentirely.2. A live
nilharvests asNIL_SENT. So the spec map stored the custom-colour override asresourceColored = NIL_SENT, a key-removal marker.3. The nil-poison guard made that marker unapplyable. Every apply site skipped writing a nil for any fkey that has a registered default, on the grounds that such markers are harvest residue.
resourceColoredhas one (false).The result is deterministic once
values.default[resourceColored]is truthy, which auto-capture seeds by itself if the baseline was in Class Resource mode when the user first clicked Custom:resourceColored = truelive. The bar shows the resource colour.classColored = falsewrites,fillR/G/Bwrite, but theNIL_SENTforresourceColoredhits the skip, so live keepstrue. The precedence rule then shows the class resource colour with the custom RGB sitting unused.trueequal to the recorded defaulttrue, so equality-retention keeps the marker in the spec map, and every later apply skips again.The store is never corrupted. The override simply can never be re-applied.
The fix
At the nil-poison sites, a
NIL_SENTon a defaults-backed key now applies the registered default value instead of being skipped.That is byte-for-byte the live state a logout/login round trip already produces: SavedVariables drop nils, and the login defaults merge refills the registered default. The reporter confirmed a
/reloadrenders the colour correctly, which is the same path. Existing poisoned profiles therefore self-heal on the first login with this build, with no migration.Deleting the guard outright was not an option: it exists to stop an imported
NIL_SENTstripping keys that consumers read raw (the new-characterSetFontcrash). Writing the default value keeps that protection while making the marker applyable.Supporting changes:
HasRegisteredDefaultbecomesReadRegisteredDefault, returning the value rather than a boolean, and is used at all five apply sites (WriteSpecValues,WriteDefaultValues, both conditional-overlay sites, and the unlock apply).WriteDefaultValuesgained the same table guards its siblings already had.resourceColored = falserather than= nil, so removals stop being minted in the first place. The runtime tests truthiness, sofalseandnilare behaviourally identical there.Scope
Two files, +52/−36. No new events, no timers, no API calls added. The behaviour change is confined to what an apply does with a stored key-removal marker on a key that has a registered default, which previously did nothing at all.
Testing
Not yet confirmed in game by the original reporter. The diagnosis is a code read, re-verified against current
mainafter this branch was brought up to date: theresourceColored = nilidiom is gone from the tree, the registered default is stillfalse, and all five apply sites route throughReadRegisteredDefault.