Merge pull request #210 from diamante0018/fix-comp

Fix Wine
This commit is contained in:
Dss0 2022-04-05 12:55:13 +02:00 committed by GitHub
commit 15b8b9910e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 13 deletions

View File

@ -6,13 +6,7 @@ namespace Components
bool Flags::HasFlag(const std::string& flag)
{
static auto parsed = false;
if (!parsed)
{
Flags::ParseFlags();
parsed = true;
}
Flags::ParseFlags();
for (const auto& entry : Flags::EnabledFlags)
{
@ -27,11 +21,17 @@ namespace Components
void Flags::ParseFlags()
{
static auto flagsParsed = false;
if (flagsParsed)
{
return;
}
// Only parse flags once
flagsParsed = true;
int numArgs;
auto* const argv = CommandLineToArgvW(GetCommandLineW(), &numArgs);
assert(Flags::EnabledFlags.empty());
if (argv)
{
for (auto i = 0; i < numArgs; ++i)
@ -40,7 +40,7 @@ namespace Components
if (wFlag[0] == L'-')
{
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
if (Utils::IsWineEnvironment() && Dedicated::IsEnabled() && !Flags::HasFlag("console") && !Flags::HasFlag("stdout"))
{
Flags::EnabledFlags.push_back("stdout");
Flags::EnabledFlags.emplace_back("stdout");
}
}
}

View File

@ -107,9 +107,9 @@ namespace Utils
void SetEnvironment()
{
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';
SetCurrentDirectoryW(exeName);