write replays next to the executable

This commit is contained in:
2026-07-01 22:43:04 +02:00
parent 0a7e9a34ef
commit 5bc581bcb8

View File

@@ -10,6 +10,7 @@
#include <string>
#include <QColor>
#include <QCoreApplication>
#include <QCursor>
#include <QDir>
#include <QFont>
@@ -162,13 +163,15 @@ GameWorldView::GameWorldView(Simulation* sim, const GameConfig* config,
}
else
{
// Record every run to disk. Replays live under <data>/replays, alongside
// the config dir that was loaded. Attaching the recorder opens the first
// file and writes the header for the initial run.
QDir replayDir(QString::fromStdString(configDir));
replayDir.cdUp();
// Record every run to disk, into a "replays" folder next to the executable.
// Uses the exe's real directory rather than traversing up from the config
// dir: with a symlinked build layout, relative traversal would resolve into
// the wrong tree. Attaching the recorder opens the first file and writes the
// header for the initial run.
const QString replayDir =
QDir(QCoreApplication::applicationDirPath()).filePath("replays");
m_commandManager.setRecorder(std::make_unique<ReplayRecorder>(
configDir, replayDir.filePath("replays").toStdString()));
configDir, replayDir.toStdString()));
}
}