Skip to content

EndGame APM stats: no error when the stats panel is not there - #5885

Open
moss-orbit-9f339e wants to merge 1 commit into
ZeroK-RTS:masterfrom
moss-orbit-9f339e:upstream/apm-stats-shutdown
Open

moss-orbit-9f339e wants to merge 1 commit into
ZeroK-RTS:masterfrom
moss-orbit-9f339e:upstream/apm-stats-shutdown

Conversation

@moss-orbit-9f339e

Copy link
Copy Markdown
Contributor

api_apm_stats.lua sends the player's stats when the player leaves or the game ends, and calls WG.AddPlayerStatsToPanel. The end-game window widget sets that function only when it loads. When the player has turned that widget off, the function is nil, and the call fails at line 71. This change checks the function before both calls. The stats message is still sent.

107 crash reports in one year have this error, for example ZeroK-RTS/CrashReports#183033 and ZeroK-RTS/CrashReports#182512.

Behaviour: no change, except that the error is gone.

Testing (Windows, RTX 3080, master ee8950e):

  • Live game as a player: at frame 60 the test turns off the end-game window and clears WG.AddPlayerStatsToPanel (the state when the widget was never loaded). The player quits at frame 300. Without this change: api_apm_stats.lua:71: attempt to call field 'AddPlayerStatsToPanel' (a nil value) in Shutdown. With this change: no error.
  • Nuclear Winter replay at full graphics: 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.

During Shutdown the panel widget can be unloaded first, so WG.AddPlayerStatsToPanel was nil (107 crash reports). Check it before the call; the stats message is still sent.

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