(Windows) Made the hack to remove double quotation marks on game launch slightly less dangerous

This commit is contained in:
Leon Styhre 2025-03-16 17:35:19 +01:00
parent 4dc5275303
commit 26472bccbc

View file

@ -1944,7 +1944,10 @@ void FileData::launchGame()
#if defined(_WIN64)
// Hack to remove double quotation marks as these can occur under some special circumstances.
command = Utils::String::replace(command, "\"\"", "\"");
const int quotationCount {static_cast<int>(
std::count_if(command.cbegin(), command.cend(), [](char c) { return c == '\"'; }))};
if (quotationCount % 2 != 0)
command = Utils::String::replace(command, "\"\"", "\"");
command = Utils::String::replace(
command, "%ESPATH%", Utils::String::replace(Utils::FileSystem::getExePath(), "/", "\\"));