Skip to content

Commit

Permalink
search: use publisher name instead of DisplayName
Browse files Browse the repository at this point in the history
The DisplayName can change between regions. For example, ZUN's games will use
"東方" when the system language is anything but English, where it will use
"Touhou" instead. It also isn't really reliable, with games like Touhou 14.3
and Touhou 18.5 not starting with "東方" (we had to make an exception for
Touhou 14.3, and Touhou 18.5 actually wasn't supported because of this).

The Publisher field doesn't seem to change between languages, and it will
definitely not change if one game decides to have a different name.
  • Loading branch information
brliron committed Jun 20, 2024
1 parent 92594f3 commit cf68fc9
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions thcrap/src/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,22 +291,27 @@ static std::wstring GetValueFromKey(HKEY key, LPCWSTR subkey, LPCWSTR valueName)

do {
value.resize(valueSize);
valueSize *= sizeof(WCHAR);
ret = RegQueryValueExW(hSub, valueName, 0, &type, (LPBYTE)value.data(), &valueSize);
valueSize /= sizeof(WCHAR);
} while (ret == ERROR_MORE_DATA);
RegCloseKey(hSub);
if (ret != ERROR_SUCCESS || type != REG_SZ) {
return L"";
}

if (value[valueSize - 1] == '\0') {
valueSize--;
}
return std::wstring(value.data(), valueSize);
}

static bool FilterOnKey(HKEY key, LPCWSTR subkey)
{
std::wstring displayName = GetValueFromKey(key, subkey, L"DisplayName");
std::wstring publisher = GetValueFromKey(key, subkey, L"Publisher");

return displayName.compare(0, wcslen(L"東方"), L"東方") == 0
|| displayName.compare(0, wcslen(L"弾幕アマノジャク"), L"弾幕アマノジャク") == 0;
return publisher == L"上海アリス幻樂団"
|| publisher == L"黄昏フロンティア";
}

static std::vector<wchar_t*> FindInstalledGamesDir()
Expand Down

0 comments on commit cf68fc9

Please sign in to comment.