Toward loading the logic by regions (docs/world-format-eu07.md, section 13, D4). The statement table keeps the
state of the tape at the start of each statement, the tape reader can move to a statement and read only to its
end (parser_tape::reader::seek, with the names of all the files of the tape), and the logic cache gives the
table back. With EU07_WORLD_REPLAY_ORDER set, a scenery replayed from its cache goes statement by statement,
each from its place on the tape with the transformations it was read with: "file" in the order of the file,
"regions" the statements of the whole package ahead of the regions, "regions-first" the regions first. A check
for the developers; without the variable the tape plays through as before.
The loop of deserialize_continue gives its dispatch to deserialize_statement(), and the transformations go
through transformations_of() and restore_transformations().
Checked in the game (--test 120 s, seed 1, world.binary 1):
- "file": the physics logs of td.scn and Glinojeck.scn the same bit for bit as from the files, so the moves on
the tape and the restored transformations give the very same scenery;
- "regions-first": the same bit for bit too, for both; the error logs hold the same lines in another order (the
models load in another order);
- "regions": td.scn ends up without vehicles, its trainsets read before the tracks they stand on. The first
thing D4 has to settle: the statements of the whole package that refer to the regions go after them.
A region loaded on its own has to set before each of its statements what the origin / rotate / scale
directives of the whole package set: the top of the origin stack and of the scale stack, if any, and the
rotation. The table now keeps a list of these contexts, as the bits of their numbers so they come back
exactly, and each statement the index of its context; a context is added only when it differs from the one
before. Nothing changes in what the game does.
Checked in the game (--test 120 s, seed 1, world.binary 1): the physics logs of td.scn and Glinojeck.scn the
same bit for bit as from the files, recorded and replayed. td.scn: 593 changes of the transformations over 1867
statements; Glinojeck.scn: 11 011 over 93 876.
Toward loading the logic by regions (docs/world-format-eu07.md, section 13, D4). While the tape of the logic
cache is recorded, the loader notes where each statement of the scenery begins on the tape and where it put
its first node or shape (basic_region::note_insert / take_insert, from insert() of nodes, shapes and lines),
and writes the table to the cache as a package block STMT: the offsets as differences and the region as a
tile of level 10 of the plane body (8192 m), or 0 for a statement of the whole package (an event with no
place, the time, the weather, a trainset, and the origin / rotate / scale directives). The logic still loads
whole, in the order of the tape, so nothing changes in what the game does.
Checked in the game (--test 120 s, seed 1, world.binary 1): the physics logs of td.scn and Glinojeck.scn the
same bit for bit as from the files, recorded and replayed. td.scn: 1867 statements in 4 regions, 1298 of the
whole package; Glinojeck.scn: 93 876 statements in 6 regions, 16 427 of the whole package. Loading a region on
its own will need the state of the transformations (origin, rotate, scale) at the start of each of its
statements, which the directives of the whole package set.
The parser tape kept a structure of about 70 bytes per token, so a scenery of 12 million tokens (Glinojeck)
took 1.8 GB at its peak while recorded and 1.5 GB while replayed, against 0.5 GB read from its files. The tape
is now written as it's recorded (parser_tape::writer, about 10 bytes a token) and decoded as it's replayed
(parser_tape::reader, tokens as views of the bytes); the names of the files are entries of the tape, and an
end mark tells a tape cut short. Glinojeck now peaks at 712 MB recorded and 601 MB replayed.
Checked in the game, on a test folder made of junctions to the data with a scenery folder of its own (nothing
was written into the SVN working copy): td.scn (23 481 entries, 29 files, a cache of 28 KB) and Glinojeck.scn
(11.9 million entries, 63 files, a cache of 8.5 MB), each run in --test for 120 s of simulation with seed 1
from the files with world.binary 0, then recorded and replayed with world.binary 1: the physics logs of every
train are the same bit for bit in all runs, and so are the error logs.
Step 2d of docs/world-format-eu07.md (#516). With world.binary 1 in eu07.ini (off by default; then nothing is
written and nothing changes) the loader looks for <scenery>.logic.eu07 in the folder of the sceneries:
- current: made by this build (GIT_HASH and SRC_DATE), from the files the tape names as they are now (names,
sizes, times of the last change) and with the same load settings (traction loaded, the binary terrain file
standing in for the terrain includes, the text put ahead of the scenery, the trainset overrides): the
scenery is replayed from the tape through the same parsers, with no file opened and no include expanded;
- not there or not current: the scenery is read from its files as before, the parser records its tape, and
the cache is written once the scenery is loaded, through a temporary file. The log says which of the two.
Never in the editor, which keeps track of the files of the nodes, nor for a Rainsted override ($.scn).
The cache file gains package blocks, data of the whole package rather than of a tile; the tape goes into them
in parts of at most 64 MB until the logic is split into regions (step 3). The SBT check moved ahead of the
parser, unchanged, as the cache depends on it.
Not checked yet in the game: that a run from the replayed scenery gives the same physicslog bit for bit.
Tests: the cache file name, FNV-1a, package blocks written and read back, and the logic cache read back while
current and refused for another build, other settings or a changed included file.