frame allocs (25.2): physics, npc, vehicles and wildlife's bounded growth declared - id tables to their most, a walker slot, a guest's copies, a player's own vehicle, a table at a load

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-28 16:01:30 +03:00
parent 082fd26bf1
commit 34664e867f
7 changed files with 8 additions and 0 deletions

View file

@ -9,6 +9,7 @@ export function npc_spawn(npc_st: mut NpcState, kind: int) -> NpcPerson {
break
}
}
@alloc_ok("a walker for each of np_max at most; one who left is reused")
if p == null {
if len(npc_st.np_walkers) >= npc_st.np_max { return null }
p = new NpcPerson

View file

@ -14,6 +14,7 @@ export function npc_mirroring(npc_st: NpcState) -> bool { return npc_st.np_mirro
# the host's slot: somebody new in it (born), or nobody (gone)
export function npc_put(npc_st: mut NpcState, slot: int, id: int, kind: int, look: int, seed: float, name: string, hx: float, hz: float) -> NpcPerson {
if slot < 0 or slot >= npc_st.np_max or kind < 0 or kind >= NPCK_COUNT { return null }
@alloc_ok("a guest's copy of the host's slots, no more than np_max")
while len(npc_st.np_walkers) <= slot {
let q = new NpcPerson
q.slot = len(npc_st.np_walkers)

View file

@ -4,6 +4,7 @@
const PH_INDEX: int = 8388607 # a body id's low 23 bits are its index (Jolt's BodyID)
# every body owns nothing: at a world's opening, the table made once at its size and kept after
@alloc_ok("the body table made at its size when a world opens, kept after")
function ph_own_reset(physics_st: mut PhysicsState, max_bodies: int) -> void {
if len(physics_st.ph_own) < max_bodies {
List.clear(physics_st.ph_own)

View file

@ -10,6 +10,7 @@ function ph_keep(physics_st: mut PhysicsState, s: pointer) -> int {
physics_st.ph_shapes[id] = s
return id
}
@alloc_ok("the id table grows to the most shapes held at once; a freed id is handed out again")
push(physics_st.ph_shapes, s)
return len(physics_st.ph_shapes) - 1
}
@ -26,6 +27,7 @@ export function phys_shape_free(physics_st: mut PhysicsState, id: int) -> void {
if s == null { return }
jph_shape_free(s)
physics_st.ph_shapes[id] = null
@alloc_ok("the spare ids, no more than the most shapes ever held")
push(physics_st.ph_spare, id)
}

View file

@ -35,6 +35,7 @@ export function phys_walker_add(physics_st: mut PhysicsState, r: float, h: float
return i
}
}
@alloc_ok("a slot for the most walkers at once; a removed one's slot is reused")
push(physics_st.ph_walkers, k)
return len(physics_st.ph_walkers) - 1
}

View file

@ -1,5 +1,6 @@
# call.ludic - a player's boat or horse brought to a place: made there the first time, fetched there
# after; gone when its player leaves
@alloc_ok("a player's own boat or horse, made the first time it is called and fetched after")
function ve_add(vehicles_st: VehiclesState, kind: int, owner: int, x: float, z: float, yaw: float) -> Vehicle {
if kind != VEHICLE_HORSE and kind != VEHICLE_BOAT { return null }
let v = new Vehicle

View file

@ -14,6 +14,7 @@ export property WildTable {
nids: IntMap = null
}
@alloc_ok("a table of animals: a load, or a guest taking the host's")
function wl__new() -> WildTable {
let w = new WildTable
let tb: Table<WildAnimal> = table_new(2, 2)