Make custom paths absolute

Then gCustomUserDataPath and relatant variables are set, they overwrite the gBasePath array, which uses absolute paths. This commit makes the custom paths absolute as well, to prevent issues with assumptions in the code (file dialog for example).
This commit is contained in:
Hielke Morsink committed 2018-02-08 14:23:21 +01:00
1 parent 04ea015302
commit e1b99479a2
1 file changed
+9 -4
+9 -4
View File
@@ -27,6 +27,7 @@
#include "../core/Memory.hpp"
#include "../core/Path.hpp"
#include "../core/String.hpp"
#include "../core/Util.hpp"
#include "../network/network.h"
#include "../object/ObjectRepository.h"
#include "../OpenRCT2.h"
@@ -197,25 +198,29 @@ exitcode_t CommandLine::HandleCommandDefault()
if (_userDataPath != nullptr)
{
String::Set(gCustomUserDataPath, sizeof(gCustomUserDataPath), _userDataPath);
utf8 absolutePath[MAX_PATH]{};
Path::GetAbsolute(absolutePath, Util::CountOf(absolutePath), _userDataPath);
String::Set(gCustomUserDataPath, Util::CountOf(gCustomUserDataPath), absolutePath);
Memory::Free(_userDataPath);
}
if (_openrctDataPath != nullptr)
{
String::Set(gCustomOpenrctDataPath, sizeof(gCustomOpenrctDataPath), _openrctDataPath);
utf8 absolutePath[MAX_PATH]{};
Path::GetAbsolute(absolutePath, Util::CountOf(absolutePath), _openrctDataPath);
String::Set(gCustomOpenrctDataPath, Util::CountOf(gCustomOpenrctDataPath), absolutePath);
Memory::Free(_openrctDataPath);
}
if (_rct2DataPath != nullptr)
{
String::Set(gCustomRCT2DataPath, sizeof(gCustomRCT2DataPath), _rct2DataPath);
String::Set(gCustomRCT2DataPath, Util::CountOf(gCustomRCT2DataPath), _rct2DataPath);
Memory::Free(_rct2DataPath);
}
if (_password != nullptr)
{
String::Set(gCustomPassword, sizeof(gCustomPassword), _password);
String::Set(gCustomPassword, Util::CountOf(gCustomPassword), _password);
Memory::Free(_password);
}