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

2 Commits

Author SHA1 Message Date
Hirek 6aca6bc4f6 fix(review): an empty Load= no longer throws, and the stale notes of the review of #531
From the review of #531:
- Load= and UnLoad= without the name of a load threw std::out_of_range as
  soon as ParseVehicleCommand() read them: extract_value() reads past the end
  of the text when nothing but spaces follows the =. Before this branch the
  same exception came later, in the RunCommand() of a vehicle standing at the
  ramp. ParseVehicleCommand() gives an empty name now, which loads and
  unloads nothing (AssignLoad("") and LoadingDone() with no name, as for an
  empty vehicle). extract_value() itself is left as it was: it has hundreds
  of callers and test_utilities.cpp records its exception at the end of the
  text. New checks in test_vehicle_command.cpp.
- compression_at() is an inline function of physics/components/internal.h,
  as square() is, rather than a global function of external linkage defined
  in collisions.cpp; its body is the same
- the comment of train_type::sn61 says what the AI does for it (the master
  controller up to a position with torque after setting the direction)
  rather than that nothing handles it
- tests/unit/COVERAGE.md names the files as they are now (physics/components/,
  vehicle/dynamic/lifecycle.cpp) instead of physics/physics.cpp, a name the
  renaming script left there

The naming of AGENTS.md, which the review asked about, stays as it is.
2026-11-29 04:13:17 +01:00
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