The two derived words the per-player turn record's ship census counts by, and the design serializers that three lanes had been told did not exist. HOW DESIGNS PERSIST. Game::ShipDesign derives from Game::ShipDesignDef and reaches IStreamable through adjustor thunks, so a design is written by TWO serializers: the base emits FAIDes/DHide/DWep/DName and exactly three section frames (command, mission, engine on the wire), the derived one appends Dtc, the Dwgv flag and, only when that flag is set, a weapon-group frame. The earlier "the writer makes no stream call at all" note named an address that is in no vftable at all. Corrected in shapes.h. THREE sections, not five. The "two reserved slots" were Dtc and Dwgv swept into the section list by the reference reader's catch-all tail; the constructor builds a three-element array. design.h's comment is corrected and the fixture loader now accepts 3-5 raw_slots so old fixtures still load; the array keeps five inert entries deliberately, since touching the slot enum reaches rules.cpp and another lane's tests for no behavioural gain. DWep and Dwgv are bools, not ints -- both writers call the bool primitive. With four-character tags a bool item and an int item are the same size on the wire and 0/1 the same bytes, so no save can tell them apart. Byte-neutral: the typed round trip is still byte-identical on all 11 saves at 100% named coverage. HULL SIZE is the section_class of the last resolved section in memory slot order, mapped Destroyer/Cruiser/Dreadnought -> 0/1/2 case-insensitively, with absent or unrecognised meaning 0 rather than an error. The DEFENCE-PLATFORM flag is one bit of a 64-bit role-flag word OR-ed across the design's sections. Neither is on the wire; both are rebuilt from the section catalog. MEASURED, not assumed: the new game_design_census test rebuilds the six census counters per player and compares them against the record the game archived for each save's own frame. 11 saves, 503 designs, 480 leaves, 0 mismatched, 0 ships with an unresolvable design, 0 designs where first- and last-resolved section disagree on hull size. COVERAGE IS THIN AND THE TEST SAYS SO: only 32 of the 480 leaves are nonzero, and three of the six census leaves (both cruiser rows and dreadnought platforms) are never exercised by any save in the corpus -- the test prints the per-leaf nonzero counts and names them unexercised rather than verified. Nothing is wired into the turn record: src/app is another lane's this cycle, so this is evaluated and reported, not written. host ctest 43/43 (was 42/42; +1, skips cleanly without the env). With a data root set, game_data_realdata and mars_text_realdata fail identically on main -- both are the absent Locale/EN/Strings.csv, not this change. clean-room OK. Reference readers fixed openly in the RE repo: save_reader 49/49, design rules 32/32, stock_designs.json regenerated (raw_slots 5->3 and dWep int->bool are the only field changes across all 127 designs).
25 lines
1.7 KiB
CMake
25 lines
1.7 KiB
CMake
# Optional CMake wiring for the game_design tests; the canonical runner is
|
|
# build_and_run.sh (plain g++). Include from the root with
|
|
# add_subdirectory(tests/game_design) after add_subdirectory(src/game/design).
|
|
add_executable(game_design_unit_tests
|
|
test_main.cpp mini_catalog.cpp test_structure.cpp test_banks.cpp test_tech.cpp test_stats.cpp test_hull.cpp test_json.cpp)
|
|
target_link_libraries(game_design_unit_tests PRIVATE game_design)
|
|
target_include_directories(game_design_unit_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
|
add_test(NAME game_design_unit COMMAND game_design_unit_tests)
|
|
|
|
add_executable(game_design_realdata_test stock_designs.cpp realdata_test.cpp)
|
|
target_link_libraries(game_design_realdata_test PRIVATE game_design)
|
|
target_include_directories(game_design_realdata_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
|
add_test(NAME game_design_realdata COMMAND game_design_realdata_test) # SKIPs without SOTS_DATA_DIR + SOTS_DESIGNS_JSON
|
|
|
|
add_executable(game_design_dump_designs stock_designs.cpp dump_designs.cpp)
|
|
target_link_libraries(game_design_dump_designs PRIVATE game_design)
|
|
target_include_directories(game_design_dump_designs PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
# The ship census against the census the game archived; needs the owner's saves
|
|
# AND a data root, and skips cleanly without either.
|
|
add_executable(game_design_census_test test_census_saves.cpp)
|
|
target_link_libraries(game_design_census_test PRIVATE game_design mars_stream)
|
|
target_include_directories(game_design_census_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
|
target_compile_options(game_design_census_test PRIVATE -Wall -Wextra -Wpedantic)
|
|
add_test(NAME game_design_census COMMAND game_design_census_test)
|