Skip to content

DCIcon: use Spring.GetGameState for the lag state - #5884

Open
moss-orbit-9f339e wants to merge 1 commit into
ZeroK-RTS:masterfrom
moss-orbit-9f339e:upstream/dcicon-lag-state
Open

moss-orbit-9f339e wants to merge 1 commit into
ZeroK-RTS:masterfrom
moss-orbit-9f339e:upstream/dcicon-lag-state

Conversation

@moss-orbit-9f339e

Copy link
Copy Markdown
Contributor

The engine removed Spring.GetHasLag in 2019 (Recoil 13a636710e). Thus, the DCIcon widget raises an error in DrawScreen on its first frame, and the widget handler removes it. This change reads the lag state from the fourth return value of Spring.GetGameState, which uses the same engine check (CGame::IsSimLagging). unit_start_state.lua already reads it this way.

104 crash reports in one year have this error.

Behaviour: the widget is off by default. When a player turns it on, it shows the icon when the game lags, as before 2019.

Testing (Windows, RTX 3080, master ee8950e):

  • Nuclear Winter replay with DCIcon on: without this change, dbg_dcicon.lua:102: attempt to call field 'GetHasLag' (a nil value), and the widget is removed. With this change, there is no error. The checksums and unit counts are the same.
  • Same replay at full graphics with the default widgets: no Lua errors. The checksums, unit counts and screenshot are the same as master.
  • I watched these test runs.

AI disclosure: Claude Code wrote this change and the tests. I reviewed the change.

The engine removed Spring.GetHasLag in 2019, so DrawScreen raised an error
and the widget handler removed the widget at once. The fourth return value
of Spring.GetGameState is the same lag state (CGame::IsSimLagging), as
unit_start_state.lua already uses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant