Skip to content
Permalink
Browse files

GCMemcard: Use std::array for DEntry.m_filename.

  • Loading branch information...
AdmiralCurtiss committed Nov 18, 2018
1 parent 443729d commit 0c638ad858cd8626c8798b37352bb58a0d5a8f01
Showing with 15 additions and 10 deletions.
  1. +7 −5 Source/Core/Core/HW/GCMemcard/GCMemcard.cpp
  2. +8 −5 Source/Core/Core/HW/GCMemcard/GCMemcard.h
@@ -371,7 +371,7 @@ u8 GCMemcard::TitlePresent(const DEntry& d) const
while (i < DIRLEN)
{
if ((BE32(CurrentDir->m_dir_entries[i].m_gamecode) == BE32(d.m_gamecode)) &&
(!memcmp(CurrentDir->m_dir_entries[i].m_filename, d.m_filename, 32)))
CurrentDir->m_dir_entries[i].m_filename == d.m_filename)
{
break;
}
@@ -428,7 +428,9 @@ std::string GCMemcard::DEntry_FileName(u8 index) const
if (!m_valid || index >= DIRLEN)
return "";

return std::string((const char*)CurrentDir->m_dir_entries[index].m_filename, DENTRY_STRLEN);
return std::string(
reinterpret_cast<const char*>(CurrentDir->m_dir_entries[index].m_filename.data()),
CurrentDir->m_dir_entries[index].m_filename.size());
}

u32 GCMemcard::DEntry_ModTime(u8 index) const
@@ -1317,7 +1319,7 @@ s32 GCMemcard::FZEROGX_MakeSaveGameValid(const Header& cardheader, const DEntry&
int block = 0;

// check for F-Zero GX system file
if (strcmp(reinterpret_cast<const char*>(direntry.m_filename), "f_zero.dat") != 0)
if (strcmp(reinterpret_cast<const char*>(direntry.m_filename.data()), "f_zero.dat") != 0)
return 0;

// get encrypted destination memory card serial numbers
@@ -1371,10 +1373,10 @@ s32 GCMemcard::PSO_MakeSaveGameValid(const Header& cardheader, const DEntry& dir
u32 pso3offset = 0x00;

// check for PSO1&2 system file
if (strcmp(reinterpret_cast<const char*>(direntry.m_filename), "PSO_SYSTEM") != 0)
if (strcmp(reinterpret_cast<const char*>(direntry.m_filename.data()), "PSO_SYSTEM") != 0)
{
// check for PSO3 system file
if (strcmp(reinterpret_cast<const char*>(direntry.m_filename), "PSO3_SYSTEM") == 0)
if (strcmp(reinterpret_cast<const char*>(direntry.m_filename.data()), "PSO3_SYSTEM") == 0)
{
// PSO3 data block size adjustment
pso3offset = 0x10;
@@ -168,7 +168,8 @@ struct DEntry
std::string GCI_FileName() const
{
std::string filename = std::string((char*)m_makercode, 2) + '-' +
std::string((char*)m_gamecode, 4) + '-' + (char*)m_filename + ".gci";
std::string((char*)m_gamecode, 4) + '-' +
reinterpret_cast<const char*>(m_filename.data()) + ".gci";
return Common::EscapeFileName(filename);
}

@@ -186,7 +187,7 @@ struct DEntry
// 10 RGB5A3 banner
// 11 ? maybe ==00? Time Splitters 2 and 3 have it and don't have banner
//
u8 m_filename[DENTRY_STRLEN]; // 0x08 0x20 Filename
std::array<u8, DENTRY_STRLEN> m_filename; // 0x08 0x20 Filename
Common::BigEndianValue<u32>
m_modification_time; // 0x28 0x04 Time of file's last modification in seconds since
// 12am, January 1st, 2000
@@ -296,9 +297,11 @@ class GCIFile
bool LoadSaveBlocks();
bool HasCopyProtection() const
{
if ((strcmp((char*)m_gci_header.m_filename, "PSO_SYSTEM") == 0) ||
(strcmp((char*)m_gci_header.m_filename, "PSO3_SYSTEM") == 0) ||
(strcmp((char*)m_gci_header.m_filename, "f_zero.dat") == 0))
if ((strcmp(reinterpret_cast<const char*>(m_gci_header.m_filename.data()), "PSO_SYSTEM") ==
0) ||
(strcmp(reinterpret_cast<const char*>(m_gci_header.m_filename.data()), "PSO3_SYSTEM") ==
0) ||
(strcmp(reinterpret_cast<const char*>(m_gci_header.m_filename.data()), "f_zero.dat") == 0))
return true;
return false;
}

0 comments on commit 0c638ad

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