Skip to content
Permalink
Browse files

GCMemcard: Use BigEndianValue for Directory.m_update_counter.

  • Loading branch information...
AdmiralCurtiss committed Nov 18, 2018
1 parent 2d77096 commit 0f776fb09147c5907fa2eae213d7193d67a63aa3
@@ -173,7 +173,7 @@ GCMemcard::GCMemcard(const std::string& filename, bool forceCreation, bool shift
// the backup should be copied?
// }
//
// if (BE16(dir_backup.m_update_counter) > BE16(dir.m_update_counter)) //check if the backup is newer
// if (dir_backup.m_update_counter > dir.m_update_counter) //check if the backup is newer
// {
// dir = dir_backup;
// bat = bat_backup; // needed?
@@ -209,7 +209,7 @@ GCMemcard::GCMemcard(const std::string& filename, bool forceCreation, bool shift

void GCMemcard::InitDirBatPointers()
{
if (BE16(dir.m_update_counter) > (BE16(dir_backup.m_update_counter)))
if (dir.m_update_counter > dir_backup.m_update_counter)
{
CurrentDir = &dir;
PreviousDir = &dir_backup;
@@ -694,7 +694,7 @@ u32 GCMemcard::ImportFile(const DEntry& direntry, std::vector<GCMBlock>& saveBlo
break;
}
}
UpdatedDir.m_update_counter = BE16(BE16(UpdatedDir.m_update_counter) + 1);
UpdatedDir.m_update_counter = UpdatedDir.m_update_counter + 1;
*PreviousDir = UpdatedDir;
if (PreviousDir == &dir)
{
@@ -797,7 +797,7 @@ u32 GCMemcard::RemoveFile(u8 index) // index in the directory array
}
*/
memset(&(UpdatedDir.m_dir_entries[index]), 0xFF, DENTRY_SIZE);
UpdatedDir.m_update_counter = BE16(BE16(UpdatedDir.m_update_counter) + 1);
UpdatedDir.m_update_counter = UpdatedDir.m_update_counter + 1;
*PreviousDir = UpdatedDir;
if (PreviousDir == &dir)
{
@@ -232,9 +232,9 @@ struct Directory
{
std::array<DEntry, DIRLEN> m_dir_entries; // 0x0000 Directory Entries (max 127)
std::array<u8, 0x3a> m_padding;
u16 m_update_counter; // 0x1ffa 2 Update Counter
u16 m_checksum; // 0x1ffc 2 Additive Checksum
u16 m_checksum_inv; // 0x1ffe 2 Inverse Checksum
Common::BigEndianValue<u16> m_update_counter; // 0x1ffa 2 Update Counter
u16 m_checksum; // 0x1ffc 2 Additive Checksum
u16 m_checksum_inv; // 0x1ffe 2 Inverse Checksum
Directory()
{
memset(this, 0xFF, BLOCK_SIZE);
@@ -429,7 +429,7 @@ inline void GCMemcardDirectory::SyncSaves()
{
Directory* current = &m_dir2;

if (BE16(m_dir1.m_update_counter) > BE16(m_dir2.m_update_counter))
if (m_dir1.m_update_counter > m_dir2.m_update_counter)
{
current = &m_dir1;
}

0 comments on commit 0f776fb

Please sign in to comment.
You can’t perform that action at this time.