AchievementManager: Resolve -Wshadow warnings

Renames some variables to avoid shadowing warnings on gcc.

Also gets rid of a FilereaderState struct, since one is already defined
in the declaration of the AchievementManager class.
This commit is contained in:
Lioncash 2023-12-12 15:36:37 -05:00
parent 87b44a2fb8
commit 18032f19a5
1 changed files with 20 additions and 22 deletions

View File

@ -183,11 +183,6 @@ void AchievementManager::HashGame(const DiscIO::Volume* volume, const ResponseCa
return; return;
} }
m_system = &Core::System::GetInstance(); m_system = &Core::System::GetInstance();
struct FilereaderState
{
int64_t position = 0;
std::unique_ptr<DiscIO::Volume> volume;
};
m_queue.EmplaceItem([this, callback] { m_queue.EmplaceItem([this, callback] {
Hash new_hash; Hash new_hash;
{ {
@ -480,19 +475,22 @@ void AchievementManager::FetchBadges()
for (size_t index = 0; index < num_achievements; index++) for (size_t index = 0; index < num_achievements; index++)
{ {
std::lock_guard lg{m_lock}; std::lock_guard lg{m_lock};
// In case the number of achievements changes since the loop started; I just don't want // In case the number of achievements changes since the loop started; I just don't want
// to lock for the ENTIRE loop so instead I reclaim the lock each cycle // to lock for the ENTIRE loop so instead I reclaim the lock each cycle
if (num_achievements != m_game_data.num_achievements) if (num_achievements != m_game_data.num_achievements)
break; break;
rc_api_achievement_definition_t& achievement = m_game_data.achievements[index];
std::string name_to_fetch(achievement.badge_name); const auto& initial_achievement = m_game_data.achievements[index];
const UnlockStatus& unlock_status = m_unlock_map[achievement.id]; const std::string badge_name_to_fetch(initial_achievement.badge_name);
if (unlock_status.unlocked_badge.name != name_to_fetch) const UnlockStatus& unlock_status = m_unlock_map[initial_achievement.id];
if (unlock_status.unlocked_badge.name != badge_name_to_fetch)
{ {
m_image_queue.EmplaceItem([this, index] { m_image_queue.EmplaceItem([this, index] {
std::string current_name, name_to_fetch; std::string current_name, name_to_fetch;
{ {
std::lock_guard lg{m_lock}; std::lock_guard lock{m_lock};
if (m_game_data.num_achievements <= index) if (m_game_data.num_achievements <= index)
{ {
INFO_LOG_FMT( INFO_LOG_FMT(
@ -501,8 +499,8 @@ void AchievementManager::FetchBadges()
index); index);
return; return;
} }
rc_api_achievement_definition_t& achievement = m_game_data.achievements[index]; const auto& achievement = m_game_data.achievements[index];
auto unlock_itr = m_unlock_map.find(achievement.id); const auto unlock_itr = m_unlock_map.find(achievement.id);
if (unlock_itr == m_unlock_map.end()) if (unlock_itr == m_unlock_map.end())
{ {
ERROR_LOG_FMT( ERROR_LOG_FMT(
@ -523,7 +521,7 @@ void AchievementManager::FetchBadges()
{ {
INFO_LOG_FMT(ACHIEVEMENTS, "Successfully downloaded unlocked achievement badge id {}.", INFO_LOG_FMT(ACHIEVEMENTS, "Successfully downloaded unlocked achievement badge id {}.",
name_to_fetch); name_to_fetch);
std::lock_guard lg{m_lock}; std::lock_guard lock{m_lock};
if (m_game_data.num_achievements <= index) if (m_game_data.num_achievements <= index)
{ {
INFO_LOG_FMT(ACHIEVEMENTS, INFO_LOG_FMT(ACHIEVEMENTS,
@ -531,8 +529,8 @@ void AchievementManager::FetchBadges()
index); index);
return; return;
} }
rc_api_achievement_definition_t& achievement = m_game_data.achievements[index]; const auto& achievement = m_game_data.achievements[index];
auto unlock_itr = m_unlock_map.find(achievement.id); const auto unlock_itr = m_unlock_map.find(achievement.id);
if (unlock_itr == m_unlock_map.end()) if (unlock_itr == m_unlock_map.end())
{ {
ERROR_LOG_FMT(ACHIEVEMENTS, ERROR_LOG_FMT(ACHIEVEMENTS,
@ -559,12 +557,12 @@ void AchievementManager::FetchBadges()
m_update_callback(); m_update_callback();
}); });
} }
if (unlock_status.locked_badge.name != name_to_fetch) if (unlock_status.locked_badge.name != badge_name_to_fetch)
{ {
m_image_queue.EmplaceItem([this, index] { m_image_queue.EmplaceItem([this, index] {
std::string current_name, name_to_fetch; std::string current_name, name_to_fetch;
{ {
std::lock_guard lg{m_lock}; std::lock_guard lock{m_lock};
if (m_game_data.num_achievements <= index) if (m_game_data.num_achievements <= index)
{ {
INFO_LOG_FMT( INFO_LOG_FMT(
@ -573,8 +571,8 @@ void AchievementManager::FetchBadges()
index); index);
return; return;
} }
rc_api_achievement_definition_t& achievement = m_game_data.achievements[index]; const auto& achievement = m_game_data.achievements[index];
auto unlock_itr = m_unlock_map.find(achievement.id); const auto unlock_itr = m_unlock_map.find(achievement.id);
if (unlock_itr == m_unlock_map.end()) if (unlock_itr == m_unlock_map.end())
{ {
ERROR_LOG_FMT( ERROR_LOG_FMT(
@ -594,7 +592,7 @@ void AchievementManager::FetchBadges()
{ {
INFO_LOG_FMT(ACHIEVEMENTS, "Successfully downloaded locked achievement badge id {}.", INFO_LOG_FMT(ACHIEVEMENTS, "Successfully downloaded locked achievement badge id {}.",
name_to_fetch); name_to_fetch);
std::lock_guard lg{m_lock}; std::lock_guard lock{m_lock};
if (m_game_data.num_achievements <= index) if (m_game_data.num_achievements <= index)
{ {
INFO_LOG_FMT(ACHIEVEMENTS, INFO_LOG_FMT(ACHIEVEMENTS,
@ -602,8 +600,8 @@ void AchievementManager::FetchBadges()
index); index);
return; return;
} }
rc_api_achievement_definition_t& achievement = m_game_data.achievements[index]; const auto& achievement = m_game_data.achievements[index];
auto unlock_itr = m_unlock_map.find(achievement.id); const auto unlock_itr = m_unlock_map.find(achievement.id);
if (unlock_itr == m_unlock_map.end()) if (unlock_itr == m_unlock_map.end())
{ {
ERROR_LOG_FMT(ACHIEVEMENTS, ERROR_LOG_FMT(ACHIEVEMENTS,