Skip to content

Commit 595bebd

Browse files
committed
[Memcard Manager] Address comments
1 parent 0d7af2b commit 595bebd

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

src/core/sio.cc

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include "core/sio.h"
2121

2222
#include <algorithm>
23-
#include <cassert>
23+
#include <stdexcept>
2424
#include <sys/stat.h>
2525

2626
#include "core/misc.h"
@@ -725,8 +725,6 @@ void PCSX::SIO::GetMcdBlockInfo(int mcd, int block, McdBlock *Info) {
725725
std::memset(Info, 0, sizeof(McdBlock));
726726

727727
char *data = GetMcdData(mcd);
728-
assert(data != nullptr);
729-
730728
char *ptr = data + block * MCD_BLOCK_SIZE + 2;
731729
char *str = Info->Title;
732730
char *sstr = Info->sTitle;
@@ -831,6 +829,7 @@ char *PCSX::SIO::GetMcdData(int mcd) {
831829
case 2:
832830
return g_mcd2Data;
833831
default:
832+
throw std::runtime_error("Attempt to access invalid memory card");
834833
return nullptr;
835834
}
836835
}
@@ -840,7 +839,6 @@ char *PCSX::SIO::GetMcdData(int mcd) {
840839
// block: A block from 1 to 15 inclusive
841840
void PCSX::SIO::FormatMcdBlock(int mcd, int block) {
842841
char *data = GetMcdData(mcd);
843-
assert(data != nullptr);
844842

845843
// Set the block data to 0
846844
const size_t offset = block * MCD_BLOCK_SIZE;
@@ -858,12 +856,14 @@ void PCSX::SIO::FormatMcdBlock(int mcd, int block) {
858856
// mcd: The memory card to back up (1 or 2)
859857
void PCSX::SIO::SaveMcd(int mcd) {
860858
const auto data = GetMcdData(mcd);
861-
862-
if (mcd == 1) {
863-
const auto path = PCSX::g_emulator->settings.get<PCSX::Emulator::SettingMcd1>().string();
864-
SaveMcd(path, data, 0, MCD_SIZE);
865-
} else if (mcd == 2) {
866-
const auto path = PCSX::g_emulator->settings.get<PCSX::Emulator::SettingMcd2>().string();
867-
SaveMcd(path, data, 0, MCD_SIZE);
859+
switch (mcd) {
860+
case 1:
861+
const auto path = PCSX::g_emulator->settings.get<PCSX::Emulator::SettingMcd1>().string();
862+
SaveMcd(path, data, 0, MCD_SIZE);
863+
break;
864+
case 2:
865+
const auto path = PCSX::g_emulator->settings.get<PCSX::Emulator::SettingMcd2>().string();
866+
SaveMcd(path, data, 0, MCD_SIZE);
867+
break;
868868
}
869869
}

0 commit comments

Comments
 (0)