Skip to content

Commit

Permalink
Fix some minor issues with cheats
Browse files Browse the repository at this point in the history
  • Loading branch information
Hydr8gon committed Jul 20, 2024
1 parent 2a96468 commit 7a323b8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/action_replay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ bool ActionReplay::loadCheats()
// Load the cheat code up until an empty line
while (fgets(data, 512, file) != nullptr && data[0] != '\n')
{
cheat.code.push_back(strtol(&data[0], nullptr, 16));
cheat.code.push_back(strtol(&data[8], nullptr, 16));
cheat.code.push_back(strtoll(&data[0], nullptr, 16));
cheat.code.push_back(strtoll(&data[8], nullptr, 16));
}
}

Expand Down
13 changes: 6 additions & 7 deletions src/desktop/cheat_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,9 @@ CheatDialog::CheatDialog(Core *core): wxDialog(nullptr, wxID_ANY, "Action Replay

// Set up the cheat name and code editors
wxBoxSizer *editSizer = new wxBoxSizer(wxVERTICAL);
nameEditor = new wxTextCtrl();
nameEditor->Create(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(size * 8, size));
nameEditor = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(size * 8, size));
editSizer->Add(nameEditor, 0, wxEXPAND | wxBOTTOM, size / 16);
codeEditor = new wxTextCtrl();
codeEditor->Create(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE);
codeEditor = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE);
editSizer->Add(codeEditor, 1, wxEXPAND | wxTOP, size / 16);

// Set up the cheat list and combine it with the editors
Expand Down Expand Up @@ -104,7 +102,7 @@ void CheatDialog::updateCheat()
{
p = code.find_first_of(" \n", i);
if (p == std::string::npos) p = code.size();
cheat->code.push_back(strtol(code.substr(i, p).c_str(), nullptr, 16));
cheat->code.push_back(strtoll(code.substr(i, p).c_str(), nullptr, 16));
}

// Ensure the code's word count is a multiple of 2
Expand All @@ -124,10 +122,11 @@ void CheatDialog::selectCheat(wxCommandEvent &event)
// Select a new cheat and put its name in the editor
if (curCheat >= 0) updateCheat();
ARCheat *cheat = &core->actionReplay.cheats[curCheat = event.GetInt()];
nameEditor->SetValue(cheat->name);
codeEditor->Clear();
nameEditor->Clear();
nameEditor->AppendText(cheat->name);

// Write the code to the editor as a string
codeEditor->Clear();
for (uint32_t i = 0; i < cheat->code.size(); i += 2)
{
char line[19];
Expand Down

0 comments on commit 7a323b8

Please sign in to comment.