ludic.compass, inventory, shop, base, things: the compass's lists are state defaults and push through kept_push; the pack clears in place; setup, bind and load paths say so in @alloc_ok

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-28 16:29:33 +03:00
parent cd71da9330
commit bdfe3f18fe
13 changed files with 26 additions and 12 deletions

View file

@ -2,10 +2,6 @@
# capture is open the marks go to whoever is listening instead, whatever the tier.
# a frame's list and marks are the state's own, emptied and reused rather than made again
export function compass_begin(compass_st: mut CompassState) -> void {
if compass_st.cmp_list == null {
compass_st.cmp_list = new []CompassMark
compass_st.cmp_back = new []CompassMark
}
List.clear(compass_st.cmp_list)
compass_st.cmp_used = 0
}
@ -14,11 +10,11 @@ export function compass_begin(compass_st: mut CompassState) -> void {
export function compass_mark(compass_st: mut CompassState, x: float, z: float, icon: int, colour: int, tier: int, prio: int, label: string) -> void {
if compass_st.cmp_list == null { compass_begin(compass_st) }
if compass_st.cmp_capturing {
push(compass_st.cmp_caught, cmp_catch(compass_st, x, z, icon, colour, tier, prio, label))
kept_push(compass_st.cmp_caught, cmp_catch(compass_st, x, z, icon, colour, tier, prio, label))
return
}
if CompassWorld.tier() < tier { return }
push(compass_st.cmp_list, cmp_take(compass_st, x, z, icon, colour, tier, prio, label))
kept_push(compass_st.cmp_list, cmp_take(compass_st, x, z, icon, colour, tier, prio, label))
}
# highest priority first, the providers' order kept within one; then the cap
@ -28,7 +24,7 @@ export function compass_end(compass_st: mut CompassState) -> void {
List.clear(out)
for p in 0 .. 3 {
let want = COMPASS_TRACKED - p
for i in 0 .. len(compass_st.cmp_list) { if cmp_band(compass_st.cmp_list[i].prio) == want and len(out) < compass_st.cmp_cap { push(out, compass_st.cmp_list[i]) } }
for i in 0 .. len(compass_st.cmp_list) { if cmp_band(compass_st.cmp_list[i].prio) == want and len(out) < compass_st.cmp_cap { kept_push(out, compass_st.cmp_list[i]) } }
}
compass_st.cmp_back = compass_st.cmp_list
compass_st.cmp_list = out

View file

@ -24,8 +24,8 @@ export open registry CompassProviders of CompassProvider as COMPASS_FROM
export state CompassState {
cmp_cap: int = 64
cmp_list: []CompassMark = null # this frame's, sorted and culled
cmp_back: []CompassMark = null # the list the sort fills, then swapped with cmp_list
cmp_list: []CompassMark = new []CompassMark # this frame's, sorted and culled
cmp_back: []CompassMark = new []CompassMark # the list the sort fills, then swapped with cmp_list
cmp_pool: []CompassMark = cmp_pool__new() # a frame's marks, made with the state and reused: Ludic frees nothing
cmp_used: int = 0
cmp_capturing: bool = false

View file

@ -1,6 +1,7 @@
# radar.ludic - the radar's tiers: a range for each compass tier (0 is no radar), which marks it
# shows, and where each falls on a unit disc with ahead at the top
@alloc_ok("at start: the radar's rings, once")
export function compass_config_radar(compass_st: mut CompassState, ranges: []float, from_tier: int) -> void {
compass_st.cmp_ranges = new []float
for i in 0 .. len(ranges) { push(compass_st.cmp_ranges, ranges[i]) }