Read the last run's log before a start has to

A start notes down which vehicles the player drove in the run before, as the
log begins anew. With the tape window never opened nothing of a long run's log
had been read yet, and Start waited on the whole of it. It is now read off the
UI thread when the simulator exits and when the starter opens.
This commit is contained in:
maj00r
2026-11-03 21:51:54 +01:00
parent 306bdc44df
commit 02ea1277fc
2 changed files with 23 additions and 0 deletions

View File

@@ -113,6 +113,17 @@ public sealed class HaslerTapes
} }
} }
/// <summary>
/// Reads what the log of the last launch has gained since the last look. A start
/// notes that down before the log begins anew, and after a long run, with nothing
/// read of it yet, it would wait on the whole log.
/// </summary>
public void FollowLastRun()
{
if (Launches().LastOrDefault() is { } launch)
PlayerIn(launch);
}
/// <summary> /// <summary>
/// The launches noted so far, oldest first. Read again only when the file has /// The launches noted so far, oldest first. Read again only when the file has
/// changed: this runs every few seconds next to a running simulator. /// changed: this runs every few seconds next to a running simulator.

View File

@@ -103,6 +103,7 @@ public partial class MainWindow : Window
_openedUtc = DateTime.UtcNow; _openedUtc = DateTime.UtcNow;
UpdateStartButton(); UpdateStartButton();
_sceneryFilesTimer.Start(); _sceneryFilesTimer.Start();
FollowLastRun();
}; };
Activated += (_, _) => CheckExternalSettings(); Activated += (_, _) => CheckExternalSettings();
_sceneryFilesTimer.Tick += async (_, _) => await LookAtSceneryFilesAsync(); _sceneryFilesTimer.Tick += async (_, _) => await LookAtSceneryFilesAsync();
@@ -693,11 +694,22 @@ public partial class MainWindow : Window
_ = simulator.WaitForExitAsync().ContinueWith(_ => Dispatcher.UIThread.Post(() => _ = simulator.WaitForExitAsync().ContinueWith(_ => Dispatcher.UIThread.Post(() =>
{ {
AppServices.Current.State.SimulatorRunning = false; AppServices.Current.State.SimulatorRunning = false;
FollowLastRun();
RestoreFromSimulator(); RestoreFromSimulator();
ReportIfCrashed(simulator, executable, started); ReportIfCrashed(simulator, executable, started);
}), TaskScheduler.Default); }), TaskScheduler.Default);
} }
/// <summary>
/// The player's vehicles in the last run, read from its log off the UI thread
/// while nobody waits: the next start has to have them before the log begins anew.
/// </summary>
private static void FollowLastRun()
{
if (AppServices.Current.Settings.PhysicsLog)
_ = Task.Run(AppServices.Current.Tapes.FollowLastRun);
}
/// <summary> /// <summary>
/// Says why the simulator is gone when it did not end the way a session does: /// Says why the simulator is gone when it did not end the way a session does:
/// an error code, or a close so soon after the start that nobody played - a /// an error code, or a close so soon after the start that nobody played - a