Skip to content

LuaParser: run Spring.TimeCheck's callback under unitsync/dedicated#3085

Merged
sprunk merged 1 commit into
beyond-all-reason:masterfrom
tomjn:fix/unitsync-timecheck-callback
Jul 13, 2026
Merged

LuaParser: run Spring.TimeCheck's callback under unitsync/dedicated#3085
sprunk merged 1 commit into
beyond-all-reason:masterfrom
tomjn:fix/unitsync-timecheck-callback

Conversation

@tomjn

@tomjn tomjn commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Under UNITSYNC and DEDICATED, TimeCheck compiled to return 0, silently dropping the function it was handed. The shipped gamedata/defs.lua wraps all unitdef/weapondef/etc. loading in Spring.TimeCheck(...), so ProcessUnits() ends up with an empty root and throws root unitdef table invalid — unitsync reports zero units for every game whose defs.lua uses TimeCheck (i.e. the standard springcontent path). Only the profiling timer needs to be excluded from those builds, not the call itself.

Surfaced by a lobby that enumerates units via unitsync; most consumers only read checksums/options, so it went unnoticed.

This also enables the callback under DEDICATED — that seems correct (the function shouldn't discard its argument), but flagging in case that build skips it deliberately.

Under UNITSYNC and DEDICATED, TimeCheck compiled to `return 0`, silently
dropping the function it was handed. The shipped gamedata/defs.lua wraps all
unitdef/weapondef/etc. loading in Spring.TimeCheck(...), so ProcessUnits() ends
up with an empty root and throws "root unitdef table invalid" - unitsync reports
zero units for every game whose defs.lua uses TimeCheck (the standard
springcontent path). Only the profiling timer needs to be excluded from those
builds, not the call itself.

@sprunk sprunk left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks alright.

There are other parts of the interface gated under if !DEDI && !UNITSYNC checks you might want to look at, but these would raise questions that are probably best kicked down the road for now.

@tomjn

tomjn commented Jul 5, 2026

Copy link
Copy Markdown
Contributor Author

Oh there's other stuff but part of it is silly things like reading mod options or map options without checking first if those APIs exist

I've worked around it for now by grabbing unit definitions via lua with shims and polyfills

@sprunk

sprunk commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

That's part of what I'm talking about though. Unitsync should probably define spGetModOptions and just have it return an empty table rather than requiring every game to sprinkle nil checks over their code.

@sprunk sprunk merged commit d306d39 into beyond-all-reason:master Jul 13, 2026
4 checks passed
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.

2 participants