diff --git a/PKHeX.Core/Legality/Encounters/Data/EncounterUtil.cs b/PKHeX.Core/Legality/Encounters/Data/EncounterUtil.cs
index 4f9b7b300..98f2c7f02 100644
--- a/PKHeX.Core/Legality/Encounters/Data/EncounterUtil.cs
+++ b/PKHeX.Core/Legality/Encounters/Data/EncounterUtil.cs
@@ -79,8 +79,8 @@ namespace PKHeX.Core
/// Personal data for use with a given species' type
internal static void MarkEncountersStaticMagnetPull(ref EncounterArea[] Areas, PersonalTable t)
{
- const int steel = 8;
- const int electric = 12;
+ const int steel = (int)MoveType.Steel;
+ const int electric = (int)MoveType.Electric;
foreach (EncounterArea Area in Areas)
{
var s = new List(); // Static
@@ -158,16 +158,18 @@ namespace PKHeX.Core
}).ToArray();
}
- ///
- /// Sets the to the for identifying where the slot is encountered.
- ///
- /// Some games / transferred data do not contain original encounter location IDs; is mainly for info purposes.
- /// Ingame encounter data
- internal static void MarkSlotLocation(ref EncounterArea[] Areas)
+ internal static T[] ConcatAll(params T[][] arr) => arr.SelectMany(z => z).ToArray();
+
+ internal static void MarkEncounterAreaArray(params EncounterArea[][] areas)
{
- foreach (EncounterArea Area in Areas)
- foreach (EncounterSlot Slot in Area.Slots)
- Slot.Location = Area.Location;
+ foreach (var area in areas)
+ MarkEncounterAreas(area);
+ }
+ internal static void MarkEncounterAreas(params EncounterArea[] areas)
+ {
+ foreach (var area in areas)
+ foreach (var slot in area.Slots)
+ slot.Area = area;
}
}
}
diff --git a/PKHeX.Core/Legality/Encounters/Data/Encounters1.cs b/PKHeX.Core/Legality/Encounters/Data/Encounters1.cs
index 8059e06c4..95e127977 100644
--- a/PKHeX.Core/Legality/Encounters/Data/Encounters1.cs
+++ b/PKHeX.Core/Legality/Encounters/Data/Encounters1.cs
@@ -38,6 +38,9 @@ namespace PKHeX.Core
Array.Resize(ref table, table.Length + 1);
table[table.Length - 1] = FishOldGood_RBY;
+ foreach (var arr in table)
+ foreach (var slot in arr.Slots)
+ slot.Area = arr;
return table;
}
diff --git a/PKHeX.Core/Legality/Encounters/Data/Encounters2.cs b/PKHeX.Core/Legality/Encounters/Data/Encounters2.cs
index 0d2d598ab..2d9fb6db4 100644
--- a/PKHeX.Core/Legality/Encounters/Data/Encounters2.cs
+++ b/PKHeX.Core/Legality/Encounters/Data/Encounters2.cs
@@ -20,6 +20,7 @@ namespace PKHeX.Core
SlotsGS = GetTables2(GameVersion.GS);
SlotsC = GetTables2(GameVersion.C);
SlotsGSC = GetTables2(GameVersion.GSC);
+ MarkEncounterAreaArray(SlotsGS, SlotsC, SlotsGSC, EncounterSafari_GSC, EncounterBCC_GSC);
ReduceAreasSize(ref SlotsGS);
ReduceAreasSize(ref SlotsC);
ReduceAreasSize(ref SlotsGSC);
@@ -83,7 +84,6 @@ namespace PKHeX.Core
MarkEncountersVersion(h_c, GameVersion.C);
var extra = AddExtraTableSlots(c, h_c, f, bcc_c, safari_c);
- MarkSlotLocation(ref extra);
return extra;
}
diff --git a/PKHeX.Core/Legality/Encounters/Data/Encounters3.cs b/PKHeX.Core/Legality/Encounters/Data/Encounters3.cs
index 9d4617cd6..8616c2b6c 100644
--- a/PKHeX.Core/Legality/Encounters/Data/Encounters3.cs
+++ b/PKHeX.Core/Legality/Encounters/Data/Encounters3.cs
@@ -33,6 +33,8 @@ namespace PKHeX.Core
var FR_Slots = get("fr", "fr");
var LG_Slots = get("lg", "lg");
+ MarkEncounterAreaArray(SlotsRSEAlt, SlotsFRLGAlt);
+
ReduceAreasSize(ref R_Slots);
ReduceAreasSize(ref S_Slots);
ReduceAreasSize(ref E_Slots);
@@ -56,12 +58,6 @@ namespace PKHeX.Core
SlotsE = AddExtraTableSlots(E_Slots, SlotsRSEAlt);
SlotsFR = AddExtraTableSlots(FR_Slots, SlotsFRLGAlt);
SlotsLG = AddExtraTableSlots(LG_Slots, SlotsFRLGAlt);
-
- MarkSlotLocation(ref SlotsR);
- MarkSlotLocation(ref SlotsS);
- MarkSlotLocation(ref SlotsE);
- MarkSlotLocation(ref SlotsFR);
- MarkSlotLocation(ref SlotsLG);
}
private static void MarkG3Slots_FRLG(ref EncounterArea[] Areas)
diff --git a/PKHeX.Core/Legality/Encounters/Data/Encounters4.cs b/PKHeX.Core/Legality/Encounters/Data/Encounters4.cs
index 0a7121c21..1f47802a3 100644
--- a/PKHeX.Core/Legality/Encounters/Data/Encounters4.cs
+++ b/PKHeX.Core/Legality/Encounters/Data/Encounters4.cs
@@ -67,6 +67,10 @@ namespace PKHeX.Core
MarkG4SlotsGreatMarsh(ref P_Slots, 52);
MarkG4SlotsGreatMarsh(ref Pt_Slots, 52);
+ MarkEncounterAreaArray(D_HoneyTrees_Slots, P_HoneyTrees_Slots, Pt_HoneyTrees_Slots,
+ DP_GreatMarshAlt, Pt_GreatMarshAlt, DPPt_Unown, DP_Trophy, DP_Feebas, Pt_Trophy, Pt_Feebas,
+ HG_Headbutt_Slots, SS_Headbutt_Slots, SlotsHGSSAlt);
+
SlotsD = AddExtraTableSlots(D_Slots, D_HoneyTrees_Slots, DP_GreatMarshAlt, DPPt_Unown, DP_Trophy, DP_Feebas);
SlotsP = AddExtraTableSlots(P_Slots, P_HoneyTrees_Slots, DP_GreatMarshAlt, DPPt_Unown, DP_Trophy, DP_Feebas);
SlotsPt = AddExtraTableSlots(Pt_Slots, Pt_HoneyTrees_Slots, Pt_GreatMarshAlt, DPPt_Unown, Pt_Trophy, Pt_Feebas);
@@ -78,12 +82,6 @@ namespace PKHeX.Core
MarkDPPtEncounterTypeSlots(ref SlotsPt);
MarkHGSSEncounterTypeSlots(ref SlotsHG);
MarkHGSSEncounterTypeSlots(ref SlotsSS);
-
- MarkSlotLocation(ref SlotsD);
- MarkSlotLocation(ref SlotsP);
- MarkSlotLocation(ref SlotsPt);
- MarkSlotLocation(ref SlotsHG);
- MarkSlotLocation(ref SlotsSS);
}
private static EncounterArea[] GetFeebasArea(EncounterArea template)
@@ -180,12 +178,8 @@ namespace PKHeX.Core
private static void MarkG4AltFormSlots(ref EncounterArea[] Areas, int Species, int form, int[] Locations)
{
foreach (EncounterArea Area in Areas.Where(a => Locations.Contains(a.Location)))
- {
- foreach (EncounterSlot Slot in Area.Slots.Where(s => s.Species == Species))
- {
- Slot.Form = form;
- }
- }
+ foreach (EncounterSlot Slot in Area.Slots.Where(s => s.Species == Species))
+ Slot.Form = form;
}
private static EncounterType GetEncounterTypeBySlotDPPt(SlotType Type, EncounterType GrassType)
{
@@ -1380,7 +1374,6 @@ namespace PKHeX.Core
new EncounterSlot { Species = 418, LevelMin = 44, LevelMax = 45, Type = SlotType.Grass_Safari }, // Buizel
};
- private static EncounterSlot[] ConcatAll(params EncounterSlot[][] arr) => arr.SelectMany(z => z).ToArray();
private static readonly EncounterArea SlotsHGSS_SafariZone = new EncounterArea
{
// Source http://bulbapedia.bulbagarden.net/wiki/Johto_Safari_Zone#Pok.C3.A9mon
diff --git a/PKHeX.Core/Legality/Encounters/Data/Encounters5.cs b/PKHeX.Core/Legality/Encounters/Data/Encounters5.cs
index 3ec70b183..14ce0a8cd 100644
--- a/PKHeX.Core/Legality/Encounters/Data/Encounters5.cs
+++ b/PKHeX.Core/Legality/Encounters/Data/Encounters5.cs
@@ -37,6 +37,7 @@ namespace PKHeX.Core
MarkB2W2SwarmSlots(SlotsW2_Swarm);
MarkG5HiddenGrottoSlots(SlotsB2_HiddenGrotto);
MarkG5HiddenGrottoSlots(SlotsW2_HiddenGrotto);
+ MarkEncounterAreaArray(SlotsB_Swarm, SlotsW_Swarm, SlotsB2_Swarm, SlotsW2_Swarm, SlotsB2_HiddenGrotto, SlotsW2_HiddenGrotto);
SlotsB = AddExtraTableSlots(BSlots, SlotsB_Swarm);
SlotsW = AddExtraTableSlots(WSlots, SlotsW_Swarm, WhiteForestSlot);
diff --git a/PKHeX.Core/Legality/Encounters/Data/Encounters6.cs b/PKHeX.Core/Legality/Encounters/Data/Encounters6.cs
index 2831ec9ef..7889fad4b 100644
--- a/PKHeX.Core/Legality/Encounters/Data/Encounters6.cs
+++ b/PKHeX.Core/Legality/Encounters/Data/Encounters6.cs
@@ -21,6 +21,7 @@ namespace PKHeX.Core
var YSlots = GetEncounterTables(GameVersion.Y);
MarkG6XYSlots(ref XSlots);
MarkG6XYSlots(ref YSlots);
+ MarkEncounterAreaArray(SlotsXYAlt);
SlotsX = AddExtraTableSlots(XSlots, SlotsXYAlt);
SlotsY = AddExtraTableSlots(YSlots, SlotsXYAlt);
diff --git a/PKHeX.Core/Legality/Encounters/Data/Encounters7.cs b/PKHeX.Core/Legality/Encounters/Data/Encounters7.cs
index 92a91f925..56037be20 100644
--- a/PKHeX.Core/Legality/Encounters/Data/Encounters7.cs
+++ b/PKHeX.Core/Legality/Encounters/Data/Encounters7.cs
@@ -39,6 +39,7 @@ namespace PKHeX.Core
MarkG7SMSlots(ref SOS_UM);
SlotsUS = AddExtraTableSlots(REG_US, SOS_US, Encounter_Pelago_UU, Encounter_Pelago_US);
SlotsUM = AddExtraTableSlots(REG_UM, SOS_UM, Encounter_Pelago_UU, Encounter_Pelago_UM);
+ MarkEncounterAreaArray(SOS_SN, SOS_MN, SOS_US, SOS_UM, Encounter_Pelago_SN, Encounter_Pelago_MN, Encounter_Pelago_US, Encounter_Pelago_UM);
}
private static void MarkG7REGSlots(ref EncounterArea[] Areas)
{
diff --git a/PKHeX.Core/Legality/Structures/EncounterArea.cs b/PKHeX.Core/Legality/Structures/EncounterArea.cs
index 3423045b1..8c01c07f0 100644
--- a/PKHeX.Core/Legality/Structures/EncounterArea.cs
+++ b/PKHeX.Core/Legality/Structures/EncounterArea.cs
@@ -39,20 +39,23 @@ namespace PKHeX.Core
LevelMax = data[5 + i * 4],
};
}
+ foreach (var slot in Slots)
+ slot.Area = this;
}
public EncounterArea Clone(int location)
{
- EncounterArea Areas = new EncounterArea
+ EncounterArea Area = new EncounterArea
{
Location = location,
Slots = new EncounterSlot[Slots.Length]
};
for (int i = 0; i < Slots.Length; i++)
{
- Areas.Slots[i] = Slots[i].Clone();
+ Area.Slots[i] = Slots[i].Clone();
+ Area.Slots[i].Area = Area;
}
- return Areas;
+ return Area;
}
public EncounterArea[] Clone(int[] locations)
@@ -162,11 +165,16 @@ namespace PKHeX.Core
var areas = new List();
while (data[ofs] != 0xFF) // end
{
- areas.Add(new EncounterArea
+ var location = data[ofs++] << 8 | data[ofs++];
+ var slots = GetSlots2_GW(data, ref ofs, t, slotSets, slotCount);
+ var area = new EncounterArea
{
- Location = data[ofs++] << 8 | data[ofs++],
- Slots = GetSlots2_GW(data, ref ofs, t, slotSets, slotCount),
- });
+ Location = location,
+ Slots = slots,
+ };
+ foreach (var slot in slots)
+ slot.Area = area;
+ areas.Add(area);
}
ofs++;
return areas;
@@ -450,12 +458,6 @@ namespace PKHeX.Core
private static EncounterArea GetArea3(byte[] data)
{
- EncounterArea Area3 = new EncounterArea();
-
- if (data.Length < 6)
- { Area3.Location = 0; Area3.Slots = new EncounterSlot[0]; return Area3; }
-
- Area3.Location = data[0];
var HaveGrassSlots = data[1] == 1;
var HaveSurfSlots = data[2] == 1;
var HaveRockSmashSlots = data[3] == 1;
@@ -471,18 +473,21 @@ namespace PKHeX.Core
slots.AddRange(GetSlots3(data, ref offset, 5, SlotType.Rock_Smash));
if (HaveFishingSlots)
slots.AddRange(GetSlots3_F(data, ref offset, 10));
- Area3.Slots = slots.ToArray();
+
+ EncounterArea Area3 = new EncounterArea
+ {
+ Location = data[0],
+ Slots = slots.ToArray()
+ };
+ foreach (var slot in Area3.Slots)
+ slot.Area = Area3;
+
return Area3;
}
private static EncounterArea GetArea4DPPt(byte[] data)
{
- EncounterArea Area4 = new EncounterArea();
- if (data.Length != 0x1AA) // 426 Bytes
- { Area4.Location = 0; Area4.Slots = new EncounterSlot[0]; return Area4; }
-
var Slots = new List();
- Area4.Location = BitConverter.ToUInt16(data, 0x00);
var GrassRatio = BitConverter.ToInt32(data, 0x02);
if (GrassRatio > 0)
@@ -524,18 +529,20 @@ namespace PKHeX.Core
if (SuperRodRatio > 0)
Slots.AddRange(GetSlots4DPPt_WFR(data, 0x182, 5, SlotType.Super_Rod));
- Area4.Slots = Slots.ToArray();
+ EncounterArea Area4 = new EncounterArea
+ {
+ Location = BitConverter.ToUInt16(data, 0x00),
+ Slots = Slots.ToArray()
+ };
+ foreach (var slot in Area4.Slots)
+ slot.Area = Area4;
+
return Area4;
}
private static EncounterArea GetArea4HGSS(byte[] data)
{
- EncounterArea Area4 = new EncounterArea();
- if (data.Length != 0xC6)
- { Area4.Location = 0; Area4.Slots = new EncounterSlot[0]; return Area4; }
-
var Slots = new List();
- Area4.Location = BitConverter.ToUInt16(data, 0x00);
var GrassRatio = data[0x02];
var SurfRatio = data[0x03];
@@ -577,7 +584,13 @@ namespace PKHeX.Core
if (data[0xC2] == 120) // Location = 182, 127, 130, 132, 167, 188, 210
Slots.AddRange(SlotsHGSS_Staryu);
- Area4.Slots = Slots.ToArray();
+ EncounterArea Area4 = new EncounterArea
+ {
+ Location = BitConverter.ToUInt16(data, 0x00),
+ Slots = Slots.ToArray()
+ };
+ foreach (var slot in Area4.Slots)
+ slot.Area = Area4;
return Area4;
}
private static readonly EncounterSlot[] SlotsHGSS_Staryu =
@@ -611,11 +624,14 @@ namespace PKHeX.Core
});
}
- return new EncounterArea
+ var Area = new EncounterArea
{
Location = BitConverter.ToUInt16(data, 0),
Slots = Slots.ToArray()
};
+ foreach (var slot in Area.Slots)
+ slot.Area = Area;
+ return Area;
}
///
@@ -849,7 +865,7 @@ namespace PKHeX.Core
/// Array of encounter areas.
public static EncounterArea[] GetArray4DPPt(byte[][] entries)
{
- return entries?.Select(GetArea4DPPt).Where(Area => Area.Slots.Any()).ToArray();
+ return entries?.Select(GetArea4DPPt).Where(Area => Area.Slots.Length != 0).ToArray();
}
///
@@ -859,7 +875,7 @@ namespace PKHeX.Core
/// Array of encounter areas.
public static EncounterArea[] GetArray4HGSS(byte[][] entries)
{
- return entries?.Select(GetArea4HGSS).Where(Area => Area.Slots.Any()).ToArray();
+ return entries?.Select(GetArea4HGSS).Where(Area => Area.Slots.Length != 0).ToArray();
}
///
@@ -869,7 +885,7 @@ namespace PKHeX.Core
/// Array of encounter areas.
public static EncounterArea[] GetArray4HGSS_Headbutt(byte[][] entries)
{
- return entries?.Select(GetArea4HGSS_Headbutt).Where(Area => Area.Slots.Any()).ToArray();
+ return entries?.Select(GetArea4HGSS_Headbutt).Where(Area => Area.Slots.Length != 0).ToArray();
}
///
diff --git a/PKHeX.Core/Legality/Structures/EncounterSlot.cs b/PKHeX.Core/Legality/Structures/EncounterSlot.cs
index cca8a1216..2f0416fc0 100644
--- a/PKHeX.Core/Legality/Structures/EncounterSlot.cs
+++ b/PKHeX.Core/Legality/Structures/EncounterSlot.cs
@@ -19,7 +19,6 @@
///
public class EncounterSlot : IEncounterable, IGeneration
{
- public int Location { get; set; } = -1;
public int Species { get; set; }
public int Form { get; set; }
public int LevelMin { get; set; }
@@ -32,18 +31,9 @@
internal EncounterSlotPermissions _perm;
public EncounterSlotPermissions Permissions => _perm ?? (_perm = new EncounterSlotPermissions());
- public virtual EncounterSlot Clone()
- {
- return new EncounterSlot
- {
- Species = Species,
- LevelMax = LevelMax,
- LevelMin = LevelMin,
- Type = Type,
- SlotNumber = SlotNumber,
- _perm = _perm
- };
- }
+ internal EncounterArea Area { get; set; }
+ public int Location => Area.Location;
+ public EncounterSlot Clone() => (EncounterSlot)MemberwiseClone();
public string Name
{
@@ -69,20 +59,5 @@
public int Rate;
internal EncounterTime Time = EncounterTime.Any;
public GameVersion Version = GameVersion.Any;
- public override EncounterSlot Clone()
- {
- return new EncounterSlot1
- {
- Species = Species,
- LevelMax = LevelMax,
- LevelMin = LevelMin,
- Type = Type,
- SlotNumber = SlotNumber,
- _perm = _perm,
- Rate = Rate,
- Time = Time,
- Generation = Generation,
- };
- }
}
}
diff --git a/PKHeX.Core/Legality/Structures/MoveType.cs b/PKHeX.Core/Legality/Structures/MoveType.cs
new file mode 100644
index 000000000..e574d5e3d
--- /dev/null
+++ b/PKHeX.Core/Legality/Structures/MoveType.cs
@@ -0,0 +1,25 @@
+namespace PKHeX.Core
+{
+ public enum MoveType
+ {
+ Any = -1,
+ Normal,
+ Fighting,
+ Flying,
+ Poison,
+ Ground,
+ Rock,
+ Bug,
+ Ghost,
+ Steel,
+ Fire,
+ Water,
+ Grass,
+ Electric,
+ Psychic,
+ Ice,
+ Dragon,
+ Dark,
+ Fairy,
+ }
+}
diff --git a/PKHeX.WinForms/MainWindow/Main.cs b/PKHeX.WinForms/MainWindow/Main.cs
index 47524da99..7bea6880b 100644
--- a/PKHeX.WinForms/MainWindow/Main.cs
+++ b/PKHeX.WinForms/MainWindow/Main.cs
@@ -100,7 +100,8 @@ namespace PKHeX.WinForms
BAKprompt = false;
CB_MainLanguage.Items.AddRange(main_langlist);
- C_SAV.HaX = PKME_Tabs.HaX = HaX = args.Any(x => string.Equals(x.Trim('-'), nameof(HaX), StringComparison.CurrentCultureIgnoreCase));
+ C_SAV.HaX = PKME_Tabs.HaX = HaX = args.Any(x => string.Equals(x.Trim('-'), nameof(HaX), StringComparison.CurrentCultureIgnoreCase))
+ || Path.GetFileNameWithoutExtension(Process.GetCurrentProcess().MainModule.FileName).EndsWith(nameof(HaX));
PB_Legal.Visible = !HaX;
int languageID = 1; // English