SDL: Fix cheats not loading
Vicki Pfau vi@endrift.com
Sat, 15 Jul 2017 07:14:42 -0700
2 files changed,
16 insertions(+),
0 deletions(-)
M
CHANGES
→
CHANGES
@@ -68,6 +68,7 @@ - Qt: Fix game unpausing after frame advancing and refocusing
- SDL: Fix game crash check - SDL: Fix race condition with audio thread when starting - SDL: Fix showing version number + - SDL: Fix cheats not loading - Test: Fix crash when loading invalid file - Test: Fix crash when fuzzing fails to load a file - Test: Don't rely on core for frames elapsed
M
src/platform/sdl/main.c
→
src/platform/sdl/main.c
@@ -14,6 +14,7 @@ #ifdef USE_EDITLINE
#include "feature/editline/cli-el-backend.h" #endif +#include <mgba/core/cheats.h> #include <mgba/core/core.h> #include <mgba/core/config.h> #include <mgba/core/input.h>@@ -97,6 +98,16 @@ freeArguments(&args);
return 1; } + struct mCheatDevice* device = NULL; + if (args.cheatsFile && (device = renderer.core->cheatDevice(renderer.core))) { + struct VFile* vf = VFileOpen(args.cheatsFile, O_RDONLY); + if (vf) { + mCheatDeviceClear(device); + mCheatParseFile(device, vf); + vf->close(vf); + } + } + mInputMapInit(&renderer.core->inputMap, &GBAInputInfo); mCoreInitConfig(renderer.core, PORT); applyArguments(&args, &subparser, &renderer.core->config);@@ -140,6 +151,10 @@ // TODO: Use opts and config
ret = mSDLRun(&renderer, &args); mSDLDetachPlayer(&renderer.events, &renderer.player); mInputMapDeinit(&renderer.core->inputMap); + + if (device) { + mCheatDeviceDestroy(device); + } mSDLDeinit(&renderer);