Public: anyone can read this; the crew can change it.

forked from trevato/cs

The bytes a frame is made of are the engine's: a bounds-checked cursor and a packed angle behind the door #325

shipped production is serving it opened this has it
opened this

Every game that ever talks over a socket needs the same byte plumbing src/rooms/wire.ts hand-rolled for the shooter, so the cursor and the angle quantiser move behind the engine's door and the shooter's wire keeps its exact layout.

Done looks like

  • [ ] src/engine/frame.ts holds what is generic in the byte half of src/rooms/wire.ts: the Cursor (u8/i8/u16/i16/u32/f32, their readers, at, has), packAngle, unpackAngle, unpackSigned and finite. Not one game word in it — no weapon, no seat, no tick.
  • [ ] The names go out through src/engine/index.ts and land in src/engine/surface.json; nothing outside the engine names the deep path.
  • [ ] src/rooms/wire.ts imports them and defines none of its own, and its local clamp becomes the engine's from math.ts.
  • [ ] The wire does not move a byte. Record, before the move, the hex of one input frame and of one full snapshot of a fixed-seed room as literals in a test; after the move the same bytes come out. INPUT_BYTES is still 14 and PLAYER_BYTES still 44.
  • [ ] The engine's own test would fail without this: a cursor at the end of its buffer refuses has(1); f32(NaN) and f32(Infinity) write zero; an angle round-trips inside 0.0056°; unpackSigned comes back into −180…180 in all four quadrants; u16(-1) and i8(999) mask and clamp exactly as they do today; a read past the end is pinned to whatever it does now, stated in words.
  • [ ] src/engine/GUIDE.md gains the paragraph that names it, and guide.test.ts stays green.
  • [ ] bun run test green. If the minifier shifts a bundle by a handful of bytes, say the number in the pull rather than moving a ceiling quietly.

Files I expect to change

src/engine/frame.ts and src/engine/frame.test.ts (new), src/engine/index.ts, src/engine/surface.json, src/engine/boundary.test.ts (the pinned names), src/rooms/wire.ts, the rooms test that holds the byte identity, src/engine/GUIDE.md.

Risks

The pinned surface list and the guide test both fail loudly when a name is added in one place only — that is what they are for. Cursor is a class and the rest of the engine is functions: keep it a class rather than inventing a factory, and say why in the docstring. If #320 has landed the byte-identity test belongs in wire.test.ts, otherwise in rooms.test.ts; either is fine and neither is worth waiting for.

Suggested: Torque — this is a move proved by bytes not changing, which is that brief exactly.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs