mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-08-23 12:56:15 -05:00
Simplify some logic
This commit is contained in:
@@ -469,7 +469,7 @@ private bool ParseSpeciesForm(string spec)
|
||||
|
||||
private void ParseSpeciesNickname(string line)
|
||||
{
|
||||
int index = line.LastIndexOf("(", StringComparison.Ordinal);
|
||||
int index = line.LastIndexOf('(');
|
||||
string n1, n2;
|
||||
if (index > 1) // correct format
|
||||
{
|
||||
@@ -479,7 +479,7 @@ private void ParseSpeciesNickname(string line)
|
||||
}
|
||||
else // nickname first (manually created set, incorrect)
|
||||
{
|
||||
int end = line.IndexOf(")", StringComparison.Ordinal);
|
||||
int end = line.IndexOf(')');
|
||||
n2 = line.Substring(index + 1, end - 1);
|
||||
n1 = line.Substring(end + 2);
|
||||
}
|
||||
|
||||
@@ -36,15 +36,11 @@ public static void SetFileInfo(this SaveFile sav, string path)
|
||||
|
||||
sav.FilePath = path;
|
||||
sav.FileFolder = Path.GetDirectoryName(path);
|
||||
sav.FileName = string.Empty;
|
||||
var bakName = Util.CleanFileName(sav.BAKName);
|
||||
sav.FileName = Path.GetFileName(path);
|
||||
if (!sav.FileName.EndsWith(".bak"))
|
||||
return;
|
||||
|
||||
// trim off any bak details to get original file name
|
||||
int index = sav.FileName.LastIndexOf(" [", StringComparison.Ordinal);
|
||||
if (index < 0)
|
||||
return;
|
||||
sav.FileName = sav.FileName.Substring(0, index);
|
||||
if (sav.FileName?.EndsWith(bakName) == true)
|
||||
sav.FileName = sav.FileName.Substring(0, sav.FileName.Length - bakName.Length);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user