ludic/packages/ludic.base/tick.ludic
Orkuncakilkaya 231715bf98 fix(leaks): what play allocated every frame and never freed - a shadow uniform's name, the Tick, a ridden vehicle's moves
Found with malloc_history over 1200 frames of play without the interface (the first Ludic function
on each allocating stack, live bytes at two marks): sh_loc built `name + "[0]"` per program per pass
per frame - 24.6 MB of 33 in the window; its callers pass both names as literals now. tick_set fills
the frame loop's one Tick instead of tick_new making one a frame. A ridden boat or horse said
VEHICLE_MOVED as a new fact every frame; the metres are added up in VehiclesState and taken once
(vehicle_moved_take / _kind / _x / _z). Play's growth without the interface: 92 -> 14.7 MB a minute
(maroon-lake tests/leakcheck.sh); what is left is phys_push (Physics' fix on lang/nav) and the HUD's
strings. Packages 407, ludic-dev test 305 pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-27 23:51:37 +03:00

31 lines
891 B
Text

# ludic.base/tick.ludic - what one frame hands a system, and the phases that order systems. A
# system names its phase; the game's list orders systems within one. Nobody says "after X".
export property Tick {
dt: float = 0.0
frame: int = 0
hours: float = 0.0
}
export const PH_INPUT: int = 0
export const PH_SENSE: int = 1
export const PH_SIMULATE: int = 2
export const PH_RESOLVE: int = 3
export const PH_COMMIT: int = 4
export const PH_PRESENT: int = 5
export const PH_COUNT: int = 6
# the same Tick filled again: the frame loop keeps one and hands it on, rather than a new one a frame
export function tick_set(t: Tick, dt: float, frame: int, hours: float) -> Tick {
t.dt = dt
t.frame = frame
t.hours = hours
return t
}
export function tick_new(dt: float, frame: int, hours: float) -> Tick {
let t = new Tick
t.dt = dt
t.frame = frame
t.hours = hours
return t
}