mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-06-28 18:09:46 -06:00
Allow AREngine
to be used independently of ARCodeFile
(#2108)
* Make `EmuInstance::cheatFile` use a `unique_ptr` - Fixes a memory leak, as the cheat file wasn't cleaned up in the destructor * Split `AREngine` and `ARCodeFile` apart - Suitable for frontends that have their own way of storing cheats - Store the cheats in `AREngine` in a `std::vector` - Apparently cheats are _supposed_ to be executed each frame; I didn't understand this until recently
This commit is contained in:
@ -33,17 +33,26 @@ ARCodeFile::ARCodeFile(const std::string& filename)
|
||||
{
|
||||
Filename = filename;
|
||||
|
||||
Error = false;
|
||||
|
||||
Categories.clear();
|
||||
|
||||
if (!Load())
|
||||
Error = true;
|
||||
}
|
||||
|
||||
ARCodeFile::~ARCodeFile()
|
||||
std::vector<ARCode> ARCodeFile::GetCodes() const noexcept
|
||||
{
|
||||
Categories.clear();
|
||||
if (Error)
|
||||
return {};
|
||||
|
||||
std::vector<ARCode> codes;
|
||||
|
||||
for (const ARCodeCat& cat : Categories)
|
||||
{
|
||||
for (const ARCode& code : cat.Codes)
|
||||
{
|
||||
codes.push_back(code);
|
||||
}
|
||||
}
|
||||
|
||||
return codes;
|
||||
}
|
||||
|
||||
bool ARCodeFile::Load()
|
||||
|
Reference in New Issue
Block a user