mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-02 14:16:48 +01:00
e27d3b7e73
The safety net of the track editor before its domain model changes (E0 of
editor-tracks-tests.md): what the editor reads from the scenery files and
writes back is read, written and read again in tests/unit, with no game data.
Tracks (test_track_text.cpp, data/tracks/). Entries written the way the game
writes them, read by TTrack::Load() and written by export_as_text(), come out
byte for byte the same, and read again give the same track field by field:
plain tracks with all their attributes (events, speed, isolated, overhead,
vradius, rail profile, friction cell), a curve with cant, radius, uneven,
buckle, cwr and sleeper models, a bridge, switches with trackbed, frogs,
movable nose, blades, uneven of both paths and timbers, a turntable, paths of
pieces, the speeds +40, -40, 0.5, 0 and none of tracks, switches and
turntables, a river, a tributary, a road and a crossing. What the game writes
otherwise than given is checked as it is (table as turn, mountain as
mountains, the length of the path, a switch heard from 10 m, the events in
order, names in lower case, model paths with forward slashes, the texture
length, rolls as floats, no overhead and no vradius left out).
The seam: TTrack built from text with no scene. The engine stubs of the tests
had none of it, so the tests link the few sources reading and writing a track
takes (world/Track.cpp, Segment.cpp, TrackUneven.cpp, MemCell.cpp,
scene/scenenode.cpp, utilities/Timer.cpp, rendering/geometrybank.cpp) and
track_stubs.cpp stands in for the rest: a renderer keeping the materials by
their names, and the scene, events, vehicles and the geometry of the rails,
which reading and writing never reach and which stop the test with their name
if one does. It tests the game's own Load() and export, where a parser of its
own would have meant rewriting Load(), and changes no code of the game. The
stub of basic_node::radius_() goes, scenenode.cpp brings the real one. The
rails don't buckle in the tests (TrackBuckle.cpp needs the environment), the
buckle declared is read and written either way; material names go through a
stand-in, the game's material manager isn't tested here.
The //$ lines (test_editor_records.cpp, data/records/). Their readers and
writers were members of editor_mode, srk_tool and the stores, with the scene
around them; they move as they were into editor/editorRecords.cpp, the one
place each kind is read and written, which the stores call (and which the
migration to the project file of E3 will need apart anyway). The methods of
scene::layer_context move into scene/scenelayercontext.cpp so it links alone.
Each kind, h r k p t w b s c o z, read from golden lines and written back comes
out the same, in the coordinates of the file and of a file placed at an
origin; //$e, the descriptions of the templates, read and saved by
editor_includes in a template in a scratch folder, leaves the file as it was.
Cant (test_cant.cpp). The paths an alignment lays roll by asin(cant/gauge),
signed with the turn, back to the cant of the line at every end; a curve the
other way rolls the other way. At a joint editor_track::match_rolls() gives
the joined track the roll for the travel across it, turned where the paths
face or stand back to back, and the track written keeps it. The inspector's
own conversion on 1500 mm stays in its lambdas here; named, as
editor_mode::cant_of_roll()/roll_of_cant(), it comes with the quick fixes.
Known bugs found, tests of the change each (doctest::should_fail, passing
until fixed, then reported to drop the decorator), data/tracks/known_lost.scn:
- angle1/angle2 are read and dropped: not written back.
- fouling1/fouling2 are read and dropped: not written back.
- name@circuit: the circuit is taken out of the name with the letter before
the @ ("tor1@iso1" becomes track "tor"; substr(0, i - 1)).
- the attributes of the entry (gauge, friction, texture sizes, speed...) are
written to 6 significant digits, a float has 9: more digits are lost on the
first save.
None in the //$ lines.
Unit tests: 957 cases before, 974 after, all passing.
32 lines
2.5 KiB
Plaintext
32 lines
2.5 KiB
Plaintext
// //$h: horizontal alignments designed in the track editor, as editor_records::alignment_lines() writes them. The element lines are
|
|
// the ones the design makes (alignment::compute()), which the editor writes in place of those it read
|
|
//$h # horizontal alignments designed in the track editor, the simulation skips these lines
|
|
//$h alignment 0.0000 0.0000 0.0000 1000.0000 0.0000 1000.0000
|
|
//$h source designed origin 1200.0000 shape clothoid speed 100.0 fit 0.125
|
|
//$h ends 0.000000000 1.000000000 1.000000000 0.000000000 0.000000 0.000000 0.000 0.000
|
|
//$h norms 1500.0 0.600 150.0 35.0 10.00 0.300 2.00 30.00 0.400
|
|
//$h pieces 3 2.000
|
|
//$h vertex 0.0000 1000.0000 0.0000 400.000 60.000 60.000 80.0 0 0 0.500000000 0
|
|
//$h click 0.0000 0.0000 50.0000
|
|
//$h element straight -1 0.0000 569.6307 0.000 0.000 0.0 0.0000 0.0000 0.000000000 1.000000000
|
|
//$h element transition 0 569.6307 60.0000 0.000 -400.000 80.0 0.0000 569.6307 0.000000000 1.000000000
|
|
//$h element arc 0 629.6307 568.3185 -400.000 -400.000 80.0 1.4994 629.5970 0.074929707 0.997188818
|
|
//$h element transition 0 1197.9492 60.0000 -400.000 0.000 80.0 370.4030 998.5006 0.997188818 0.074929707
|
|
//$h element straight -1 1257.9492 569.6307 0.000 0.000 0.0 430.3693 1000.0000 1.000000000 0.000000000
|
|
//$h end
|
|
//$h alignment 2000.0000 0.0000 0.0000 3000.0000 0.0000 2000.0000
|
|
//$h source traced origin 0.0000 shape parabola speed 80.0
|
|
//$h ends 0.000000000 1.000000000 1.000000000 0.000000000 0.000000 0.000000 1200.000 0.000 turns 1 0 curved 1 0 60.0 0.0
|
|
//$h norms 1500.0 0.600 150.0 35.0 10.00 0.300 2.00 30.00 0.400
|
|
//$h pieces 2 1.500
|
|
//$h kept 10.0000 1500.0000
|
|
//$h vertex 2000.0000 2000.0000 0.0000 600.000 50.000 50.000 70.0 0 1 0.500000000 1 900.000 40.000 0.500000000 cants 70.0 50.0 ramps 0.000 -1.000 5.000 60.000
|
|
//$h element straight -1 0.0000 1289.6263 0.000 0.000 0.0 2000.0000 0.0000 0.000000000 1.000000000
|
|
//$h element transition 0 1289.6263 50.0000 0.000 -600.000 70.0 2000.0000 1289.6263 0.000000000 1.000000000
|
|
//$h element arc 0 1339.6263 433.7389 -600.000 -600.000 70.0 2000.6944 1339.6176 0.041654611 0.999132070
|
|
//$h element transition 0 1773.3652 40.0000 -600.000 -900.000 70.0 2167.1634 1729.9587 0.692223009 0.721683660
|
|
//$h element arc 0 1813.3652 650.6083 -900.000 -900.000 50.0 2195.6917 1757.9894 0.731227954 0.682133183
|
|
//$h element transition 0 2463.9735 50.0000 -900.000 0.000 50.0 2784.6148 1999.5371 0.999614222 0.027774206
|
|
//$h element straight -1 2513.9735 165.3891 0.000 0.000 0.0 2834.6109 2000.0000 1.000000000 0.000000000
|
|
//$h end
|