main: support running the app in Wine/Proton.

Turns out the flag I used for SHGetKnownFolderPath() is not only deprecated
starting with Win10 1703, but it also isn't implemented in Wine. It also was
completely useless because the Save Tool isn't a "packaged process", as the
docs call it. Ah, the joys of using WinAPI...
This commit is contained in:
Guillaume Jacquemin 2023-08-28 13:51:32 +02:00
parent 39d71a7a09
commit 81430de345
Signed by: williamjcm
SSH key fingerprint: SHA256:AYLOg+iTV0ElElnlu4vqM4edFazVdRiuQB0Y5LoKc4A
2 changed files with 11 additions and 3 deletions

View file

@ -198,9 +198,17 @@ SaveTool::findGameDataDirectory() -> bool {
wchar_t* localappdata_path = nullptr;
Containers::ScopeGuard guard{localappdata_path, CoTaskMemFree};
if(SHGetKnownFolderPath(FOLDERID_LocalAppData, KF_FLAG_NO_APPCONTAINER_REDIRECTION, nullptr, &localappdata_path) != S_OK)
auto result = SHGetKnownFolderPath(FOLDERID_LocalAppData, KF_FLAG_DEFAULT, nullptr, &localappdata_path);
if(result != S_OK)
{
_lastError = Utility::format("SHGetKnownFolderPath() failed with error code {}.", GetLastError());
char* message_buffer = nullptr;
auto size = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS,
nullptr, result, MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),
reinterpret_cast<char*>(&message_buffer), 0, nullptr);
String message{message_buffer, size};
LocalFree(message_buffer);
_lastError = Utility::format("SHGetKnownFolderPath() failed with error code {}: {}", result, message);
LOG_ERROR(_lastError);
return false;
}

View file

@ -45,7 +45,7 @@ int main(int argc, char** argv) {
Containers::StringView locale{str};
LOG_INFO_FORMAT("Current locale: {}", locale);
if(!locale.hasSuffix(".utf8")) {
if(!locale.hasSuffix(".utf8") && !locale.hasSuffix(".65001")) {
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error",
"Your system doesn't support UTF-8.", nullptr);
return EXIT_FAILURE;