mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-19 22:44:59 +01:00
fix(blackbox): the tapes go on after the editor, with the physics logs off
The tapes of the user's vehicles were written by update() after the check for the writer of the recording, which close() drops on entering the editor (F11). With "physicslog no", the speed recorder's tape ended at F11 while the drivers' own logs of "physicslog yes" went on. The tapes are files of their own: they are kept from the moment the recording was to be made, the file made or not, closed or not, until the simulator closes, after the gap of the time in the editor. Only the recording itself stops at F11, as before. Reported in the review of #385. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -30,7 +30,8 @@ for a while doesn't lose its lines: they are written once it can be, the last 64
|
||||
|
||||
The recording starts once the scenery is loaded and ends when the simulator closes. Going into the
|
||||
editor (F11) ends it too, since the editor may take away the tracks and the vehicles it refers to; no
|
||||
new one starts when driving goes on after that.
|
||||
new one starts when driving goes on after that. The `.dat` logs it gives with the physics logs off go on
|
||||
then, after the gap of the time in the editor, until the simulator closes: they are files of their own.
|
||||
|
||||
It is written as the session goes and flushed once a second, so the file can be read while the simulator
|
||||
still writes it, and after a crash all but the last second is there. A file without the `end` record
|
||||
|
||||
@@ -238,22 +238,26 @@ void blackbox_recorder::update(double const Deltatime) {
|
||||
// "blackbox yes" or "no" of eu07.ini decides by itself, with no entry it goes with the physics logs
|
||||
if (false == Global.BlackBox.value_or(WriteLogFlag || WriteTrainLogFlag) || Global.editor_session)
|
||||
return;
|
||||
m_taping = true;
|
||||
open();
|
||||
}
|
||||
if (m_writer == nullptr)
|
||||
if (false == m_taping)
|
||||
return;
|
||||
|
||||
std::scoped_lock lock{m_mutex};
|
||||
m_time += Deltatime;
|
||||
if (m_time >= m_cabdue) {
|
||||
write_cab();
|
||||
m_cabdue = std::max(m_cabdue + cabinterval, m_time);
|
||||
}
|
||||
// with the physics logs on, each driver writes its own all the time
|
||||
// with the physics logs on, each driver writes its own all the time. the tapes are files of their own: they go on
|
||||
// after the recording ends in the editor, and with a recording which couldn't be made
|
||||
if (false == WriteLogFlag && m_time >= m_tapedue) {
|
||||
keep_tape_line();
|
||||
m_tapedue = std::max(m_tapedue + tapeinterval, m_time);
|
||||
}
|
||||
if (m_writer == nullptr)
|
||||
return;
|
||||
if (m_time >= m_cabdue) {
|
||||
write_cab();
|
||||
m_cabdue = std::max(m_cabdue + cabinterval, m_time);
|
||||
}
|
||||
if (m_time >= m_cameradue) {
|
||||
write_camera();
|
||||
m_cameradue = std::max(m_cameradue + camerainterval, m_time);
|
||||
|
||||
@@ -32,13 +32,14 @@ enum class user_command;
|
||||
namespace simulation {
|
||||
|
||||
// the black box of the session (see blackbox_doc.md): written along with the physics logs, in driver mode,
|
||||
// from the moment the scenario is loaded until the simulator closes or the editor is entered
|
||||
// from the moment the scenario is loaded until the simulator closes or the editor is entered. the tapes of the user's
|
||||
// vehicles, with the physics logs off, go on after the editor until the simulator closes
|
||||
class blackbox_recorder {
|
||||
public:
|
||||
// starts the recording once the scenario is ready, if it is to be made, then records what is due.
|
||||
// Deltatime: simulation time passed since the last call
|
||||
void update(double Deltatime);
|
||||
// writes the end of the recording and closes the file. a recording closed isn't started again
|
||||
// writes the end of the recording and closes the file. a recording closed isn't started again; its tapes go on
|
||||
void close();
|
||||
|
||||
// what happens between the looks, from wherever it happens; the cabs may run on threads of their own.
|
||||
@@ -112,6 +113,7 @@ private:
|
||||
std::ofstream m_file;
|
||||
std::unique_ptr<blackbox::writer> m_writer;
|
||||
bool m_started{false}; // tried to start, made or not
|
||||
bool m_taping{false}; // the recording was to be made: its tapes are kept from then on, the file made or not, closed or not
|
||||
double m_time{0.0};
|
||||
double m_cabdue{0.0};
|
||||
double m_tapedue{0.0};
|
||||
|
||||
Reference in New Issue
Block a user