diff --git a/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTrade8.cs b/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTrade8.cs index 2b7544583..eaf9e03d1 100644 --- a/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTrade8.cs +++ b/PKHeX.Core/Legality/Encounters/EncounterTrade/EncounterTrade8.cs @@ -17,15 +17,15 @@ namespace PKHeX.Core public int OT_Feeling { get; set; } public int OT_Intensity { get; set; } - public EncounterTrade8(GameVersion game, int species, int level, int m, int a, int f, int i) : base(game) + public EncounterTrade8(GameVersion game, int species, int level, int memory, int arg, int feel, int intensity) : base(game) { Species = species; Level = level; - OT_Memory = m; - OT_TextVar = a; - OT_Feeling = f; - OT_Intensity = i; + OT_Memory = memory; + OT_TextVar = arg; + OT_Feeling = feel; + OT_Intensity = intensity; } public override bool IsMatchExact(PKM pkm, DexLevel evo) diff --git a/PKHeX.Core/Legality/Encounters/Verifiers/MysteryGiftVerifier.cs b/PKHeX.Core/Legality/Encounters/Verifiers/MysteryGiftVerifier.cs index 18ac84c86..45218b05c 100644 --- a/PKHeX.Core/Legality/Encounters/Verifiers/MysteryGiftVerifier.cs +++ b/PKHeX.Core/Legality/Encounters/Verifiers/MysteryGiftVerifier.cs @@ -16,7 +16,7 @@ namespace PKHeX.Core return s; } - private static string RestrictionSetName(int i) => $"mgrestrict{i}.pkl"; + private static string RestrictionSetName(int generation) => $"mgrestrict{generation}.pkl"; private static Dictionary GetRestriction(int generation) { diff --git a/PKHeX.Core/Legality/Moves/Breeding/EggSource.cs b/PKHeX.Core/Legality/Moves/Breeding/EggSource.cs index a90f46110..74bffcbcf 100644 --- a/PKHeX.Core/Legality/Moves/Breeding/EggSource.cs +++ b/PKHeX.Core/Legality/Moves/Breeding/EggSource.cs @@ -95,11 +95,11 @@ namespace PKHeX.Core /// public static string GetSource(object parse, int generation, int index) { - static string GetLine(T[] arr, Func act, int i) + static string GetLine(T[] arr, Func act, int index) { - if (i >= arr.Length) + if ((uint)index >= arr.Length) return LMoveSourceEmpty; - return act(arr[i]); + return act(arr[index]); } return generation switch diff --git a/PKHeX.Core/PKM/Shared/PokeListGB.cs b/PKHeX.Core/PKM/Shared/PokeListGB.cs index b8a4a93be..f4a94c41b 100644 --- a/PKHeX.Core/PKM/Shared/PokeListGB.cs +++ b/PKHeX.Core/PKM/Shared/PokeListGB.cs @@ -78,9 +78,9 @@ namespace PKHeX.Core return result; } - private int GetOffsetPKMData(int base_ofs, int i) => base_ofs + (Entry_Size * i); - private int GetOffsetPKMOT(int base_ofs, int i) => GetOffsetPKMData(base_ofs, Capacity) + (StringLength * i); - private int GetOffsetPKMNickname(int base_ofs, int i) => GetOffsetPKMOT(base_ofs, Capacity) + (StringLength * i); + private int GetOffsetPKMData(int base_ofs, int index) => base_ofs + (Entry_Size * index); + private int GetOffsetPKMOT(int base_ofs, int index) => GetOffsetPKMData(base_ofs, Capacity) + (StringLength * index); + private int GetOffsetPKMNickname(int base_ofs, int index) => GetOffsetPKMOT(base_ofs, Capacity) + (StringLength * index); private static int GetStringLength(bool jp) => jp ? GBPKML.StringLengthJapanese : GBPKML.StringLengthNotJapan; protected bool IsFormatParty => IsCapacityPartyFormat((PokeListType)Capacity); @@ -131,26 +131,26 @@ namespace PKHeX.Core return Data; } - private T GetEntry(int base_ofs, int i) + private T GetEntry(int base_ofs, int index) { - int pkOfs = GetOffsetPKMData(base_ofs, i); - int otOfs = GetOffsetPKMOT(base_ofs, i); - int nkOfs = GetOffsetPKMNickname(base_ofs, i); + int pkOfs = GetOffsetPKMData(base_ofs, index); + int otOfs = GetOffsetPKMOT(base_ofs, index); + int nkOfs = GetOffsetPKMNickname(base_ofs, index); var dat = Data.Slice(pkOfs, Entry_Size); var otname = Data.Slice(otOfs, StringLength); var nick = Data.Slice(nkOfs, StringLength); - return GetEntry(dat, otname, nick, Data[1 + i] == 0xFD); + return GetEntry(dat, otname, nick, Data[1 + index] == 0xFD); } - private void SetEntry(int base_ofs, int i) + private void SetEntry(int base_ofs, int index) { - int pkOfs = GetOffsetPKMData(base_ofs, i); - int otOfs = GetOffsetPKMOT(base_ofs, i); - int nkOfs = GetOffsetPKMNickname(base_ofs, i); + int pkOfs = GetOffsetPKMData(base_ofs, index); + int otOfs = GetOffsetPKMOT(base_ofs, index); + int nkOfs = GetOffsetPKMNickname(base_ofs, index); - var pk = Pokemon[i]; + var pk = Pokemon[index]; Array.Copy(pk.Data, 0, Data, pkOfs, Entry_Size); pk.RawOT.CopyTo(Data, otOfs); pk.RawNickname.CopyTo(Data, nkOfs); diff --git a/PKHeX.Core/Saves/Encryption/SwishCrypto/SCBlockMetadata.cs b/PKHeX.Core/Saves/Encryption/SwishCrypto/SCBlockMetadata.cs index e02039f75..53a900c29 100644 --- a/PKHeX.Core/Saves/Encryption/SwishCrypto/SCBlockMetadata.cs +++ b/PKHeX.Core/Saves/Encryption/SwishCrypto/SCBlockMetadata.cs @@ -72,14 +72,14 @@ namespace PKHeX.Core return text[(8 + 3 + 4 + 1)..]; } - private string GetBlockHint(SCBlock z, int i) + private string GetBlockHint(SCBlock z, int index) { var blockName = GetBlockName(z, out _); var isBool = z.Type.IsBoolean(); var type = (isBool ? "Bool" : z.Type.ToString()); if (blockName != null) return $"*{type} {blockName}"; - var result = $"{z.Key:X8} - {i:0000} {type}"; + var result = $"{z.Key:X8} - {index:0000} {type}"; if (z.Type is SCTypeCode.Object or SCTypeCode.Array) result += $" 0x{z.Data.Length:X3}"; else if (!isBool) diff --git a/PKHeX.Core/Saves/SAV1.cs b/PKHeX.Core/Saves/SAV1.cs index 731941e59..855c7f8df 100644 --- a/PKHeX.Core/Saves/SAV1.cs +++ b/PKHeX.Core/Saves/SAV1.cs @@ -175,11 +175,11 @@ namespace PKHeX.Core return outData; } - private int GetBoxRawDataOffset(int i) + private int GetBoxRawDataOffset(int box) { - if (i < BoxCount / 2) - return 0x4000 + (i * SIZE_STOREDBOX); - return 0x6000 + ((i - (BoxCount / 2)) * SIZE_STOREDBOX); + if (box < BoxCount / 2) + return 0x4000 + (box * SIZE_STOREDBOX); + return 0x6000 + ((box - (BoxCount / 2)) * SIZE_STOREDBOX); } // Configuration diff --git a/PKHeX.Core/Saves/SAV1Stadium.cs b/PKHeX.Core/Saves/SAV1Stadium.cs index e138e58f1..c9b4643cf 100644 --- a/PKHeX.Core/Saves/SAV1Stadium.cs +++ b/PKHeX.Core/Saves/SAV1Stadium.cs @@ -71,26 +71,26 @@ namespace PKHeX.Core ClearBoxes(); } - protected override bool GetIsBoxChecksumValid(int i) + protected override bool GetIsBoxChecksumValid(int box) { - var boxOfs = GetBoxOffset(i) - ListHeaderSize; + var boxOfs = GetBoxOffset(box) - ListHeaderSize; var size = BoxSize - 2; var chk = Checksums.CheckSum16(new ReadOnlySpan(Data, boxOfs, size)); var actual = BigEndian.ToUInt16(Data, boxOfs + size); return chk == actual; } - protected override void SetBoxChecksum(int i) + protected override void SetBoxChecksum(int box) { - var boxOfs = GetBoxOffset(i) - ListHeaderSize; + var boxOfs = GetBoxOffset(box) - ListHeaderSize; var size = BoxSize - 2; var chk = Checksums.CheckSum16(new ReadOnlySpan(Data, boxOfs, size)); BigEndian.GetBytes(chk).CopyTo(Data, boxOfs + size); } - protected override void SetBoxMetadata(int i) + protected override void SetBoxMetadata(int box) { - var bdata = GetBoxOffset(i); + var bdata = GetBoxOffset(box); // Set box count int count = 0; diff --git a/PKHeX.Core/Saves/SAV1StadiumJ.cs b/PKHeX.Core/Saves/SAV1StadiumJ.cs index 3fadc4dc0..75aa3736e 100644 --- a/PKHeX.Core/Saves/SAV1StadiumJ.cs +++ b/PKHeX.Core/Saves/SAV1StadiumJ.cs @@ -56,24 +56,24 @@ namespace PKHeX.Core ClearBoxes(); } - protected override bool GetIsBoxChecksumValid(int i) + protected override bool GetIsBoxChecksumValid(int box) { - var boxOfs = GetBoxOffset(i) - ListHeaderSize; + var boxOfs = GetBoxOffset(box) - ListHeaderSize; const int size = BoxSizeJ - 2; var chk = Checksums.CheckSum16(new ReadOnlySpan(Data, boxOfs, size)); var actual = BigEndian.ToUInt16(Data, boxOfs + size); return chk == actual; } - protected override void SetBoxChecksum(int i) + protected override void SetBoxChecksum(int box) { - var boxOfs = GetBoxOffset(i) - ListHeaderSize; + var boxOfs = GetBoxOffset(box) - ListHeaderSize; const int size = BoxSizeJ - 2; var chk = Checksums.CheckSum16(new ReadOnlySpan(Data, boxOfs, size)); BigEndian.GetBytes(chk).CopyTo(Data, boxOfs + size); } - protected override void SetBoxMetadata(int i) + protected override void SetBoxMetadata(int box) { // Not implemented } diff --git a/PKHeX.Core/Saves/SAV2Stadium.cs b/PKHeX.Core/Saves/SAV2Stadium.cs index 74db9e968..132153a78 100644 --- a/PKHeX.Core/Saves/SAV2Stadium.cs +++ b/PKHeX.Core/Saves/SAV2Stadium.cs @@ -69,18 +69,18 @@ namespace PKHeX.Core ClearBoxes(); } - protected override bool GetIsBoxChecksumValid(int i) + protected override bool GetIsBoxChecksumValid(int box) { - var boxOfs = GetBoxOffset(i) - ListHeaderSizeBox; + var boxOfs = GetBoxOffset(box) - ListHeaderSizeBox; var size = BoxSize - 2; var chk = Checksums.CheckSum16(new ReadOnlySpan(Data, boxOfs, size)); var actual = BigEndian.ToUInt16(Data, boxOfs + size); return chk == actual; } - protected override void SetBoxMetadata(int i) + protected override void SetBoxMetadata(int box) { - var bdata = GetBoxOffset(i); + var bdata = GetBoxOffset(box); // Set box count int count = 0; @@ -105,9 +105,9 @@ namespace PKHeX.Core } } - protected override void SetBoxChecksum(int i) + protected override void SetBoxChecksum(int box) { - var boxOfs = GetBoxOffset(i) - ListHeaderSizeBox; + var boxOfs = GetBoxOffset(box) - ListHeaderSizeBox; var size = BoxSize - 2; var chk = Checksums.CheckSum16(new ReadOnlySpan(Data, boxOfs, size)); BigEndian.GetBytes(chk).CopyTo(Data, boxOfs + size); diff --git a/PKHeX.Core/Saves/SAV3.cs b/PKHeX.Core/Saves/SAV3.cs index f2e10c808..eabbe601e 100644 --- a/PKHeX.Core/Saves/SAV3.cs +++ b/PKHeX.Core/Saves/SAV3.cs @@ -555,9 +555,9 @@ namespace PKHeX.Core protected abstract int MailOffset { get; } public int GetMailOffset(int index) => (index * Mail3.SIZE) + MailOffset; - public Mail GetMail(int i) + public Mail GetMail(int mailIndex) { - var ofs = GetMailOffset(i); + var ofs = GetMailOffset(mailIndex); var data = Large.Slice(ofs, Mail3.SIZE); return new Mail3(data, ofs, Japanese); } diff --git a/PKHeX.Core/Saves/SAV4.cs b/PKHeX.Core/Saves/SAV4.cs index d3108052f..e0be10d79 100644 --- a/PKHeX.Core/Saves/SAV4.cs +++ b/PKHeX.Core/Saves/SAV4.cs @@ -534,9 +534,9 @@ namespace PKHeX.Core public byte[] GetMailData(int ofs) => General.Slice(ofs, Mail4.SIZE); - public Mail4 GetMail(int i) + public Mail4 GetMail(int mailIndex) { - int ofs = GetMailOffset(i); + int ofs = GetMailOffset(mailIndex); return new Mail4(GetMailData(ofs), ofs); } } diff --git a/PKHeX.Core/Saves/SAV4HGSS.cs b/PKHeX.Core/Saves/SAV4HGSS.cs index 6e467be64..f770f0feb 100644 --- a/PKHeX.Core/Saves/SAV4HGSS.cs +++ b/PKHeX.Core/Saves/SAV4HGSS.cs @@ -220,8 +220,8 @@ namespace PKHeX.Core } // Apricorn Pouch - public int GetApricornCount(int i) => General[0xE558 + i]; - public void SetApricornCount(int i, int count) => General[0xE558 + i] = (byte)count; + public int GetApricornCount(int index) => General[0xE558 + index]; + public void SetApricornCount(int index, int count) => General[0xE558 + index] = (byte)count; // Pokewalker public const int WalkerPair = 0xE5E0; diff --git a/PKHeX.Core/Saves/SAV5.cs b/PKHeX.Core/Saves/SAV5.cs index bb246b391..ba35144bc 100644 --- a/PKHeX.Core/Saves/SAV5.cs +++ b/PKHeX.Core/Saves/SAV5.cs @@ -210,9 +210,9 @@ namespace PKHeX.Core public byte[] GetMailData(int offset) => GetData(offset, Mail5.SIZE); public int GetBattleBoxSlot(int slot) => BattleBoxOffset + (slot * SIZE_STORED); - public Mail GetMail(int i) + public Mail GetMail(int mailIndex) { - int ofs = GetMailOffset(i); + int ofs = GetMailOffset(mailIndex); var data = GetMailData(ofs); return new Mail5(data, ofs); } diff --git a/PKHeX.Core/Saves/SAV_STADIUM.cs b/PKHeX.Core/Saves/SAV_STADIUM.cs index ffe09011d..5576390b7 100644 --- a/PKHeX.Core/Saves/SAV_STADIUM.cs +++ b/PKHeX.Core/Saves/SAV_STADIUM.cs @@ -48,10 +48,10 @@ public sealed override void SetBoxName(int box, string value) { } public sealed override bool ChecksumsValid => GetBoxChecksumsValid(); public sealed override string ChecksumInfo => ChecksumsValid ? "Checksum valid." : "Checksum invalid"; - protected abstract void SetBoxChecksum(int i); - protected abstract bool GetIsBoxChecksumValid(int i); + protected abstract void SetBoxChecksum(int box); + protected abstract bool GetIsBoxChecksumValid(int box); protected sealed override void SetChecksums() => SetBoxChecksums(); - protected abstract void SetBoxMetadata(int i); + protected abstract void SetBoxMetadata(int box); protected void SetBoxChecksums() { diff --git a/PKHeX.Core/Saves/SaveFile.cs b/PKHeX.Core/Saves/SaveFile.cs index a52aca2af..93e93c9d8 100644 --- a/PKHeX.Core/Saves/SaveFile.cs +++ b/PKHeX.Core/Saves/SaveFile.cs @@ -290,9 +290,9 @@ namespace PKHeX.Core return true; } - private bool IsPartySlotNotEggOrEmpty(int i) + private bool IsPartySlotNotEggOrEmpty(int index) { - var slot = GetPartySlotAtIndex(i); + var slot = GetPartySlotAtIndex(index); return !slot.IsEgg && slot.Species != 0; } diff --git a/PKHeX.Core/Saves/Substructures/Gen3/CXD/ShadowInfoTableXD.cs b/PKHeX.Core/Saves/Substructures/Gen3/CXD/ShadowInfoTableXD.cs index 842bf1de4..d94954a79 100644 --- a/PKHeX.Core/Saves/Substructures/Gen3/CXD/ShadowInfoTableXD.cs +++ b/PKHeX.Core/Saves/Substructures/Gen3/CXD/ShadowInfoTableXD.cs @@ -15,19 +15,15 @@ namespace PKHeX.Core int eCount = data.Length/SIZE_ENTRY; Entries = new ShadowInfoEntryXD[eCount]; for (int i = 0; i < eCount; i++) - { - var entry = GetEntry(data, i); - Entries[i] = entry; - } + Entries[i] = GetEntry(data, i); } public ShadowInfoTableXD() : this(new byte[SIZE_ENTRY * MaxCount]) { } - private static ShadowInfoEntryXD GetEntry(byte[] data, int i) + private static ShadowInfoEntryXD GetEntry(byte[] data, int index) { - var d = data.Slice(i * SIZE_ENTRY, SIZE_ENTRY); - var entry = new ShadowInfoEntryXD(d); - return entry; + var slice = data.Slice(index * SIZE_ENTRY, SIZE_ENTRY); + return new ShadowInfoEntryXD(slice); } public byte[] Write() => Entries.SelectMany(entry => entry.Data).Take(MaxLength).ToArray(); diff --git a/PKHeX.Core/Saves/Substructures/Gen3/HallFame3.cs b/PKHeX.Core/Saves/Substructures/Gen3/HallFame3.cs index 7a97490ad..be2be475c 100644 --- a/PKHeX.Core/Saves/Substructures/Gen3/HallFame3.cs +++ b/PKHeX.Core/Saves/Substructures/Gen3/HallFame3.cs @@ -19,8 +19,8 @@ namespace PKHeX.Core Offset = offset; } - private int GetMemberOffset(int i) => Offset + (i * HallFame3PKM.SIZE); - private HallFame3PKM GetMember(int i) => new(Parent, GetMemberOffset(i), Japanese); + private int GetMemberOffset(int index) => Offset + (index * HallFame3PKM.SIZE); + private HallFame3PKM GetMember(int index) => new(Parent, GetMemberOffset(index), Japanese); public HallFame3PKM[] Team { diff --git a/PKHeX.Core/Saves/Substructures/Gen3/SecretBase3Team.cs b/PKHeX.Core/Saves/Substructures/Gen3/SecretBase3Team.cs index 64ad7a6d4..39e9cc829 100644 --- a/PKHeX.Core/Saves/Substructures/Gen3/SecretBase3Team.cs +++ b/PKHeX.Core/Saves/Substructures/Gen3/SecretBase3Team.cs @@ -11,10 +11,10 @@ namespace PKHeX.Core private const int O_Level = 0x3C; private const int O_EV = 0x42; - private static int GetOffsetPID(int i) => O_PID + (i * 4); - private static int GetOffsetMove(int i, int move) => O_Moves + (i * 8) + (move * 2); - private static int GetOffsetSpecies(int i) => O_Species + (i * 2); - private static int GetOffsetItem(int i) => O_Item + (i * 2); + private static int GetOffsetPID(int index) => O_PID + (index * 4); + private static int GetOffsetMove(int index, int move) => O_Moves + (index * 8) + (move * 2); + private static int GetOffsetSpecies(int index) => O_Species + (index * 2); + private static int GetOffsetItem(int index) => O_Item + (index * 2); public readonly SecretBase3PKM[] Team; private readonly byte[] Data; @@ -34,34 +34,34 @@ namespace PKHeX.Core return Data; } - private SecretBase3PKM GetPKM(int i) + private SecretBase3PKM GetPKM(int index) { return new() { - PID = BitConverter.ToUInt32(Data, GetOffsetPID(i)), - Species = BitConverter.ToUInt16(Data, GetOffsetSpecies(i)), - HeldItem = BitConverter.ToUInt16(Data, GetOffsetItem(i)), - Move1 = BitConverter.ToUInt16(Data, GetOffsetMove(i, 0)), - Move2 = BitConverter.ToUInt16(Data, GetOffsetMove(i, 1)), - Move3 = BitConverter.ToUInt16(Data, GetOffsetMove(i, 2)), - Move4 = BitConverter.ToUInt16(Data, GetOffsetMove(i, 3)), - Level = Data[O_Level + i], - EVAll = Data[O_EV + i], + PID = BitConverter.ToUInt32(Data, GetOffsetPID(index)), + Species = BitConverter.ToUInt16(Data, GetOffsetSpecies(index)), + HeldItem = BitConverter.ToUInt16(Data, GetOffsetItem(index)), + Move1 = BitConverter.ToUInt16(Data, GetOffsetMove(index, 0)), + Move2 = BitConverter.ToUInt16(Data, GetOffsetMove(index, 1)), + Move3 = BitConverter.ToUInt16(Data, GetOffsetMove(index, 2)), + Move4 = BitConverter.ToUInt16(Data, GetOffsetMove(index, 3)), + Level = Data[O_Level + index], + EVAll = Data[O_EV + index], }; } - private void SetPKM(int i) + private void SetPKM(int index) { - var pk = Team[i]; - BitConverter.GetBytes(pk.PID).CopyTo(Data, GetOffsetPID(i)); - BitConverter.GetBytes((ushort)pk.Species).CopyTo(Data, GetOffsetSpecies(i)); - BitConverter.GetBytes((ushort)pk.HeldItem).CopyTo(Data, GetOffsetItem(i)); - BitConverter.GetBytes((ushort)pk.Move1).CopyTo(Data, GetOffsetMove(i, 0)); - BitConverter.GetBytes((ushort)pk.Move2).CopyTo(Data, GetOffsetMove(i, 1)); - BitConverter.GetBytes((ushort)pk.Move3).CopyTo(Data, GetOffsetMove(i, 2)); - BitConverter.GetBytes((ushort)pk.Move4).CopyTo(Data, GetOffsetMove(i, 3)); - Data[O_Level + i] = (byte) pk.Level; - Data[O_EV + i] = (byte) pk.EVAll; + var pk = Team[index]; + BitConverter.GetBytes(pk.PID).CopyTo(Data, GetOffsetPID(index)); + BitConverter.GetBytes((ushort)pk.Species).CopyTo(Data, GetOffsetSpecies(index)); + BitConverter.GetBytes((ushort)pk.HeldItem).CopyTo(Data, GetOffsetItem(index)); + BitConverter.GetBytes((ushort)pk.Move1).CopyTo(Data, GetOffsetMove(index, 0)); + BitConverter.GetBytes((ushort)pk.Move2).CopyTo(Data, GetOffsetMove(index, 1)); + BitConverter.GetBytes((ushort)pk.Move3).CopyTo(Data, GetOffsetMove(index, 2)); + BitConverter.GetBytes((ushort)pk.Move4).CopyTo(Data, GetOffsetMove(index, 3)); + Data[O_Level + index] = (byte)pk.Level; + Data[O_EV + index] = (byte)pk.EVAll; } } } \ No newline at end of file diff --git a/PKHeX.Core/Saves/Substructures/Gen7/ConfigSave6.cs b/PKHeX.Core/Saves/Substructures/Gen7/ConfigSave6.cs index 01c1da6ba..90cdb8010 100644 --- a/PKHeX.Core/Saves/Substructures/Gen7/ConfigSave6.cs +++ b/PKHeX.Core/Saves/Substructures/Gen7/ConfigSave6.cs @@ -97,8 +97,8 @@ namespace PKHeX.Core set => ConfigValue = ((ConfigValue & ~0xF0) | SetLanguageID(value) << 4); } - private static int GetLanguageID(int i) => i >= (int)LanguageID.UNUSED_6 ? i + 1 : i; // sets langBank to LanguageID - private static int SetLanguageID(int i) => i > (int)LanguageID.UNUSED_6 ? i - 1 : i; // sets LanguageID to langBank + private static int GetLanguageID(int rawValue) => rawValue >= (int)LanguageID.UNUSED_6 ? rawValue + 1 : rawValue; // sets langBank to LanguageID + private static int SetLanguageID(int rawValue) => rawValue > (int)LanguageID.UNUSED_6 ? rawValue - 1 : rawValue; // sets LanguageID to langBank public enum BattleAnimationSetting { diff --git a/PKHeX.Core/Saves/Substructures/Gen7/ConfigSave7.cs b/PKHeX.Core/Saves/Substructures/Gen7/ConfigSave7.cs index 66e333c49..05b3c86b2 100644 --- a/PKHeX.Core/Saves/Substructures/Gen7/ConfigSave7.cs +++ b/PKHeX.Core/Saves/Substructures/Gen7/ConfigSave7.cs @@ -69,8 +69,8 @@ namespace PKHeX.Core set => ConfigValue = ((ConfigValue & ~0xF0) | SetLanguageID(value) << 4); } - private static int GetLanguageID(int i) => i >= (int)LanguageID.UNUSED_6 ? i + 1 : i; // sets langBank to LanguageID - private static int SetLanguageID(int i) => i > (int)LanguageID.UNUSED_6 ? i - 1 : i; // sets LanguageID to langBank + private static int GetLanguageID(int rawValue) => rawValue >= (int)LanguageID.UNUSED_6 ? rawValue + 1 : rawValue; // sets langBank to LanguageID + private static int SetLanguageID(int rawValue) => rawValue > (int)LanguageID.UNUSED_6 ? rawValue - 1 : rawValue; // sets LanguageID to langBank public enum BattleAnimationSetting { diff --git a/PKHeX.Core/Saves/Substructures/Gen7/ConfigSave7b.cs b/PKHeX.Core/Saves/Substructures/Gen7/ConfigSave7b.cs index a590e5cde..797b09dc4 100644 --- a/PKHeX.Core/Saves/Substructures/Gen7/ConfigSave7b.cs +++ b/PKHeX.Core/Saves/Substructures/Gen7/ConfigSave7b.cs @@ -50,8 +50,8 @@ namespace PKHeX.Core set => ConfigValue = ((ConfigValue & ~0xF0) | SetLanguageID(value) << 4); } - private static int GetLanguageID(int i) => i >= (int) LanguageID.UNUSED_6 ? i + 1 : i; // sets langBank to LanguageID - private static int SetLanguageID(int i) => i > (int) LanguageID.UNUSED_6 ? i - 1 : i; // sets LanguageID to langBank + private static int GetLanguageID(int rawValue) => rawValue >= (int) LanguageID.UNUSED_6 ? rawValue + 1 : rawValue; // sets langBank to LanguageID + private static int SetLanguageID(int rawValue) => rawValue > (int) LanguageID.UNUSED_6 ? rawValue - 1 : rawValue; // sets LanguageID to langBank public enum BattleAnimationSetting { diff --git a/PKHeX.Core/Saves/Substructures/PokeDex/Zukan.cs b/PKHeX.Core/Saves/Substructures/PokeDex/Zukan.cs index 6a5b7638b..fe1bdcae5 100644 --- a/PKHeX.Core/Saves/Substructures/PokeDex/Zukan.cs +++ b/PKHeX.Core/Saves/Substructures/PokeDex/Zukan.cs @@ -92,11 +92,11 @@ namespace PKHeX.Core return false; } - public bool GetSeen(int species, int i) => GetFlag(OFS_SEEN + (i * BitSeenSize), species - 1); - public void SetSeen(int species, int i, bool value) => SetFlag(OFS_SEEN + (i * BitSeenSize), species - 1, value); + public bool GetSeen(int species, int bitRegion) => GetFlag(OFS_SEEN + (bitRegion * BitSeenSize), species - 1); + public void SetSeen(int species, int bitRegion, bool value) => SetFlag(OFS_SEEN + (bitRegion * BitSeenSize), species - 1, value); - public bool GetDisplayed(int bit, int i) => GetFlag(OFS_SEEN + ((i + 4) * BitSeenSize), bit); - public void SetDisplayed(int bit, int i, bool value) => SetFlag(OFS_SEEN + ((i + 4) * BitSeenSize), bit, value); + public bool GetDisplayed(int bit, int bitRegion) => GetFlag(OFS_SEEN + ((bitRegion + 4) * BitSeenSize), bit); + public void SetDisplayed(int bit, int bitRegion, bool value) => SetFlag(OFS_SEEN + ((bitRegion + 4) * BitSeenSize), bit, value); public bool GetLanguageFlag(int bit, int lang) => GetFlag(PokeDexLanguageFlags, (bit * DexLangIDCount) + lang); public void SetLanguageFlag(int bit, int lang, bool value) => SetFlag(PokeDexLanguageFlags, (bit * DexLangIDCount) + lang, value); diff --git a/PKHeX.WinForms/Subforms/PKM Editors/BatchEditor.cs b/PKHeX.WinForms/Subforms/PKM Editors/BatchEditor.cs index 609ed44a1..040b0b94e 100644 --- a/PKHeX.WinForms/Subforms/PKM Editors/BatchEditor.cs +++ b/PKHeX.WinForms/Subforms/PKM Editors/BatchEditor.cs @@ -228,12 +228,12 @@ namespace PKHeX.WinForms mi.Invoke(); } - private void SetProgressBar(int i) + private void SetProgressBar(int position) { if (PB_Show.InvokeRequired) - PB_Show.Invoke((MethodInvoker)(() => PB_Show.Value = i)); + PB_Show.Invoke((MethodInvoker)(() => PB_Show.Value = position)); else - PB_Show.Value = i; + PB_Show.Value = position; } // Mass Editing diff --git a/PKHeX.WinForms/Subforms/SAV_FolderList.cs b/PKHeX.WinForms/Subforms/SAV_FolderList.cs index cfafb2ec2..d7c10229d 100644 --- a/PKHeX.WinForms/Subforms/SAV_FolderList.cs +++ b/PKHeX.WinForms/Subforms/SAV_FolderList.cs @@ -356,9 +356,9 @@ namespace PKHeX.WinForms cm.ResumeBinding(); } - private static void ToggleRowVisibility(DataGridView dg, int column, string text, int i) + private static void ToggleRowVisibility(DataGridView dg, int column, string text, int rowIndex) { - var row = dg.Rows[i]; + var row = dg.Rows[rowIndex]; if (text.Length == 0 || column < 0) { row.Visible = true; diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen4/PoffinCase4Editor.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen4/PoffinCase4Editor.cs index 5558b06cc..bbd0063f3 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen4/PoffinCase4Editor.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen4/PoffinCase4Editor.cs @@ -30,7 +30,7 @@ namespace PKHeX.WinForms Updating = false; } - private string GetPoffinText(int i) => $"{i + 1:000} - {Case.Poffins[i].Type.ToString().Replace('_', '-')}"; + private string GetPoffinText(int index) => $"{index + 1:000} - {Case.Poffins[index].Type.ToString().Replace('_', '-')}"; public void Save() { @@ -38,24 +38,24 @@ namespace PKHeX.WinForms Case.Save(); } - private void SaveIndex(int i) + private void SaveIndex(int index) { // do nothing, propertygrid handles everything - if (i < 0) + if (index < 0) return; Updating = true; - LB_Poffins.Items[i] = GetPoffinText(i); + LB_Poffins.Items[index] = GetPoffinText(index); Updating = false; } - private void LoadIndex(int i) + private void LoadIndex(int index) { - if (i < 0) + if (index < 0) { LB_Poffins.SelectedIndex = 0; return; } - PG_Poffins.SelectedObject = Case.Poffins[i]; + PG_Poffins.SelectedObject = Case.Poffins[index]; } private void LB_Poffins_SelectedIndexChanged(object sender, EventArgs e) diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_SuperTrain.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_SuperTrain.cs index 556566719..d91fcf047 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_SuperTrain.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen6/SAV_SuperTrain.cs @@ -1,6 +1,5 @@ using System; using System.Globalization; -using System.Linq; using System.Windows.Forms; using PKHeX.Core; diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_FestivalPlaza.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_FestivalPlaza.cs index b8d210459..d7b05e196 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_FestivalPlaza.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen7/SAV_FestivalPlaza.cs @@ -224,10 +224,13 @@ namespace PKHeX.WinForms }; } - private int GetColorCount(int i) => - i >= 0 && i < RES_FacilityColor.Length - (SAV is SAV7USUM ? 0 : 1) - ? RES_FacilityColor[i].Length - 1 - : 3; + private int GetColorCount(int type) + { + var colors = RES_FacilityColor; + if (type >= 0 && type < colors.Length - (SAV is SAV7USUM ? 0 : 1)) + return colors[type].Length - 1; + return 3; + } private void LoadFacility() {