ludic/packages/ludic.devlink/state.ludic
Orkuncakilkaya 18755d9057 ludic.devlink: an editor's live link into a running dev build (protocol v1, stage 1)
A package on ludic.base alone. DevlinkNet is the transport (a game binds Udp, the test a fake);
DevlinkWorld's members are the verbs, each defaulting to "not offered" (err unbound): ping, hello (with
Build.schema_hash as 16 hex digits), cam_get / cam_set / cam_release, goto, map_load, time, weather, shot,
pause / resume / step. One request a frame, parsed in place from a fixed 8 KB buffer and answered into
another; map_load, shot and step answer later by id, one at a time, 5 s at most. Loopback senders only,
opened only when enabled() (dev_tools), co-op refuses everything but ping and hello. tests/devlink_test:
each answer byte for byte, bad arguments, a stranger dropped, co-op, the late answers and their timeout,
a closed build that never opens. Compiles; not run (the Master runs the package tests).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 19:09:59 +03:00

29 lines
1.1 KiB
Text

# state.ludic - the socket, the two buffers and the one late answer in flight; made once, reused every frame
export const DL_BUF: int = 8192
export const DL_LATE_S: float = 5.0 # a late answer gives up after this long
export const DL_NONE: int = 0 # what is waiting to be answered
export const DL_MAP: int = 1
export const DL_SHOT: int = 2
export const DL_STEP: int = 3
export state DevlinkState {
dl_h: int = -1
dl_tried: bool = false
dl_in: []byte = buffer(DL_BUF)
dl_out: []byte = buffer(DL_BUF)
dl_str: []byte = buffer(DL_BUF) # a quoted argument, unescaped
dl_path: []byte = buffer(1024) # the waiting shot's path, for its answer
dl_path_n: int = 0
dl_n: int = 0 # bytes in dl_in
dl_at: int = 0 # the reader's cursor
dl_bad: bool = false # the reader met something it could not read
dl_o: int = 0 # bytes in dl_out
dl_ip: int = 0
dl_port: int = 0
dl_pend: int = 0
dl_pend_id: int = 0
dl_pend_ip: int = 0
dl_pend_port: int = 0
dl_pend_t: float = 0.0
dl_cam: DevlinkCam = new DevlinkCam
}