Fix Wine
This commit is contained in:
parent
3982dfe5cc
commit
7e8d14120d
@ -5,14 +5,8 @@ namespace Components
|
|||||||
std::vector<std::string> Flags::EnabledFlags;
|
std::vector<std::string> Flags::EnabledFlags;
|
||||||
|
|
||||||
bool Flags::HasFlag(const std::string& flag)
|
bool Flags::HasFlag(const std::string& flag)
|
||||||
{
|
|
||||||
static auto parsed = false;
|
|
||||||
|
|
||||||
if (!parsed)
|
|
||||||
{
|
{
|
||||||
Flags::ParseFlags();
|
Flags::ParseFlags();
|
||||||
parsed = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const auto& entry : Flags::EnabledFlags)
|
for (const auto& entry : Flags::EnabledFlags)
|
||||||
{
|
{
|
||||||
@ -27,11 +21,17 @@ namespace Components
|
|||||||
|
|
||||||
void Flags::ParseFlags()
|
void Flags::ParseFlags()
|
||||||
{
|
{
|
||||||
|
static auto flagsParsed = false;
|
||||||
|
if (flagsParsed)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only parse flags once
|
||||||
|
flagsParsed = true;
|
||||||
int numArgs;
|
int numArgs;
|
||||||
auto* const argv = CommandLineToArgvW(GetCommandLineW(), &numArgs);
|
auto* const argv = CommandLineToArgvW(GetCommandLineW(), &numArgs);
|
||||||
|
|
||||||
assert(Flags::EnabledFlags.empty());
|
|
||||||
|
|
||||||
if (argv)
|
if (argv)
|
||||||
{
|
{
|
||||||
for (auto i = 0; i < numArgs; ++i)
|
for (auto i = 0; i < numArgs; ++i)
|
||||||
@ -40,7 +40,7 @@ namespace Components
|
|||||||
if (wFlag[0] == L'-')
|
if (wFlag[0] == L'-')
|
||||||
{
|
{
|
||||||
wFlag.erase(wFlag.begin());
|
wFlag.erase(wFlag.begin());
|
||||||
Flags::EnabledFlags.push_back(Utils::String::Convert(wFlag));
|
Flags::EnabledFlags.emplace_back(Utils::String::Convert(wFlag));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ namespace Components
|
|||||||
// Workaround for wine
|
// Workaround for wine
|
||||||
if (Utils::IsWineEnvironment() && Dedicated::IsEnabled() && !Flags::HasFlag("console") && !Flags::HasFlag("stdout"))
|
if (Utils::IsWineEnvironment() && Dedicated::IsEnabled() && !Flags::HasFlag("console") && !Flags::HasFlag("stdout"))
|
||||||
{
|
{
|
||||||
Flags::EnabledFlags.push_back("stdout");
|
Flags::EnabledFlags.emplace_back("stdout");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,9 +107,9 @@ namespace Utils
|
|||||||
void SetEnvironment()
|
void SetEnvironment()
|
||||||
{
|
{
|
||||||
wchar_t exeName[512];
|
wchar_t exeName[512];
|
||||||
GetModuleFileNameW(GetModuleHandle(nullptr), exeName, sizeof(exeName) / 2);
|
GetModuleFileNameW(GetModuleHandle(nullptr), exeName, sizeof(exeName) / sizeof(wchar_t));
|
||||||
|
|
||||||
wchar_t* exeBaseName = wcsrchr(exeName, L'\\');
|
auto* exeBaseName = wcsrchr(exeName, L'\\');
|
||||||
exeBaseName[0] = L'\0';
|
exeBaseName[0] = L'\0';
|
||||||
|
|
||||||
SetCurrentDirectoryW(exeName);
|
SetCurrentDirectoryW(exeName);
|
||||||
|
Loading…
Reference in New Issue
Block a user