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

@ -23,6 +23,7 @@ export state InventoryState {
}
# the kinds, by the name each is saved under; the pack starts empty
@alloc_ok("once: the pack's kinds are bound at start")
export function inv_config(inventory_st: mut InventoryState, keys: []string) -> void {
inventory_st.iv_keys = keys
if len(inventory_st.iv_pool) == 0 { for i in 0 .. IV_POOL { push(inventory_st.iv_pool, new ItemChanged) } }

View file

@ -37,6 +37,10 @@ export function inv_set(inventory_st: mut InventoryState, it: int, n: int) -> vo
# everything gone, silently: a new trip, or before a load
export function inv_clear(inventory_st: mut InventoryState) -> void {
inventory_st.iv_counts = new []int
for i in 0 .. inv_kinds(inventory_st) { push(inventory_st.iv_counts, 0) }
if inventory_st.iv_counts == null {
@alloc_ok("once: the counts are made the first time the pack is cleared")
inventory_st.iv_counts = new []int
}
List.clear(inventory_st.iv_counts)
for i in 0 .. inv_kinds(inventory_st) { kept_push(inventory_st.iv_counts, 0) }
}