From 82a6701f795a883d80c3b0167b4d3f3e224a5cd8 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Thu, 28 Dec 2017 10:13:53 +0100 Subject: Optionally delete savestate that gets loaded at boot --- Source/Android/jni/MainAndroid.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'Source/Android/jni/MainAndroid.cpp') diff --git a/Source/Android/jni/MainAndroid.cpp b/Source/Android/jni/MainAndroid.cpp index c4ab13f59c..b1bd33093c 100644 --- a/Source/Android/jni/MainAndroid.cpp +++ b/Source/Android/jni/MainAndroid.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include "ButtonManager.h" @@ -482,8 +483,8 @@ Java_org_dolphinemu_dolphinemu_NativeLibrary_CacheClassesAndMethods(JNIEnv* env, JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_Run__Ljava_lang_String_2( JNIEnv* env, jobject obj, jstring jFile); JNIEXPORT void JNICALL -Java_org_dolphinemu_dolphinemu_NativeLibrary_Run__Ljava_lang_String_2Ljava_lang_String_2( - JNIEnv* env, jobject obj, jstring jFile, jstring jSavestate); +Java_org_dolphinemu_dolphinemu_NativeLibrary_Run__Ljava_lang_String_2Ljava_lang_String_2Z( + JNIEnv* env, jobject obj, jstring jFile, jstring jSavestate, jboolean jDeleteSavestate); JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SurfaceChanged(JNIEnv* env, jobject obj, jobject surf); @@ -805,7 +806,8 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_RefreshWiimo WiimoteReal::Refresh(); } -static void Run(const std::string& path, std::optional savestate_path = {}) +static void Run(const std::string& path, std::optional savestate_path = {}, + bool delete_savestate = false) { __android_log_print(ANDROID_LOG_INFO, DOLPHIN_TAG, "Running : %s", path.c_str()); @@ -823,7 +825,9 @@ static void Run(const std::string& path, std::optional savestate_pa // No use running the loop when booting fails s_have_wm_user_stop = false; - if (BootManager::BootCore(BootParameters::GenerateFromFile(path, savestate_path))) + std::unique_ptr boot = BootParameters::GenerateFromFile(path, savestate_path); + boot->delete_savestate = delete_savestate; + if (BootManager::BootCore(std::move(boot))) { static constexpr int TIMEOUT = 10000; static constexpr int WAIT_STEP = 25; @@ -861,10 +865,10 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_Run__Ljava_l } JNIEXPORT void JNICALL -Java_org_dolphinemu_dolphinemu_NativeLibrary_Run__Ljava_lang_String_2Ljava_lang_String_2( - JNIEnv* env, jobject obj, jstring jFile, jstring jSavestate) +Java_org_dolphinemu_dolphinemu_NativeLibrary_Run__Ljava_lang_String_2Ljava_lang_String_2Z( + JNIEnv* env, jobject obj, jstring jFile, jstring jSavestate, jboolean jDeleteSavestate) { - Run(GetJString(env, jFile), GetJString(env, jSavestate)); + Run(GetJString(env, jFile), GetJString(env, jSavestate), jDeleteSavestate); } #ifdef __cplusplus -- cgit v1.2.3