nx_pets_netstate.nx
buildroot/runtime/nx_pets_netstate.nx
about
nx_pets_netstate.nx -- sovereign player-state codec for multiplayer pixelmon.
Packs a player snapshot into a compact 28-byte frame for the server-relay
(nx_room_relay): each player POSTs its frame, reads the roster of OTHER players,
unpacks their frames -> renders peer avatars. Pure buffer ops, NO syscalls ->
wasm-friendly (compiles via nxc2 --target wat, same path as the game) AND reusable
by the native relay daemon. Versioned + magic-guarded = forward/backward compatible
(mirrors gi_save discipline: a peer's short/older frame still decodes its fields;
the layout is APPEND-ONLY so newer frames decode their known prefix on older readers).
Frame layout (PS_LEN = 28 bytes):
[0]=0x50 'P' [1]=0x4D 'M' [2]=version(1) [3]=flags
[4..7]=x [8..11]=y [12..15]=z [16..19]=yaw [20..23]=pitch (i32 LE, voxel fixed-pt)
[24]=species_held [25]=caught_count [26]=action [27]=anim
Fields array f[10] (caller-owned): x,y,z,yaw,pitch, species,caught,action,anim, flags
license_tier: ORIGINAL
dependencies 0 imports · 3 importers
imports: none
imported by: nx_game_room_gate.nxnx_pets_mp_relay_gate.nxnx_wasm_mineworld.nx
structs
| none |
consts
| 17 | const PS_MAGIC0: i64 = 0x50 |
| 18 | const PS_MAGIC1: i64 = 0x4D |
| 19 | const PS_VER: i64 = 1 |
| 20 | const PS_LEN: i64 = 28 |
functions
| 23 | func ps_wr32(buf: *u8, off: i64, v: i64) -> i64 called by 1: ps_pack |
| 33 | func ps_rd32(buf: *u8, off: i64) -> i64 called by 1: ps_unpack |
| 45 | func ps_pack(buf: *u8, f: *i64) -> i64 |
| 65 | func ps_unpack(buf: *u8, n: i64, f: *i64) -> i64 |