Simplify expression, emit inner error messages

existing logic had been overwriting the inner error messages with the
generic fail message

Remove backwards conversion precondition check; the ConvertPKM method
has no branches that allow conversion so it'll naturally fail -- end
result is the same with less upfront logic.
This commit is contained in:
Kurt 2019-04-16 22:38:50 -07:00
parent 86d10af78b
commit 5a53c2490a

View file

@ -239,19 +239,11 @@ namespace PKHeX.Core
string fromName = fromType.Name; string fromName = fromType.Name;
Debug.WriteLine($"Trying to convert {fromName} to {toName}."); Debug.WriteLine($"Trying to convert {fromName} to {toName}.");
int fromFormat = fromName.Last() - '0';
int toFormat = toName.Last() - '0'; int toFormat = toName.Last() - '0';
if (fromFormat > toFormat && fromFormat != 2)
{
comment = string.Format(MsgPKMConvertFailFormat, fromName, toName);
return null;
}
var pkm = ConvertPKM(pk, PKMType, toFormat, ref comment); var pkm = ConvertPKM(pk, PKMType, toFormat, ref comment);
var msg = pkm == null ? MsgPKMConvertFailFormat : MsgPKMConvertSuccess;
comment = pkm == null var formatted = string.Format(msg, fromName, toName);
? string.Format(MsgPKMConvertFailFormat, fromName, toName) comment = comment == null ? formatted : string.Concat(formatted, Environment.NewLine, comment);
: string.Format(MsgPKMConvertSuccess, fromName, toName);
return pkm; return pkm;
} }