ludic/packages/ludic.telemetry/props_nest.ludic
Orkuncakilkaya 3ac1179440 fix(allocs): ludic.update, steps, effects and telemetry at 0 frame allocs and 0 keeps
ludic.update: whether this copy can update itself is worked out once, when the updater is configured
(the panel asked every frame, building the path to the executable each time); the notes are a list
the state keeps, filled by update_notes_for when the version or the language changes, which the
game calls from its update tick. The feed's address is declared (once, when a check starts).
ludic.steps, ludic.effects, ludic.telemetry: what is left is made on an event and declared with its
bound - an arc's tables, a chapter's columns, a step's fact, an effect's start, end and clear, the
fact pool's growth, the player id, a props record's nesting stack - and two pushes into a caller's
kept list, at most a chapter's steps and the ring's size.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-28 20:13:06 +03:00

44 lines
1.8 KiB
Text

# props_nest.ludic - an object or a list inside an event's properties ($set, a photograph's subjects, the
# party's names), written into the same kept buffer; and a signature of what was written, to tell a
# change without keeping a copy
export function telemetry_obj(p: TelemetryProps, k: string) -> void { tn_open(p, k, 123) }
export function telemetry_list(p: TelemetryProps, k: string) -> void { tn_open(p, k, 91) }
export function telemetry_obj_end(p: TelemetryProps) -> void { tn_close(p, 125) }
export function telemetry_list_end(p: TelemetryProps) -> void { tn_close(p, 93) }
function tn_open(p: TelemetryProps, k: string, c: int) -> void {
tp_key(p, k)
sb_byte(p.sb, c)
@alloc_ok("one nesting stack per props record, the first time it nests")
if p.lv == null { p.lv = words(8) }
if p.d < len(p.lv) - 1 { p.d += 1 }
p.lv[p.d] = 0
}
function tn_close(p: TelemetryProps, c: int) -> void {
sb_byte(p.sb, c)
if p.d > 0 { p.d -= 1 }
}
# a string in the list being written
export function telemetry_item_str(p: TelemetryProps, s: string) -> void {
tp_next(p)
tj_str(p.sb, s)
}
# a string item made of numbers the caller writes itself (sb_int, sb_byte - no quote or backslash)
export function telemetry_item_open(p: TelemetryProps) -> StrBuf {
tp_next(p)
sb_byte(p.sb, 34)
return p.sb
}
export function telemetry_item_close(p: TelemetryProps) -> void { sb_byte(p.sb, 34) }
# the same for a named string property; closed with telemetry_item_close
export function telemetry_str_open(p: TelemetryProps, k: string) -> StrBuf {
tp_key(p, k)
sb_byte(p.sb, 34)
return p.sb
}
# a number standing for what has been written: equal when the bytes are (FNV-1a, 31 bits)
export function telemetry_props_sig(p: TelemetryProps) -> int {
var h = 2166136261 & 2147483647
for i in 0 .. sb_len(p.sb) { h = ((h ^ p.sb.b[i]) * 16777619) & 2147483647 }
return h
}