public void GenerateWonderCardJob(uint year, List<int> months, int hourMin, int hourMax, Profile profile, uint shinyOffset, bool fastSearch, int listIndex, int shiny) { uint minAdvances = generators[listIndex].InitialFrame; var array = new uint[80]; array[6] = (uint) (profile.MAC_Address & 0xFFFF); if (profile.SoftReset) { array[6] = array[6] ^ 0x01000000; } var upperMAC = (uint) (profile.MAC_Address >> 16); array[7] = (upperMAC ^ (profile.VFrame*0x1000000) ^ profile.GxStat); // Get the version-unique part of the message Array.Copy(Nazos.Nazo(profile.Version, profile.Language, profile.DSType), array, 5); array[10] = 0x00000000; array[11] = 0x00000000; array[13] = 0x80000000; array[14] = 0x00000000; array[15] = 0x000001A0; List<List<ButtonComboType>> keypressList = profile.GetKeypresses(); List<ButtonComboType>[] buttons = keypressList.ToArray(); var buttonMashValue = new uint[keypressList.Count]; for (int i = 0; i < buttons.Length; i++) { buttonMashValue[i] = Functions.buttonMashed(buttons[i]); } uint searchRange = generator.MaxResults; // necessary to keep track of fast searching // for frames 1-6 var included = new bool[6]; for (int i = 0; i < 6; i++) { if (i >= (generators[listIndex].InitialFrame - 1) && i < (generators[listIndex].InitialFrame + generators[listIndex].MaxResults - 1)) included[i] = true; else included[i] = false; } foreach (int month in months) { float interval = ((float) DateTime.DaysInMonth((int) year, month)/cpus + (float) 0.05); var dayMin = (int) (interval*listIndex + 1); var dayMax = (int) (interval*(listIndex + 1)); string yearMonth = String.Format("{0:00}", year%2000) + String.Format("{0:00}", month); for (int buttonCount = 0; buttonCount < keypressList.Count; buttonCount++) { array[12] = buttonMashValue[buttonCount]; for (uint timer0 = profile.Timer0Min; timer0 <= profile.Timer0Max; timer0++) { array[5] = (profile.VCount << 16) + timer0; array[5] = Functions.Reorder(array[5]); for (int day = dayMin; day <= dayMax; day++) { var searchTime = new DateTime((int) year, month, day); string dateString = String.Format("{0:00}", (int) searchTime.DayOfWeek); dateString = String.Format("{0:00}", searchTime.Day) + dateString; dateString = yearMonth + dateString; array[8] = uint.Parse(dateString, NumberStyles.HexNumber); array[9] = 0x0; // For seeds with the same date, the contents of the SHA-1 array will be the same for the first 8 steps // We are precomputing those 8 steps to save time // Trying to precompute beyond 8 steps is complicated and does not save much time, also runs the risk of errors uint[] alpha = Functions.alphaSHA1(array, 8); // We are also precomputing select portions of the SHA-1 array during the expansion process // As they are also the same array[16] = Functions.RotateLeft(array[13] ^ array[8] ^ array[2] ^ array[0], 1); array[18] = Functions.RotateLeft(array[15] ^ array[10] ^ array[4] ^ array[2], 1); array[19] = Functions.RotateLeft(array[16] ^ array[11] ^ array[5] ^ array[3], 1); array[21] = Functions.RotateLeft(array[18] ^ array[13] ^ array[7] ^ array[5], 1); array[22] = Functions.RotateLeft(array[19] ^ array[14] ^ array[8] ^ array[6], 1); array[24] = Functions.RotateLeft(array[21] ^ array[16] ^ array[10] ^ array[8], 1); array[27] = Functions.RotateLeft(array[24] ^ array[19] ^ array[13] ^ array[11], 1); for (int hour = hourMin; hour <= hourMax; hour++) { //int seedHour = hour; for (int minute = 0; minute <= 59; minute++) { waitHandle.WaitOne(); for (int second = 0; second <= 59; second++) { array[9] = Functions.seedSecond(second) | Functions.seedMinute(minute) | Functions.seedHour(hour, profile.DSType); ulong seed = Functions.EncryptSeed(array, alpha, 9); // Set this to our seed here generators[listIndex].InitialSeed = seed; generators[listIndex].InitialFrame = Functions.initialPIDRNG(seed, profile) + minAdvances + (profile.IsBW2() ? 2u : 0); if (iframes.Count > 1000000) break; // This is where we actually go ahead and call our // generator for a list of IVs based on parameters // that have been passed in. List<Frame> frames = generators[listIndex].GenerateWonderCard(frameCompare, profile.ID, profile.SID, shiny); progressSearched += searchRange; progressFound += (ulong) frames.Count; // Now we need to iterate through each result here // and create a collection of the information that // we are going to place into our grid. foreach (Frame frame in frames) { var iframe = new IFrameCapture(); frame.DisplayPrep(); iframe.Offset = frame.Number; iframe.Seed = seed; iframe.Frame = frame; iframe.Advances = iframe.Offset - (generators[listIndex].InitialFrame - minAdvances); iframe.TimeDate = searchTime.AddHours(hour).AddMinutes(minute).AddSeconds(second); iframe.KeyPresses = buttons[buttonCount]; iframe.Timer0 = timer0; lock (threadLock) { iframes.Add(iframe); } } if (frames.Count > 0) { refreshQueue = true; } } } } } } } } }
private void GenerateCGearCapJob(ulong mac_address, uint minEfgh, uint maxEfgh, bool fastSearch, ushort id, ushort sid) { uint seed; uint searchRange = generator.MaxResults; List<Frame> frames; var included = new bool[6]; for (int i = 0; i < 6; i++) { if ((i + 20) >= (generator.InitialFrame - 1) && (i + 20) < (generator.InitialFrame + generator.MaxResults - 1)) included[i] = true; else included[i] = false; } if (fastSearch) { //frames = new List<Frame>(); //todo: reverse order of ab/efgh loop for optimization // Iterate through delay range + year for (uint efgh = minEfgh; efgh <= maxEfgh; efgh++) { waitHandle.WaitOne(); // Iterate through all CD for (uint cd = 0; cd <= 23; cd++) { for (uint ab = 1; ab <= 255; ab++) { // First we need to build a seed for this iteration // based on all of our information. This should be // fairly easy since we are not using dates ;) seed = (ab << 24) + (cd << 16) + efgh; seed = (uint) (seed + (mac_address & 0xFFFFFF)); progressSearched += searchRange; for (uint i = 0; i < 6; i++) { if (included[i]) { if (list[i].ContainsKey(seed)) { uint ivHash = list[i][seed]; frames = generator.Generate(frameCompare, seed, ivHash, i + 21); progressFound += (uint) frames.Count; foreach (Frame frame in frames) { var iframe = new IFrameCapture(); frame.DisplayPrep(); iframe.Offset = frame.Number; iframe.Seed = frame.Seed; iframe.Frame = frame; iframe.MACAddress = (uint) mac_address; lock (threadLock) { iframes.Add(iframe); } refreshQueue = true; } } } } } } } } else { // Iterate through all AB for (uint ab = 1; ab <= 255; ab++) { waitHandle.WaitOne(); // Iterate through all CD for (uint cd = 0; cd <= 23; cd++) { // Iterate through delay range + year for (uint efgh = minEfgh; efgh <= maxEfgh; efgh++) { // First we need to build a seed for this iteration // based on all of our information. This should be // fairly easy since we are not using dates ;) seed = (ab << 24) + (cd << 16) + efgh; seed = (uint) (seed + (mac_address & 0xFFFFFF)); // Set this to our seed here generator.InitialSeed = seed; if (iframes.Count > 1000000) break; // This is where we actually go ahead and call our // generator for a list of IVs based on parameters // that have been passed in. frames = generator.Generate(frameCompare, id, sid); progressSearched += searchRange; progressFound += (uint) frames.Count; // Now we need to iterate through each result here // and create a collection of the information that // we are going to place into our grid. foreach (Frame frame in frames) { var iframe = new IFrameCapture(); frame.DisplayPrep(); iframe.Offset = frame.Number; iframe.Seed = seed; iframe.Frame = frame; iframe.MACAddress = (uint) mac_address; lock (threadLock) { iframes.Add(iframe); } refreshQueue = true; } } } } } }
public void GenerateShinyJob(uint year, List<int> months, int hourMin, int hourMax, Profile profile, List<List<ButtonComboType>> keypressList, bool fastSearch, int listIndex) { var rngIVs = new uint[6]; List<ButtonComboType>[] buttons = keypressList.ToArray(); var buttonMashValue = new uint[keypressList.Count]; for (int i = 0; i < buttons.Length; i++) { buttonMashValue[i] = Functions.buttonMashed(buttons[i]); } uint minAdvances = shinygenerators[listIndex].InitialFrame; foreach (int month in months) { int dayMax = DateTime.DaysInMonth((int) year, month); for (int buttonCount = 0; buttonCount < buttons.Length; buttonCount++) { for (int day = 1; day <= dayMax; day++) { waitHandle.WaitOne(); for (uint Timer0 = profile.Timer0Min; Timer0 <= profile.Timer0Max; Timer0++) { for (int hour = hourMin; hour <= hourMax; hour++) { for (int minute = 0; minute <= 59; minute++) { for (int second = 0; second <= 59; second++) { var searchTime = new DateTime((int) year, month, day, hour, minute, second); ulong seed = Functions.EncryptSeed(searchTime, profile.MAC_Address, profile.Version, profile.Language, profile.DSType, profile.SoftReset, profile.VCount, Timer0, profile.GxStat, profile.VFrame, buttonMashValue[buttonCount]); generators[listIndex].InitialSeed = seed >> 32; List<Frame> frames = generators[listIndex].Generate(frameCompare, profile.ID, profile.SID); if (frames.Count > 0) { if (!frameCompare.CompareEggIVs(frames[0])) { continue; } } else { continue; } rngIVs[0] = frames[0].Hp; rngIVs[1] = frames[0].Atk; rngIVs[2] = frames[0].Def; rngIVs[3] = frames[0].Spa; rngIVs[4] = frames[0].Spd; rngIVs[5] = frames[0].Spe; shinygenerators[listIndex].RNGIVs = rngIVs; shinygenerators[listIndex].InitialSeed = seed; shinygenerators[listIndex].InitialFrame = Functions.initialPIDRNG(seed, profile) + minAdvances; frames = shinygenerators[listIndex].Generate(subFrameCompare, profile.ID, profile.SID); if (frames.Count > 0) { foreach (Frame frame in frames) { frame.DisplayPrep(); var iframeEgg = new IFrameCapture { Frame = frame, Seed = seed, Offset = frame.Number, TimeDate = searchTime, KeyPresses = buttons[buttonCount], Timer0 = Timer0 }; lock (threadLock) { iframesEgg.Add(iframeEgg); } } refreshQueue = true; progressFound = (ulong) iframesEgg.Count; } progressSearched += shinygenerators[listIndex].MaxResults; } } } } } } } }
private void Generate(FrameGenerator generator, IEnumerable <DateTime> possibleDates, uint minFrame, uint maxFrame, Profile profile, uint groupSize, uint calibratedDelay) { const uint incrementFound = 1; List <List <ButtonComboType> > keypresses = profile.GetKeypresses(); foreach (DateTime seedTime in possibleDates) { waitHandle.WaitOne(); foreach (var combo in keypresses) { for (uint timer0 = profile.Timer0Min; timer0 <= profile.Timer0Max; timer0++) { ulong seed = Functions.EncryptSeed(seedTime, profile, timer0, Functions.buttonMashed(combo)); generator.InitialSeed = seed; generator.InitialFrame = Functions.initialPIDRNG(seed, profile) + minFrame; generator.MaxResults = maxFrame - minFrame + 1; List <Frame> frames = generator.Generate(frameCompare, 0, 0); IFrameCapture previous = null; bool previouslyAdded = false; var frameGroup = new List <IFrameCapture>(); // quick check and if it's impossible that this is a match don't waste our time loop // breaks search progress so that needs to get fixed if (frames.Count < groupSize) { continue; } foreach (Frame frame in frames) { var iframe = new IFrameCapture { Offset = frame.Number, Seed = seed, Frame = frame, TimeDate = seedTime, Timer0 = timer0, Delay = calibratedDelay, KeyPresses = combo }; // Calibrated delay instead of the real delay for correct CGear Times if (previous != null && (iframe.Offset == previous.Offset + 1 || iframe.Offset == previous.Offset + 2)) { if (!previouslyAdded) { frameGroup.Add(previous); } frameGroup.Add(iframe); previouslyAdded = true; } else { if (frameGroup.Count >= groupSize) { lock (threadLock) { foreach (IFrameCapture t in frameGroup) { t.Frame.Synchable = grey; } iframes.AddRange(frameGroup); grey = !grey; } refreshQueue = true; progressFound += incrementFound; } frameGroup = new List <IFrameCapture>(); previouslyAdded = false; } previous = iframe; } progressSearched += (uint)frames.Count; if (frameGroup.Count >= groupSize) { lock (threadLock) { for (int i = 0; i < frameGroup.Count; ++i) { frameGroup[i].Frame.Synchable = grey; } iframes.AddRange(frameGroup); grey = !grey; } refreshQueue = true; progressFound += incrementFound; } } } } }
private void Generate() { var profile = (Profile)comboBoxProfiles.SelectedItem; uint minFrame = uint.Parse(maskedTextBoxCapMinOffset.Text); uint maxFrame = uint.Parse(maskedTextBoxCapMaxOffset.Text); DateTime seedTime = datePicker.Value; iframes = new List <IFrameCapture>(); generator = new FrameGenerator { FrameType = (FrameType)((ComboBoxItem)comboBoxMethod.SelectedItem).Reference, EncounterType = (EncounterType)((ComboBoxItem)comboBoxEncounterType.SelectedItem).Reference, EncounterMod = (EncounterMod)((ComboBoxItem)comboBoxLead.SelectedItem).Reference, SynchNature = -2, InitialFrame = minFrame + (profile.IsBW2() ? 2u : 0), MaxResults = maxFrame - minFrame + 1 }; // Now that each combo box item is a custom object containing the FrameType reference // We can simply retrieve the FrameType from the selected item frameCompare = new FrameCompare( 0, CompareType.None, 0, CompareType.None, 0, CompareType.None, 0, CompareType.None, 0, CompareType.None, 0, CompareType.None, null, -1, false, false, false, null, new NoGenderFilter()); switch (generator.FrameType) { case FrameType.Method5Standard: CapSeed.DefaultCellStyle.Format = "X16"; EncounterSlot.Visible = false; PID.Visible = false; Shiny.Visible = false; Nature.Visible = false; Ability.Visible = false; CapHP.Visible = true; CapAtk.Visible = true; CapDef.Visible = true; CapSpA.Visible = true; CapSpD.Visible = true; CapSpe.Visible = true; f25.Visible = false; f50.Visible = false; f75.Visible = false; f125.Visible = false; break; case FrameType.Method5Natures: CapSeed.DefaultCellStyle.Format = "X16"; if (generator.EncounterType != EncounterType.Stationary && generator.EncounterType != EncounterType.Gift && generator.EncounterType != EncounterType.Roamer && generator.EncounterType != EncounterType.LarvestaEgg) { EncounterSlot.Visible = true; } else { EncounterSlot.Visible = false; } PID.Visible = true; Shiny.Visible = true; Nature.Visible = true; Ability.Visible = true; CapHP.Visible = false; CapAtk.Visible = false; CapDef.Visible = false; CapSpA.Visible = false; CapSpD.Visible = false; CapSpe.Visible = false; f25.Visible = true; f50.Visible = true; f75.Visible = true; f125.Visible = true; break; case FrameType.BWBred: generator.FrameType = FrameType.Method5Standard; generator.InitialFrame = 14; generator.MaxResults = 7; CapSeed.DefaultCellStyle.Format = "X16"; EncounterSlot.Visible = false; PID.Visible = false; Shiny.Visible = false; Nature.Visible = false; Ability.Visible = false; CapHP.Visible = true; CapAtk.Visible = true; CapDef.Visible = true; CapSpA.Visible = true; CapSpD.Visible = true; CapSpe.Visible = true; f25.Visible = false; f50.Visible = false; f75.Visible = false; f125.Visible = false; break; case FrameType.Wondercard5thGen: case FrameType.Wondercard5thGenFixed: CapSeed.DefaultCellStyle.Format = "X16"; EncounterSlot.Visible = false; PID.Visible = false; Shiny.Visible = false; Nature.Visible = true; Ability.Visible = false; CapHP.Visible = true; CapAtk.Visible = true; CapDef.Visible = true; CapSpA.Visible = true; CapSpD.Visible = true; CapSpe.Visible = true; f25.Visible = false; f50.Visible = false; f75.Visible = false; f125.Visible = false; break; } for (int seconds = (int)numericUpDownSeconds.Value * -1; seconds <= numericUpDownSeconds.Value; seconds++) { for (uint timer0 = profile.Timer0Min - 1; timer0 <= profile.Timer0Max + 1; timer0++) { ulong seed = Functions.EncryptSeed(seedTime.AddSeconds(seconds), profile.MAC_Address, profile.Version, profile.Language, profile.DSType, profile.SoftReset, profile.VCount, timer0, profile.GxStat, profile.VFrame, buttonValue()); if (seconds == 0 && timer0 == profile.Timer0Min) { seedMatch = seed; } switch (generator.FrameType) { case FrameType.Method5Standard: generator.InitialSeed = seed >> 32; break; case FrameType.Method5Natures: case FrameType.Wondercard5thGen: case FrameType.Wondercard5thGenFixed: generator.InitialSeed = seed; generator.InitialFrame = Functions.initialPIDRNG(seed, profile) + minFrame; break; } List <Frame> frames = generator.Generate(frameCompare, profile.ID, profile.SID); foreach (Frame frame in frames) { var iframe = new IFrameCapture(); frame.DisplayPrep(); iframe.Offset = frame.Number; iframe.Seed = seed; iframe.Frame = frame; iframe.TimeDate = seedTime.AddSeconds(seconds); iframe.Timer0 = timer0; iframes.Add(iframe); } } } listBindingCap = new BindingSource { DataSource = iframes }; dataGridViewCapValues.DataSource = listBindingCap; foreach (DataGridViewRow row in dataGridViewCapValues.Rows) { if ((ulong)row.Cells[0].Value == seedMatch) { dataGridViewCapValues.CurrentCell = row.Cells[0]; dataGridViewCapValues.FirstDisplayedScrollingRowIndex = row.Index; break; } } dataGridViewCapValues.Focus(); }
private void Generate4thGenCapJob(List<uint> hpList, List<uint> atkList, List<uint> defList, List<uint> spaList, List<uint> spdList, List<uint> speList, List<uint> natures, uint minEfgh, uint maxEfgh) { //if the lists are null we shouldn't be searching so do nothing if (hpList == null || atkList == null || defList == null || spaList == null || spdList == null || speList == null) return; uint incrementFound = 1; if (natures != null) incrementFound = incrementFound*(uint) natures.Count; foreach (uint hp in hpList) { foreach (uint atk in atkList) { foreach (uint def in defList) { foreach (uint spa in spaList) { foreach (uint spd in spdList) { foreach (uint spe in speList) { waitHandle.WaitOne(); List<Frame> frames = generator.Generate(frameCompare, hp, atk, def, spa, spd, spe, natures, minEfgh, maxEfgh, id, sid); foreach (Frame frame in frames) { frame.DisplayPrep(); var iframe = new IFrameCapture { Frame = frame, Seed = frame.Seed, Offset = frame.Number }; lock (threadLock) { iframes.Add(iframe); } refreshQueue = true; } progressSearched += incrementFound; progressFound += (uint) frames.Count; } } } } } } }
private void Generate() { var profile = (Profile) comboBoxProfiles.SelectedItem; uint minFrame = uint.Parse(maskedTextBoxCapMinOffset.Text); uint maxFrame = uint.Parse(maskedTextBoxCapMaxOffset.Text); DateTime seedTime = datePicker.Value; iframes = new List<IFrameCapture>(); generator = new FrameGenerator { FrameType = (FrameType) ((ComboBoxItem) comboBoxMethod.SelectedItem).Reference, EncounterType = (EncounterType) ((ComboBoxItem) comboBoxEncounterType.SelectedItem).Reference, EncounterMod = (EncounterMod) ((ComboBoxItem) comboBoxLead.SelectedItem).Reference, SynchNature = -2, InitialFrame = minFrame + (profile.IsBW2() ? 2u : 0), MaxResults = maxFrame - minFrame + 1 }; // Now that each combo box item is a custom object containing the FrameType reference // We can simply retrieve the FrameType from the selected item frameCompare = new FrameCompare( 0, CompareType.None, 0, CompareType.None, 0, CompareType.None, 0, CompareType.None, 0, CompareType.None, 0, CompareType.None, null, -1, false, false, false, null, new NoGenderFilter()); switch (generator.FrameType) { case FrameType.Method5Standard: CapSeed.DefaultCellStyle.Format = "X16"; EncounterSlot.Visible = false; PID.Visible = false; Shiny.Visible = false; Nature.Visible = false; Ability.Visible = false; CapHP.Visible = true; CapAtk.Visible = true; CapDef.Visible = true; CapSpA.Visible = true; CapSpD.Visible = true; CapSpe.Visible = true; f25.Visible = false; f50.Visible = false; f75.Visible = false; f125.Visible = false; break; case FrameType.Method5Natures: CapSeed.DefaultCellStyle.Format = "X16"; if (generator.EncounterType != EncounterType.Stationary && generator.EncounterType != EncounterType.Gift && generator.EncounterType != EncounterType.Roamer && generator.EncounterType != EncounterType.LarvestaEgg) EncounterSlot.Visible = true; else EncounterSlot.Visible = false; PID.Visible = true; Shiny.Visible = true; Nature.Visible = true; Ability.Visible = true; CapHP.Visible = false; CapAtk.Visible = false; CapDef.Visible = false; CapSpA.Visible = false; CapSpD.Visible = false; CapSpe.Visible = false; f25.Visible = true; f50.Visible = true; f75.Visible = true; f125.Visible = true; break; case FrameType.BWBred: generator.FrameType = FrameType.Method5Standard; generator.InitialFrame = 14; generator.MaxResults = 7; CapSeed.DefaultCellStyle.Format = "X16"; EncounterSlot.Visible = false; PID.Visible = false; Shiny.Visible = false; Nature.Visible = false; Ability.Visible = false; CapHP.Visible = true; CapAtk.Visible = true; CapDef.Visible = true; CapSpA.Visible = true; CapSpD.Visible = true; CapSpe.Visible = true; f25.Visible = false; f50.Visible = false; f75.Visible = false; f125.Visible = false; break; case FrameType.Wondercard5thGen: case FrameType.Wondercard5thGenFixed: CapSeed.DefaultCellStyle.Format = "X16"; EncounterSlot.Visible = false; PID.Visible = false; Shiny.Visible = false; Nature.Visible = true; Ability.Visible = false; CapHP.Visible = true; CapAtk.Visible = true; CapDef.Visible = true; CapSpA.Visible = true; CapSpD.Visible = true; CapSpe.Visible = true; f25.Visible = false; f50.Visible = false; f75.Visible = false; f125.Visible = false; break; } for (int seconds = (int) numericUpDownSeconds.Value*-1; seconds <= numericUpDownSeconds.Value; seconds++) { for (uint timer0 = profile.Timer0Min - 1; timer0 <= profile.Timer0Max + 1; timer0++) { ulong seed = Functions.EncryptSeed(seedTime.AddSeconds(seconds), profile.MAC_Address, profile.Version, profile.Language, profile.DSType, profile.SoftReset, profile.VCount, timer0, profile.GxStat, profile.VFrame, buttonValue()); if (seconds == 0 && timer0 == profile.Timer0Min) { seedMatch = seed; } switch (generator.FrameType) { case FrameType.Method5Standard: generator.InitialSeed = seed >> 32; break; case FrameType.Method5Natures: case FrameType.Wondercard5thGen: case FrameType.Wondercard5thGenFixed: generator.InitialSeed = seed; generator.InitialFrame = Functions.initialPIDRNG(seed, profile) + minFrame; break; } List<Frame> frames = generator.Generate(frameCompare, profile.ID, profile.SID); foreach (Frame frame in frames) { var iframe = new IFrameCapture(); frame.DisplayPrep(); iframe.Offset = frame.Number; iframe.Seed = seed; iframe.Frame = frame; iframe.TimeDate = seedTime.AddSeconds(seconds); iframe.Timer0 = timer0; iframes.Add(iframe); } } } listBindingCap = new BindingSource {DataSource = iframes}; dataGridViewCapValues.DataSource = listBindingCap; foreach (DataGridViewRow row in dataGridViewCapValues.Rows) { if ((ulong) row.Cells[0].Value == seedMatch) { dataGridViewCapValues.CurrentCell = row.Cells[0]; dataGridViewCapValues.FirstDisplayedScrollingRowIndex = row.Index; break; } } dataGridViewCapValues.Focus(); }
private void Generate(FrameGenerator generator, IEnumerable<DateTime> possibleDates, uint minFrame, uint maxFrame, Profile profile, uint groupSize, uint calibratedDelay) { const uint incrementFound = 1; List<List<ButtonComboType>> keypresses = profile.GetKeypresses(); foreach (DateTime seedTime in possibleDates) { waitHandle.WaitOne(); foreach (var combo in keypresses) { for (uint timer0 = profile.Timer0Min; timer0 <= profile.Timer0Max; timer0++) { ulong seed = Functions.EncryptSeed(seedTime, profile, timer0, Functions.buttonMashed(combo)); generator.InitialSeed = seed; generator.InitialFrame = Functions.initialPIDRNG(seed, profile) + minFrame; generator.MaxResults = maxFrame - minFrame + 1; List<Frame> frames = generator.Generate(frameCompare, 0, 0); IFrameCapture previous = null; bool previouslyAdded = false; var frameGroup = new List<IFrameCapture>(); // quick check and if it's impossible that this is a match don't waste our time loop // breaks search progress so that needs to get fixed if (frames.Count < groupSize) continue; foreach (Frame frame in frames) { var iframe = new IFrameCapture { Offset = frame.Number, Seed = seed, Frame = frame, TimeDate = seedTime, Timer0 = timer0, Delay = calibratedDelay, KeyPresses = combo }; // Calibrated delay instead of the real delay for correct CGear Times if (previous != null && (iframe.Offset == previous.Offset + 1 || iframe.Offset == previous.Offset + 2)) { if (!previouslyAdded) frameGroup.Add(previous); frameGroup.Add(iframe); previouslyAdded = true; } else { if (frameGroup.Count >= groupSize) { lock (threadLock) { foreach (IFrameCapture t in frameGroup) t.Frame.Synchable = grey; iframes.AddRange(frameGroup); grey = !grey; } refreshQueue = true; progressFound += incrementFound; } frameGroup = new List<IFrameCapture>(); previouslyAdded = false; } previous = iframe; } progressSearched += (uint) frames.Count; if (frameGroup.Count >= groupSize) { lock (threadLock) { for (int i = 0; i < frameGroup.Count; ++i) frameGroup[i].Frame.Synchable = grey; iframes.AddRange(frameGroup); grey = !grey; } refreshQueue = true; progressFound += incrementFound; } } } } }