GCMemcard: Use BigEndianValue for Directory.m_update_counter.

This commit is contained in:
Admiral H. Curtiss
2018-11-19 00:04:56 +01:00
parent 2d77096d63
commit 0f776fb091
3 changed files with 8 additions and 8 deletions

View File

@ -173,7 +173,7 @@ GCMemcard::GCMemcard(const std::string& filename, bool forceCreation, bool shift
// the backup should be copied? // 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; // dir = dir_backup;
// bat = bat_backup; // needed? // bat = bat_backup; // needed?
@ -209,7 +209,7 @@ GCMemcard::GCMemcard(const std::string& filename, bool forceCreation, bool shift
void GCMemcard::InitDirBatPointers() 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; CurrentDir = &dir;
PreviousDir = &dir_backup; PreviousDir = &dir_backup;
@ -694,7 +694,7 @@ u32 GCMemcard::ImportFile(const DEntry& direntry, std::vector<GCMBlock>& saveBlo
break; break;
} }
} }
UpdatedDir.m_update_counter = BE16(BE16(UpdatedDir.m_update_counter) + 1); UpdatedDir.m_update_counter = UpdatedDir.m_update_counter + 1;
*PreviousDir = UpdatedDir; *PreviousDir = UpdatedDir;
if (PreviousDir == &dir) 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); 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; *PreviousDir = UpdatedDir;
if (PreviousDir == &dir) if (PreviousDir == &dir)
{ {

View File

@ -232,9 +232,9 @@ struct Directory
{ {
std::array<DEntry, DIRLEN> m_dir_entries; // 0x0000 Directory Entries (max 127) std::array<DEntry, DIRLEN> m_dir_entries; // 0x0000 Directory Entries (max 127)
std::array<u8, 0x3a> m_padding; std::array<u8, 0x3a> m_padding;
u16 m_update_counter; // 0x1ffa 2 Update Counter Common::BigEndianValue<u16> m_update_counter; // 0x1ffa 2 Update Counter
u16 m_checksum; // 0x1ffc 2 Additive Checksum u16 m_checksum; // 0x1ffc 2 Additive Checksum
u16 m_checksum_inv; // 0x1ffe 2 Inverse Checksum u16 m_checksum_inv; // 0x1ffe 2 Inverse Checksum
Directory() Directory()
{ {
memset(this, 0xFF, BLOCK_SIZE); memset(this, 0xFF, BLOCK_SIZE);

View File

@ -429,7 +429,7 @@ inline void GCMemcardDirectory::SyncSaves()
{ {
Directory* current = &m_dir2; 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; current = &m_dir1;
} }