Simplify execution path for extension checks

This commit is contained in:
YoshiRulz 2020-06-07 19:59:18 +10:00
parent 81cb8eb094
commit 95dbd7c20b
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
1 changed files with 30 additions and 33 deletions

View File

@ -924,7 +924,7 @@ namespace BizHawk.Client.Common
try try
{ {
var doExtensionChecks = false; var cancel = false;
if (OpenAdvanced is OpenAdvanced_Libretro) if (OpenAdvanced is OpenAdvanced_Libretro)
{ {
@ -994,44 +994,41 @@ namespace BizHawk.Client.Common
} }
else else
{ {
// if not libretro: do extension checking
doExtensionChecks = true;
// do the archive binding we had to skip // do the archive binding we had to skip
if (!HandleArchiveBinding(file)) if (!HandleArchiveBinding(file))
{ {
return false; return false;
} }
}
var cancel = false; // not libretro: do extension checking
var ext = file.Extension.ToLowerInvariant(); var ext = file.Extension.ToLowerInvariant();
if (doExtensionChecks) switch (ext) switch (ext)
{ {
case ".m3u": case ".m3u":
(nextEmulator, game) = LoadM3U(path, nextComm, file); (nextEmulator, game) = LoadM3U(path, nextComm, file);
break; break;
case ".xml": case ".xml":
var result = LoadXML(path, nextComm, file); // must be called before LoadOther because of SNES hacks var result = LoadXML(path, nextComm, file); // must be called before LoadOther because of SNES hacks
if (result == null) return false; if (result == null) return false;
(nextEmulator, rom, game) = result.Value; (nextEmulator, rom, game) = result.Value;
break; break;
case ".psf": case ".psf":
case ".minipsf": case ".minipsf":
(nextEmulator, rom, game) = LoadPSF(path, nextComm, file); (nextEmulator, rom, game) = LoadPSF(path, nextComm, file);
break; break;
default: default:
if (Disc.IsValidExtension(ext)) if (Disc.IsValidExtension(ext))
{ {
var result1 = LoadDisc(path, nextComm, file, ext); var result1 = LoadDisc(path, nextComm, file, ext);
if (result1 == null) return false; if (result1 == null) return false;
(nextEmulator, game) = result1.Value; (nextEmulator, game) = result1.Value;
} }
else else
{ {
(nextEmulator, rom, game) = LoadOther(path, nextComm, forceAccurateCore, file, out cancel); (nextEmulator, rom, game) = LoadOther(path, nextComm, forceAccurateCore, file, out cancel);
} }
break; break;
}
} }
if (nextEmulator == null) if (nextEmulator == null)