feat(tapes): tape recording turns the black box on, not the physics log of every vehicle

The simulator now records the black box on its own ("blackbox yes") and writes the .dat tapes of the
vehicles the player was in when it closes, so the tapes no longer need "physicslog yes", which keeps a
log of every vehicle of the scenery open and written twenty times a second (some 500 files on
Tomaszewo, past what the runtime allowed).

- The settings have a box of their own for the black box and its tapes, next to the physics log of
  every vehicle, which stays for diagnostics.
- "Turn on recording" of the tapes' window turns the black box on.
- The key is read as the simulator reads it: with no line of its own it goes with the physics log. It
  is written where it says more than the physics log or where the file has it already, so an ini
  without it stays so.
- A launch is noted for the tapes with either one on; "live" follows a tape only with the physics log,
  as the black box writes its tapes at the end, and its tip says so.
This commit is contained in:
maj00r
2026-11-14 00:05:06 +01:00
parent 1ef630b1b6
commit 4429eff4ef
15 changed files with 149 additions and 16 deletions

View File

@@ -1302,4 +1302,86 @@ public class SettingsStoreTests
Assert.False(store.LoadFailed);
Assert.Equal(60, store.Settings.FieldOfView);
}
[Theory]
[InlineData("physicslog yes\n", true)]
[InlineData("physicslog no\n", false)]
[InlineData("physicslog yes\nblackbox no\n", false)]
[InlineData("physicslog no\nblackbox yes\n", true)]
public void The_black_box_goes_with_the_physics_log_unless_the_ini_says_otherwise(string ini, bool recorded)
{
var installation = WithHome(new InMemoryFileSystem().WithFile(UserIni, ini));
installation.SettingsStore.Load();
Assert.Equal(recorded, installation.SettingsStore.Settings.BlackBox);
}
[Fact]
public void Tapes_turned_on_write_the_black_box_and_leave_the_physics_log_off()
{
var installation = WithHome(new InMemoryFileSystem().WithFile(UserIni, "physicslog no\n"));
installation.SettingsStore.Load();
installation.SettingsStore.Settings.BlackBox = true;
installation.SettingsStore.Save();
Assert.Equal("blackbox yes", LineFor(installation, "blackbox"));
Assert.Equal("physicslog no", LineFor(installation, "physicslog"));
}
[Fact]
public void A_black_box_that_says_no_more_than_the_physics_log_adds_no_line()
{
var installation = WithHome(new InMemoryFileSystem().WithFile(UserIni, "physicslog yes\n"));
installation.SettingsStore.Load();
installation.SettingsStore.Settings.Width = 1600;
installation.SettingsStore.Save();
Assert.Null(LineFor(installation, "blackbox"));
}
[Theory]
[InlineData("physicslog yes\nblackbox yes\n")]
[InlineData("physicslog no\nblackbox yes\n")]
public void A_black_box_line_of_the_file_says_no_once_the_box_is_off(string ini)
{
var installation = WithHome(new InMemoryFileSystem().WithFile(UserIni, ini));
installation.SettingsStore.Load();
installation.SettingsStore.Settings.BlackBox = false;
installation.SettingsStore.Settings.PhysicsLog = false;
installation.SettingsStore.Save();
Assert.Equal("blackbox no", LineFor(installation, "blackbox"));
Assert.Equal("physicslog no", LineFor(installation, "physicslog"));
}
[Fact]
public void The_physics_log_turned_off_keeps_the_tapes_it_brought()
{
// an ini of before the black box had a key: the tapes came with the physics log
var installation = WithHome(new InMemoryFileSystem().WithFile(UserIni, "physicslog yes\n"));
installation.SettingsStore.Load();
installation.SettingsStore.Settings.PhysicsLog = false;
installation.SettingsStore.Save();
Assert.Equal("blackbox yes", LineFor(installation, "blackbox"));
}
[Fact]
public void A_black_box_line_written_once_goes_away_when_it_says_no_more()
{
var installation = WithHome(new InMemoryFileSystem().WithFile(UserIni, "physicslog no\n"));
installation.SettingsStore.Load();
installation.SettingsStore.Settings.BlackBox = true;
installation.SettingsStore.Save();
installation.SettingsStore.Settings.BlackBox = false;
installation.SettingsStore.Save();
Assert.Null(LineFor(installation, "blackbox"));
}
}

View File

@@ -40,6 +40,18 @@ public class StartSimulationTests
Assert.Contains($"vehicle\t{driven}\tPKP/EP07\tep07.mmd", noted);
}
[Fact]
public void With_the_black_box_alone_the_launch_is_noted_for_the_tapes_it_writes_at_the_end()
{
var (start, _, installation) = Rig(files => files.WithExecutable(Build), sceneryClock: "07:52");
installation.SettingsStore.Settings.BlackBox = true;
start.Execute(freeFly: false, saveSettings: false);
string noted = installation.Files.ReadAllText(TestInstallation.At("physicslog", "starter-launch.txt"));
Assert.Contains("clock\t07:52", noted);
}
[Fact]
public void Without_the_physics_log_nothing_is_noted()
{