From f4740bbe52b15e97b56cf4c0fc07bf16c57c5006 Mon Sep 17 00:00:00 2001 From: Kurt Date: Tue, 9 Apr 2019 20:58:19 -0700 Subject: [PATCH] Capture reused variables --- PKHeX.Core/PKM/Util/PKMConverter.cs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/PKHeX.Core/PKM/Util/PKMConverter.cs b/PKHeX.Core/PKM/Util/PKMConverter.cs index 3eccc15e9..f6872e9ee 100644 --- a/PKHeX.Core/PKM/Util/PKMConverter.cs +++ b/PKHeX.Core/PKM/Util/PKMConverter.cs @@ -69,8 +69,10 @@ public static int GetPKMDataFormat(byte[] data) return -1; } return 6; + + default: + return -1; } - return -1; } /// @@ -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; }