ludic/packages/ludic.base/index.ludic
Orkuncakilkaya c592974055 ludic.base: baked files - the header, baked_open, a streamed reader, the inputs hash (ludic bake's API)
What is deterministic is made at build time by the game's own code (`ludic bake`) and read at run
time. baked.ludic, baked_hash.ludic, baked_stream.ludic:

- The header, 32 bytes little-endian: "LBAK" | u32 format (BAKE_FORMAT 1) | u32 generator version |
  u32 payload offset | u64 inputs hash | u64 payload length | then the key (UTF-8, zero-padded to 8),
  then the payload at its offset, whose layout is the bake's own.
- bake_write(path, key, version, inputs_hash, payload, n) makes the directories and writes it;
  bake_inputs_hash(inputs) is FNV-1a 64 over each space-separated input: its path, a 0, its bytes.
- baked_open(path, key, version) -> []byte: the payload as a view of the file (no copy), or null for
  a missing file or another format, key or version. The runtime never hashes inputs; `ludic bake
  --check` holds a baked file to them at build time.
- baked_open_range(path, key, version) -> BakedFile kept open (header checked once),
  baked_read(bf, at, n, into) -> count read into the caller's buffer from payload offset `at`
  (held to the buffer and the payload), baked_len, baked_close: a streamed bake (placements by chunk,
  terrain by tile) with nothing made per read. Pack-aware through file_open: on macOS a packed entry
  is an fmemopen over the mapped pack (a seek is free), on Windows a temporary copy of the entry made
  once when it is opened.
- baked_path(map, file), bake_missing(bake_st, key) (a dev build's line, once a key).

tests/baked_test.ludic: a payload round-trips for its key and version only, a streamed read at an
offset and one past the end, the inputs hash follows path and bytes. Written, type-checked, not run
(compile-only rule).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 17:21:02 +03:00

34 lines
985 B
Text

# ludic.base - what a mechanic may use and nothing else: the frame it is handed, the phases
# that order it, queues for the facts it reports, its own dice, its save section, its system
module ludic_base uses
numbers float
import "tick.ludic"
import "kept.ludic"
import "handle.ludic"
import "queue.ludic"
import "queue_ring.ludic"
import "text_buf.ludic"
import "text_intern.ludic"
import "text_ring.ludic"
import "baked.ludic"
import "baked_hash.ludic"
import "baked_stream.ludic"
import "rng.ludic"
import "save.ludic"
import "save_fields.ludic"
import "system.ludic"
import "ecs_table.ludic"
import "ecs_hooks.ludic"
import "ecs_table_remove.ludic"
import "ecs_table_reserve.ludic"
import "ecs_table_set.ludic"
import "ecs_grid.ludic"
import "ecs_grid_file.ludic"
import "ecs_grid_query.ludic"
import "ecs_grid_within.ludic"
import "ecs_grid_where.ludic"
import "ecs_index.ludic"
import "ecs_index_slot.ludic"
import "ecs_map.ludic"
import "ecs_plan.ludic"
import "ecs_group.ludic"