Write replays next to the executable

Place the "replays" folder in the executable's real directory
(QCoreApplication::applicationDirPath()) instead of traversing up from the
config dir with cdUp(). Relative traversal resolves incorrectly under a
symlinked build layout (landing in bin rather than the build tree); using the
exe's actual location avoids that. configDir is still passed for the config hash.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DUsFgd2Ga6pmLz8giS8WUn
This commit is contained in:
2026-07-01 22:40:45 +02:00
parent 0a7e9a34ef
commit aa0fd6c363

View File

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