diff --git a/packages/ludic.clock/verbs.ludic b/packages/ludic.clock/verbs.ludic index 74cc37b6..e66b9ce6 100644 --- a/packages/ludic.clock/verbs.ludic +++ b/packages/ludic.clock/verbs.ludic @@ -41,11 +41,13 @@ export function clock_advance(clock_st: mut ClockState, gh: float) -> void { # a new trip: day one at the start hour, the moon somewhere in its month export function clock_reset(clock_st: mut ClockState) -> void { if clock_st.ck_dice == null { - @alloc_ok("once: the clock's dice, seeded again on every new trip after") - clock_st.ck_dice = rng_new(ClockWorld.seed()) + clock_st.ck_dice = ck_dice_new(ClockWorld.seed()) } else { rng_seed(clock_st.ck_dice, ClockWorld.seed()) } clock_st.ck_day = 1 clock_st.ck_hours = clock_st.ck_start_hours clock_st.ck_moon = rng_span(clock_st.ck_dice, clock_st.ck_moon_lo, clock_st.ck_moon_hi) % 1.0 q_clear(clock_days(clock_st)) } + +@alloc_ok("once: the clock's dice, seeded again on every new trip after") +function ck_dice_new(seed: int) -> Rng { return rng_new(seed) } diff --git a/packages/ludic.fishing/state.ludic b/packages/ludic.fishing/state.ludic index 2590f7df..43b161b0 100644 --- a/packages/ludic.fishing/state.ludic +++ b/packages/ludic.fishing/state.ludic @@ -42,7 +42,7 @@ export function fishing_config(fishing_st: mut FishingState, min_depth: float, d fishing_st.fishing_min_depth = min_depth fishing_st.fishing_deep = deep fishing_st.fishing_seed_n = seed - fishing_st.fishing_dice = rng_new(seed) + fishing_dice_seed(fishing_st, seed) } export function fishing_facts(fishing_st: FishingState) -> Queue { @@ -50,10 +50,21 @@ export function fishing_facts(fishing_st: FishingState) -> Queue { } function fishing_rand(fishing_st: mut FishingState) -> float { - if fishing_st.fishing_dice == null { fishing_st.fishing_dice = rng_new(fishing_st.fishing_seed_n) } + if fishing_st.fishing_dice == null { fishing_dice_seed(fishing_st, fishing_st.fishing_seed_n) } return rng_float(fishing_st.fishing_dice) } +# the line's dice: made the first time, seeded again after (a reset, a new trip) +function fishing_dice_seed(fishing_st: mut FishingState, seed: int) -> void { + if fishing_st.fishing_dice != null { + rng_seed(fishing_st.fishing_dice, seed) + return + } + fishing_st.fishing_dice = fishing_dice_new(seed) +} +@alloc_ok("once: the line's dice") +function fishing_dice_new(seed: int) -> Rng { return rng_new(seed) } + function fishing_say(fishing_st: mut FishingState, what: int) -> void { let f = fishing_fact_record(fishing_st) f.what = what diff --git a/packages/ludic.fishing/system.ludic b/packages/ludic.fishing/system.ludic index c3384d66..2c6cc7e3 100644 --- a/packages/ludic.fishing/system.ludic +++ b/packages/ludic.fishing/system.ludic @@ -5,7 +5,7 @@ export function fishing_reset(fishing_st: mut FishingState) -> void { fishing_st.fishing_n = 0 fishing_st.fishing_big = 0 fishing_st.fishing_leg = false - fishing_st.fishing_dice = rng_new(fishing_st.fishing_seed_n) + fishing_dice_seed(fishing_st, fishing_st.fishing_seed_n) q_clear(fishing_facts(fishing_st)) } diff --git a/packages/ludic.minimap/grid.ludic b/packages/ludic.minimap/grid.ludic index f9af4713..de4e15e1 100644 --- a/packages/ludic.minimap/grid.ludic +++ b/packages/ludic.minimap/grid.ludic @@ -47,6 +47,7 @@ export function minimap_config(minimap_st: mut MinimapState, cells: int, cell_m: minimap_st.mm_core_n = minimap_st.mm_cells @alloc_ok("once per map configured: its explored grid") minimap_st.mm_seen = new []int + @alloc_ok("once per map configured: as above") for i in 0 .. minimap_st.mm_cells * minimap_st.mm_cells { push(minimap_st.mm_seen, 0) } minimap_st.mm_land_n = 0 minimap_st.mm_version += 1 diff --git a/packages/ludic.minimap/pins.ludic b/packages/ludic.minimap/pins.ludic index 03403852..42ad3889 100644 --- a/packages/ludic.minimap/pins.ludic +++ b/packages/ludic.minimap/pins.ludic @@ -48,6 +48,7 @@ export function minimap_pin_add(minimap_st: mut MinimapState, x: float, z: float p.icon = Math.clamp(icon, 0, minimap_st.mm_symbols - 1) p.day = MinimapWorld.day() p.label = label + @alloc_ok("a mark put down: kept, and the map holds at most its most") push(minimap_st.mm_pins, p) minimap_st.mm_last = p.icon return len(minimap_st.mm_pins) - 1 @@ -65,6 +66,7 @@ export function minimap_pin_put(minimap_st: mut MinimapState, x: float, z: float p.colour = Math.clamp(colour, 0, minimap_st.mm_colours - 1) p.day = day p.label = label + @alloc_ok("a mark put down: kept, and the map holds at most its most") push(minimap_st.mm_pins, p) return len(minimap_st.mm_pins) - 1 } @@ -91,7 +93,7 @@ export function minimap_pins_near(minimap_st: mut MinimapState, x: float, z: flo } } if best < 0 { break } - push(out, best) + kept_push(out, best) } return out } diff --git a/packages/ludic.net/stun.ludic b/packages/ludic.net/stun.ludic index 4cf8016a..5cb7ddc1 100644 --- a/packages/ludic.net/stun.ludic +++ b/packages/ludic.net/stun.ludic @@ -2,8 +2,7 @@ # from outside: the router's address and the port it mapped function net__stun_send(net_st: mut NetState) -> void { - @alloc_ok("once: the transport's dice, seeded by its config the first time a STUN request goes") - if net_st.net__dice == null { net_st.net__dice = rng_new(net__conf(net_st).seed) } + if net_st.net__dice == null { net_st.net__dice = net__dice_new(net__conf(net_st).seed) } if net_st.net__stun_ip == 0 { let c = net__conf(net_st) if len(c.stun_at) > 0 and net_parse_code(net_st, c.stun_at) { @@ -63,3 +62,6 @@ function net__stun_packet(net_st: mut NetState, n: int) -> bool { # what this machine looks like from outside, once STUN has said (0 until then) export function net_outside_ip(net_st: NetState) -> int { return net_st.net__pub_ip } export function net_outside_port(net_st: NetState) -> int { return net_st.net__pub_port } + +@alloc_ok("once: the transport's dice, seeded by its config the first time a STUN request goes") +function net__dice_new(seed: int) -> Rng { return rng_new(seed) }