ludic/packages/ludic.vehicles/fact_pool.ludic

21 lines
772 B
Text

# ludic.vehicles/fact_pool.ludic - the facts' records made at the start (VEHICLEFACTS of them) with a free list
# of room for all, so a frame holding a new peak of facts makes nothing until that many are held
const VE_FACTS: int = 64
function ve_fpool_new() -> []VehicleFact {
let l = new []VehicleFact
for i in 0 .. VE_FACTS { push(l, new VehicleFact) }
return l
}
function ve_ffree_new() -> []VehicleFact {
let l = ve_fpool_new()
List.clear(l)
return l
}
# past them: a record for the new peak, kept in the pool for good
@alloc_ok("a new peak of facts held at once, past the 64 made at the start; kept and reused")
function ve_fact_more(vehicles_st: mut VehiclesState) -> VehicleFact {
let f = new VehicleFact
push(vehicles_st.ve_fpool, f)
return f
}