mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-23 12:33:06 +00:00
ArgumentException -> ArgumentOutOfRangeException
This commit is contained in:
parent
27059268ba
commit
8f0fb902d1
35 changed files with 92 additions and 91 deletions
|
@ -83,7 +83,7 @@ namespace PKHeX.Core
|
||||||
case 1: pk.Move2_PP = pk.GetMovePP(pk.Move2, pk.Move2_PPUps); return;
|
case 1: pk.Move2_PP = pk.GetMovePP(pk.Move2, pk.Move2_PPUps); return;
|
||||||
case 2: pk.Move3_PP = pk.GetMovePP(pk.Move3, pk.Move3_PPUps); return;
|
case 2: pk.Move3_PP = pk.GetMovePP(pk.Move3, pk.Move3_PPUps); return;
|
||||||
case 3: pk.Move4_PP = pk.GetMovePP(pk.Move4, pk.Move4_PPUps); return;
|
case 3: pk.Move4_PP = pk.GetMovePP(pk.Move4, pk.Move4_PPUps); return;
|
||||||
default: throw new ArgumentException(nameof(index));
|
default: throw new ArgumentOutOfRangeException(nameof(index));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ namespace PKHeX.Core
|
||||||
return new EvolutionMethod(method + 1, species, argument: arg, level: arg);
|
return new EvolutionMethod(method + 1, species, argument: arg, level: arg);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new ArgumentException(nameof(method));
|
throw new ArgumentOutOfRangeException(nameof(method));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace PKHeX.Core
|
||||||
int species = BitConverter.ToUInt16(data, offset + 4);
|
int species = BitConverter.ToUInt16(data, offset + 4);
|
||||||
|
|
||||||
if (method == 0)
|
if (method == 0)
|
||||||
throw new ArgumentException(nameof(data));
|
throw new ArgumentOutOfRangeException(nameof(method));
|
||||||
|
|
||||||
// To have the same structure as gen 6
|
// To have the same structure as gen 6
|
||||||
// Gen 4 Method 6 is Gen 6 Method 7, G4 7 = G6 8, and so on
|
// Gen 4 Method 6 is Gen 6 Method 7, G4 7 = G6 8, and so on
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace PKHeX.Core
|
||||||
int species = BitConverter.ToUInt16(data, offset + 4);
|
int species = BitConverter.ToUInt16(data, offset + 4);
|
||||||
|
|
||||||
if (method == 0)
|
if (method == 0)
|
||||||
throw new ArgumentException(nameof(data));
|
throw new ArgumentOutOfRangeException(nameof(method));
|
||||||
|
|
||||||
var lvl = EvolutionSet6.EvosWithArg.Contains(method) ? 0 : arg;
|
var lvl = EvolutionSet6.EvosWithArg.Contains(method) ? 0 : arg;
|
||||||
return new EvolutionMethod(method, species, argument: arg, level: lvl);
|
return new EvolutionMethod(method, species, argument: arg, level: lvl);
|
||||||
|
|
|
@ -24,7 +24,7 @@ namespace PKHeX.Core
|
||||||
RNGType.LCRNG => RNG.LCRNG,
|
RNGType.LCRNG => RNG.LCRNG,
|
||||||
RNGType.XDRNG => RNG.XDRNG,
|
RNGType.XDRNG => RNG.XDRNG,
|
||||||
RNGType.ARNG => RNG.ARNG,
|
RNGType.ARNG => RNG.ARNG,
|
||||||
_ => throw new ArgumentException(nameof(type)),
|
_ => throw new ArgumentOutOfRangeException(nameof(type)),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,16 +35,16 @@ namespace PKHeX.Core
|
||||||
/// <returns>Object containing search criteria to be passed by reference to search/filter methods.</returns>
|
/// <returns>Object containing search criteria to be passed by reference to search/filter methods.</returns>
|
||||||
public FrameGenerator(PKM pk)
|
public FrameGenerator(PKM pk)
|
||||||
{
|
{
|
||||||
var ver = (GameVersion)pk.Version;
|
var version = (GameVersion)pk.Version;
|
||||||
switch (ver)
|
switch (version)
|
||||||
{
|
{
|
||||||
// Method H
|
// Method H
|
||||||
case R or S or E or FR or LG:
|
case R or S or E or FR or LG:
|
||||||
DPPt = false;
|
DPPt = false;
|
||||||
FrameType = FrameType.MethodH;
|
FrameType = FrameType.MethodH;
|
||||||
Safari3 = pk.Ball == 5 && ver is not (FR or LG);
|
Safari3 = pk.Ball == 5 && version is not (FR or LG);
|
||||||
|
|
||||||
if (ver != E)
|
if (version != E)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
AllowLeads = true;
|
AllowLeads = true;
|
||||||
|
@ -75,7 +75,7 @@ namespace PKHeX.Core
|
||||||
FrameType = FrameType.MethodK;
|
FrameType = FrameType.MethodK;
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
throw new ArgumentException(nameof(ver));
|
throw new ArgumentOutOfRangeException(nameof(version));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -285,7 +285,7 @@ namespace PKHeX.Core
|
||||||
{
|
{
|
||||||
00 or 01 or 02 => AbilityType, // Fixed 0/1/2
|
00 or 01 or 02 => AbilityType, // Fixed 0/1/2
|
||||||
03 or 04 => criteria.GetAbilityFromType(AbilityType), // 0/1 or 0/1/H
|
03 or 04 => criteria.GetAbilityFromType(AbilityType), // 0/1 or 0/1/H
|
||||||
_ => throw new ArgumentException(nameof(AbilityType)),
|
_ => throw new ArgumentOutOfRangeException(nameof(AbilityType)),
|
||||||
};
|
};
|
||||||
|
|
||||||
private void SetPID(PKM pk, int av)
|
private void SetPID(PKM pk, int av)
|
||||||
|
|
|
@ -415,7 +415,7 @@ namespace PKHeX.Core
|
||||||
{
|
{
|
||||||
00 or 01 or 02 => AbilityType, // Fixed 0/1/2
|
00 or 01 or 02 => AbilityType, // Fixed 0/1/2
|
||||||
03 or 04 => criteria.GetAbilityFromType(AbilityType), // 0/1 or 0/1/H
|
03 or 04 => criteria.GetAbilityFromType(AbilityType), // 0/1 or 0/1/H
|
||||||
_ => throw new ArgumentException(nameof(AbilityType)),
|
_ => throw new ArgumentOutOfRangeException(nameof(AbilityType)),
|
||||||
};
|
};
|
||||||
|
|
||||||
private void SetPID(PKM pk)
|
private void SetPID(PKM pk)
|
||||||
|
|
|
@ -413,7 +413,7 @@ namespace PKHeX.Core
|
||||||
{
|
{
|
||||||
00 or 01 or 02 => AbilityType, // Fixed 0/1/2
|
00 or 01 or 02 => AbilityType, // Fixed 0/1/2
|
||||||
03 or 04 => criteria.GetAbilityFromType(AbilityType), // 0/1 or 0/1/H
|
03 or 04 => criteria.GetAbilityFromType(AbilityType), // 0/1 or 0/1/H
|
||||||
_ => throw new ArgumentException(nameof(AbilityType)),
|
_ => throw new ArgumentOutOfRangeException(nameof(AbilityType)),
|
||||||
};
|
};
|
||||||
|
|
||||||
private void SetPID(PKM pk)
|
private void SetPID(PKM pk)
|
||||||
|
|
|
@ -445,7 +445,7 @@ namespace PKHeX.Core
|
||||||
{
|
{
|
||||||
00 or 01 or 02 => AbilityType, // Fixed 0/1/2
|
00 or 01 or 02 => AbilityType, // Fixed 0/1/2
|
||||||
03 or 04 => criteria.GetAbilityFromType(AbilityType), // 0/1 or 0/1/H
|
03 or 04 => criteria.GetAbilityFromType(AbilityType), // 0/1 or 0/1/H
|
||||||
_ => throw new ArgumentException(nameof(AbilityType)),
|
_ => throw new ArgumentOutOfRangeException(nameof(AbilityType)),
|
||||||
};
|
};
|
||||||
|
|
||||||
private void SetPID(PKM pk)
|
private void SetPID(PKM pk)
|
||||||
|
|
|
@ -169,7 +169,7 @@ namespace PKHeX.Core
|
||||||
2 => Shiny.AlwaysStar,
|
2 => Shiny.AlwaysStar,
|
||||||
3 => Shiny.AlwaysSquare,
|
3 => Shiny.AlwaysSquare,
|
||||||
4 => Shiny.FixedValue,
|
4 => Shiny.FixedValue,
|
||||||
_ => throw new ArgumentException(),
|
_ => throw new ArgumentOutOfRangeException(nameof(PIDType)),
|
||||||
};
|
};
|
||||||
|
|
||||||
public int MetLevel { get => Data[CardStart + 0x249]; set => Data[CardStart + 0x249] = (byte)value; }
|
public int MetLevel { get => Data[CardStart + 0x249]; set => Data[CardStart + 0x249] = (byte)value; }
|
||||||
|
@ -499,7 +499,7 @@ namespace PKHeX.Core
|
||||||
{
|
{
|
||||||
00 or 01 or 02 => AbilityType, // Fixed 0/1/2
|
00 or 01 or 02 => AbilityType, // Fixed 0/1/2
|
||||||
03 or 04 => criteria.GetAbilityFromType(AbilityType), // 0/1 or 0/1/H
|
03 or 04 => criteria.GetAbilityFromType(AbilityType), // 0/1 or 0/1/H
|
||||||
_ => throw new ArgumentException(nameof(AbilityType)),
|
_ => throw new ArgumentOutOfRangeException(nameof(AbilityType)),
|
||||||
};
|
};
|
||||||
|
|
||||||
private uint GetPID(ITrainerID tr, byte type)
|
private uint GetPID(ITrainerID tr, byte type)
|
||||||
|
@ -511,7 +511,7 @@ namespace PKHeX.Core
|
||||||
2 => (uint) (((tr.TID ^ tr.SID ^ (PID & 0xFFFF) ^ 1) << 16) | (PID & 0xFFFF)), // Fixed, Force Star
|
2 => (uint) (((tr.TID ^ tr.SID ^ (PID & 0xFFFF) ^ 1) << 16) | (PID & 0xFFFF)), // Fixed, Force Star
|
||||||
3 => (uint) (((tr.TID ^ tr.SID ^ (PID & 0xFFFF) ^ 0) << 16) | (PID & 0xFFFF)), // Fixed, Force Square
|
3 => (uint) (((tr.TID ^ tr.SID ^ (PID & 0xFFFF) ^ 0) << 16) | (PID & 0xFFFF)), // Fixed, Force Square
|
||||||
4 => PID, // Fixed, Force Value
|
4 => PID, // Fixed, Force Value
|
||||||
_ => throw new ArgumentException(),
|
_ => throw new ArgumentOutOfRangeException(nameof(type)),
|
||||||
};
|
};
|
||||||
|
|
||||||
static uint GetAntishiny(ITrainerID tr)
|
static uint GetAntishiny(ITrainerID tr)
|
||||||
|
|
|
@ -475,7 +475,7 @@ namespace PKHeX.Core
|
||||||
public bool GetMoveRecordFlag(int index)
|
public bool GetMoveRecordFlag(int index)
|
||||||
{
|
{
|
||||||
if ((uint) index > 112) // 14 bytes, 8 bits
|
if ((uint) index > 112) // 14 bytes, 8 bits
|
||||||
throw new ArgumentException(nameof(index));
|
throw new ArgumentOutOfRangeException(nameof(index));
|
||||||
int ofs = index >> 3;
|
int ofs = index >> 3;
|
||||||
return FlagUtil.GetFlag(Data, 0x127 + ofs, index & 7);
|
return FlagUtil.GetFlag(Data, 0x127 + ofs, index & 7);
|
||||||
}
|
}
|
||||||
|
@ -483,7 +483,7 @@ namespace PKHeX.Core
|
||||||
public void SetMoveRecordFlag(int index, bool value)
|
public void SetMoveRecordFlag(int index, bool value)
|
||||||
{
|
{
|
||||||
if ((uint)index > 112) // 14 bytes, 8 bits
|
if ((uint)index > 112) // 14 bytes, 8 bits
|
||||||
throw new ArgumentException(nameof(index));
|
throw new ArgumentOutOfRangeException(nameof(index));
|
||||||
int ofs = index >> 3;
|
int ofs = index >> 3;
|
||||||
FlagUtil.SetFlag(Data, 0x127 + ofs, index & 7, value);
|
FlagUtil.SetFlag(Data, 0x127 + ofs, index & 7, value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ namespace PKHeX.Core
|
||||||
SCTypeCode.Single => sizeof(float),
|
SCTypeCode.Single => sizeof(float),
|
||||||
SCTypeCode.Double => sizeof(double),
|
SCTypeCode.Double => sizeof(double),
|
||||||
|
|
||||||
_ => throw new ArgumentException(type.ToString(), nameof(type)),
|
_ => throw new ArgumentOutOfRangeException(nameof(type), type.ToString()),
|
||||||
};
|
};
|
||||||
|
|
||||||
public static Type GetType(this SCTypeCode type) => type switch
|
public static Type GetType(this SCTypeCode type) => type switch
|
||||||
|
@ -69,7 +69,7 @@ namespace PKHeX.Core
|
||||||
SCTypeCode.Single => typeof(float),
|
SCTypeCode.Single => typeof(float),
|
||||||
SCTypeCode.Double => typeof(double),
|
SCTypeCode.Double => typeof(double),
|
||||||
|
|
||||||
_ => throw new ArgumentException(type.ToString(), nameof(type)),
|
_ => throw new ArgumentOutOfRangeException(nameof(type), type.ToString()),
|
||||||
};
|
};
|
||||||
|
|
||||||
public static object GetValue(this SCTypeCode type, byte[] data)
|
public static object GetValue(this SCTypeCode type, byte[] data)
|
||||||
|
@ -88,7 +88,7 @@ namespace PKHeX.Core
|
||||||
case SCTypeCode.Single: return BitConverter.ToSingle(data, 0);
|
case SCTypeCode.Single: return BitConverter.ToSingle(data, 0);
|
||||||
case SCTypeCode.Double: return BitConverter.ToDouble(data, 0);
|
case SCTypeCode.Double: return BitConverter.ToDouble(data, 0);
|
||||||
default:
|
default:
|
||||||
throw new ArgumentException(type.ToString(), nameof(type));
|
throw new ArgumentOutOfRangeException(nameof(type), type.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,7 +109,8 @@ namespace PKHeX.Core
|
||||||
case SCTypeCode.Single: BitConverter.GetBytes((float)value).CopyTo(data, 0); break;
|
case SCTypeCode.Single: BitConverter.GetBytes((float)value).CopyTo(data, 0); break;
|
||||||
case SCTypeCode.Double: BitConverter.GetBytes((double)value).CopyTo(data, 0); break;
|
case SCTypeCode.Double: BitConverter.GetBytes((double)value).CopyTo(data, 0); break;
|
||||||
|
|
||||||
default: throw new ArgumentException(type.ToString(), nameof(type));
|
default:
|
||||||
|
throw new ArgumentOutOfRangeException(nameof(type), type.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -306,7 +306,7 @@ namespace PKHeX.Core
|
||||||
public sealed override bool GetEventFlag(int flagNumber)
|
public sealed override bool GetEventFlag(int flagNumber)
|
||||||
{
|
{
|
||||||
if (flagNumber >= EventFlagMax)
|
if (flagNumber >= EventFlagMax)
|
||||||
throw new ArgumentException($"Event Flag to get ({flagNumber}) is greater than max ({EventFlagMax}).");
|
throw new ArgumentOutOfRangeException(nameof(flagNumber), $"Event Flag to get ({flagNumber}) is greater than max ({EventFlagMax}).");
|
||||||
|
|
||||||
var start = EventFlag;
|
var start = EventFlag;
|
||||||
return GetFlag(start + (flagNumber >> 3), flagNumber & 7);
|
return GetFlag(start + (flagNumber >> 3), flagNumber & 7);
|
||||||
|
@ -315,7 +315,7 @@ namespace PKHeX.Core
|
||||||
public sealed override void SetEventFlag(int flagNumber, bool value)
|
public sealed override void SetEventFlag(int flagNumber, bool value)
|
||||||
{
|
{
|
||||||
if (flagNumber >= EventFlagMax)
|
if (flagNumber >= EventFlagMax)
|
||||||
throw new ArgumentException($"Event Flag to set ({flagNumber}) is greater than max ({EventFlagMax}).");
|
throw new ArgumentOutOfRangeException(nameof(flagNumber), $"Event Flag to set ({flagNumber}) is greater than max ({EventFlagMax}).");
|
||||||
|
|
||||||
var start = EventFlag;
|
var start = EventFlag;
|
||||||
SetFlag(start + (flagNumber >> 3), flagNumber & 7, value);
|
SetFlag(start + (flagNumber >> 3), flagNumber & 7, value);
|
||||||
|
|
|
@ -77,14 +77,14 @@ namespace PKHeX.Core
|
||||||
public bool GetPoketchAppUnlocked(PoketchApp index)
|
public bool GetPoketchAppUnlocked(PoketchApp index)
|
||||||
{
|
{
|
||||||
if (index > PoketchApp.Alarm_Clock)
|
if (index > PoketchApp.Alarm_Clock)
|
||||||
throw new ArgumentException(nameof(index));
|
throw new ArgumentOutOfRangeException(nameof(index));
|
||||||
return General[PoketchStart + 3 + (int) index] != 0;
|
return General[PoketchStart + 3 + (int) index] != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetPoketchAppUnlocked(PoketchApp index, bool value = true)
|
public void SetPoketchAppUnlocked(PoketchApp index, bool value = true)
|
||||||
{
|
{
|
||||||
if (index > PoketchApp.Alarm_Clock)
|
if (index > PoketchApp.Alarm_Clock)
|
||||||
throw new ArgumentException(nameof(index));
|
throw new ArgumentOutOfRangeException(nameof(index));
|
||||||
var b = value ? 1 : 0;
|
var b = value ? 1 : 0;
|
||||||
General[PoketchStart + 3 + (int)index] = (byte)b;
|
General[PoketchStart + 3 + (int)index] = (byte)b;
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ namespace PKHeX.Core
|
||||||
public HoneyTreeValue GetHoneyTree(int index)
|
public HoneyTreeValue GetHoneyTree(int index)
|
||||||
{
|
{
|
||||||
if ((uint)index > 21)
|
if ((uint)index > 21)
|
||||||
throw new ArgumentException(nameof(index));
|
throw new ArgumentOutOfRangeException(nameof(index));
|
||||||
return new HoneyTreeValue(General.Slice(OFS_HONEY + (HONEY_SIZE * index), HONEY_SIZE));
|
return new HoneyTreeValue(General.Slice(OFS_HONEY + (HONEY_SIZE * index), HONEY_SIZE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -169,7 +169,7 @@ namespace PKHeX.Core
|
||||||
public virtual bool GetEventFlag(int flagNumber)
|
public virtual bool GetEventFlag(int flagNumber)
|
||||||
{
|
{
|
||||||
if ((uint)flagNumber >= EventFlagMax)
|
if ((uint)flagNumber >= EventFlagMax)
|
||||||
throw new ArgumentException($"Event Flag to get ({flagNumber}) is greater than max ({EventFlagMax}).");
|
throw new ArgumentOutOfRangeException(nameof(flagNumber), $"Event Flag to get ({flagNumber}) is greater than max ({EventFlagMax}).");
|
||||||
return GetFlag(EventFlag + (flagNumber >> 3), flagNumber & 7);
|
return GetFlag(EventFlag + (flagNumber >> 3), flagNumber & 7);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,7 +182,7 @@ namespace PKHeX.Core
|
||||||
public virtual void SetEventFlag(int flagNumber, bool value)
|
public virtual void SetEventFlag(int flagNumber, bool value)
|
||||||
{
|
{
|
||||||
if ((uint)flagNumber >= EventFlagMax)
|
if ((uint)flagNumber >= EventFlagMax)
|
||||||
throw new ArgumentException($"Event Flag to set ({flagNumber}) is greater than max ({EventFlagMax}).");
|
throw new ArgumentOutOfRangeException(nameof(flagNumber), $"Event Flag to set ({flagNumber}) is greater than max ({EventFlagMax}).");
|
||||||
SetFlag(EventFlag + (flagNumber >> 3), flagNumber & 7, value);
|
SetFlag(EventFlag + (flagNumber >> 3), flagNumber & 7, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,7 +313,7 @@ namespace PKHeX.Core
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (value.Count is 0 or > MaxPartyCount)
|
if (value.Count is 0 or > MaxPartyCount)
|
||||||
throw new ArgumentException($"Expected 1-6, got {value.Count}");
|
throw new ArgumentOutOfRangeException(nameof(value), $"Expected 1-6, got {value.Count}");
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
if (value[0].Species == 0)
|
if (value[0].Species == 0)
|
||||||
System.Diagnostics.Debug.WriteLine($"Empty first slot, received {value.Count}.");
|
System.Diagnostics.Debug.WriteLine($"Empty first slot, received {value.Count}.");
|
||||||
|
|
|
@ -25,7 +25,7 @@ namespace PKHeX.Core
|
||||||
public string GetGroupName(int group)
|
public string GetGroupName(int group)
|
||||||
{
|
{
|
||||||
if ((uint)group > 10)
|
if ((uint)group > 10)
|
||||||
throw new ArgumentException($"{nameof(group)} must be 1-10.");
|
throw new ArgumentOutOfRangeException(nameof(group), $"{nameof(group)} must be 0-10.");
|
||||||
int offset = 0x8 + (GroupNameSpacing * group) + 2; // skip over " "
|
int offset = 0x8 + (GroupNameSpacing * group) + 2; // skip over " "
|
||||||
return GetString(offset, GroupNameSize / 2);
|
return GetString(offset, GroupNameSize / 2);
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,13 +49,13 @@ namespace PKHeX.Core
|
||||||
public int PouchBall { get; private set; } = -1;
|
public int PouchBall { get; private set; } = -1;
|
||||||
public int PouchPC { get; private set; } = -1;
|
public int PouchPC { get; private set; } = -1;
|
||||||
|
|
||||||
private void LoadOffsetsInternational(GameVersion Version)
|
private void LoadOffsetsInternational(GameVersion version)
|
||||||
{
|
{
|
||||||
RTCFlags = 0x0C60;
|
RTCFlags = 0x0C60;
|
||||||
|
|
||||||
DaylightSavings = 0x2042;
|
DaylightSavings = 0x2042;
|
||||||
OtherCurrentBox = 0x284C;
|
OtherCurrentBox = 0x284C;
|
||||||
switch (Version)
|
switch (version)
|
||||||
{
|
{
|
||||||
case GameVersion.GS:
|
case GameVersion.GS:
|
||||||
TimePlayed = 0x2053;
|
TimePlayed = 0x2053;
|
||||||
|
@ -107,11 +107,11 @@ namespace PKHeX.Core
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new ArgumentException(nameof(Version));
|
throw new ArgumentException(nameof(version));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadOffsetsJapanese(GameVersion Version)
|
private void LoadOffsetsJapanese(GameVersion version)
|
||||||
{
|
{
|
||||||
DaylightSavings = 0x2029;
|
DaylightSavings = 0x2029;
|
||||||
TimePlayed = 0x2034;
|
TimePlayed = 0x2034;
|
||||||
|
@ -119,7 +119,7 @@ namespace PKHeX.Core
|
||||||
CurrentBox = 0x2D10;
|
CurrentBox = 0x2D10;
|
||||||
OtherCurrentBox = 0x2842;
|
OtherCurrentBox = 0x2842;
|
||||||
|
|
||||||
switch (Version)
|
switch (version)
|
||||||
{
|
{
|
||||||
case GameVersion.GS:
|
case GameVersion.GS:
|
||||||
RTCFlags = 0x1000;
|
RTCFlags = 0x1000;
|
||||||
|
@ -169,7 +169,7 @@ namespace PKHeX.Core
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new ArgumentException(nameof(Version));
|
throw new ArgumentException(nameof(version));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,14 +52,14 @@ namespace PKHeX.Core
|
||||||
public void SetStat(int stat, byte value)
|
public void SetStat(int stat, byte value)
|
||||||
{
|
{
|
||||||
if ((uint) stat > 5)
|
if ((uint) stat > 5)
|
||||||
throw new ArgumentException(nameof(stat));
|
throw new ArgumentOutOfRangeException(nameof(stat));
|
||||||
Data[1 + stat] = value;
|
Data[1 + stat] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte GetStat(int stat)
|
public byte GetStat(int stat)
|
||||||
{
|
{
|
||||||
if ((uint)stat > 5)
|
if ((uint)stat > 5)
|
||||||
throw new ArgumentException(nameof(stat));
|
throw new ArgumentOutOfRangeException(nameof(stat));
|
||||||
return Data[1 + stat];
|
return Data[1 + stat];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,9 +23,9 @@ namespace PKHeX.Core
|
||||||
private int GetBadgeVictorySpeciesOffset(uint badge, uint slot)
|
private int GetBadgeVictorySpeciesOffset(uint badge, uint slot)
|
||||||
{
|
{
|
||||||
if (badge >= 8)
|
if (badge >= 8)
|
||||||
throw new ArgumentException(nameof(badge));
|
throw new ArgumentOutOfRangeException(nameof(badge));
|
||||||
if (slot >= 6)
|
if (slot >= 6)
|
||||||
throw new ArgumentException(nameof(slot));
|
throw new ArgumentOutOfRangeException(nameof(slot));
|
||||||
|
|
||||||
return Offset + BadgeVictoryOffset + (int)(((6 * badge) + slot) * sizeof(ushort));
|
return Offset + BadgeVictoryOffset + (int)(((6 * badge) + slot) * sizeof(ushort));
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace PKHeX.Core
|
||||||
public ushort GetPWTRecord(PWTRecordID id)
|
public ushort GetPWTRecord(PWTRecordID id)
|
||||||
{
|
{
|
||||||
if (id is < PWTRecordID.Normal or > PWTRecordID.MixMaster)
|
if (id is < PWTRecordID.Normal or > PWTRecordID.MixMaster)
|
||||||
throw new ArgumentException(nameof(id));
|
throw new ArgumentOutOfRangeException(nameof(id));
|
||||||
int ofs = Offset + 0x5C + ((int)id * 2);
|
int ofs = Offset + 0x5C + ((int)id * 2);
|
||||||
return BitConverter.ToUInt16(Data, ofs);
|
return BitConverter.ToUInt16(Data, ofs);
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ namespace PKHeX.Core
|
||||||
public void SetPWTRecord(PWTRecordID id, ushort value)
|
public void SetPWTRecord(PWTRecordID id, ushort value)
|
||||||
{
|
{
|
||||||
if (id is < PWTRecordID.Normal or > PWTRecordID.MixMaster)
|
if (id is < PWTRecordID.Normal or > PWTRecordID.MixMaster)
|
||||||
throw new ArgumentException(nameof(id));
|
throw new ArgumentOutOfRangeException(nameof(id));
|
||||||
int ofs = Offset + 0x5C + ((int)id * 2);
|
int ofs = Offset + 0x5C + ((int)id * 2);
|
||||||
SAV.SetData(BitConverter.GetBytes(value), ofs);
|
SAV.SetData(BitConverter.GetBytes(value), ofs);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,9 +24,9 @@ namespace PKHeX.Core
|
||||||
private int GetBadgeVictorySpeciesOffset(uint badge, uint slot)
|
private int GetBadgeVictorySpeciesOffset(uint badge, uint slot)
|
||||||
{
|
{
|
||||||
if (badge >= 8)
|
if (badge >= 8)
|
||||||
throw new ArgumentException(nameof(badge));
|
throw new ArgumentOutOfRangeException(nameof(badge));
|
||||||
if (slot >= 6)
|
if (slot >= 6)
|
||||||
throw new ArgumentException(nameof(slot));
|
throw new ArgumentOutOfRangeException(nameof(slot));
|
||||||
|
|
||||||
return Offset + BadgeVictoryOffset + (int)(((6 * badge) + slot) * sizeof(ushort));
|
return Offset + BadgeVictoryOffset + (int)(((6 * badge) + slot) * sizeof(ushort));
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ namespace PKHeX.Core
|
||||||
public bool GetIsRegimenUnlocked(int index)
|
public bool GetIsRegimenUnlocked(int index)
|
||||||
{
|
{
|
||||||
if ((uint)index >= MAX)
|
if ((uint)index >= MAX)
|
||||||
throw new ArgumentException(nameof(index));
|
throw new ArgumentOutOfRangeException(nameof(index));
|
||||||
return SAV.GetFlag(Offset, index);
|
return SAV.GetFlag(Offset, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ namespace PKHeX.Core
|
||||||
public void SetIsRegimenUnlocked(int index, bool value)
|
public void SetIsRegimenUnlocked(int index, bool value)
|
||||||
{
|
{
|
||||||
if ((uint)index >= MAX)
|
if ((uint)index >= MAX)
|
||||||
throw new ArgumentException(nameof(index));
|
throw new ArgumentOutOfRangeException(nameof(index));
|
||||||
SAV.SetFlag(Offset, index, value);
|
SAV.SetFlag(Offset, index, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ namespace PKHeX.Core
|
||||||
public bool GetIsDistributionUnlocked(int index)
|
public bool GetIsDistributionUnlocked(int index)
|
||||||
{
|
{
|
||||||
if ((uint)index >= MAX_DIST)
|
if ((uint)index >= MAX_DIST)
|
||||||
throw new ArgumentException(nameof(index));
|
throw new ArgumentOutOfRangeException(nameof(index));
|
||||||
return SAV.GetFlag(Offset + 6, index);
|
return SAV.GetFlag(Offset + 6, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ namespace PKHeX.Core
|
||||||
public void SetIsDistributionUnlocked(int index, bool value)
|
public void SetIsDistributionUnlocked(int index, bool value)
|
||||||
{
|
{
|
||||||
if ((uint)index >= MAX_DIST)
|
if ((uint)index >= MAX_DIST)
|
||||||
throw new ArgumentException(nameof(index));
|
throw new ArgumentOutOfRangeException(nameof(index));
|
||||||
SAV.SetFlag(Offset + 6, index, value);
|
SAV.SetFlag(Offset + 6, index, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ namespace PKHeX.Core
|
||||||
public float GetTime1(int index)
|
public float GetTime1(int index)
|
||||||
{
|
{
|
||||||
if ((uint) index >= MAX)
|
if ((uint) index >= MAX)
|
||||||
throw new ArgumentException(nameof(index));
|
throw new ArgumentOutOfRangeException(nameof(index));
|
||||||
|
|
||||||
return BitConverter.ToSingle(Data, Offset + 0x08 + (4 * index));
|
return BitConverter.ToSingle(Data, Offset + 0x08 + (4 * index));
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ namespace PKHeX.Core
|
||||||
public void SetTime1(int index, float value = 0)
|
public void SetTime1(int index, float value = 0)
|
||||||
{
|
{
|
||||||
if ((uint)index >= MAX)
|
if ((uint)index >= MAX)
|
||||||
throw new ArgumentException(nameof(index));
|
throw new ArgumentOutOfRangeException(nameof(index));
|
||||||
|
|
||||||
BitConverter.GetBytes(value).CopyTo(Data, Offset + 0x08 + (4 * index));
|
BitConverter.GetBytes(value).CopyTo(Data, Offset + 0x08 + (4 * index));
|
||||||
}
|
}
|
||||||
|
@ -116,7 +116,7 @@ namespace PKHeX.Core
|
||||||
public float GetTime2(int index)
|
public float GetTime2(int index)
|
||||||
{
|
{
|
||||||
if ((uint)index >= MAX)
|
if ((uint)index >= MAX)
|
||||||
throw new ArgumentException(nameof(index));
|
throw new ArgumentOutOfRangeException(nameof(index));
|
||||||
|
|
||||||
return BitConverter.ToSingle(Data, Offset + 0xC8 + (4 * index));
|
return BitConverter.ToSingle(Data, Offset + 0xC8 + (4 * index));
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,7 @@ namespace PKHeX.Core
|
||||||
public void SetTime2(int index, float value = 0)
|
public void SetTime2(int index, float value = 0)
|
||||||
{
|
{
|
||||||
if ((uint)index >= MAX)
|
if ((uint)index >= MAX)
|
||||||
throw new ArgumentException(nameof(index));
|
throw new ArgumentOutOfRangeException(nameof(index));
|
||||||
|
|
||||||
BitConverter.GetBytes(value).CopyTo(Data, Offset + 0xC8 + (4 * index));
|
BitConverter.GetBytes(value).CopyTo(Data, Offset + 0xC8 + (4 * index));
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,7 @@ namespace PKHeX.Core
|
||||||
public SuperTrainingSpeciesRecord GetHolder1(int index)
|
public SuperTrainingSpeciesRecord GetHolder1(int index)
|
||||||
{
|
{
|
||||||
if ((uint)index >= MAX)
|
if ((uint)index >= MAX)
|
||||||
throw new ArgumentException(nameof(index));
|
throw new ArgumentOutOfRangeException(nameof(index));
|
||||||
|
|
||||||
return new SuperTrainingSpeciesRecord(Data, Offset + 0x188 + (4 * index));
|
return new SuperTrainingSpeciesRecord(Data, Offset + 0x188 + (4 * index));
|
||||||
}
|
}
|
||||||
|
@ -155,7 +155,7 @@ namespace PKHeX.Core
|
||||||
public SuperTrainingSpeciesRecord GetHolder2(int index)
|
public SuperTrainingSpeciesRecord GetHolder2(int index)
|
||||||
{
|
{
|
||||||
if ((uint)index >= MAX)
|
if ((uint)index >= MAX)
|
||||||
throw new ArgumentException(nameof(index));
|
throw new ArgumentOutOfRangeException(nameof(index));
|
||||||
|
|
||||||
return new SuperTrainingSpeciesRecord(Data, Offset + 0x248 + (4 * index));
|
return new SuperTrainingSpeciesRecord(Data, Offset + 0x248 + (4 * index));
|
||||||
}
|
}
|
||||||
|
@ -167,7 +167,7 @@ namespace PKHeX.Core
|
||||||
public byte GetBag(int index)
|
public byte GetBag(int index)
|
||||||
{
|
{
|
||||||
if ((uint)index >= MAX_BAG)
|
if ((uint)index >= MAX_BAG)
|
||||||
throw new ArgumentException(nameof(index));
|
throw new ArgumentOutOfRangeException(nameof(index));
|
||||||
return Data[Offset + 0x308 + index];
|
return Data[Offset + 0x308 + index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ namespace PKHeX.Core
|
||||||
public void SetBag(int index, byte value)
|
public void SetBag(int index, byte value)
|
||||||
{
|
{
|
||||||
if ((uint)index >= MAX_BAG)
|
if ((uint)index >= MAX_BAG)
|
||||||
throw new ArgumentException(nameof(index));
|
throw new ArgumentOutOfRangeException(nameof(index));
|
||||||
Data[Offset + 0x308 + index] = value;
|
Data[Offset + 0x308 + index] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,7 +219,7 @@ namespace PKHeX.Core
|
||||||
public void RemoveBag(int index)
|
public void RemoveBag(int index)
|
||||||
{
|
{
|
||||||
if ((uint)index >= MAX_BAG)
|
if ((uint)index >= MAX_BAG)
|
||||||
throw new ArgumentException(nameof(index));
|
throw new ArgumentOutOfRangeException(nameof(index));
|
||||||
for (int i = index; i < MAX_BAG - 1; i++)
|
for (int i = index; i < MAX_BAG - 1; i++)
|
||||||
{
|
{
|
||||||
var next = GetBag(i + 1);
|
var next = GetBag(i + 1);
|
||||||
|
@ -241,7 +241,7 @@ namespace PKHeX.Core
|
||||||
public void ClearRecord1(int index)
|
public void ClearRecord1(int index)
|
||||||
{
|
{
|
||||||
if ((uint)index >= MAX)
|
if ((uint)index >= MAX)
|
||||||
throw new ArgumentException(nameof(index));
|
throw new ArgumentOutOfRangeException(nameof(index));
|
||||||
|
|
||||||
SetTime1(index, 0f);
|
SetTime1(index, 0f);
|
||||||
GetHolder1(index).Clear();
|
GetHolder1(index).Clear();
|
||||||
|
@ -254,7 +254,7 @@ namespace PKHeX.Core
|
||||||
public void ClearRecord2(int index)
|
public void ClearRecord2(int index)
|
||||||
{
|
{
|
||||||
if ((uint)index >= MAX)
|
if ((uint)index >= MAX)
|
||||||
throw new ArgumentException(nameof(index));
|
throw new ArgumentOutOfRangeException(nameof(index));
|
||||||
|
|
||||||
SetTime2(index, 0f);
|
SetTime2(index, 0f);
|
||||||
GetHolder2(index).Clear();
|
GetHolder2(index).Clear();
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace PKHeX.Core
|
||||||
public int GetTreeStreak(int battletype, bool super, bool max)
|
public int GetTreeStreak(int battletype, bool super, bool max)
|
||||||
{
|
{
|
||||||
if (battletype > 3)
|
if (battletype > 3)
|
||||||
throw new ArgumentException(nameof(battletype));
|
throw new ArgumentOutOfRangeException(nameof(battletype));
|
||||||
|
|
||||||
var offset = GetStreakOffset(battletype, super, max);
|
var offset = GetStreakOffset(battletype, super, max);
|
||||||
return BitConverter.ToUInt16(Data, Offset + offset);
|
return BitConverter.ToUInt16(Data, Offset + offset);
|
||||||
|
@ -21,7 +21,7 @@ namespace PKHeX.Core
|
||||||
public void SetTreeStreak(int value, int battletype, bool super, bool max)
|
public void SetTreeStreak(int value, int battletype, bool super, bool max)
|
||||||
{
|
{
|
||||||
if (battletype > 3)
|
if (battletype > 3)
|
||||||
throw new ArgumentException(nameof(battletype));
|
throw new ArgumentOutOfRangeException(nameof(battletype));
|
||||||
|
|
||||||
if (value > ushort.MaxValue)
|
if (value > ushort.MaxValue)
|
||||||
value = ushort.MaxValue;
|
value = ushort.MaxValue;
|
||||||
|
@ -45,7 +45,7 @@ namespace PKHeX.Core
|
||||||
public BattleTreeTrainer GetTrainer(in int index)
|
public BattleTreeTrainer GetTrainer(in int index)
|
||||||
{
|
{
|
||||||
if ((uint)index >= ScoutCount)
|
if ((uint)index >= ScoutCount)
|
||||||
throw new ArgumentException(nameof(index));
|
throw new ArgumentOutOfRangeException(nameof(index));
|
||||||
|
|
||||||
var id = BitConverter.ToInt16(Data, Offset + 0x24 + (index * 2));
|
var id = BitConverter.ToInt16(Data, Offset + 0x24 + (index * 2));
|
||||||
var p1 = BitConverter.ToInt16(Data, Offset + 0x88 + (index * 2));
|
var p1 = BitConverter.ToInt16(Data, Offset + 0x88 + (index * 2));
|
||||||
|
@ -62,7 +62,7 @@ namespace PKHeX.Core
|
||||||
public void SetTrainer(BattleTreeTrainer tr, in int index)
|
public void SetTrainer(BattleTreeTrainer tr, in int index)
|
||||||
{
|
{
|
||||||
if ((uint)index >= ScoutCount)
|
if ((uint)index >= ScoutCount)
|
||||||
throw new ArgumentException(nameof(index));
|
throw new ArgumentOutOfRangeException(nameof(index));
|
||||||
|
|
||||||
BitConverter.GetBytes(tr.ID).CopyTo(Data, Offset + 0x24 + (index * 2));
|
BitConverter.GetBytes(tr.ID).CopyTo(Data, Offset + 0x24 + (index * 2));
|
||||||
BitConverter.GetBytes(tr.Poke1.ID).CopyTo(Data, Offset + 0x88 + (index * 2));
|
BitConverter.GetBytes(tr.Poke1.ID).CopyTo(Data, Offset + 0x88 + (index * 2));
|
||||||
|
|
|
@ -58,7 +58,7 @@ namespace PKHeX.Core
|
||||||
{
|
{
|
||||||
int max = GetFlagCount(type);
|
int max = GetFlagCount(type);
|
||||||
if ((uint)index > max)
|
if ((uint)index > max)
|
||||||
throw new ArgumentException(nameof(index));
|
throw new ArgumentOutOfRangeException(nameof(index));
|
||||||
var start = GetFlagStart(type);
|
var start = GetFlagStart(type);
|
||||||
return start + index;
|
return start + index;
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ namespace PKHeX.Core
|
||||||
{
|
{
|
||||||
int max = GetWorkCount(type);
|
int max = GetWorkCount(type);
|
||||||
if ((uint)index > max)
|
if ((uint)index > max)
|
||||||
throw new ArgumentException(nameof(index));
|
throw new ArgumentOutOfRangeException(nameof(index));
|
||||||
var start = GetWorkStart(type);
|
var start = GetWorkStart(type);
|
||||||
return start + index;
|
return start + index;
|
||||||
}
|
}
|
||||||
|
@ -107,7 +107,7 @@ namespace PKHeX.Core
|
||||||
if (subIndex < EventFlagCount)
|
if (subIndex < EventFlagCount)
|
||||||
return EventVarType.Event;
|
return EventVarType.Event;
|
||||||
|
|
||||||
throw new ArgumentException(nameof(index));
|
throw new ArgumentOutOfRangeException(nameof(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
public EventVarType GetWorkType(int index, out int subIndex)
|
public EventVarType GetWorkType(int index, out int subIndex)
|
||||||
|
@ -128,7 +128,7 @@ namespace PKHeX.Core
|
||||||
if (subIndex < EventWorkCount)
|
if (subIndex < EventWorkCount)
|
||||||
return EventVarType.Event;
|
return EventVarType.Event;
|
||||||
|
|
||||||
throw new ArgumentException(nameof(index));
|
throw new ArgumentOutOfRangeException(nameof(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int GetFlagStart(EventVarType type) => type switch
|
private static int GetFlagStart(EventVarType type) => type switch
|
||||||
|
@ -137,7 +137,7 @@ namespace PKHeX.Core
|
||||||
EventVarType.System => SystemFlagStart,
|
EventVarType.System => SystemFlagStart,
|
||||||
EventVarType.Vanish => VanishFlagStart,
|
EventVarType.Vanish => VanishFlagStart,
|
||||||
EventVarType.Event => EventFlagStart,
|
EventVarType.Event => EventFlagStart,
|
||||||
_ => throw new ArgumentException(nameof(type)),
|
_ => throw new ArgumentOutOfRangeException(nameof(type)),
|
||||||
};
|
};
|
||||||
|
|
||||||
private static int GetWorkStart(EventVarType type) => type switch
|
private static int GetWorkStart(EventVarType type) => type switch
|
||||||
|
@ -146,7 +146,7 @@ namespace PKHeX.Core
|
||||||
EventVarType.System => SystemWorkStart,
|
EventVarType.System => SystemWorkStart,
|
||||||
EventVarType.Scene => SceneWorkStart,
|
EventVarType.Scene => SceneWorkStart,
|
||||||
EventVarType.Event => EventWorkStart,
|
EventVarType.Event => EventWorkStart,
|
||||||
_ => throw new ArgumentException(nameof(type)),
|
_ => throw new ArgumentOutOfRangeException(nameof(type)),
|
||||||
};
|
};
|
||||||
|
|
||||||
private static int GetFlagCount(EventVarType type) => type switch
|
private static int GetFlagCount(EventVarType type) => type switch
|
||||||
|
@ -155,7 +155,7 @@ namespace PKHeX.Core
|
||||||
EventVarType.System => SystemFlagCount,
|
EventVarType.System => SystemFlagCount,
|
||||||
EventVarType.Vanish => VanishFlagCount,
|
EventVarType.Vanish => VanishFlagCount,
|
||||||
EventVarType.Event => EventFlagCount,
|
EventVarType.Event => EventFlagCount,
|
||||||
_ => throw new ArgumentException(nameof(type)),
|
_ => throw new ArgumentOutOfRangeException(nameof(type)),
|
||||||
};
|
};
|
||||||
|
|
||||||
private static int GetWorkCount(EventVarType type) => type switch
|
private static int GetWorkCount(EventVarType type) => type switch
|
||||||
|
@ -164,7 +164,7 @@ namespace PKHeX.Core
|
||||||
EventVarType.System => SystemWorkCount,
|
EventVarType.System => SystemWorkCount,
|
||||||
EventVarType.Scene => SceneWorkCount,
|
EventVarType.Scene => SceneWorkCount,
|
||||||
EventVarType.Event => EventWorkCount,
|
EventVarType.Event => EventWorkCount,
|
||||||
_ => throw new ArgumentException(nameof(type)),
|
_ => throw new ArgumentOutOfRangeException(nameof(type)),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -89,7 +89,7 @@ namespace PKHeX.Core
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if ((ushort)value > 1000 && value != SLOT_EMPTY)
|
if ((ushort)value > 1000 && value != SLOT_EMPTY)
|
||||||
throw new ArgumentException(nameof(value));
|
throw new ArgumentOutOfRangeException(nameof(value));
|
||||||
PokeListInfo[STARTER] = (ushort)value;
|
PokeListInfo[STARTER] = (ushort)value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,7 @@ namespace PKHeX.Core
|
||||||
public int GetPartyOffset(int slot)
|
public int GetPartyOffset(int slot)
|
||||||
{
|
{
|
||||||
if ((uint)slot >= 6)
|
if ((uint)slot >= 6)
|
||||||
throw new ArgumentException(nameof(slot) + " expected to be < 6.");
|
throw new ArgumentOutOfRangeException(nameof(slot) + " expected to be < 6.");
|
||||||
int position = PokeListInfo[slot];
|
int position = PokeListInfo[slot];
|
||||||
return SAV.GetBoxSlotOffset(position);
|
return SAV.GetBoxSlotOffset(position);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,14 +35,14 @@ namespace PKHeX.Core
|
||||||
public int GetPokebeanCount(int bean_id)
|
public int GetPokebeanCount(int bean_id)
|
||||||
{
|
{
|
||||||
if ((uint)bean_id > 14)
|
if ((uint)bean_id > 14)
|
||||||
throw new ArgumentException("Invalid bean id!");
|
throw new ArgumentOutOfRangeException(nameof(bean_id));
|
||||||
return Data[Offset + 0x564C + bean_id];
|
return Data[Offset + 0x564C + bean_id];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetPokebeanCount(int bean_id, int count)
|
public void SetPokebeanCount(int bean_id, int count)
|
||||||
{
|
{
|
||||||
if ((uint)bean_id > 14)
|
if ((uint)bean_id > 14)
|
||||||
throw new ArgumentException("Invalid bean id!");
|
throw new ArgumentOutOfRangeException(nameof(bean_id));
|
||||||
if (count < 0)
|
if (count < 0)
|
||||||
count = 0;
|
count = 0;
|
||||||
if (count > 255)
|
if (count > 255)
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace PKHeX.Core
|
||||||
private int GetRecordOffset(int index)
|
private int GetRecordOffset(int index)
|
||||||
{
|
{
|
||||||
if (index >= RecordMax)
|
if (index >= RecordMax)
|
||||||
throw new ArgumentException(nameof(index));
|
throw new ArgumentOutOfRangeException(nameof(index));
|
||||||
|
|
||||||
return Offset + (index * WR7.Size);
|
return Offset + (index * WR7.Size);
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ namespace PKHeX.Core
|
||||||
private int GetFlagOffset(int flag)
|
private int GetFlagOffset(int flag)
|
||||||
{
|
{
|
||||||
if (flag >= FlagCountMax)
|
if (flag >= FlagCountMax)
|
||||||
throw new ArgumentException(nameof(flag));
|
throw new ArgumentOutOfRangeException(nameof(flag));
|
||||||
return FlagStart + (flag / 8);
|
return FlagStart + (flag / 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ namespace PKHeX.Core
|
||||||
{
|
{
|
||||||
PokeDexLanguageFlags = langflag;
|
PokeDexLanguageFlags = langflag;
|
||||||
if (langflag > dex)
|
if (langflag > dex)
|
||||||
throw new ArgumentException(nameof(langflag));
|
throw new ArgumentOutOfRangeException(nameof(langflag));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract int OFS_SEEN { get; }
|
protected abstract int OFS_SEEN { get; }
|
||||||
|
|
|
@ -209,7 +209,7 @@ namespace PKHeX.Core
|
||||||
|
|
||||||
Value |= (uint)(val << (BitsPerForm * i));
|
Value |= (uint)(val << (BitsPerForm * i));
|
||||||
if (i >= readCt)
|
if (i >= readCt)
|
||||||
throw new ArgumentException("Array count should be less than bitfield count", nameof(Forms));
|
throw new ArgumentOutOfRangeException(nameof(readCt), "Array count should be less than bitfield count");
|
||||||
}
|
}
|
||||||
return Value;
|
return Value;
|
||||||
}
|
}
|
||||||
|
|
|
@ -213,7 +213,7 @@ namespace PKHeX.Core
|
||||||
public bool GetSeenRegion(Zukan8Index entry, int form, int region)
|
public bool GetSeenRegion(Zukan8Index entry, int form, int region)
|
||||||
{
|
{
|
||||||
if ((uint)region >= SeenRegionCount)
|
if ((uint)region >= SeenRegionCount)
|
||||||
throw new ArgumentException(nameof(region));
|
throw new ArgumentOutOfRangeException(nameof(region));
|
||||||
if ((uint)form > 63)
|
if ((uint)form > 63)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -235,7 +235,7 @@ namespace PKHeX.Core
|
||||||
public void SetSeenRegion(Zukan8Index entry, int form, int region, bool value = true)
|
public void SetSeenRegion(Zukan8Index entry, int form, int region, bool value = true)
|
||||||
{
|
{
|
||||||
if ((uint) region >= SeenRegionCount)
|
if ((uint) region >= SeenRegionCount)
|
||||||
throw new ArgumentException(nameof(region));
|
throw new ArgumentOutOfRangeException(nameof(region));
|
||||||
if ((uint) form > 63)
|
if ((uint) form > 63)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -728,7 +728,7 @@ namespace PKHeX.Core
|
||||||
|
|
||||||
SW or SH or SWSH => new SAV8SWSH(),
|
SW or SH or SWSH => new SAV8SWSH(),
|
||||||
|
|
||||||
_ => throw new ArgumentException(nameof(game)),
|
_ => throw new ArgumentOutOfRangeException(nameof(game)),
|
||||||
};
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -789,17 +789,17 @@ namespace PKHeX.Core
|
||||||
public static bool IsSizeValid(int size) => Sizes.Contains(size) || Handlers.Any(z => z.IsRecognized(size));
|
public static bool IsSizeValid(int size) => Sizes.Contains(size) || Handlers.Any(z => z.IsRecognized(size));
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Force loads the provided <see cref="sav"/> to the requested <see cref="ver"/>.
|
/// Force loads the provided <see cref="sav"/> to the requested <see cref="version"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sav">SaveFile data to force</param>
|
/// <param name="sav">SaveFile data to force</param>
|
||||||
/// <param name="ver">Version to retrieve for</param>
|
/// <param name="version"> Version to retrieve for</param>
|
||||||
/// <returns>New <see cref="SaveFile"/> object.</returns>
|
/// <returns>New <see cref="SaveFile"/> object.</returns>
|
||||||
public static SAV3 GetG3SaveOverride(SaveFile sav, GameVersion ver) => ver switch // Reset save file info
|
public static SAV3 GetG3SaveOverride(SaveFile sav, GameVersion version) => version switch // Reset save file info
|
||||||
{
|
{
|
||||||
R or S or RS => new SAV3RS(sav.State.BAK),
|
R or S or RS => new SAV3RS(sav.State.BAK),
|
||||||
E => new SAV3E(sav.State.BAK),
|
E => new SAV3E(sav.State.BAK),
|
||||||
FR or LG or FRLG => new SAV3FRLG(sav.State.BAK),
|
FR or LG or FRLG => new SAV3FRLG(sav.State.BAK),
|
||||||
_ => throw new ArgumentException(nameof(ver)),
|
_ => throw new ArgumentOutOfRangeException(nameof(version)),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,7 +128,7 @@ namespace PKHeX.WinForms
|
||||||
|
|
||||||
var p = Pouches.FirstOrDefault(z => z.Type == InventoryType.KeyItems);
|
var p = Pouches.FirstOrDefault(z => z.Type == InventoryType.KeyItems);
|
||||||
if (p == null)
|
if (p == null)
|
||||||
throw new ArgumentException(nameof(InventoryPouch.Type));
|
throw new ArgumentOutOfRangeException(nameof(InventoryPouch.Type));
|
||||||
|
|
||||||
// check for missing tickets
|
// check for missing tickets
|
||||||
var missing = tickets.Where(z => !p.Items.Any(item => item.Index == z && item.Count == 1)).ToList();
|
var missing = tickets.Where(z => !p.Items.Any(item => item.Index == z && item.Count == 1)).ToList();
|
||||||
|
|
|
@ -66,7 +66,7 @@ namespace PKHeX.WinForms
|
||||||
|
|
||||||
var species = WinFormsUtil.GetIndex(CB_Species);
|
var species = WinFormsUtil.GetIndex(CB_Species);
|
||||||
if (!Dex.DexLookup.TryGetValue(species, out var info))
|
if (!Dex.DexLookup.TryGetValue(species, out var info))
|
||||||
throw new ArgumentException(nameof(species));
|
throw new ArgumentOutOfRangeException(nameof(species));
|
||||||
|
|
||||||
var index = info.AbsoluteIndex - 1;
|
var index = info.AbsoluteIndex - 1;
|
||||||
if (LB_Species.SelectedIndex != index)
|
if (LB_Species.SelectedIndex != index)
|
||||||
|
|
|
@ -28,7 +28,7 @@ namespace PKHeX.WinForms
|
||||||
{
|
{
|
||||||
4 => PopulateViewGiftsG4().ToArray(),
|
4 => PopulateViewGiftsG4().ToArray(),
|
||||||
5 or 6 or 7 => PopulateViewGiftsG567().ToArray(),
|
5 or 6 or 7 => PopulateViewGiftsG567().ToArray(),
|
||||||
_ => throw new ArgumentException("Game not supported."),
|
_ => throw new ArgumentOutOfRangeException(nameof(SAV.Generation), "Game not supported."),
|
||||||
};
|
};
|
||||||
foreach (var pb in pba)
|
foreach (var pb in pba)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue