ludic.wildlife: wildlife_reserve sizes both animal tables and their id maps at a world's start

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-28 21:45:55 +03:00
parent bd2d62ddca
commit a0f60e5296

View file

@ -94,3 +94,12 @@ export function wildlife_count(wildlife_st: WildlifeState, sp: int) -> int {
for k in 0 .. len(rows) { if not wildlife_st.wl.tab.rec[rows[k]].legend { n += 1 } }
return n
}
# room for `n` animals (both tables: this player's and the host's it draws) before anything grows:
# a world that spawns in play sizes its table once, at the start
export function wildlife_reserve(wildlife_st: mut WildlifeState, n: int) -> void {
tb_reserve(wildlife_st.wl.tab, n)
imap_reserve(wildlife_st.wl.nids, n)
tb_reserve(wildlife_st.wl_host.tab, n)
imap_reserve(wildlife_st.wl_host.nids, n)
}