Changing the Gecko code comparison from metadata to data comparison
because different data sometimes have the same metadata
This commit is contained in:
parent
4dad640d5f
commit
80b09c074e
|
@ -63,6 +63,38 @@ u32 GeckoCode::Code::GetAddress() const
|
|||
return gcaddress + (use_po ? pointer_address : (base_address & 0xFE000000));
|
||||
}
|
||||
|
||||
// return true if a code exists
|
||||
bool GeckoCode::Exist(u32 address, u32 data)
|
||||
{
|
||||
std::vector<GeckoCode::Code>::const_iterator
|
||||
codes_iter = codes.begin(),
|
||||
codes_end = codes.end();
|
||||
for (; codes_iter != codes_end; ++codes_iter)
|
||||
{
|
||||
if (codes_iter->address == address && codes_iter->data == data)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// return true if the code is identical
|
||||
bool GeckoCode::Compare(GeckoCode compare) const
|
||||
{
|
||||
if (codes.size() != compare.codes.size())
|
||||
return false;
|
||||
|
||||
int exist = 0;
|
||||
std::vector<GeckoCode::Code>::const_iterator
|
||||
codes_iter = codes.begin(),
|
||||
codes_end = codes.end();
|
||||
for (; codes_iter != codes_end; ++codes_iter)
|
||||
{
|
||||
if (compare.Exist(codes_iter->address, codes_iter->data))
|
||||
exist++;
|
||||
}
|
||||
return exist == codes.size();
|
||||
}
|
||||
|
||||
static std::mutex active_codes_lock;
|
||||
|
||||
// currently running code
|
||||
|
|
|
@ -66,6 +66,9 @@ namespace Gecko
|
|||
std::vector<std::string> notes;
|
||||
|
||||
bool enabled;
|
||||
|
||||
bool Compare(GeckoCode compare) const;
|
||||
bool Exist(u32 address, u32 data);
|
||||
};
|
||||
|
||||
void SetActiveCodes(const std::vector<GeckoCode>& gcodes);
|
||||
|
|
|
@ -283,9 +283,8 @@ void CodeConfigPanel::DownloadCodes(wxCommandEvent&)
|
|||
break;
|
||||
}
|
||||
|
||||
// code with this name+creator exists
|
||||
if (existing_gcodes_iter->name == gcodes_iter->name &&
|
||||
existing_gcodes_iter->creator == gcodes_iter->creator)
|
||||
// code exists
|
||||
if (existing_gcodes_iter->Compare(*gcodes_iter))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue