Permalink
Browse files

PatchEngine: Give Patch and PatchEntry default member initializers

Avoids potentially using the values uninitialized. While we're at it,
also drop the prefixed underscores from one of the constructors.
  • Loading branch information...
lioncash committed May 13, 2018
1 parent 9d1157f commit a166cf24812451f62680eac971b6f50173653084
@@ -24,19 +24,19 @@ extern const char* PatchTypeStrings[];
struct PatchEntry
{
PatchEntry() {}
PatchEntry(PatchType _t, u32 _addr, u32 _value) : type(_t), address(_addr), value(_value) {}
PatchType type;
u32 address;
u32 value;
PatchEntry() = default;
PatchEntry(PatchType t, u32 addr, u32 value_) : type(t), address(addr), value(value_) {}
PatchType type = PatchType::PATCH_8BIT;
u32 address = 0;
u32 value = 0;
};
struct Patch
{
std::string name;
std::vector<PatchEntry> entries;
bool active;
bool user_defined; // False if this code is shipped with Dolphin.
bool active = false;
bool user_defined = false; // False if this code is shipped with Dolphin.
};
int GetSpeedhackCycles(const u32 addr);
@@ -79,11 +79,7 @@ void NewPatchDialog::ConnectWidgets()
void NewPatchDialog::AddEntry()
{
PatchEngine::PatchEntry entry;
entry.type = PatchEngine::PATCH_8BIT;
entry.address = entry.value = 0;
m_patch.entries.push_back(entry);
m_patch.entries.emplace_back();
m_entry_layout->addWidget(CreateEntry(static_cast<int>(m_patch.entries.size() - 1)));
}
@@ -42,7 +42,7 @@ void CPatchAddEdit::CreateGUIControls(int _selection)
if (_selection == -1)
{
tempEntries.clear();
tempEntries.emplace_back(PatchEngine::PATCH_8BIT, 0x00000000, 0x00000000);
tempEntries.emplace_back();
}
else
{
@@ -165,7 +165,7 @@ void CPatchAddEdit::AddEntry(wxCommandEvent& event)
if (!UpdateTempEntryData(itCurEntry))
return;
PatchEngine::PatchEntry peEmptyEntry(PatchEngine::PATCH_8BIT, 0x00000000, 0x00000000);
PatchEngine::PatchEntry peEmptyEntry;
++itCurEntry;
currentItem++;
itCurEntry = tempEntries.insert(itCurEntry, peEmptyEntry);

0 comments on commit a166cf2

Please sign in to comment.