Fix gen2 slot set

Fixes #1007
Closes #1008 with a slightly different implementation of the validation
check; other fixes for legality incorporated. Thanks @javierhimura !

Note for the Electrode encounter: both PIDIVs should be method 1 (not
J/K) thus only one is kept in the array.
This commit is contained in:
Kurt
2017-03-29 17:43:17 -07:00
parent 7feb5a8451
commit f2c072bc8a
3 changed files with 18 additions and 21 deletions

View File

@@ -3151,7 +3151,7 @@ public bool verifiedPKM()
CB_RelearnMove1, CB_RelearnMove2, CB_RelearnMove3, CB_RelearnMove4 // Moves
};
ComboBox cb = cba.FirstOrDefault(c => c.BackColor == Color.DarkSalmon);
ComboBox cb = cba.FirstOrDefault(c => c.BackColor == Color.DarkSalmon && c.Items.Count != 0);
if (cb != null)
{
Control c = cb.Parent;

View File

@@ -398,35 +398,27 @@ private static IEnumerable<EncounterSlot> getSlots4_G_Replace(byte[] data, ref i
private static IEnumerable<EncounterSlot> getSlots4_G_TimeReplace(byte[] data, ref int ofs, EncounterSlot[] GrassSlots, SlotType t, int[] slotnums)
{
var slots = new List<EncounterSlot>();
int[] CountReplaced = new int[2];
// Slots for day, morning and night slots in DPPt. Only contain species data, level is copy from grass slot
for (int i = 0; i < 3; i++)
{
int species = BitConverter.ToInt32(data, ofs + i * 4);
if (species <= 0)
continue;
for (int j = 0; j < 2; j++)
{
int species = BitConverter.ToInt32(data, ofs + j * 4);
if (species <= 0)
continue;
var slot = GrassSlots[slotnums[j]].Clone();
slot.Species = species;
slot.Species = j;
slot.Type = t;
slots.Add(slot);
CountReplaced[j]++;
}
ofs += 8;
}
// If the grass slot is replaced by all the time slots that means the species in the grass slot will never be used
// Unlike radio slot and gba dual slot the time of the day is always day, morning or night
if (CountReplaced[0] == 3)
GrassSlots[2].Species = 0;
if (CountReplaced[1] == 3)
GrassSlots[3].Species = 0;
// Even if the three time replacer slots overwrite the original grass slot it still possible for that encounter to happen
// Original encounter should not be removed
//Grass slots with species = 0 are added too, it is needed for the swarm encounters, it will be deleted after add swarms
// Grass slots with species = 0 are added too, it is needed for the swarm encounters, it will be deleted after add swarms
return GrassSlots.Concat(slots);
}
private static IEnumerable<EncounterSlot> getSlots4DPPt_WFR(byte[] data, ref int ofs, int numslots, SlotType t)
@@ -434,7 +426,7 @@ private static IEnumerable<EncounterSlot> getSlots4DPPt_WFR(byte[] data, ref int
var slots = new List<EncounterSlot>();
for (int i = 0; i < numslots; i++)
{
// min, max, unused, unused, [32bit species]
// max, min, unused, unused, [32bit species]
int Species = BitConverter.ToInt32(data, ofs + 4 + i * 8);
if (Species <= 0)
continue;
@@ -442,8 +434,8 @@ private static IEnumerable<EncounterSlot> getSlots4DPPt_WFR(byte[] data, ref int
// DPPt does not have fishing or surf swarms
slots.Add(new EncounterSlot
{
LevelMin = data[ofs + 0 + i * 8],
LevelMax = data[ofs + 1 + i * 8],
LevelMax = data[ofs + 0 + i * 8],
LevelMin = data[ofs + 1 + i * 8],
Species = Species,
Type = t
});

View File

@@ -182,7 +182,7 @@ public static partial class Legal
414, 441, 239, 402, 334, 393, 387, 340,
271, 257, 282, 389, 129, 253, 162, 220,
081, 366, 356, 388, 277, 272, 215, 067,
143, 335, 450,
143, 335, 450, 029
};
internal static readonly int[] SpecialTutors_4 =
@@ -507,6 +507,11 @@ public static partial class Legal
new EncounterStatic { Gift = true, Species = 023, Level = 15, Location = 131, Version = GameVersion.HG }, // Ekans
new EncounterStatic { Gift = true, Species = 027, Level = 15, Location = 131, Version = GameVersion.SS }, // Sandshrew
new EncounterStatic { Gift = true, Species = 147, Level = 15, Location = 131 }, // Dratini
//Team_Rocket_HQ Trap Floor
// new EncounterStatic { Species = 101, Level = 23, Location = 213, }, // Electrode Overlaps stationary
new EncounterStatic { Species = 100, Level = 23, Location = 213, }, // Voltorb
new EncounterStatic { Species = 074, Level = 23, Location = 213, }, // Geodude
new EncounterStatic { Species = 109, Level = 23, Location = 213, }, // Koffing
//Stationary
new EncounterStatic { Species = 130, Level = 30, Location = 135, Shiny = true }, //Gyarados @ Lake of Rage