mirror of
https://github.com/stenzek/duckstation.git
synced 2025-06-06 19:45:33 +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;
|
return;
|
||||||
|
|
||||||
// update the game list, this should be fairly quick
|
// 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,
|
GameList::UpdateAchievementData(s_state.game_hash.value(), s_state.game_id,
|
||||||
s_state.game_summary.num_core_achievements,
|
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
|
// if the file is empty, need to write the header
|
||||||
writer.WriteU32(1);
|
writer.WriteU32(1);
|
||||||
writer.WriteU32(game_id);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// update the count
|
// update the count
|
||||||
if (!FileSystem::FSeek64(fp.get(), 0, SEEK_SET, &error) || !writer.WriteU32(game_count + 1) ||
|
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());
|
ERROR_LOG("Failed to write seek/update header in progress database: {}", error.GetDescription());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
writer.WriteU32(game_id);
|
||||||
writer.WriteU16(Truncate16(hardcore ? 0 : achievements_unlocked));
|
writer.WriteU16(Truncate16(hardcore ? 0 : achievements_unlocked));
|
||||||
writer.WriteU16(Truncate16(hardcore ? achievements_unlocked : 0));
|
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.achievements_game_id = game_id;
|
||||||
entry.num_achievements = Truncate16(num_achievements);
|
entry.num_achievements = Truncate16(num_achievements);
|
||||||
if (hardcore)
|
if (hardcore)
|
||||||
entry.unlocked_achievements_hc = Truncate16(num_achievements);
|
entry.unlocked_achievements_hc = Truncate16(num_unlocked);
|
||||||
else
|
else
|
||||||
entry.unlocked_achievements = Truncate16(num_unlocked);
|
entry.unlocked_achievements = Truncate16(num_unlocked);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user