Skip to content

Commit b60bf6b

Browse files
committed
fixed -loadgame for absolute paths
1 parent bd3c01c commit b60bf6b

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

Sources/MainWindow.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3137,7 +3137,8 @@ MainWindow::ShellCommand MainWindow::generateLaunchCommand( const QString & base
31373137
}
31383138

31393139
//-- launch mode and parameters ------------------------------------------------
3140-
// Beware that -loadgame must be relative to -savedir, while -record and -playdemo are relative to the working dir.
3140+
// Beware that -loadgame must be relative to -savedir (cannot be absolute),
3141+
// while -record and -playdemo are either absolute or relative to the working dir.
31413142

31423143
LaunchMode launchMode = getLaunchModeFromUI();
31433144
if (launchMode == LaunchMap)
@@ -3148,7 +3149,7 @@ MainWindow::ShellCommand MainWindow::generateLaunchCommand( const QString & base
31483149
{
31493150
// save dir cannot be empty, otherwise the saveFileCmbBox would be empty
31503151
QString saveBaseDir = getSaveDir(); // ui->saveDirLine or engine.configDir
3151-
PathContext saveBase( saveBaseDir, pathContext.baseDir(), pathContext.pathStyle(), quotePaths );
3152+
PathContext saveBase( saveBaseDir, pathContext.baseDir(), PathStyle::Relative, quotePaths );
31523153
QString savePath = getPathFromFileName( saveBaseDir, ui->saveFileCmbBox->currentText() );
31533154
p.checkFilePath( savePath, "the selected save file", "Please select another one." );
31543155
cmd.arguments << "-loadgame" << saveBase.rebaseAndQuotePath( savePath );

Sources/Utils/FileSystemUtils.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,11 @@ inline QString getPathFromFileName( const QString & dirPath, const QString & fil
176176
return QDir( dirPath ).filePath( fileName );
177177
}
178178

179+
inline QString getAbsolutePathFromFileName( const QString & dirPath, const QString & fileName )
180+
{
181+
return QDir( dirPath ).absoluteFilePath( fileName );
182+
}
183+
179184
inline QString getFileNameFromPath( const QString & filePath )
180185
{
181186
return QFileInfo( filePath ).fileName();

0 commit comments

Comments
 (0)