Skip sending info on missing ID, Use id on blank name

This commit is contained in:
Ender's Games 2018-09-30 05:51:51 -04:00
parent dc5a3df78f
commit c1494b9363
2 changed files with 12 additions and 8 deletions

View File

@ -659,7 +659,7 @@ public class GL2JNIView extends GLSurfaceView
} }
void reiosInfo(String reiosId, String reiosSoftware) { void reiosInfo(String reiosId, String reiosSoftware) {
if (fileName != null && !reiosId.equals("") && !reiosSoftware.equals("")) { if (fileName != null) {
String gameId = reiosId.replaceAll("[^a-zA-Z0-9]+", "").toLowerCase(); String gameId = reiosId.replaceAll("[^a-zA-Z0-9]+", "").toLowerCase();
SharedPreferences mPrefs = context.getSharedPreferences(gameId, Activity.MODE_PRIVATE); SharedPreferences mPrefs = context.getSharedPreferences(gameId, Activity.MODE_PRIVATE);
Emulator app = (Emulator) context.getApplicationContext(); Emulator app = (Emulator) context.getApplicationContext();
@ -668,6 +668,8 @@ public class GL2JNIView extends GLSurfaceView
((GL2JNIActivity) context).getPad().joystick[0] = mPrefs.getBoolean( ((GL2JNIActivity) context).getPad().joystick[0] = mPrefs.getBoolean(
Gamepad.pref_js_merged + "_A", Gamepad.pref_js_merged + "_A",
((GL2JNIActivity) context).getPad().joystick[0]); ((GL2JNIActivity) context).getPad().joystick[0]);
// Assign the ID as a placeholder if a name isn't found
if (reiosSoftware.equals("")) reiosSoftware = reiosId;
mPrefs.edit().putString(Config.game_title, reiosSoftware.trim()).apply(); mPrefs.edit().putString(Config.game_title, reiosSoftware.trim()).apply();
} }
} }

View File

@ -390,14 +390,16 @@ JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_query(JNIEnv *env,job
jmethodID reiosInfoMid=env->GetMethodID(env->GetObjectClass(emu_thread),"reiosInfo","(Ljava/lang/String;Ljava/lang/String;)V"); jmethodID reiosInfoMid=env->GetMethodID(env->GetObjectClass(emu_thread),"reiosInfo","(Ljava/lang/String;Ljava/lang/String;)V");
char *id = (char*)malloc(11); char *id = (char*)malloc(11);
// Verify that there is an ID assigned
if ((id != NULL) && (id[0] == '\0')) {
strcpy(id, reios_disk_id()); strcpy(id, reios_disk_id());
jstring reios_id = env->NewStringUTF(id); jstring reios_id = env->NewStringUTF(id);
char *name = (char *) malloc(129); char *name = (char *) malloc(129);
strcpy(name, reios_software_name); strcpy(name, reios_software_name);
jstring reios_name = env->NewStringUTF(name); jstring reios_name = env->NewStringUTF(name);
env->CallVoidMethod(emu_thread, reiosInfoMid, reios_id, reios_name); env->CallVoidMethod(emu_thread, reiosInfoMid, reios_id, reios_name);
}
dc_init(); dc_init();
} }