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.
This commit is contained in:
Lioncash 2018-05-13 13:53:49 -04:00
parent 9d1157f695
commit a166cf2481
3 changed files with 10 additions and 14 deletions

View File

@ -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);

View File

@ -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)));
}

View File

@ -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);