mirror of
https://github.com/stenzek/duckstation.git
synced 2025-06-06 03:25:36 +00:00
Achievements: Fix progress database corruption
This commit is contained in:
parent
90cb92bcc7
commit
fa3815d681
@ -4208,7 +4208,7 @@ void Achievements::UpdateProgressDatabase(bool force)
|
||||
return;
|
||||
|
||||
// update the game list, this should be fairly quick
|
||||
if (!s_state.game_hash.has_value())
|
||||
if (s_state.game_hash.has_value())
|
||||
{
|
||||
GameList::UpdateAchievementData(s_state.game_hash.value(), s_state.game_id,
|
||||
s_state.game_summary.num_core_achievements,
|
||||
@ -4302,19 +4302,19 @@ void Achievements::UpdateProgressDatabase(bool force)
|
||||
{
|
||||
// if the file is empty, need to write the header
|
||||
writer.WriteU32(1);
|
||||
writer.WriteU32(game_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
// update the count
|
||||
if (!FileSystem::FSeek64(fp.get(), 0, SEEK_SET, &error) || !writer.WriteU32(game_count + 1) ||
|
||||
!FileSystem::FSeek64(fp.get(), SEEK_END, 0, &error))
|
||||
!FileSystem::FSeek64(fp.get(), 0, SEEK_END, &error))
|
||||
{
|
||||
ERROR_LOG("Failed to write seek/update header in progress database: {}", error.GetDescription());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
writer.WriteU32(game_id);
|
||||
writer.WriteU16(Truncate16(hardcore ? 0 : achievements_unlocked));
|
||||
writer.WriteU16(Truncate16(hardcore ? achievements_unlocked : 0));
|
||||
}
|
||||
|
@ -748,7 +748,7 @@ void GameList::UpdateAchievementData(const std::span<u8, 16> hash, u32 game_id,
|
||||
entry.achievements_game_id = game_id;
|
||||
entry.num_achievements = Truncate16(num_achievements);
|
||||
if (hardcore)
|
||||
entry.unlocked_achievements_hc = Truncate16(num_achievements);
|
||||
entry.unlocked_achievements_hc = Truncate16(num_unlocked);
|
||||
else
|
||||
entry.unlocked_achievements = Truncate16(num_unlocked);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user