Reference count netcode_init, default zeroed configs, deterministic simulator rng#147
Merged
Conversation
…imulator rng Three ergonomics and reproducibility fixes: - netcode_init/netcode_term are reference counted, so multiple subsystems in the same application can init and term independently. Previously a second init was assert-only and silently re-ran platform init in release. - netcode_client_create/netcode_server_create default the allocator functions if the caller passes a zeroed config instead of calling netcode_default_*_config first. Previously this was a NULL deref. - The network simulator uses a per-instance seeded xorshift64* instead of global rand(). Simulator behavior is now deterministic across runs and isolated from application use of rand(). netcode_random_float is removed; it was only used by the simulator. Adds test_init_and_defaults and test_network_simulator_determinism (suite is now 40 tests). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Remaining small-sharp-edges work (Tier 2 + 3):
netcode_init/netcode_termare reference counted — multiple subsystems in one application can init/term independently. A second init previously tripped a debug-only assert and silently re-ranWSAStartup/sodium_initin release; an unbalanced term now returns cleanly instead of underflowing.netcode_default_client_config/netcode_default_server_configwas a NULL-deref in the create paths; it now just means defaultmalloc/free, matching hownetcode_read_packetalready defended.rand(). Simulator runs are reproducible across runs and platforms, isolated from applicationrand()usage, and reset restores the seed.netcode_random_floatis removed (simulator-only; soak/profile have their own local helpers).New tests:
test_init_and_defaults,test_network_simulator_determinism(two identical simulators with 25% loss, 50ms jitter, 25% duplication must drop/delay/duplicate identically). Suite is now 40 tests.Test plan
🤖 Generated with Claude Code