From 4a41ab17155e4103ea7844b6e6aa3c434dbb7e63 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Fri, 6 Mar 2015 12:26:40 +0100 Subject: [PATCH] Fix 4.0-5689 regression (AR codes, patches) CreateCodeTab, ARCodeAddEdit and PatchAddEdit need to be able to modify arCodes/onFrame. --- Source/Core/Core/ActionReplay.cpp | 4 ++-- Source/Core/Core/ActionReplay.h | 2 +- Source/Core/Core/PatchEngine.h | 1 - Source/Core/DolphinWX/ARCodeAddEdit.cpp | 21 ++++++++++--------- Source/Core/DolphinWX/ARCodeAddEdit.h | 4 ++-- .../DolphinWX/Cheats/CreateCodeDialog.cpp | 4 ++-- .../Core/DolphinWX/Cheats/CreateCodeDialog.h | 4 ++-- Source/Core/DolphinWX/ISOProperties.cpp | 8 +++---- Source/Core/DolphinWX/PatchAddEdit.cpp | 16 +++++++------- Source/Core/DolphinWX/PatchAddEdit.h | 4 ++-- 10 files changed, 34 insertions(+), 34 deletions(-) diff --git a/Source/Core/Core/ActionReplay.cpp b/Source/Core/Core/ActionReplay.cpp index 769a89269f..e3035ae1d2 100644 --- a/Source/Core/Core/ActionReplay.cpp +++ b/Source/Core/Core/ActionReplay.cpp @@ -934,9 +934,9 @@ bool RunCode(const ARCode &arcode) return true; } -std::vector GetARCodes() +std::vector* GetARCodes() { - return arCodes; + return &arCodes; } } // namespace ActionReplay diff --git a/Source/Core/Core/ActionReplay.h b/Source/Core/Core/ActionReplay.h index 1ab4f8cb2c..3207a1c4fa 100644 --- a/Source/Core/Core/ActionReplay.h +++ b/Source/Core/Core/ActionReplay.h @@ -36,5 +36,5 @@ void UpdateActiveList(); void EnableSelfLogging(bool enable); const std::vector &GetSelfLog(); bool IsSelfLogging(); -std::vector GetARCodes(); +std::vector* GetARCodes(); } // namespace diff --git a/Source/Core/Core/PatchEngine.h b/Source/Core/Core/PatchEngine.h index c67d23c725..73039eb8b1 100644 --- a/Source/Core/Core/PatchEngine.h +++ b/Source/Core/Core/PatchEngine.h @@ -8,7 +8,6 @@ #include #include "Common/CommonTypes.h" -#include "Core/PatchEngine.h" class IniFile; diff --git a/Source/Core/DolphinWX/ARCodeAddEdit.cpp b/Source/Core/DolphinWX/ARCodeAddEdit.cpp index 1ce3d93edd..bb180f9365 100644 --- a/Source/Core/DolphinWX/ARCodeAddEdit.cpp +++ b/Source/Core/DolphinWX/ARCodeAddEdit.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2 // Refer to the license.txt file included. +#include #include #include #include @@ -28,7 +29,7 @@ #include "DolphinWX/ARCodeAddEdit.h" #include "DolphinWX/WxUtils.h" -CARCodeAddEdit::CARCodeAddEdit(int _selection, const std::vector& _arCodes, wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& position, const wxSize& size, long style) +CARCodeAddEdit::CARCodeAddEdit(int _selection, std::vector* _arCodes, wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& position, const wxSize& size, long style) : wxDialog(parent, id, title, position, size, style) , arCodes(_arCodes) , selection(_selection) @@ -36,7 +37,7 @@ CARCodeAddEdit::CARCodeAddEdit(int _selection, const std::vectorat(selection).name); + tempEntries = arCodes->at(selection); } wxBoxSizer* sEditCheat = new wxBoxSizer(wxVERTICAL); @@ -57,8 +58,8 @@ CARCodeAddEdit::CARCodeAddEdit(int _selection, const std::vectorSetValue(currentName); EntrySelection = new wxSpinButton(this); - EntrySelection->SetRange(1, ((int)arCodes.size()) > 0 ? (int)arCodes.size() : 1); - EntrySelection->SetValue((int)(arCodes.size() - selection)); + EntrySelection->SetRange(1, std::max((int)arCodes->size(), 1)); + EntrySelection->SetValue((int)(arCodes->size() - selection)); EntrySelection->Bind(wxEVT_SPIN, &CARCodeAddEdit::ChangeEntry, this); EditCheatCode = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(300, 100), wxTE_MULTILINE); @@ -81,7 +82,7 @@ CARCodeAddEdit::CARCodeAddEdit(int _selection, const std::vectorat((int)arCodes->size() - event.GetPosition()); EditCheatName->SetValue(StrToWxStr(currentCode.name)); UpdateTextCtrl(currentCode); } @@ -161,13 +162,13 @@ void CARCodeAddEdit::SaveCheatData(wxCommandEvent& WXUNUSED(event)) newCheat.ops = decryptedLines; newCheat.active = true; - arCodes.push_back(newCheat); + arCodes->push_back(newCheat); } else { // Update the currently-selected AR cheat code. - arCodes.at(selection).name = WxStrToStr(EditCheatName->GetValue()); - arCodes.at(selection).ops = decryptedLines; + arCodes->at(selection).name = WxStrToStr(EditCheatName->GetValue()); + arCodes->at(selection).ops = decryptedLines; } AcceptAndClose(); diff --git a/Source/Core/DolphinWX/ARCodeAddEdit.h b/Source/Core/DolphinWX/ARCodeAddEdit.h index cbf99a28fa..9baeab575d 100644 --- a/Source/Core/DolphinWX/ARCodeAddEdit.h +++ b/Source/Core/DolphinWX/ARCodeAddEdit.h @@ -21,7 +21,7 @@ namespace ActionReplay { struct ARCode; } class CARCodeAddEdit : public wxDialog { public: - CARCodeAddEdit(int _selection, const std::vector& _arCodes, + CARCodeAddEdit(int _selection, std::vector* _arCodes, wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Edit ActionReplay Code"), @@ -34,7 +34,7 @@ private: wxSpinButton* EntrySelection; wxTextCtrl* EditCheatCode; - std::vector arCodes; + std::vector* arCodes; void SaveCheatData(wxCommandEvent& event); void ChangeEntry(wxSpinEvent& event); diff --git a/Source/Core/DolphinWX/Cheats/CreateCodeDialog.cpp b/Source/Core/DolphinWX/Cheats/CreateCodeDialog.cpp index c9766cd2ce..4ba0926ab3 100644 --- a/Source/Core/DolphinWX/Cheats/CreateCodeDialog.cpp +++ b/Source/Core/DolphinWX/Cheats/CreateCodeDialog.cpp @@ -20,7 +20,7 @@ // Fired when an ActionReplay code is created. wxDEFINE_EVENT(UPDATE_CHEAT_LIST_EVENT, wxCommandEvent); -CreateCodeDialog::CreateCodeDialog(wxWindow* const parent, const u32 address, const std::vector& _arCodes) +CreateCodeDialog::CreateCodeDialog(wxWindow* const parent, const u32 address, std::vector* _arCodes) : wxDialog(parent, wxID_ANY, _("Create AR Code")) , m_code_address(address) , arCodes(_arCodes) @@ -92,7 +92,7 @@ void CreateCodeDialog::PressOK(wxCommandEvent& ev) { CISOProperties isoprops(SConfig::GetInstance().m_LastFilename, this); // add the code to the isoproperties arcode list - arCodes.push_back(new_cheat); + arCodes->push_back(new_cheat); // save the gameini isoprops.SaveGameConfig(); isoprops.ActionReplayList_Load(); // loads the new arcodes diff --git a/Source/Core/DolphinWX/Cheats/CreateCodeDialog.h b/Source/Core/DolphinWX/Cheats/CreateCodeDialog.h index d1860ffed6..c0ece93e11 100644 --- a/Source/Core/DolphinWX/Cheats/CreateCodeDialog.h +++ b/Source/Core/DolphinWX/Cheats/CreateCodeDialog.h @@ -19,11 +19,11 @@ wxDECLARE_EVENT(UPDATE_CHEAT_LIST_EVENT, wxCommandEvent); class CreateCodeDialog final : public wxDialog { public: - CreateCodeDialog(wxWindow* const parent, const u32 address, const std::vector& _arCodes); + CreateCodeDialog(wxWindow* const parent, const u32 address, std::vector* _arCodes); private: const u32 m_code_address; - std::vector arCodes; + std::vector* arCodes; wxTextCtrl* m_textctrl_name; wxTextCtrl* m_textctrl_code; diff --git a/Source/Core/DolphinWX/ISOProperties.cpp b/Source/Core/DolphinWX/ISOProperties.cpp index e0f83a76d6..64ef6f2cb8 100644 --- a/Source/Core/DolphinWX/ISOProperties.cpp +++ b/Source/Core/DolphinWX/ISOProperties.cpp @@ -1388,13 +1388,13 @@ void CISOProperties::PatchButtonClicked(wxCommandEvent& event) { case ID_EDITPATCH: { - CPatchAddEdit dlg(selection, onFrame, this); + CPatchAddEdit dlg(selection, &onFrame, this); dlg.ShowModal(); } break; case ID_ADDPATCH: { - CPatchAddEdit dlg(-1, onFrame, this, 1, _("Add Patch")); + CPatchAddEdit dlg(-1, &onFrame, this, 1, _("Add Patch")); if (dlg.ShowModal() == wxID_OK) { Patches->Append(StrToWxStr(onFrame.back().name)); @@ -1468,13 +1468,13 @@ void CISOProperties::ActionReplayButtonClicked(wxCommandEvent& event) { case ID_EDITCHEAT: { - CARCodeAddEdit dlg(selection, arCodes, this); + CARCodeAddEdit dlg(selection, &arCodes, this); dlg.ShowModal(); } break; case ID_ADDCHEAT: { - CARCodeAddEdit dlg(-1, arCodes, this, 1, _("Add ActionReplay Code")); + CARCodeAddEdit dlg(-1, &arCodes, this, 1, _("Add ActionReplay Code")); if (dlg.ShowModal() == wxID_OK) { Cheats->Append(StrToWxStr(arCodes.back().name)); diff --git a/Source/Core/DolphinWX/PatchAddEdit.cpp b/Source/Core/DolphinWX/PatchAddEdit.cpp index 5d388977bb..bce75ad391 100644 --- a/Source/Core/DolphinWX/PatchAddEdit.cpp +++ b/Source/Core/DolphinWX/PatchAddEdit.cpp @@ -28,12 +28,12 @@ #include "DolphinWX/PatchAddEdit.h" #include "DolphinWX/WxUtils.h" -CPatchAddEdit::CPatchAddEdit(int _selection, const std::vector& _onFrame, wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& position, const wxSize& size, long style) +CPatchAddEdit::CPatchAddEdit(int _selection, std::vector* _onFrame, wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& position, const wxSize& size, long style) : wxDialog(parent, id, title, position, size, style) + , onFrame(_onFrame) + , selection(_selection) { - selection = _selection; CreateGUIControls(selection); - onFrame = _onFrame; Bind(wxEVT_BUTTON, &CPatchAddEdit::SavePatchData, this, wxID_OK); } @@ -53,8 +53,8 @@ void CPatchAddEdit::CreateGUIControls(int _selection) } else { - currentName = StrToWxStr(onFrame.at(_selection).name); - tempEntries = onFrame.at(_selection).entries; + currentName = StrToWxStr(onFrame->at(_selection).name); + tempEntries = onFrame->at(_selection).entries; } itCurEntry = tempEntries.begin(); @@ -142,12 +142,12 @@ void CPatchAddEdit::SavePatchData(wxCommandEvent& event) newPatch.entries = tempEntries; newPatch.active = true; - onFrame.push_back(newPatch); + onFrame->push_back(newPatch); } else { - onFrame.at(selection).name = WxStrToStr(EditPatchName->GetValue()); - onFrame.at(selection).entries = tempEntries; + onFrame->at(selection).name = WxStrToStr(EditPatchName->GetValue()); + onFrame->at(selection).entries = tempEntries; } AcceptAndClose(); diff --git a/Source/Core/DolphinWX/PatchAddEdit.h b/Source/Core/DolphinWX/PatchAddEdit.h index 1fbd3e77b1..7bfee69708 100644 --- a/Source/Core/DolphinWX/PatchAddEdit.h +++ b/Source/Core/DolphinWX/PatchAddEdit.h @@ -25,7 +25,7 @@ class wxWindow; class CPatchAddEdit : public wxDialog { public: - CPatchAddEdit(int _selection, const std::vector& _onFrame, + CPatchAddEdit(int _selection, std::vector* _onFrame, wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Edit Patch"), @@ -43,7 +43,7 @@ private: wxButton* EntryAdd; wxButton* EntryRemove; wxStaticBoxSizer* sbEntry; - std::vector onFrame; + std::vector* onFrame; void CreateGUIControls(int selection); void ChangeEntry(wxSpinEvent& event);