From 3d641ada3840b078f0b2b2ff14fd1f5165c67cb3 Mon Sep 17 00:00:00 2001 From: Kurt Date: Mon, 12 Jun 2017 16:54:39 -0700 Subject: [PATCH] Fix gen2 fishing slots Correlate mapID to table, thanks @pokecal ! #1217 instead of duplicating quilfish tables, just shift remoraid down one. --- .../Legality/Structures/EncounterArea.cs | 51 +++++++++++++----- PKHeX.Core/Resources/byte/encounter_gsc_f.pkl | Bin 485 -> 484 bytes 2 files changed, 37 insertions(+), 14 deletions(-) diff --git a/PKHeX.Core/Legality/Structures/EncounterArea.cs b/PKHeX.Core/Legality/Structures/EncounterArea.cs index 60d9aa387..c1a453e93 100644 --- a/PKHeX.Core/Legality/Structures/EncounterArea.cs +++ b/PKHeX.Core/Legality/Structures/EncounterArea.cs @@ -147,25 +147,21 @@ private static IEnumerable getAreas2(byte[] data, ref int ofs, Sl ofs++; return areas; } - private static IEnumerable getAreas2_F(byte[] data, ref int ofs) + private static List getAreas2_F(byte[] data, ref int ofs) { var areas = new List(); var types = new[] {SlotType.Old_Rod, SlotType.Good_Rod, SlotType.Super_Rod}; - while (data.Length < ofs) + while (ofs != 0x18C) { - int count = 0; - while (ofs != 0x18D) - { - areas.Add(new EncounterArea - { - Location = count++, - Slots = getSlots2_F(data, ref ofs, types[count%3]), - }); - } + areas.Add(new EncounterArea { + Slots = getSlots2_F(data, ref ofs, types[0]) + .Concat(getSlots2_F(data, ref ofs, types[1])) + .Concat(getSlots2_F(data, ref ofs, types[2])).ToArray() }); } + // Read TimeFishGroups var dl = new List(); - while (data.Length < ofs) + while (ofs < data.Length) dl.Add(new DexLevel {Species = data[ofs++], Level = data[ofs++]}); // Add TimeSlots @@ -179,7 +175,7 @@ private static IEnumerable getAreas2_F(byte[] data, ref int ofs) continue; Array.Resize(ref slots, slots.Length + 1); - Array.Copy(slots, i, slots, i+1, slots.Length - i); + Array.Copy(slots, i, slots, i+1, slots.Length - i - 1); // shift slots down slots[i+1] = slot.Clone(); // differentiate copied slot int index = slot.LevelMin*2; @@ -766,7 +762,34 @@ public static EncounterArea[] getArray2_GW(byte[] data) public static EncounterArea[] getArray2_F(byte[] data) { int ofs = 0; - return getAreas2_F(data, ref ofs).ToArray(); + var f = getAreas2_F(data, ref ofs); + + // Fishing Tables are not associated to a single map; a map picks a table to use. + // For all maps that use a table, create a new EncounterArea with reference to the table's slots. + sbyte[] convMapIDtoFishLocationID = + { + -1, 1, -1, 0, 3, 3, 3, -1, 10, 3, 2, -1, -1, 2, 3, 0, + -1, -1, 3, -1, -1, -1, 3, -1, -1, -1, -1, 0, -1, -1, 0, 9, + 1, 0, 2, 2, -1, 3, 7, 3, -1, 3, 4, 8, 2, -1, 2, 1, + -1, 3, -1, -1, -1, -1, -1, 0, 2, 2, -1, -1, 3, 1, -1, -1, + -1, 2, -1, 2, -1, -1, -1, -1, -1, -1, 11, 11, 0, -1, -1, -1, + -1, 7, 0, 1, -1, 1, 1, 3, -1, -1, -1, 1, 1, 2, 3, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + }; + var areas = new List(); + for (int i = 0; i < convMapIDtoFishLocationID.Length; i++) + { + var loc = convMapIDtoFishLocationID[i]; + if (convMapIDtoFishLocationID[i] == -1) // no table for map + continue; + areas.Add(new EncounterArea { Location = i, Slots = f[loc].Slots }); + } + + // Some maps have two tables. Fortunately, there's only two. Add the second table. + areas.Add(new EncounterArea { Location = 0x1B, Slots = f[1].Slots }); // Olivine City (0: Harbor, 1: City) + areas.Add(new EncounterArea { Location = 0x2E, Slots = f[3].Slots }); // Silver Cave (2: Inside, 3: Outside) + return areas.ToArray(); } public static EncounterArea[] getArray2_H(byte[] data) { diff --git a/PKHeX.Core/Resources/byte/encounter_gsc_f.pkl b/PKHeX.Core/Resources/byte/encounter_gsc_f.pkl index e18158beaf862edd75a2438b4e1b9a5c434031aa..3254575a1ce22109c09e2323ad68da0539c373ac 100644 GIT binary patch delta 7 OcmaFL{DgVK6Gi|IwF6}U delta 9 QcmaFD{FHga6Glcw02QDEhX4Qo