commit
15b8b9910e
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user