Skip to content

Commit

Permalink
Achievements: Fix badge download bug
Browse files Browse the repository at this point in the history
Where it would download the incorrect icon if the locked badge was the
first image seen.
  • Loading branch information
stenzek committed Aug 25, 2024
1 parent 5c2fc68 commit 6deb2eb
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/core/achievements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ std::string Achievements::GetGameHash(CDImage* image)
std::string Achievements::GetLocalImagePath(const std::string_view image_name, int type)
{
std::string_view prefix;
std::string_view suffix;
switch (type)
{
case RC_IMAGE_TYPE_GAME:
Expand All @@ -323,7 +324,14 @@ std::string Achievements::GetLocalImagePath(const std::string_view image_name, i
break;

case RC_IMAGE_TYPE_ACHIEVEMENT: // https://media.retroachievements.org/Badge/{}.png
prefix = "badge";
break;

case RC_IMAGE_TYPE_ACHIEVEMENT_LOCKED:
prefix = "badge";
suffix = "_lock";
break;

default:
prefix = "badge";
break;
Expand All @@ -332,8 +340,8 @@ std::string Achievements::GetLocalImagePath(const std::string_view image_name, i
std::string ret;
if (!image_name.empty())
{
ret = fmt::format("{}" FS_OSPATH_SEPARATOR_STR "{}" FS_OSPATH_SEPARATOR_STR "{}_{}.png", EmuFolders::Cache,
CACHE_SUBDIRECTORY_NAME, prefix, Path::SanitizeFileName(image_name));
ret = fmt::format("{}" FS_OSPATH_SEPARATOR_STR "{}" FS_OSPATH_SEPARATOR_STR "{}_{}{}.png", EmuFolders::Cache,
CACHE_SUBDIRECTORY_NAME, prefix, Path::SanitizeFileName(image_name), suffix);
}

return ret;
Expand Down

0 comments on commit 6deb2eb

Please sign in to comment.