Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #10395 from AdmiralCurtiss/memcard-size-setting
Port memory card size override setting to new config system.
  • Loading branch information
AdmiralCurtiss committed Jan 29, 2022
2 parents 8e4155a + 407aefb commit 63df67b
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 8 deletions.
2 changes: 2 additions & 0 deletions Source/Core/Core/Config/MainSettings.cpp
Expand Up @@ -88,6 +88,8 @@ const Info<std::string>& GetInfoForGCIPathOverride(ExpansionInterface::Slot slot
return *infos[slot];
}

const Info<int> MAIN_MEMORY_CARD_SIZE{{System::Main, "Core", "MemoryCardSize"}, -1};

const Info<ExpansionInterface::EXIDeviceType> MAIN_SLOT_A{
{System::Main, "Core", "SlotA"}, ExpansionInterface::EXIDeviceType::MemoryCardFolder};
const Info<ExpansionInterface::EXIDeviceType> MAIN_SLOT_B{{System::Main, "Core", "SlotB"},
Expand Down
1 change: 1 addition & 0 deletions Source/Core/Core/Config/MainSettings.h
Expand Up @@ -73,6 +73,7 @@ const Info<std::string>& GetInfoForAGPCartPath(ExpansionInterface::Slot slot);
extern const Info<std::string> MAIN_GCI_FOLDER_A_PATH_OVERRIDE;
extern const Info<std::string> MAIN_GCI_FOLDER_B_PATH_OVERRIDE;
const Info<std::string>& GetInfoForGCIPathOverride(ExpansionInterface::Slot slot);
extern const Info<int> MAIN_MEMORY_CARD_SIZE;
extern const Info<ExpansionInterface::EXIDeviceType> MAIN_SLOT_A;
extern const Info<ExpansionInterface::EXIDeviceType> MAIN_SLOT_B;
extern const Info<ExpansionInterface::EXIDeviceType> MAIN_SERIAL_PORT_1;
Expand Down
1 change: 1 addition & 0 deletions Source/Core/Core/ConfigLoaders/NetPlayConfigLoader.cpp
Expand Up @@ -40,6 +40,7 @@ class NetPlayConfigLayerLoader final : public Config::ConfigLayerLoader
layer->Set(Config::MAIN_OVERCLOCK, m_settings.m_OCFactor);
for (ExpansionInterface::Slot slot : ExpansionInterface::SLOTS)
layer->Set(Config::GetInfoForEXIDevice(slot), m_settings.m_EXIDevice[slot]);
layer->Set(Config::MAIN_MEMORY_CARD_SIZE, m_settings.m_MemcardSizeOverride);
layer->Set(Config::SESSION_SAVE_DATA_WRITABLE, m_settings.m_WriteToMemcard);
layer->Set(Config::MAIN_RAM_OVERRIDE_ENABLE, m_settings.m_RAMOverrideEnable);
layer->Set(Config::MAIN_MEM1_SIZE, m_settings.m_Mem1Size);
Expand Down
5 changes: 1 addition & 4 deletions Source/Core/Core/HW/EXI/EXI.cpp
Expand Up @@ -8,7 +8,6 @@

#include "Common/ChunkFile.h"
#include "Common/CommonTypes.h"
#include "Common/IniFile.h"

#include "Core/Config/MainSettings.h"
#include "Core/ConfigManager.h"
Expand Down Expand Up @@ -114,9 +113,7 @@ void Init()

{
u16 size_mbits = Memcard::MBIT_SIZE_MEMORY_CARD_2043;
int size_override;
IniFile gameIni = SConfig::GetInstance().LoadGameIni();
gameIni.GetOrCreateSection("Core")->Get("MemoryCardSize", &size_override, -1);
int size_override = Config::Get(Config::MAIN_MEMORY_CARD_SIZE);
if (size_override >= 0 && size_override <= 4)
size_mbits = Memcard::MBIT_SIZE_MEMORY_CARD_59 << size_override;
const bool shift_jis =
Expand Down
2 changes: 2 additions & 0 deletions Source/Core/Core/NetPlayClient.cpp
Expand Up @@ -822,6 +822,8 @@ void NetPlayClient::OnStartGame(sf::Packet& packet)
for (auto slot : ExpansionInterface::SLOTS)
packet >> m_net_settings.m_EXIDevice[slot];

packet >> m_net_settings.m_MemcardSizeOverride;

for (u32& value : m_net_settings.m_SYSCONFSettings)
packet >> value;

Expand Down
1 change: 1 addition & 0 deletions Source/Core/Core/NetPlayProto.h
Expand Up @@ -47,6 +47,7 @@ struct NetSettings
bool m_OCEnable = false;
float m_OCFactor = 0;
Common::EnumMap<ExpansionInterface::EXIDeviceType, ExpansionInterface::MAX_SLOT> m_EXIDevice{};
int m_MemcardSizeOverride = -1;

std::array<u32, Config::SYSCONF_SETTINGS.size()> m_SYSCONFSettings{};

Expand Down
9 changes: 5 additions & 4 deletions Source/Core/Core/NetPlayServer.cpp
Expand Up @@ -1324,6 +1324,8 @@ bool NetPlayServer::SetupNetSettings()
settings.m_EXIDevice[slot] = device;
}

settings.m_MemcardSizeOverride = Config::Get(Config::MAIN_MEMORY_CARD_SIZE);

for (size_t i = 0; i < Config::SYSCONF_SETTINGS.size(); ++i)
{
std::visit(
Expand Down Expand Up @@ -1510,6 +1512,8 @@ bool NetPlayServer::StartGame()
for (auto slot : ExpansionInterface::SLOTS)
spac << static_cast<int>(m_settings.m_EXIDevice[slot]);

spac << m_settings.m_MemcardSizeOverride;

for (u32 value : m_settings.m_SYSCONFSettings)
spac << value;

Expand Down Expand Up @@ -1674,10 +1678,7 @@ bool NetPlayServer::SyncSaveData()

MemoryCard::CheckPath(path, region, slot);

int size_override;
IniFile gameIni = SConfig::LoadGameIni(game->GetGameID(), game->GetRevision());
gameIni.GetOrCreateSection("Core")->Get("MemoryCardSize", &size_override, -1);

const int size_override = m_settings.m_MemcardSizeOverride;
if (size_override >= 0 && size_override <= 4)
{
path.insert(path.find_last_of('.'),
Expand Down

0 comments on commit 63df67b

Please sign in to comment.