ludic.compass: the marks' pools made with the state (512), compass_at's empty mark kept; ludic.base imap_clear in place; ludic.things' kept lists through kept_push; ludic.net's once-per-room and STUN log lines declared

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-28 16:22:48 +03:00
parent 8dfcccad41
commit d3911d4ba8
11 changed files with 40 additions and 19 deletions

View file

@ -8,7 +8,7 @@ export function compass_count(compass_st: CompassState) -> int {
# the i-th mark, or an empty one past the end
export function compass_at(compass_st: CompassState, i: int) -> CompassMark {
if i < 0 or i >= compass_count(compass_st) { return new CompassMark }
if i < 0 or i >= compass_count(compass_st) { return compass_st.cmp_none }
return compass_st.cmp_list[i]
}

View file

@ -1,10 +1,6 @@
# capture.ludic - someone else wants to know where the providers point (a guide's arrow): until the
# end every mark is theirs, whatever the tier, and the frame's list is left alone
export function compass_capture_begin(compass_st: mut CompassState) -> void {
if compass_st.cmp_caught == null {
compass_st.cmp_caught = new []CompassMark
compass_st.cmp_cpool = new []CompassMark
}
List.clear(compass_st.cmp_caught)
compass_st.cmp_cused = 0
compass_st.cmp_capturing = true
@ -13,14 +9,15 @@ export function compass_capture_begin(compass_st: mut CompassState) -> void {
# what was caught: the compass's own list and marks, good until the next capture begins
export function compass_capture_end(compass_st: mut CompassState) -> []CompassMark {
compass_st.cmp_capturing = false
if compass_st.cmp_caught == null { compass_st.cmp_caught = new []CompassMark }
return compass_st.cmp_caught
}
# the capture pool's next mark, filled (one made only when the pool is short)
function cmp_catch(compass_st: mut CompassState, x: float, z: float, icon: int, colour: int, tier: int, prio: int, label: string) -> CompassMark {
if compass_st.cmp_cpool == null { compass_st.cmp_cpool = new []CompassMark }
if compass_st.cmp_cused >= len(compass_st.cmp_cpool) { push(compass_st.cmp_cpool, new CompassMark) }
if compass_st.cmp_cused >= len(compass_st.cmp_cpool) {
@alloc_ok("past COMPASS_POOL marks in one capture only, then kept")
push(compass_st.cmp_cpool, new CompassMark)
}
compass_st.cmp_cused += 1
return cmp_fill(compass_st.cmp_cpool[compass_st.cmp_cused - 1], x, z, icon, colour, tier, prio, label)
}

View file

@ -5,7 +5,6 @@ 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
compass_st.cmp_pool = new []CompassMark
}
List.clear(compass_st.cmp_list)
compass_st.cmp_used = 0
@ -37,7 +36,10 @@ export function compass_end(compass_st: mut CompassState) -> void {
# the pool's next mark, filled (one made only when the pool is short)
function cmp_take(compass_st: mut CompassState, x: float, z: float, icon: int, colour: int, tier: int, prio: int, label: string) -> CompassMark {
if compass_st.cmp_used >= len(compass_st.cmp_pool) { push(compass_st.cmp_pool, new CompassMark) }
if compass_st.cmp_used >= len(compass_st.cmp_pool) {
@alloc_ok("past COMPASS_POOL marks in one frame only, then kept")
push(compass_st.cmp_pool, new CompassMark)
}
compass_st.cmp_used += 1
return cmp_fill(compass_st.cmp_pool[compass_st.cmp_used - 1], x, z, icon, colour, tier, prio, label)
}
@ -56,3 +58,11 @@ export function compass_gather(compass_st: mut CompassState) -> void {
}
export function compass_capturing(compass_st: CompassState) -> bool { return compass_st.cmp_capturing }
# more marks than any frame has asked for (the tracking view's peak is well under it)
const COMPASS_POOL: int = 512
function cmp_pool__new() -> []CompassMark {
let xs = new []CompassMark
for i in 0 .. COMPASS_POOL { push(xs, new CompassMark) }
return xs
}

View file

@ -26,11 +26,12 @@ 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_pool: []CompassMark = null # a frame's marks, reused: Ludic frees nothing
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
cmp_caught: []CompassMark = null # what providers said while someone was listening
cmp_cpool: []CompassMark = null # the capture's marks, reused from one capture to the next
cmp_caught: []CompassMark = new []CompassMark # what providers said while someone was listening
cmp_cpool: []CompassMark = cmp_pool__new() # the capture's marks, reused from one capture to the next
cmp_none: CompassMark = new CompassMark # what compass_at answers past the end
cmp_cused: int = 0
cmp_ranges: []float = null
cmp_radar_from: int = 2 # marks of at least this tier are blips; the tracked one always is