From 78c7dd1303d9e6777c29c47be78930f984efb79c Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Sat, 21 Sep 2024 13:58:28 +0100 Subject: [PATCH] Fix #12945: Relative paths passed to -c were not made absolute (#12946) --- src/fileio.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fileio.cpp b/src/fileio.cpp index b1ecca60fa..a63f74dce2 100644 --- a/src/fileio.cpp +++ b/src/fileio.cpp @@ -822,11 +822,11 @@ void DetermineBasePaths(const char *exe) if (end == std::string::npos) { /* _config_file is not in a folder, so use current directory. */ tmp = cwd; - AppendPathSeparator(tmp); - _searchpaths[SP_WORKING_DIR] = tmp; } else { - _searchpaths[SP_WORKING_DIR] = _config_file.substr(0, end + 1); + tmp = FS2OTTD(std::filesystem::weakly_canonical(std::filesystem::path(OTTD2FS(_config_file))).parent_path()); } + AppendPathSeparator(tmp); + _searchpaths[SP_WORKING_DIR] = tmp; } /* Change the working directory to that one of the executable */