- deserialize_ordered plays each statement as the loop over the tape
does, up to the next statement: a stray token is a keyword there too,
and the read that ends the part replays what the tape holds after the
statement (the closes of the files it ends), before the load ends.
- reader::seek points at the table of files instead of copying it for
each statement.
- The table of statements and the files are kept only when an order is
asked for, the only time they are read.
- EU07_WORLD_REPLAY_ORDER is described as the debugging aid it is: the
region orders don't load a real scenery yet.
- A test replays the statements of a recorded tape one by one through
seek() and compares them with the tape played through.
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 2c of docs/world-format-eu07.md (#516, section 7): the logic layer of the cache holds the node definitions as
tokens read back through today's parsers. cParser::startRecording() makes the outermost parser write down every
token as it comes out to the reader (includes expanded, template parameters put in, injected text included),
with what the reader may ask about it (Name, Line, LineMain, TokenBegin/End, InLayerFile), and the side effects
the includes have on the way: the node groups of *.inc templates opened and closed, and the terrain files the
binary terrain stands in for. A parser made from the tape gives the same reader the same answers and repeats
the side effects at the same places, with no file opened: injectString() does nothing there, as the tape holds
the injected tokens already. The reads the parser makes for itself (the name and parameters of an include) are
not recorded.
With a tape the fast path that takes model entries straight from the text is off (remainingText() is empty),
so every token goes through the tape. The loader takes the case-kept header of a node from the new
headerText(4), its first four words: the same words as before, recorded and replayed as a text entry. Without
a tape nothing changes.
parser_tape::write/read keep a tape as bytes, the state of a token as differences from the one before in
variable-length integers.
Tests: a reader asking the way the loader does (several tokens, case-kept ones, a vector, a look ahead, the
header) gets the same transcript from the files with and without recording and from the tape through bytes,
with templates, parameters, nested includes, injected text and traction loaded or left out; the node groups
are on the tape, a skipped terrain file is counted on replay as on the first reading, and a cut or foreign
tape doesn't read.