18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-01 12:57:06 +01:00
Commit Graph

2 Commits

Author SHA1 Message Date
Hirek e5639e9d48 refactor(physics): the commands between the vehicles are VehicleCommand, not text
The vehicles of a train passed their commands to each other as strings
(SendCtrlToNext("MainCtrl", ...)), and RunCommand() found out what to do by
comparing the text with 54 names. A misspelt name compiled and did nothing.

- physics/vehiclecommand.h/.cpp: enum class VehicleCommand, one value for
  each command a vehicle knows, plus none and unknown; ParseVehicleCommand()
  reads a text, VehicleCommandName() gives the name back
- SendCtrlToNext(), SetInternalCommand(), RunCommand() and its groups take
  VehicleCommand; Load= and UnLoad= carry the name of the load as the
  argument of RunCommand()
- the text is read once, where a command comes as text: PutCommand() (the
  events, Lua, the AI). TCommand keeps that text, as the AI reads the
  commands it knows itself (SetVelocity...) from it
- two commands sent but known to no vehicle stay as they were, passed on and
  not done: EpFuseSwitch and SandboxAutoAllow
- removed the unused GetExternalCommand(), CommandOut, ValueOut and
  CommandLast (written, never read)
- the names are the ones the sceneries and scripts have always used, compared
  exactly; new tests check that every command reads back from its name

No change in behaviour: 1144/1144 tests (2 new), golden traces exact against
staging 62f7a29b.
2026-11-27 20:40:13 +01:00
Hirek 653aec7fbe refactor(physics): physics/mover.cpp split into the files of its subsystems
The 15 900 lines of mover.cpp go into physics/mover/, a file for each part of
the vehicle, from 220 to 1850 lines:

  mover.cpp           the vehicle as a body: construction, forces, movement
  couplers.cpp        attaching, detaching, coupler forces, automatic coupling
  collisions.cpp      collisions of the ends, crush, derailment, repair
  pneumatics.cpp      brake controls, pipes, valves, compressor, spring brake
  electrics.cpp       batteries, main switch, pantographs, converter, heating,
                      lights, genset
  traction.cpp        traction motors and forces of each drive, relays, fuses,
                      dynamic brake
  controllers.cpp     master and secondary controllers, automatic relay,
                      camshaft, integrated controller, speed control
  diesel.cpp          diesel engine, gearbox, clutch, hydraulic transmission
  cab.cpp             cab activation, direction, horns
  doors.cpp           doors and the load exchange
  securitysystem.cpp  vigilance, cab signalling, radio-stop
  commands.cpp        commands passed between the vehicles
  fizparser.cpp       reading the .fiz: the parser and its tables
  fizsections.cpp     reading the .fiz: the sections and their keywords
  setup.cpp           checks, brake valves, handles and pipes after loading

Every definition moved as it was, byte for byte, in its original order. The
helpers of the anonymous namespaces went with the file using them; the seven
used by several files (CouplerTune, square, DirPatch, DirF,
TableInterpolation, compression_at, issection) are declared or defined in
physics/mover/internal.h, which only these files include.

`git blame -C -C` follows the lines into the new files.

1142/1142 tests, golden traces exact against staging 62f7a29b.
2026-11-27 17:47:24 +01:00