Repository-cleanup / DX pass folding three tracker items into one coherent change, verified green end to end (`bin/x test` 49/0, `bin/x selfhost-test` 29/0, `bin/x test-tools` 29/0). #28 — curate & categorise examples/ - 42 flat entries regrouped into intent-revealing subdirs: games/, rendering/, ecs/, events/, networking/, lang/, library/ (was lib/). - chronorift dir-vs-file duplication resolved: the entry file and its import modules now live together under games/chronorift(.ludic). - Every path reference updated repo-wide (test runner, editor-tool drivers, docs/site, design docs). - New examples/README.md indexes the whole set with run commands. - Showcase examples without a self-asserting entry (hello, events, net_rt) now get a compile-only rot guard in `bin/x test`, so nothing here rots silently. #30 — text-diffable golden baseline - The 4 binary selfhost/golden/*.ppm blobs are replaced by a single selfhost/golden/renders.sha256 manifest (SHA-256 per render). Hashes are byte-identical to the old PPMs, so the baseline is unchanged — only its form. - game_case now compares framebuffer hashes; a regression shows as a changed hex line in review, not "binary files differ". - New `bin/x golden` regenerates the manifest deliberately (review with `git diff selfhost/golden/renders.sha256`). #27 — PPM & asset handling - Headless renders now write build/out.ppm, never the repo root; `x app`, `x clean`, messaging and .gitignore updated to match. Nothing is written to the working root any more. - Redundant local Kenney .zip archives removed (the art ships extracted; .gitignore already excludes *.zip). CC0 License.txt files retained. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
33 lines
1.6 KiB
Text
33 lines
1.6 KiB
Text
# net_rt.ludic — a blessed, server-authoritative replication runtime (NETWORKING
|
|
# N6). It ties the language's networking primitives together into a batteries-
|
|
# included default, the way tests/mod_c/mod.c proved the event ABI — but written
|
|
# in Ludic, over the built-in transport, with no foreign code.
|
|
#
|
|
# This is LIBRARY POLICY, not the language (NETWORKING-DESIGN §10, §12): it picks
|
|
# server-authoritative state replication. The seams stay open — swap this for
|
|
# lockstep+rollback (world_save + tick_fixed on misprediction) or your own.
|
|
#
|
|
# Frame layout on the wire: [i32 entity id][synced field bytes]. The authority
|
|
# calls rt_replicate(e) per entity each tick; a peer calls rt_receive() to drain
|
|
# inbound snapshots and apply them. serialize/apply are the compiler-generated
|
|
# @Sync codecs; net_send/net_poll are the transport seam (built-in loopback here,
|
|
# a real socket when a program binds `extern fn net_send/net_poll`).
|
|
|
|
# The authority ships one entity's authoritative synced state to peers.
|
|
function rt_replicate(e: int) -> void {
|
|
let w = words(512)
|
|
w[0] = e # entity id in the first word
|
|
let n = serialize(e, offset(w, 4)) # synced fields after it
|
|
net_send(0, w, 4 + n)
|
|
}
|
|
|
|
# A peer drains every inbound snapshot and applies it to the named entity. One
|
|
# datagram per poll (the transport is datagram-preserving), so loop until empty.
|
|
function rt_receive() -> void {
|
|
let w = words(512)
|
|
var n = net_poll(w, 2048)
|
|
while n > 0 {
|
|
apply(w[0], offset(w, 4), n - 4) # w[0] = entity id; bytes follow
|
|
n = net_poll(w, 2048)
|
|
}
|
|
}
|