Capture reused variables

This commit is contained in:
Kurt
2019-04-09 20:58:19 -07:00
parent 1a343c3b21
commit f4740bbe52

View File

@@ -69,8 +69,10 @@ public static int GetPKMDataFormat(byte[] data)
return -1;
}
return 6;
default:
return -1;
}
return -1;
}
/// <summary>
@@ -233,21 +235,23 @@ private static PKM ConvertPKM(PKM pk, Type PKMType, Type fromType, out string co
if (IsNotTransferable(pk, out comment))
return null;
Debug.WriteLine($"Trying to convert {fromType.Name} to {PKMType.Name}.");
string toName = PKMType.Name;
string fromName = fromType.Name;
Debug.WriteLine($"Trying to convert {fromName} to {toName}.");
int fromFormat = int.Parse(fromType.Name.Last().ToString());
int toFormat = int.Parse(PKMType.Name.Last().ToString());
int fromFormat = fromName.Last() - '0';
int toFormat = toName.Last() - '0';
if (fromFormat > toFormat && fromFormat != 2)
{
comment = string.Format(MsgPKMConvertFailFormat, fromType.Name, PKMType.Name);
comment = string.Format(MsgPKMConvertFailFormat, toName, fromName);
return null;
}
var pkm = ConvertPKM(pk, PKMType, toFormat, ref comment);
comment = pkm == null
? string.Format(MsgPKMConvertFailFormat, fromType.Name, PKMType.Name)
: string.Format(MsgPKMConvertSuccess, fromType.Name, PKMType.Name);
? string.Format(MsgPKMConvertFailFormat, toName, fromName)
: string.Format(MsgPKMConvertSuccess, toName, fromName);
return pkm;
}