From c7abf7e8d255c439cb88ab01030223dab5ec99ac Mon Sep 17 00:00:00 2001 From: John Chadwick Date: Sun, 7 Apr 2013 12:18:07 -0400 Subject: [PATCH] Allow disabling memory card writes in netplay. Fixes issue 6217. --- Source/Core/Core/Src/CoreParameter.cpp | 3 ++- Source/Core/Core/Src/CoreParameter.h | 1 + Source/Core/Core/Src/HW/EXI_DeviceMemoryCard.cpp | 3 +++ Source/Core/Core/Src/NetPlay.cpp | 10 ++++++++++ Source/Core/Core/Src/NetPlay.h | 1 + Source/Core/DolphinWX/Src/NetWindow.cpp | 13 ++++++++++++- Source/Core/DolphinWX/Src/NetWindow.h | 2 ++ 7 files changed, 31 insertions(+), 2 deletions(-) diff --git a/Source/Core/Core/Src/CoreParameter.cpp b/Source/Core/Core/Src/CoreParameter.cpp index 589e37bce2..fcb35eccc3 100644 --- a/Source/Core/Core/Src/CoreParameter.cpp +++ b/Source/Core/Core/Src/CoreParameter.cpp @@ -46,7 +46,7 @@ SCoreStartupParameter::SCoreStartupParameter() bCPUThread(true), bDSPThread(false), bDSPHLE(true), bSkipIdle(true), bNTSC(false), bForceNTSCJ(false), bHLE_BS2(true), bEnableCheats(false), - bMergeBlocks(false), + bMergeBlocks(false), bEnableMemcardSaving(true), bDPL2Decoder(false), iLatency(14), bRunCompareServer(false), bRunCompareClient(false), bMMU(false), bDCBZOFF(false), iTLBHack(0), bVBeam(false), @@ -81,6 +81,7 @@ void SCoreStartupParameter::LoadDefaults() bSyncGPU = false; bFastDiscSpeed = false; bMergeBlocks = false; + bEnableMemcardSaving = true; SelectedLanguage = 0; bWii = false; bDPL2Decoder = false; diff --git a/Source/Core/Core/Src/CoreParameter.h b/Source/Core/Core/Src/CoreParameter.h index 896f111ab7..3a1dc2ba3a 100644 --- a/Source/Core/Core/Src/CoreParameter.h +++ b/Source/Core/Core/Src/CoreParameter.h @@ -105,6 +105,7 @@ struct SCoreStartupParameter bool bHLE_BS2; bool bEnableCheats; bool bMergeBlocks; + bool bEnableMemcardSaving; bool bDPL2Decoder; int iLatency; diff --git a/Source/Core/Core/Src/HW/EXI_DeviceMemoryCard.cpp b/Source/Core/Core/Src/HW/EXI_DeviceMemoryCard.cpp index 967193a696..8030eb1b57 100644 --- a/Source/Core/Core/Src/HW/EXI_DeviceMemoryCard.cpp +++ b/Source/Core/Core/Src/HW/EXI_DeviceMemoryCard.cpp @@ -150,6 +150,9 @@ void CEXIMemoryCard::Flush(bool exiting) if(!m_bDirty) return; + if (!Core::g_CoreStartupParameter.bEnableMemcardSaving) + return; + if (flushThread.joinable()) { flushThread.join(); diff --git a/Source/Core/Core/Src/NetPlay.cpp b/Source/Core/Core/Src/NetPlay.cpp index 05331bc6cc..ec4493bfd0 100644 --- a/Source/Core/Core/Src/NetPlay.cpp +++ b/Source/Core/Core/Src/NetPlay.cpp @@ -271,6 +271,16 @@ bool NetPlay::StopGame() return true; } +void NetPlay::SetMemcardWriteEnabled(bool enabled) +{ + std::lock_guard lkg(m_crit.game); + + if (m_is_running) + { + Core::g_CoreStartupParameter.bEnableMemcardSaving = enabled; + } +} + // called from ---CPU--- thread u8 NetPlay::GetPadNum(u8 numPAD) { diff --git a/Source/Core/Core/Src/NetPlay.h b/Source/Core/Core/Src/NetPlay.h index 96ff78995a..dfe72d87a3 100644 --- a/Source/Core/Core/Src/NetPlay.h +++ b/Source/Core/Core/Src/NetPlay.h @@ -111,6 +111,7 @@ public: virtual bool StartGame(const std::string &path); virtual bool StopGame(); + virtual void SetMemcardWriteEnabled(bool enabled); //void PushPadStates(unsigned int count); u8 GetPadNum(u8 numPAD); diff --git a/Source/Core/DolphinWX/Src/NetWindow.cpp b/Source/Core/DolphinWX/Src/NetWindow.cpp index 76bb76881b..b82426ef4e 100644 --- a/Source/Core/DolphinWX/Src/NetWindow.cpp +++ b/Source/Core/DolphinWX/Src/NetWindow.cpp @@ -22,6 +22,7 @@ #include "NetPlay.h" #include "NetWindow.h" #include "Frame.h" +#include "Core.h" #include #include @@ -333,8 +334,11 @@ NetPlayDiag::NetPlayDiag(wxWindow* const parent, const CGameListCtrl* const game padbuf_btn->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &NetPlayDiag::OnPadBuffHelp, this); bottom_szr->Add(padbuf_spin, 0, wxCENTER); bottom_szr->Add(padbuf_btn); + m_memcard_write = new wxCheckBox(panel, wxID_ANY, _("Write memcards (GC)")); + m_memcard_write->Bind(wxEVT_COMMAND_CHECKBOX_CLICKED, &NetPlayDiag::OnMemcardWriteCheck, this); + bottom_szr->Add(m_memcard_write, 0, wxCENTER); } - + bottom_szr->AddStretchSpacer(1); bottom_szr->Add(quit_btn); @@ -397,6 +401,8 @@ void NetPlayDiag::OnStop(wxCommandEvent&) void NetPlayDiag::BootGame(const std::string& filename) { main_frame->BootGame(filename); + + Core::g_CoreStartupParameter.bEnableMemcardSaving = m_memcard_write->GetValue(); } void NetPlayDiag::StopGame() @@ -449,6 +455,11 @@ void NetPlayDiag::OnPadBuffHelp(wxCommandEvent&) m_chat_text->AppendText(StrToWxStr(ss.str())); } +void NetPlayDiag::OnMemcardWriteCheck(wxCommandEvent &event) +{ + netplay_ptr->SetMemcardWriteEnabled(m_memcard_write->GetValue()); +} + void NetPlayDiag::OnAdjustBuffer(wxCommandEvent& event) { const int val = ((wxSpinCtrl*)event.GetEventObject())->GetValue(); diff --git a/Source/Core/DolphinWX/Src/NetWindow.h b/Source/Core/DolphinWX/Src/NetWindow.h index ae27a75921..bc029ed9d6 100644 --- a/Source/Core/DolphinWX/Src/NetWindow.h +++ b/Source/Core/DolphinWX/Src/NetWindow.h @@ -96,6 +96,7 @@ private: void OnChat(wxCommandEvent& event); void OnQuit(wxCommandEvent& event); void OnPadBuffHelp(wxCommandEvent& event); + void OnMemcardWriteCheck(wxCommandEvent& event); void OnThread(wxCommandEvent& event); void OnChangeGame(wxCommandEvent& event); void OnAdjustBuffer(wxCommandEvent& event); @@ -104,6 +105,7 @@ private: wxListBox* m_player_lbox; wxTextCtrl* m_chat_text; wxTextCtrl* m_chat_msg_text; + wxCheckBox* m_memcard_write; std::string m_selected_game; wxButton* m_game_btn;