ludic/packages/ludic.vehicles/moved.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

19 lines
1 KiB
Text

# moved.ludic - the ground the ridden vehicle covers, added up rather than said a frame at a time: a
# fact a frame was a new record a frame, and Ludic frees nothing. The game takes the sum when it asks.
function ve_moved_add(vehicles_st: mut VehiclesState, v: Vehicle, d: float) -> void {
vehicles_st.ve_moved += d
vehicles_st.ve_moved_kind = v.kind
vehicles_st.ve_moved_x = v.x
vehicles_st.ve_moved_z = v.z
}
# the metres covered since the last take (0 when nothing moved), and the sum starts again
export function vehicle_moved_take(vehicles_st: mut VehiclesState) -> float {
let d = vehicles_st.ve_moved
vehicles_st.ve_moved = 0.0
return d
}
# what covered them, and where it was when it last moved
export function vehicle_moved_kind(vehicles_st: VehiclesState) -> int { return vehicles_st.ve_moved_kind }
export function vehicle_moved_x(vehicles_st: VehiclesState) -> float { return vehicles_st.ve_moved_x }
export function vehicle_moved_z(vehicles_st: VehiclesState) -> float { return vehicles_st.ve_moved_z }