GCI Folder: if there are too many files in the folder, try to leave free directory entries.
Rule: Load first 112 files, any remaining files in the folder are ignored unless they are the same gameid as the current game
This commit is contained in:
parent
46c18aa909
commit
f6d89c5c98
|
@ -4,6 +4,7 @@
|
||||||
#include <cinttypes>
|
#include <cinttypes>
|
||||||
|
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
|
#include "Common/FileSearch.h"
|
||||||
#include "Core/ConfigManager.h"
|
#include "Core/ConfigManager.h"
|
||||||
#include "Core/Core.h"
|
#include "Core/Core.h"
|
||||||
#include "Core/HW/GCMemcardDirectory.h"
|
#include "Core/HW/GCMemcardDirectory.h"
|
||||||
|
@ -12,7 +13,7 @@
|
||||||
const int NO_INDEX = -1;
|
const int NO_INDEX = -1;
|
||||||
static const char *MC_HDR = "MC_SYSTEM_AREA";
|
static const char *MC_HDR = "MC_SYSTEM_AREA";
|
||||||
|
|
||||||
int GCMemcardDirectory::LoadGCI(std::string fileName, DiscIO::IVolume::ECountry card_region)
|
int GCMemcardDirectory::LoadGCI(std::string fileName, DiscIO::IVolume::ECountry card_region, bool currentGameOnly)
|
||||||
{
|
{
|
||||||
File::IOFile gcifile(fileName, "rb");
|
File::IOFile gcifile(fileName, "rb");
|
||||||
if (gcifile)
|
if (gcifile)
|
||||||
|
@ -89,6 +90,10 @@ int GCMemcardDirectory::LoadGCI(std::string fileName, DiscIO::IVolume::ECountry
|
||||||
{
|
{
|
||||||
gci.LoadSaveBlocks();
|
gci.LoadSaveBlocks();
|
||||||
}
|
}
|
||||||
|
else if (currentGameOnly)
|
||||||
|
{
|
||||||
|
return NO_INDEX;
|
||||||
|
}
|
||||||
u16 first_block = m_bat1.AssignBlocksContiguous(numBlocks);
|
u16 first_block = m_bat1.AssignBlocksContiguous(numBlocks);
|
||||||
if (first_block == 0xFFFF)
|
if (first_block == 0xFFFF)
|
||||||
{
|
{
|
||||||
|
@ -131,12 +136,24 @@ GCMemcardDirectory::GCMemcardDirectory(std::string directory, int slot, u16 size
|
||||||
|
|
||||||
File::FSTEntry FST_Temp;
|
File::FSTEntry FST_Temp;
|
||||||
File::ScanDirectoryTree(m_SaveDirectory, FST_Temp);
|
File::ScanDirectoryTree(m_SaveDirectory, FST_Temp);
|
||||||
for (u32 j = 0; j < FST_Temp.children.size(); j++)
|
|
||||||
|
CFileSearch::XStringVector Directory;
|
||||||
|
Directory.push_back(m_SaveDirectory);
|
||||||
|
CFileSearch::XStringVector Extensions;
|
||||||
|
Extensions.push_back("*.gci");
|
||||||
|
|
||||||
|
CFileSearch FileSearch(Extensions, Directory);
|
||||||
|
const CFileSearch::XStringVector& rFilenames = FileSearch.GetFileNames();
|
||||||
|
|
||||||
|
if (rFilenames.size() > 112)
|
||||||
{
|
{
|
||||||
std::string ext;
|
Core::DisplayMessage(
|
||||||
std::string const &name = FST_Temp.children[j].virtualName;
|
StringFromFormat("WARNING: There are more than 112 save files on this memorycards"\
|
||||||
SplitPath(name, nullptr, nullptr, &ext);
|
"\n Only loading the first 112 in the folder, unless the gameid is the current games id"),
|
||||||
if (strcasecmp(ext.c_str(), ".gci") == 0)
|
4000);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto gciFile : rFilenames)
|
||||||
{
|
{
|
||||||
if (m_saves.size() == DIRLEN)
|
if (m_saves.size() == DIRLEN)
|
||||||
{
|
{
|
||||||
|
@ -144,13 +161,14 @@ GCMemcardDirectory::GCMemcardDirectory(std::string directory, int slot, u16 size
|
||||||
m_SaveDirectory.c_str());
|
m_SaveDirectory.c_str());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
int index = LoadGCI(FST_Temp.children[j].physicalName, card_region);
|
int index = LoadGCI(gciFile, card_region, m_saves.size() > 112 );
|
||||||
if (index != NO_INDEX)
|
if (index != NO_INDEX)
|
||||||
{
|
{
|
||||||
m_loaded_saves.push_back(m_saves.at(index).m_gci_header.GCI_FileName());
|
m_loaded_saves.push_back(m_saves.at(index).m_gci_header.GCI_FileName());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
m_loaded_saves.clear();
|
m_loaded_saves.clear();
|
||||||
m_dir1.fixChecksums();
|
m_dir1.fixChecksums();
|
||||||
m_dir2 = m_dir1;
|
m_dir2 = m_dir1;
|
||||||
|
|
|
@ -25,7 +25,7 @@ public:
|
||||||
void DoState(PointerWrap &p) override;
|
void DoState(PointerWrap &p) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int LoadGCI(std::string fileName, DiscIO::IVolume::ECountry card_region);
|
int LoadGCI(std::string fileName, DiscIO::IVolume::ECountry card_region, bool currentGameOnly);
|
||||||
inline s32 SaveAreaRW(u32 block, bool writing = false);
|
inline s32 SaveAreaRW(u32 block, bool writing = false);
|
||||||
// s32 DirectoryRead(u32 offset, u32 length, u8* destaddress);
|
// s32 DirectoryRead(u32 offset, u32 length, u8* destaddress);
|
||||||
s32 DirectoryWrite(u32 destaddress, u32 length, u8 *srcaddress);
|
s32 DirectoryWrite(u32 destaddress, u32 length, u8 *srcaddress);
|
||||||
|
|
Loading…
Reference in New Issue