Replace MemoryCard251 setting with generic MemoryCardSize

This allows for a broader range of game-specific memory card sizes to
be configured.
This commit is contained in:
Techjar
2021-05-27 01:59:12 -04:00
parent 52a388af9a
commit 33a6701e56
12 changed files with 44 additions and 23 deletions

View File

@ -39,6 +39,7 @@
#include "Core/ConfigManager.h"
#include "Core/GeckoCode.h"
#include "Core/HW/EXI/EXI_DeviceIPL.h"
#include "Core/HW/GCMemcard/GCMemcard.h"
#include "Core/HW/SI/SI.h"
#include "Core/HW/SI/SI_Device.h"
#include "Core/HW/SI/SI_DeviceGCController.h"
@ -856,8 +857,8 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet)
bool is_slot_a;
std::string region;
bool mc251;
packet >> is_slot_a >> region >> mc251;
int size_override;
packet >> is_slot_a >> region >> size_override;
// This check is mainly intended to filter out characters which have special meanings in paths
if (region != JAP_DIR && region != USA_DIR && region != EUR_DIR)
@ -866,8 +867,15 @@ unsigned int NetPlayClient::OnData(sf::Packet& packet)
return 0;
}
std::string size_suffix;
if (size_override >= 0 && size_override <= 4)
{
size_suffix = fmt::format(
".{}", Memcard::MbitToFreeBlocks(Memcard::MBIT_SIZE_MEMORY_CARD_59 << size_override));
}
const std::string path = File::GetUserPath(D_GCUSER_IDX) + GC_MEMCARD_NETPLAY +
(is_slot_a ? "A." : "B.") + region + (mc251 ? ".251" : "") + ".raw";
(is_slot_a ? "A." : "B.") + region + size_suffix + ".raw";
if (File::Exists(path) && !File::Delete(path))
{
PanicAlertFmtT("Failed to delete NetPlay memory card. Verify your write permissions.");