ArgumentException -> ArgumentOutOfRangeException

This commit is contained in:
Kurt 2021-08-21 16:51:50 -07:00
parent 27059268ba
commit 8f0fb902d1
35 changed files with 92 additions and 91 deletions

View file

@ -83,7 +83,7 @@ namespace PKHeX.Core
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 3: pk.Move4_PP = pk.GetMovePP(pk.Move4, pk.Move4_PPUps); return;
default: throw new ArgumentException(nameof(index));
default: throw new ArgumentOutOfRangeException(nameof(index));
}
}
}

View file

@ -38,7 +38,7 @@ namespace PKHeX.Core
return new EvolutionMethod(method + 1, species, argument: arg, level: arg);
default:
throw new ArgumentException(nameof(method));
throw new ArgumentOutOfRangeException(nameof(method));
}
}

View file

@ -15,7 +15,7 @@ namespace PKHeX.Core
int species = BitConverter.ToUInt16(data, offset + 4);
if (method == 0)
throw new ArgumentException(nameof(data));
throw new ArgumentOutOfRangeException(nameof(method));
// To have the same structure as gen 6
// Gen 4 Method 6 is Gen 6 Method 7, G4 7 = G6 8, and so on

View file

@ -15,7 +15,7 @@ namespace PKHeX.Core
int species = BitConverter.ToUInt16(data, offset + 4);
if (method == 0)
throw new ArgumentException(nameof(data));
throw new ArgumentOutOfRangeException(nameof(method));
var lvl = EvolutionSet6.EvosWithArg.Contains(method) ? 0 : arg;
return new EvolutionMethod(method, species, argument: arg, level: lvl);

View file

@ -24,7 +24,7 @@ namespace PKHeX.Core
RNGType.LCRNG => RNG.LCRNG,
RNGType.XDRNG => RNG.XDRNG,
RNGType.ARNG => RNG.ARNG,
_ => throw new ArgumentException(nameof(type)),
_ => throw new ArgumentOutOfRangeException(nameof(type)),
};
}
}

View file

@ -35,16 +35,16 @@ namespace PKHeX.Core
/// <returns>Object containing search criteria to be passed by reference to search/filter methods.</returns>
public FrameGenerator(PKM pk)
{
var ver = (GameVersion)pk.Version;
switch (ver)
var version = (GameVersion)pk.Version;
switch (version)
{
// Method H
case R or S or E or FR or LG:
DPPt = false;
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;
AllowLeads = true;
@ -75,7 +75,7 @@ namespace PKHeX.Core
FrameType = FrameType.MethodK;
return;
default:
throw new ArgumentException(nameof(ver));
throw new ArgumentOutOfRangeException(nameof(version));
}
}

View file

@ -285,7 +285,7 @@ namespace PKHeX.Core
{
00 or 01 or 02 => AbilityType, // Fixed 0/1/2
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)

View file

@ -415,7 +415,7 @@ namespace PKHeX.Core
{
00 or 01 or 02 => AbilityType, // Fixed 0/1/2
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)

View file

@ -413,7 +413,7 @@ namespace PKHeX.Core
{
00 or 01 or 02 => AbilityType, // Fixed 0/1/2
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)

View file

@ -445,7 +445,7 @@ namespace PKHeX.Core
{
00 or 01 or 02 => AbilityType, // Fixed 0/1/2
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)

View file

@ -169,7 +169,7 @@ namespace PKHeX.Core
2 => Shiny.AlwaysStar,
3 => Shiny.AlwaysSquare,
4 => Shiny.FixedValue,
_ => throw new ArgumentException(),
_ => throw new ArgumentOutOfRangeException(nameof(PIDType)),
};
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
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)
@ -511,7 +511,7 @@ namespace PKHeX.Core
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
4 => PID, // Fixed, Force Value
_ => throw new ArgumentException(),
_ => throw new ArgumentOutOfRangeException(nameof(type)),
};
static uint GetAntishiny(ITrainerID tr)

View file

@ -475,7 +475,7 @@ namespace PKHeX.Core
public bool GetMoveRecordFlag(int index)
{
if ((uint) index > 112) // 14 bytes, 8 bits
throw new ArgumentException(nameof(index));
throw new ArgumentOutOfRangeException(nameof(index));
int ofs = index >> 3;
return FlagUtil.GetFlag(Data, 0x127 + ofs, index & 7);
}
@ -483,7 +483,7 @@ namespace PKHeX.Core
public void SetMoveRecordFlag(int index, bool value)
{
if ((uint)index > 112) // 14 bytes, 8 bits
throw new ArgumentException(nameof(index));
throw new ArgumentOutOfRangeException(nameof(index));
int ofs = index >> 3;
FlagUtil.SetFlag(Data, 0x127 + ofs, index & 7, value);
}

View file

@ -51,7 +51,7 @@ namespace PKHeX.Core
SCTypeCode.Single => sizeof(float),
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
@ -69,7 +69,7 @@ namespace PKHeX.Core
SCTypeCode.Single => typeof(float),
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)
@ -88,7 +88,7 @@ namespace PKHeX.Core
case SCTypeCode.Single: return BitConverter.ToSingle(data, 0);
case SCTypeCode.Double: return BitConverter.ToDouble(data, 0);
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.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());
}
}
}

View file

@ -306,7 +306,7 @@ namespace PKHeX.Core
public sealed override bool GetEventFlag(int flagNumber)
{
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;
return GetFlag(start + (flagNumber >> 3), flagNumber & 7);
@ -315,7 +315,7 @@ namespace PKHeX.Core
public sealed override void SetEventFlag(int flagNumber, bool value)
{
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;
SetFlag(start + (flagNumber >> 3), flagNumber & 7, value);

View file

@ -77,14 +77,14 @@ namespace PKHeX.Core
public bool GetPoketchAppUnlocked(PoketchApp index)
{
if (index > PoketchApp.Alarm_Clock)
throw new ArgumentException(nameof(index));
throw new ArgumentOutOfRangeException(nameof(index));
return General[PoketchStart + 3 + (int) index] != 0;
}
public void SetPoketchAppUnlocked(PoketchApp index, bool value = true)
{
if (index > PoketchApp.Alarm_Clock)
throw new ArgumentException(nameof(index));
throw new ArgumentOutOfRangeException(nameof(index));
var b = value ? 1 : 0;
General[PoketchStart + 3 + (int)index] = (byte)b;
}
@ -119,7 +119,7 @@ namespace PKHeX.Core
public HoneyTreeValue GetHoneyTree(int index)
{
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));
}

View file

@ -169,7 +169,7 @@ namespace PKHeX.Core
public virtual bool GetEventFlag(int flagNumber)
{
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);
}
@ -182,7 +182,7 @@ namespace PKHeX.Core
public virtual void SetEventFlag(int flagNumber, bool value)
{
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);
}
@ -313,7 +313,7 @@ namespace PKHeX.Core
set
{
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 (value[0].Species == 0)
System.Diagnostics.Debug.WriteLine($"Empty first slot, received {value.Count}.");

View file

@ -25,7 +25,7 @@ namespace PKHeX.Core
public string GetGroupName(int group)
{
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 " "
return GetString(offset, GroupNameSize / 2);
}

View file

@ -49,13 +49,13 @@ namespace PKHeX.Core
public int PouchBall { get; private set; } = -1;
public int PouchPC { get; private set; } = -1;
private void LoadOffsetsInternational(GameVersion Version)
private void LoadOffsetsInternational(GameVersion version)
{
RTCFlags = 0x0C60;
DaylightSavings = 0x2042;
OtherCurrentBox = 0x284C;
switch (Version)
switch (version)
{
case GameVersion.GS:
TimePlayed = 0x2053;
@ -107,11 +107,11 @@ namespace PKHeX.Core
break;
default:
throw new ArgumentException(nameof(Version));
throw new ArgumentException(nameof(version));
}
}
private void LoadOffsetsJapanese(GameVersion Version)
private void LoadOffsetsJapanese(GameVersion version)
{
DaylightSavings = 0x2029;
TimePlayed = 0x2034;
@ -119,7 +119,7 @@ namespace PKHeX.Core
CurrentBox = 0x2D10;
OtherCurrentBox = 0x2842;
switch (Version)
switch (version)
{
case GameVersion.GS:
RTCFlags = 0x1000;
@ -169,7 +169,7 @@ namespace PKHeX.Core
break;
default:
throw new ArgumentException(nameof(Version));
throw new ArgumentException(nameof(version));
}
}

View file

@ -52,14 +52,14 @@ namespace PKHeX.Core
public void SetStat(int stat, byte value)
{
if ((uint) stat > 5)
throw new ArgumentException(nameof(stat));
throw new ArgumentOutOfRangeException(nameof(stat));
Data[1 + stat] = value;
}
public byte GetStat(int stat)
{
if ((uint)stat > 5)
throw new ArgumentException(nameof(stat));
throw new ArgumentOutOfRangeException(nameof(stat));
return Data[1 + stat];
}

View file

@ -23,9 +23,9 @@ namespace PKHeX.Core
private int GetBadgeVictorySpeciesOffset(uint badge, uint slot)
{
if (badge >= 8)
throw new ArgumentException(nameof(badge));
throw new ArgumentOutOfRangeException(nameof(badge));
if (slot >= 6)
throw new ArgumentException(nameof(slot));
throw new ArgumentOutOfRangeException(nameof(slot));
return Offset + BadgeVictoryOffset + (int)(((6 * badge) + slot) * sizeof(ushort));
}

View file

@ -11,7 +11,7 @@ namespace PKHeX.Core
public ushort GetPWTRecord(PWTRecordID id)
{
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);
return BitConverter.ToUInt16(Data, ofs);
}
@ -21,7 +21,7 @@ namespace PKHeX.Core
public void SetPWTRecord(PWTRecordID id, ushort value)
{
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);
SAV.SetData(BitConverter.GetBytes(value), ofs);
}

View file

@ -24,9 +24,9 @@ namespace PKHeX.Core
private int GetBadgeVictorySpeciesOffset(uint badge, uint slot)
{
if (badge >= 8)
throw new ArgumentException(nameof(badge));
throw new ArgumentOutOfRangeException(nameof(badge));
if (slot >= 6)
throw new ArgumentException(nameof(slot));
throw new ArgumentOutOfRangeException(nameof(slot));
return Offset + BadgeVictoryOffset + (int)(((6 * badge) + slot) * sizeof(ushort));
}

View file

@ -35,7 +35,7 @@ namespace PKHeX.Core
public bool GetIsRegimenUnlocked(int index)
{
if ((uint)index >= MAX)
throw new ArgumentException(nameof(index));
throw new ArgumentOutOfRangeException(nameof(index));
return SAV.GetFlag(Offset, index);
}
@ -47,7 +47,7 @@ namespace PKHeX.Core
public void SetIsRegimenUnlocked(int index, bool value)
{
if ((uint)index >= MAX)
throw new ArgumentException(nameof(index));
throw new ArgumentOutOfRangeException(nameof(index));
SAV.SetFlag(Offset, index, value);
}
@ -59,7 +59,7 @@ namespace PKHeX.Core
public bool GetIsDistributionUnlocked(int index)
{
if ((uint)index >= MAX_DIST)
throw new ArgumentException(nameof(index));
throw new ArgumentOutOfRangeException(nameof(index));
return SAV.GetFlag(Offset + 6, index);
}
@ -71,7 +71,7 @@ namespace PKHeX.Core
public void SetIsDistributionUnlocked(int index, bool value)
{
if ((uint)index >= MAX_DIST)
throw new ArgumentException(nameof(index));
throw new ArgumentOutOfRangeException(nameof(index));
SAV.SetFlag(Offset + 6, index, value);
}
@ -91,7 +91,7 @@ namespace PKHeX.Core
public float GetTime1(int index)
{
if ((uint) index >= MAX)
throw new ArgumentException(nameof(index));
throw new ArgumentOutOfRangeException(nameof(index));
return BitConverter.ToSingle(Data, Offset + 0x08 + (4 * index));
}
@ -104,7 +104,7 @@ namespace PKHeX.Core
public void SetTime1(int index, float value = 0)
{
if ((uint)index >= MAX)
throw new ArgumentException(nameof(index));
throw new ArgumentOutOfRangeException(nameof(index));
BitConverter.GetBytes(value).CopyTo(Data, Offset + 0x08 + (4 * index));
}
@ -116,7 +116,7 @@ namespace PKHeX.Core
public float GetTime2(int index)
{
if ((uint)index >= MAX)
throw new ArgumentException(nameof(index));
throw new ArgumentOutOfRangeException(nameof(index));
return BitConverter.ToSingle(Data, Offset + 0xC8 + (4 * index));
}
@ -129,7 +129,7 @@ namespace PKHeX.Core
public void SetTime2(int index, float value = 0)
{
if ((uint)index >= MAX)
throw new ArgumentException(nameof(index));
throw new ArgumentOutOfRangeException(nameof(index));
BitConverter.GetBytes(value).CopyTo(Data, Offset + 0xC8 + (4 * index));
}
@ -142,7 +142,7 @@ namespace PKHeX.Core
public SuperTrainingSpeciesRecord GetHolder1(int index)
{
if ((uint)index >= MAX)
throw new ArgumentException(nameof(index));
throw new ArgumentOutOfRangeException(nameof(index));
return new SuperTrainingSpeciesRecord(Data, Offset + 0x188 + (4 * index));
}
@ -155,7 +155,7 @@ namespace PKHeX.Core
public SuperTrainingSpeciesRecord GetHolder2(int index)
{
if ((uint)index >= MAX)
throw new ArgumentException(nameof(index));
throw new ArgumentOutOfRangeException(nameof(index));
return new SuperTrainingSpeciesRecord(Data, Offset + 0x248 + (4 * index));
}
@ -167,7 +167,7 @@ namespace PKHeX.Core
public byte GetBag(int index)
{
if ((uint)index >= MAX_BAG)
throw new ArgumentException(nameof(index));
throw new ArgumentOutOfRangeException(nameof(index));
return Data[Offset + 0x308 + index];
}
@ -179,7 +179,7 @@ namespace PKHeX.Core
public void SetBag(int index, byte value)
{
if ((uint)index >= MAX_BAG)
throw new ArgumentException(nameof(index));
throw new ArgumentOutOfRangeException(nameof(index));
Data[Offset + 0x308 + index] = value;
}
@ -219,7 +219,7 @@ namespace PKHeX.Core
public void RemoveBag(int index)
{
if ((uint)index >= MAX_BAG)
throw new ArgumentException(nameof(index));
throw new ArgumentOutOfRangeException(nameof(index));
for (int i = index; i < MAX_BAG - 1; i++)
{
var next = GetBag(i + 1);
@ -241,7 +241,7 @@ namespace PKHeX.Core
public void ClearRecord1(int index)
{
if ((uint)index >= MAX)
throw new ArgumentException(nameof(index));
throw new ArgumentOutOfRangeException(nameof(index));
SetTime1(index, 0f);
GetHolder1(index).Clear();
@ -254,7 +254,7 @@ namespace PKHeX.Core
public void ClearRecord2(int index)
{
if ((uint)index >= MAX)
throw new ArgumentException(nameof(index));
throw new ArgumentOutOfRangeException(nameof(index));
SetTime2(index, 0f);
GetHolder2(index).Clear();

View file

@ -12,7 +12,7 @@ namespace PKHeX.Core
public int GetTreeStreak(int battletype, bool super, bool max)
{
if (battletype > 3)
throw new ArgumentException(nameof(battletype));
throw new ArgumentOutOfRangeException(nameof(battletype));
var offset = GetStreakOffset(battletype, super, max);
return BitConverter.ToUInt16(Data, Offset + offset);
@ -21,7 +21,7 @@ namespace PKHeX.Core
public void SetTreeStreak(int value, int battletype, bool super, bool max)
{
if (battletype > 3)
throw new ArgumentException(nameof(battletype));
throw new ArgumentOutOfRangeException(nameof(battletype));
if (value > ushort.MaxValue)
value = ushort.MaxValue;
@ -45,7 +45,7 @@ namespace PKHeX.Core
public BattleTreeTrainer GetTrainer(in int index)
{
if ((uint)index >= ScoutCount)
throw new ArgumentException(nameof(index));
throw new ArgumentOutOfRangeException(nameof(index));
var id = BitConverter.ToInt16(Data, Offset + 0x24 + (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)
{
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.Poke1.ID).CopyTo(Data, Offset + 0x88 + (index * 2));

View file

@ -58,7 +58,7 @@ namespace PKHeX.Core
{
int max = GetFlagCount(type);
if ((uint)index > max)
throw new ArgumentException(nameof(index));
throw new ArgumentOutOfRangeException(nameof(index));
var start = GetFlagStart(type);
return start + index;
}
@ -67,7 +67,7 @@ namespace PKHeX.Core
{
int max = GetWorkCount(type);
if ((uint)index > max)
throw new ArgumentException(nameof(index));
throw new ArgumentOutOfRangeException(nameof(index));
var start = GetWorkStart(type);
return start + index;
}
@ -107,7 +107,7 @@ namespace PKHeX.Core
if (subIndex < EventFlagCount)
return EventVarType.Event;
throw new ArgumentException(nameof(index));
throw new ArgumentOutOfRangeException(nameof(index));
}
public EventVarType GetWorkType(int index, out int subIndex)
@ -128,7 +128,7 @@ namespace PKHeX.Core
if (subIndex < EventWorkCount)
return EventVarType.Event;
throw new ArgumentException(nameof(index));
throw new ArgumentOutOfRangeException(nameof(index));
}
private static int GetFlagStart(EventVarType type) => type switch
@ -137,7 +137,7 @@ namespace PKHeX.Core
EventVarType.System => SystemFlagStart,
EventVarType.Vanish => VanishFlagStart,
EventVarType.Event => EventFlagStart,
_ => throw new ArgumentException(nameof(type)),
_ => throw new ArgumentOutOfRangeException(nameof(type)),
};
private static int GetWorkStart(EventVarType type) => type switch
@ -146,7 +146,7 @@ namespace PKHeX.Core
EventVarType.System => SystemWorkStart,
EventVarType.Scene => SceneWorkStart,
EventVarType.Event => EventWorkStart,
_ => throw new ArgumentException(nameof(type)),
_ => throw new ArgumentOutOfRangeException(nameof(type)),
};
private static int GetFlagCount(EventVarType type) => type switch
@ -155,7 +155,7 @@ namespace PKHeX.Core
EventVarType.System => SystemFlagCount,
EventVarType.Vanish => VanishFlagCount,
EventVarType.Event => EventFlagCount,
_ => throw new ArgumentException(nameof(type)),
_ => throw new ArgumentOutOfRangeException(nameof(type)),
};
private static int GetWorkCount(EventVarType type) => type switch
@ -164,7 +164,7 @@ namespace PKHeX.Core
EventVarType.System => SystemWorkCount,
EventVarType.Scene => SceneWorkCount,
EventVarType.Event => EventWorkCount,
_ => throw new ArgumentException(nameof(type)),
_ => throw new ArgumentOutOfRangeException(nameof(type)),
};
}
}

View file

@ -89,7 +89,7 @@ namespace PKHeX.Core
set
{
if ((ushort)value > 1000 && value != SLOT_EMPTY)
throw new ArgumentException(nameof(value));
throw new ArgumentOutOfRangeException(nameof(value));
PokeListInfo[STARTER] = (ushort)value;
}
}
@ -118,7 +118,7 @@ namespace PKHeX.Core
public int GetPartyOffset(int slot)
{
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];
return SAV.GetBoxSlotOffset(position);
}

View file

@ -35,14 +35,14 @@ namespace PKHeX.Core
public int GetPokebeanCount(int bean_id)
{
if ((uint)bean_id > 14)
throw new ArgumentException("Invalid bean id!");
throw new ArgumentOutOfRangeException(nameof(bean_id));
return Data[Offset + 0x564C + bean_id];
}
public void SetPokebeanCount(int bean_id, int count)
{
if ((uint)bean_id > 14)
throw new ArgumentException("Invalid bean id!");
throw new ArgumentOutOfRangeException(nameof(bean_id));
if (count < 0)
count = 0;
if (count > 255)

View file

@ -14,7 +14,7 @@ namespace PKHeX.Core
private int GetRecordOffset(int index)
{
if (index >= RecordMax)
throw new ArgumentException(nameof(index));
throw new ArgumentOutOfRangeException(nameof(index));
return Offset + (index * WR7.Size);
}
@ -22,7 +22,7 @@ namespace PKHeX.Core
private int GetFlagOffset(int flag)
{
if (flag >= FlagCountMax)
throw new ArgumentException(nameof(flag));
throw new ArgumentOutOfRangeException(nameof(flag));
return FlagStart + (flag / 8);
}

View file

@ -60,7 +60,7 @@ namespace PKHeX.Core
{
PokeDexLanguageFlags = langflag;
if (langflag > dex)
throw new ArgumentException(nameof(langflag));
throw new ArgumentOutOfRangeException(nameof(langflag));
}
protected abstract int OFS_SEEN { get; }

View file

@ -209,7 +209,7 @@ namespace PKHeX.Core
Value |= (uint)(val << (BitsPerForm * i));
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;
}

View file

@ -213,7 +213,7 @@ namespace PKHeX.Core
public bool GetSeenRegion(Zukan8Index entry, int form, int region)
{
if ((uint)region >= SeenRegionCount)
throw new ArgumentException(nameof(region));
throw new ArgumentOutOfRangeException(nameof(region));
if ((uint)form > 63)
return false;
@ -235,7 +235,7 @@ namespace PKHeX.Core
public void SetSeenRegion(Zukan8Index entry, int form, int region, bool value = true)
{
if ((uint) region >= SeenRegionCount)
throw new ArgumentException(nameof(region));
throw new ArgumentOutOfRangeException(nameof(region));
if ((uint) form > 63)
return;

View file

@ -728,7 +728,7 @@ namespace PKHeX.Core
SW or SH or SWSH => new SAV8SWSH(),
_ => throw new ArgumentException(nameof(game)),
_ => throw new ArgumentOutOfRangeException(nameof(game)),
};
/// <summary>
@ -789,17 +789,17 @@ namespace PKHeX.Core
public static bool IsSizeValid(int size) => Sizes.Contains(size) || Handlers.Any(z => z.IsRecognized(size));
/// <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>
/// <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>
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),
E => new SAV3E(sav.State.BAK),
FR or LG or FRLG => new SAV3FRLG(sav.State.BAK),
_ => throw new ArgumentException(nameof(ver)),
_ => throw new ArgumentOutOfRangeException(nameof(version)),
};
}
}

View file

@ -128,7 +128,7 @@ namespace PKHeX.WinForms
var p = Pouches.FirstOrDefault(z => z.Type == InventoryType.KeyItems);
if (p == null)
throw new ArgumentException(nameof(InventoryPouch.Type));
throw new ArgumentOutOfRangeException(nameof(InventoryPouch.Type));
// check for missing tickets
var missing = tickets.Where(z => !p.Items.Any(item => item.Index == z && item.Count == 1)).ToList();

View file

@ -66,7 +66,7 @@ namespace PKHeX.WinForms
var species = WinFormsUtil.GetIndex(CB_Species);
if (!Dex.DexLookup.TryGetValue(species, out var info))
throw new ArgumentException(nameof(species));
throw new ArgumentOutOfRangeException(nameof(species));
var index = info.AbsoluteIndex - 1;
if (LB_Species.SelectedIndex != index)

View file

@ -28,7 +28,7 @@ namespace PKHeX.WinForms
{
4 => PopulateViewGiftsG4().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)
{