Skip to content

Synced Lua: call lua_next directly in next, one closure for pairs - #3484

Open
moss-orbit-9f339e wants to merge 2 commits into
beyond-all-reason:masterfrom
moss-orbit-9f339e:fix/lua-handle-fixes
Open

moss-orbit-9f339e wants to merge 2 commits into
beyond-all-reason:masterfrom
moss-orbit-9f339e:fix/lua-handle-fixes

Conversation

@moss-orbit-9f339e

@moss-orbit-9f339e moss-orbit-9f339e commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Synced next called the original next through the registry with lua_call for every step of a pairs loop, and synced pairs made a new C closure on each call. next now calls lua_next directly (same key type checks), and pairs returns one closure kept as an upvalue. Also removes the unused origNextRef and uses #pragma once in LuaHandleSynced.h.

Sync: same keys in the same order; fewer allocations, so GC timing can differ from master, identically on all clients.
Testing: Zero-K replay, same checksums as master, no Lua errors. Replay speed A/B: no measurable change (-0.49% median, within noise).

The CallAsTeam and collision callin fixes from the first version are now #3502 and #3503.

AI disclosure: found by OpenAI Codex in a code audit; checked, edited and tested with Claude Code.

🤖 Generated with Claude Code

moss-orbit-9f339e added a commit to moss-orbit-9f339e/RecoilEngine that referenced this pull request Oct 13, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sprunk

sprunk commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator

Looks ok but does 3 unrelated things, split this into separate PRs.

moss-orbit-9f339e and others added 2 commits October 13, 2026 11:22
- SyncedNext called the original next through the registry with
  lua_call for each step of a synced pairs loop. It now calls lua_next
  directly, as luaB_next does, with the same results and the same key
  type checks.
- SyncedPairs made a new C closure for SyncedNext on each call. It now
  returns one closure kept as an upvalue.
- LuaHandleSynced.h: remove the unused origNextRef, and use #pragma once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@moss-orbit-9f339e moss-orbit-9f339e changed the title Lua handles: restore permissions after a CallAsTeam error, collision callin error paths, simpler synced next/pairs Synced Lua: call lua_next directly in next, one closure for pairs Oct 13, 2026
@moss-orbit-9f339e

Copy link
Copy Markdown
Contributor Author

Split: this PR now has only the synced next/pairs change. CallAsTeam is #3502 and the collision callins are #3503. I left out the CopyPushData change, which I had not measured.

This branch has not been deployed

No deployments
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