Fix xorpad infinite loop when loading from exepath

This commit is contained in:
Kurt 2015-12-12 23:39:43 -08:00
parent 2a94b64617
commit c51e3ae8a5

View file

@ -635,6 +635,7 @@ namespace PKHeX
string xorpath = exepath.Clone().ToString(); string xorpath = exepath.Clone().ToString();
string[] XORpads = Directory.GetFiles(xorpath); string[] XORpads = Directory.GetFiles(xorpath);
int loop = 0;
check: check:
foreach (byte[] data in from file in XORpads let fi = new FileInfo(file) where (fi.Name.ToLower().Contains("xorpad") || fi.Name.ToLower().Contains("key")) && (fi.Length == 0x10009C || fi.Length == 0x100000) select File.ReadAllBytes(file)) foreach (byte[] data in from file in XORpads let fi = new FileInfo(file) where (fi.Name.ToLower().Contains("xorpad") || fi.Name.ToLower().Contains("key")) && (fi.Length == 0x10009C || fi.Length == 0x100000) select File.ReadAllBytes(file))
{ {
@ -669,7 +670,7 @@ namespace PKHeX
return true; return true;
} }
// End file check loop, check the input path for xorpads too if it isn't the same as the EXE (quite common). // End file check loop, check the input path for xorpads too if it isn't the same as the EXE (quite common).
if (xorpath != exepath) return false; // no xorpad compatible if (xorpath != exepath || loop++ > 0) return false; // no xorpad compatible
xorpath = Path.GetDirectoryName(path); goto check; xorpath = Path.GetDirectoryName(path); goto check;
} }
private void openSave(bool oras) private void openSave(bool oras)