refactor(packages): 0.R5 - a question no longer starts its state - 64 lazy starts ('if st.x == null { st.x = ... }' inside a getter) are the state's defaults, gear__ensure is gone, and ludic migrate state --tighten took mut off 208 package parameters: things_all, thing_find, gear_charge, gear_level, jobs_state and the rest read

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-27 00:51:03 +03:00
parent 54f5efb23f
commit 9862ec82e3
102 changed files with 320 additions and 351 deletions

View file

@ -66,7 +66,7 @@ export state SessionState {
session__max: int = 4
session__open: bool = true
session__near_i: int = 0
session__facts: Queue<SessionFact> = null
session__facts: Queue<SessionFact> = session__facts__new()
session__vote_id: int = 0
session__vote_kind: int = 0
session__vote_param: int = 0
@ -78,12 +78,11 @@ export state SessionState {
session__vote_passed: int = -1 # the last vote: -1 none, 0 failed, 1 passed
}
export function ses_facts(session_st: mut SessionState) -> Queue<SessionFact> {
if session_st.session__facts == null { session_st.session__facts = queue_new("session.facts") }
export function ses_facts(session_st: SessionState) -> Queue<SessionFact> {
return session_st.session__facts
}
function session__fact(session_st: mut SessionState, what: int, slot: int, pid: int) -> SessionFact {
function session__fact(session_st: SessionState, what: int, slot: int, pid: int) -> SessionFact {
let f = new SessionFact
f.what = what
f.slot = slot
@ -99,3 +98,4 @@ function session__init(session_st: mut SessionState) -> void {
for i in 0 .. PLY_MAX { push(session_st.session__slot, new PartyMember) }
session_st.session__slot[0].on = true
}
function session__facts__new() -> Queue<SessionFact> { return queue_new("session.facts") }

View file

@ -14,14 +14,14 @@ program SessionTest {
function fname() -> string { return "me" }
bind SessionLocal { x: fn fx, y: fn fy, z: fn fz, name: fn fname }
function whats(session_st: mut SessionState) -> []int {
function whats(session_st: SessionState) -> []int {
let fs = q_drain(ses_facts(session_st))
let out = new []int
for i in 0 .. len(fs) { push(out, fs[i].what) }
return out
}
function last_of(session_st: mut SessionState, what: int) -> SessionFact {
function last_of(session_st: SessionState, what: int) -> SessionFact {
let fs = q_drain(ses_facts(session_st))
var f: SessionFact = null
for i in 0 .. len(fs) { if fs[i].what == what { f = fs[i] } }

View file

@ -92,7 +92,7 @@ function session__vote_finish(session_st: mut SessionState) -> void {
f.yes = passed
}
function session__vote_fact(session_st: mut SessionState, what: int) -> SessionFact {
function session__vote_fact(session_st: SessionState, what: int) -> SessionFact {
let f = session__fact(session_st, what, -1, 0)
f.id = session_st.session__vote_id
f.kind = session_st.session__vote_kind