Tweak casting

I'm a little too averse for extra lines of code :)

Regarding remaining discussion on #136
Resharper gives suggestion to null check
Path.GetFileNameWithoutExtension and Path.GetExtension, so it won't
hurt. Just because it's set up to work properly now doesn't mean someone
modifying it / operating systems years from now will supply the correct
arguments.
This commit is contained in:
Kaphotics 2016-07-18 20:36:52 -07:00
parent 83c2f02fd1
commit fb9c18c151

View file

@ -2705,12 +2705,16 @@ namespace PKHeX
// Currently saved Value
ulong oldval = 0;
if (tb == TB_GameSync)
oldval = ((SAV6) SAV).GameSyncID;
else if (tb == TB_Secure1)
oldval = ((SAV6) SAV).Secure1;
else if (tb == TB_Secure2)
oldval = ((SAV6) SAV).Secure2;
if (SAV.Generation == 6)
{
SAV6 sav6 = (SAV6) SAV;
if (tb == TB_GameSync)
oldval = sav6.GameSyncID;
else if (tb == TB_Secure1)
oldval = sav6.Secure1;
else if (tb == TB_Secure2)
oldval = sav6.Secure2;
}
string filterText = Util.getOnlyHex(tb.Text);
@ -2724,14 +2728,17 @@ namespace PKHeX
// Write final value back to the save
ulong newval = Convert.ToUInt64(filterText, 16);
if (newval != oldval)
if (newval == oldval) return;
if (SAV.Generation == 6)
{
SAV6 sav6 = (SAV6) SAV;
if (tb == TB_GameSync)
((SAV6) SAV).GameSyncID = newval;
sav6.GameSyncID = newval;
else if (tb == TB_Secure1)
((SAV6) SAV).Secure1 = newval;
sav6.Secure1 = newval;
else if (tb == TB_Secure2)
((SAV6) SAV).Secure2 = newval;
sav6.Secure2 = newval;
SAV.Edited = true;
}
}