Skip to content

Low power structures lose their dark appearance after saving the game #3126

Description

@bobtista

Prerequisites

  • I have searched for similar issues and confirmed this is not a duplicate

Game Version

  • Command & Conquer Generals
  • Command & Conquer Generals: Zero Hour

Bug Description

When a structure has no power it is drawn dark grey and shows the low power lightning bolt icon. Saving the game makes that dark grey drawing fade away within a few seconds, while the structure is still unpowered and still shows the lightning bolt. It keeps looking normal until its status changes.

The same applies to everything else that is drawn dark indefinitely: EMP'd or otherwise disabled objects, subdual damaged objects, and frenzied objects.

Cause: TintEnvelope::m_sustainCounter became a Real in #1651, but the retail compatible save path still round-trips it through an UnsignedInt:

if (version <= 1)
{
	UnsignedInt sustainCounter = (UnsignedInt)m_sustainCounter;
	xfer->xferUnsignedInt( &sustainCounter );
	m_sustainCounter = (Real)sustainCounter;
}

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 that value is assigned back into m_sustainCounter, this fires while saving, not only on load: the counter becomes 0, the envelope leaves its sustain phase and calls release(), and the dark drawing decays away. Application is edge triggered, so it is not re-established while the status stays the same.

RETAIL_COMPATIBLE_XFER_SAVE defaults to 1, so this is the shipping path. It also writes 0x00000000 where retail wrote 0xfffffffe.

Loading a save is not affected — Drawable::xfer deliberately resets m_prevTintStatus on load, which re-triggers the drawing.

Reproduction Steps

  1. Start a Skirmish as USA (set the opponent slot to Closed so nothing interferes).
  2. With the starting Dozer, build a Cold Fusion Reactor, then a Patriot Missile System (it needs 3 power; the reactor supplies 5).
  3. Select the Cold Fusion Reactor and sell it. The Patriot is now unpowered — it turns dark grey and shows the low power lightning bolt. It stays dark for as long as you watch.
  4. Open the in-game menu, choose SAVE/LOAD, save the game, and return to the game.
  5. Within a few seconds the Patriot goes back to its normal colours, while still unpowered and still showing the lightning bolt.

Expected: it stays dark until power is restored.

Metadata

Metadata

Assignees

Labels

BugSomething is not working right, typically is user facing

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions