mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-03 12:25:27 +01:00
ac1ebd5426
A damaged or edited snapshot could put an index past a table, a count which takes forever or a number out of the range of its type into the simulation, and a file cut short was put back half way. - Reading a value: a whole number has to be whole and fit its type (an enum its underlying one), a float can't be past its largest value; what doesn't fit is refused. Every refusal names the entry, the key and the value, and goes to the log (errors.txt), up to 100 lines and a count. - Ranges: coupler ends 0 or 1 and the flags of a coupling; couplings which would close a ring of vehicles; the count of the points of a driver's table and of its point limits (not past the keys of the entry), the indices into the table (tablelast, semnext, semnextstop); the order stack and its position, the timetable station, the driver's enums and directions; the path, events and distance of an axle, facing and first axle; the date and time; switch states, made track ends, crossing segments, event siblings and times, launcher timers, the weather; the load (amount, and a name which isn't a path); the whole numbers inside number lists (flags of a table point, the stop of a coupler pair, the track flags under a vehicle, the fuse count of a power source, the cab of the vigilance device). - The positions of the controllers are brought within the ranges of the vehicle: master and secondary controller (set and actual), reverser, cabs, light, compressor and wiper switches, brake handle, hand brake, dimmer. - A document with problems isn't loaded unless --load-snapshot-force says so; a test run ends with the error code then. The header counts the entries, so a file cut between two entries is found too. A file of a newer version is a warning, not a problem. - A snapshot is written to <file>.tmp and renamed over the file only when the stream didn't fail. - Unit tests of the reader on damaged input.