Skip to content

bugfix(saveload): Keep the dark low power appearance on disabled objects when saving - #3127

Draft
bobtista wants to merge 1 commit into
TheSuperHackers:mainfrom
bobtista:bobtista/bugfix/save-clears-low-power-appearance
Draft

bugfix(saveload): Keep the dark low power appearance on disabled objects when saving#3127
bobtista wants to merge 1 commit into
TheSuperHackers:mainfrom
bobtista:bobtista/bugfix/save-clears-low-power-appearance

Conversation

@bobtista

@bobtista bobtista commented Aug 13, 2026

Copy link
Copy Markdown

Fixes #3126. Follow up for #1651, which changed TintEnvelope::m_sustainCounter from UnsignedInt to Real.

The retail compatible save path still round-trips that counter through an UnsignedInt. SUSTAIN_INDEFINITELY is 0xfffffffe, and (Real)0xfffffffe rounds up to 4294967296, which is out of range for UnsignedInt — so converting it back is undefined, and on MSVC it yields 0 (checked on both x86 and x64). Because TintEnvelope::xfer assigns the converted value back into m_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 calls release(), and the object stops being drawn dark while it is still disabled. RETAIL_COMPATIBLE_XFER_SAVE defaults to 1, so this is the shipping path. It also writes 0x00000000 where retail wrote 0xfffffffe, 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 main using the reproduction in #3126 — an unpowered Patriot Missile System loses its dark drawing within seconds of a save on main, and keeps it with this change. Mean brightness of the Patriot's area on screen:

stage main this branch
before saving (unpowered, dark) 83.8 87.4
immediately after saving 95.2 76.1
5s after saving 99.1 84.2
15s after saving 107.1 88.6

Before:
F_post15
After:
FIX_F_post15

Todo:

  • Test that an unpowered structure stays dark across a save
  • Test save/load round trip restores the dark drawing
  • Replicate to Generals

@bobtista bobtista self-assigned this Aug 13, 2026
@bobtista bobtista added Bug Something is not working right, typically is user facing Minor Severity: Minor < Major < Critical < Blocker labels Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something is not working right, typically is user facing Minor Severity: Minor < Major < Critical < Blocker

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Low power structures lose their dark appearance after saving the game

1 participant