The serializer recovery reaches this repo as a generated wire schema
(include/generated/sots_stream_schema.h, 386 classes / 2042 items): for each
class, the ordered sequence of items its Write puts on the stream. Facts only —
no field offsets, no sizeof, no strides. This engine reads and writes the on-disk
format; it does not inherit the original's memory layout.
The table is a specification, not a program: the recovery is a linear pass over
Write, so it cannot see Write's branches (StarShip's BQ2 is gated on hbq but
listed unconditionally) and it flattens container loops. A codec driven off it
would desynchronise. The hand-written io() shapes stay the codec; SchemaProbe
(probe.h) walks them with every branch taken and test_wire_schema LCS-aligns
that against the table — 56 shapes bound, 657 items matched, 0 mismatches.
Four defects the check found, all invisible to a round-trip test:
- SystemParams field 1 is a string, not an int. It is the empty string in
every save, and an empty string is four zero bytes — byte-identical to the
int 0, so it round-tripped by luck. A named planet would have desynced.
- ObservedTech/ObservedWeapon odet is a bool, not an int. Byte-safe only
because a 4-char tag makes a bool item and an int item both 12 bytes.
- SpeciesRatios nv and ShipRecords srbd are counts, not fields.
CoverageArchive separates items a field names from items a Node merely carries,
because a byte-identical round trip is not a coverage claim. Typed coverage of a
real save goes 37.9% -> 97.1% (97.2/97.2/97.6 on the others) with the round trip
still byte-identical, by typing TechTree (both NumTechs sections), Events,
ShipRecs, sprjs, civr, comms, spy2, spymgr, aid, Ojvs, AIEnf, FNG, trdmgr and
the Des section/gun-bank tree. Ratchet at 95%.
trdmgr resolves a recorded trap: ServerTradeManager's Read/Write really are the
inherited no-op, but the call is virtual and ServerTradeManagerImpl has the real
serializer. Same shape resolves IServerSpyManager -> ServerSpyManager.
ctest 34/34, clean_room_check OK, test_save skips cleanly with SOTS_SAVES_DIR unset.
27 lines
1.5 KiB
CMake
27 lines
1.5 KiB
CMake
# mars/stream + mars/rng tests. test_save reads the owner's saves via SOTS_SAVES_DIR at run time
|
|
# and skips cleanly when it is unset (saves never enter the repo).
|
|
add_executable(mars_stream_test_rng test_rng.cpp)
|
|
target_link_libraries(mars_stream_test_rng PRIVATE mars_rng)
|
|
add_test(NAME mars_rng_unit COMMAND mars_stream_test_rng)
|
|
|
|
add_executable(mars_stream_test_stream test_stream.cpp)
|
|
target_link_libraries(mars_stream_test_stream PRIVATE mars_stream)
|
|
add_test(NAME mars_stream_unit COMMAND mars_stream_test_stream)
|
|
|
|
add_executable(mars_stream_test_save test_save.cpp)
|
|
target_link_libraries(mars_stream_test_save PRIVATE mars_stream mars_rng)
|
|
add_test(NAME mars_stream_save COMMAND mars_stream_test_save)
|
|
|
|
foreach(_t mars_stream_test_rng mars_stream_test_stream mars_stream_test_save)
|
|
target_include_directories(${_t} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
|
target_compile_options(${_t} PRIVATE -Wall -Wextra -Wpedantic)
|
|
endforeach()
|
|
|
|
# Conformance of the typed shapes against the wire schema recovered from the game's
|
|
# serializers (include/generated/sots_stream_schema.h). No game data: the generated
|
|
# table plus shapes.h, so this one always runs.
|
|
add_executable(mars_stream_test_wire_schema test_wire_schema.cpp)
|
|
target_link_libraries(mars_stream_test_wire_schema PRIVATE mars_stream sots_addresses)
|
|
add_test(NAME mars_stream_wire_schema COMMAND mars_stream_test_wire_schema)
|
|
target_include_directories(mars_stream_test_wire_schema PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
|
target_compile_options(mars_stream_test_wire_schema PRIVATE -Wall -Wextra -Wpedantic)
|