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:
parent
54f5efb23f
commit
9862ec82e3
102 changed files with 320 additions and 351 deletions
|
|
@ -1,8 +1,7 @@
|
|||
# ports.ludic - the config, and what the ports answer when the game leaves them unbound
|
||||
export function telemetry_config(telemetry_st: mut TelemetryState, c: TelemetryConfig) -> void { telemetry_st.telemetry__cfg = c }
|
||||
|
||||
function telemetry__conf(telemetry_st: mut TelemetryState) -> TelemetryConfig {
|
||||
if telemetry_st.telemetry__cfg == null { telemetry_st.telemetry__cfg = new TelemetryConfig }
|
||||
function telemetry__conf(telemetry_st: TelemetryState) -> TelemetryConfig {
|
||||
return telemetry_st.telemetry__cfg
|
||||
}
|
||||
|
||||
|
|
@ -10,7 +9,7 @@ function telemetry__yes() -> bool { return true }
|
|||
function telemetry__wall_ms(telemetry_st: TelemetryState) -> int { return (Time.now() - telemetry_st.telemetry__t0) * 1000 }
|
||||
function telemetry__wall_stamp() -> string { return DateTime.format(Time.now(), "YYYY-MM-DDTHH:mm:ssZ") }
|
||||
|
||||
function telemetry__can_send(telemetry_st: mut TelemetryState) -> bool {
|
||||
function telemetry__can_send(telemetry_st: TelemetryState) -> bool {
|
||||
let c = telemetry__conf(telemetry_st)
|
||||
if len(c.host) == 0 or len(c.key) == 0 { return false }
|
||||
return TelemetryWorld.can_send()
|
||||
|
|
@ -40,7 +39,7 @@ function telemetry__http_poll(h: int) -> int {
|
|||
|
||||
function telemetry__http_drop(h: int) -> void { Http.free(h) }
|
||||
|
||||
function telemetry__send(telemetry_st: mut TelemetryState, body: string) -> int { return TelemetryTransport.send(telemetry__conf(telemetry_st).host + telemetry__conf(telemetry_st).path, body) }
|
||||
function telemetry__send(telemetry_st: TelemetryState, body: string) -> int { return TelemetryTransport.send(telemetry__conf(telemetry_st).host + telemetry__conf(telemetry_st).path, body) }
|
||||
function telemetry__poll(h: int) -> int { return TelemetryTransport.poll(h) }
|
||||
|
||||
# a request abandoned (the player said no)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
export function telemetry_id(telemetry_st: TelemetryState) -> string { return telemetry_st.telemetry__id }
|
||||
export function telemetry_session(telemetry_st: TelemetryState) -> string { return telemetry_st.telemetry__session }
|
||||
export function telemetry_ready(telemetry_st: TelemetryState) -> bool { return telemetry_st.telemetry__ready }
|
||||
export function telemetry_get_config(telemetry_st: mut TelemetryState) -> TelemetryConfig { return telemetry__conf(telemetry_st) }
|
||||
export function telemetry_get_config(telemetry_st: TelemetryState) -> TelemetryConfig { return telemetry__conf(telemetry_st) }
|
||||
export function telemetry_fails(telemetry_st: TelemetryState) -> int { return telemetry_st.telemetry__fails }
|
||||
export function telemetry_next_ms(telemetry_st: TelemetryState) -> int { return telemetry_st.telemetry__next_ms }
|
||||
export function telemetry_in_flight(telemetry_st: TelemetryState) -> bool { return telemetry_st.telemetry__h >= 0 }
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ export function telemetry_start(telemetry_st: mut TelemetryState) -> void {
|
|||
}
|
||||
|
||||
# may an event be kept right now?
|
||||
export function telemetry_on(telemetry_st: mut TelemetryState) -> bool { return telemetry_st.telemetry__ready and telemetry__enabled() and telemetry__can_send(telemetry_st) }
|
||||
export function telemetry_on(telemetry_st: TelemetryState) -> bool { return telemetry_st.telemetry__ready and telemetry__enabled() and telemetry__can_send(telemetry_st) }
|
||||
|
||||
# an event: the properties (null for none) with the session and the library added, and the player
|
||||
# as a mark put in when the batch goes, so an event queued before the id is known is not misfiled
|
||||
|
|
@ -77,7 +77,7 @@ function telemetry__queue_drop(telemetry_st: mut TelemetryState, n: int) -> void
|
|||
}
|
||||
|
||||
# the batch: the first n lines joined, with the player id put in - no parsing
|
||||
export function telemetry_batch_body(telemetry_st: mut TelemetryState, n: int) -> string {
|
||||
export function telemetry_batch_body(telemetry_st: TelemetryState, n: int) -> string {
|
||||
let part = new []string
|
||||
for i in 0 .. n { push(part, telemetry_st.telemetry__q[i]) }
|
||||
let head = Value.object()
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ export state TelemetryState {
|
|||
telemetry__proc_t0: int = 0
|
||||
telemetry__rand_n: int = 0
|
||||
telemetry__clock_on: bool = false
|
||||
telemetry__cfg: TelemetryConfig = null
|
||||
telemetry__cfg: TelemetryConfig = new TelemetryConfig
|
||||
telemetry__ready: bool = false
|
||||
telemetry__id: string = ""
|
||||
telemetry__session: string = ""
|
||||
|
|
@ -64,15 +64,14 @@ export state TelemetryState {
|
|||
telemetry__saved_ms: int = 0 # when the queue was last put on disk
|
||||
telemetry__fails: int = 0 # sends failed in a row
|
||||
telemetry__t0: int = 0 # the default clock's zero, wall seconds
|
||||
telemetry__facts: Queue<TelemetryFact> = null
|
||||
telemetry__facts: Queue<TelemetryFact> = telemetry__facts__new()
|
||||
}
|
||||
|
||||
export function telemetry_facts(telemetry_st: mut TelemetryState) -> Queue<TelemetryFact> {
|
||||
if telemetry_st.telemetry__facts == null { telemetry_st.telemetry__facts = queue_new("telemetry.facts") }
|
||||
export function telemetry_facts(telemetry_st: TelemetryState) -> Queue<TelemetryFact> {
|
||||
return telemetry_st.telemetry__facts
|
||||
}
|
||||
|
||||
function telemetry__fact(telemetry_st: mut TelemetryState, what: int, count: int, status: int, retry: int) -> void {
|
||||
function telemetry__fact(telemetry_st: TelemetryState, what: int, count: int, status: int, retry: int) -> void {
|
||||
let f = new TelemetryFact
|
||||
f.what = what
|
||||
f.count = count
|
||||
|
|
@ -80,3 +79,4 @@ function telemetry__fact(telemetry_st: mut TelemetryState, what: int, count: int
|
|||
f.retry_ms = retry
|
||||
q_push(telemetry_facts(telemetry_st), f)
|
||||
}
|
||||
function telemetry__facts__new() -> Queue<TelemetryFact> { return queue_new("telemetry.facts") }
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ program TelemetryTest {
|
|||
telemetry_tick(telemetry_st)
|
||||
}
|
||||
|
||||
function facts_of(telemetry_st: mut TelemetryState, what: int) -> int {
|
||||
function facts_of(telemetry_st: TelemetryState, what: int) -> int {
|
||||
let fs = q_drain(telemetry_facts(telemetry_st))
|
||||
var n = 0
|
||||
for i in 0 .. len(fs) { if fs[i].what == what { n += 1 } }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue