Skip to main content

Module ltr

Module ltr 

Source
Expand description

LTR binary letter-table support. LTR binary reader and writer.

LTR resources store third-order Markov probability tables used by KotOR name generation.

§Shape of the container

A 9-byte header, then three probability blocks of first, second and third Markov order. Nothing points anywhere: every size falls out of the header’s letter_count, so the whole file is positional.

The recurring factor of three is position within a name – start, middle and end each carry their own distribution. At KotOR’s 28 letters the blocks are 3 x 28, 28 x (3 x 28) and 28 x 28 x (3 x 28) floats, which makes every file exactly 273,177 bytes. The engine closes its read by asserting the final offset equals the buffer length, so there is no slack: a file a byte off is rejected rather than partially accepted.

Byte-level field maps live in docs/src/formats/text/ltr.md, with the engine’s own load sequence.

Structs§

Ltr
In-memory LTR container.
LtrProbabilityBlock
One LTR probability block.

Enums§

LtrBinaryError
Errors produced while parsing or serializing LTR binary data.

Constants§

LTR_CHARACTER_COUNT
Number of letters in KotOR LTR tables (a-z, ', -).

Functions§

read_ltr
Reads an LTR file from a reader.
read_ltr_from_bytes
Reads an LTR file directly from bytes.
write_ltr
Writes an LTR file to a writer.
write_ltr_to_vec
Serializes an LTR file into a byte vector.