bugfix(saveload): Keep the dark low power appearance on disabled objects when saving - #3127
Draft
bobtista wants to merge 1 commit into
Draft
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.
Fixes #3126. Follow up for #1651, which changed
TintEnvelope::m_sustainCounterfromUnsignedInttoReal.The retail compatible save path still round-trips that counter through an
UnsignedInt.SUSTAIN_INDEFINITELYis0xfffffffe, and(Real)0xffffffferounds up to4294967296, which is out of range forUnsignedInt— so converting it back is undefined, and on MSVC it yields 0 (checked on both x86 and x64). BecauseTintEnvelope::xferassigns the converted value back intom_sustainCounter, this fires on save as well as load: the live counter becomes 0, the envelope leaves its sustain branch on the next update and callsrelease(), and the object stops being drawn dark while it is still disabled.RETAIL_COMPATIBLE_XFER_SAVEdefaults to 1, so this is the shipping path. It also writes0x00000000where retail wrote0xfffffffe, defeating the byte compatibility the guard exists to preserve.Affected are the objects drawn dark indefinitely: unpowered and otherwise disabled objects, subdual damaged objects, and frenzied objects.
Now maps the sentinel explicitly in both directions so the v1 stream keeps retail's
0xfffffffe, and only assigns the serialized value back when loading, so saving can no longer change live state. Finite sustain values serialize exactly as before, so existing saves are unaffected.Verified in game on a clean build of
mainusing the reproduction in #3126 — an unpowered Patriot Missile System loses its dark drawing within seconds of a save onmain, and keeps it with this change. Mean brightness of the Patriot's area on screen:mainBefore:


After:
Todo: