Пример #1
0
        private void DynamicSearchRngDump(Action action)
        {
            ResetGridHighlighting();

            try
            {
                var rng = new RNG2002();
                (uint[] mt, int mti) = ZodiacMemory.GetMtAndMti(MemoryData.MtAddress);

                rng.LoadState(mti, in mt);
                _rngDump = rng.Dump(Config.SearchDepth);

                action.Invoke();
            }
            catch (Exception ex)
            {
                if (ex is OutOfMemoryException)
                {
                    MessageBox.Show("Ran out of memory, lower your search depth.");
                }
            }
            finally
            {
                _rngDump = Array.Empty <uint>();
                if (_foundIndex < 0)
                {
                    MessageBox.Show("Nothing found.");
                }
                else if (_foundIndex < dataGridView2.RowCount)
                {
                    dataGridView2.Rows[_foundIndex].DefaultCellStyle.BackColor          = HighlightBackColor;
                    dataGridView2.Rows[_foundIndex].DefaultCellStyle.SelectionBackColor =
                        SelectionHighlightBackColor;
                    dataGridView2.FirstDisplayedScrollingRowIndex = _foundIndex;
                }
            }
        }
Пример #2
0
        // TODO: Make searching better so it only generates the amount of random numbers needed for the current search and gets new every iteration instead of just dumping the whole thing.
        private int SearchPercentages(PSearch[] percentages)
        {
            try
            {
                var rng = new RNG2002();
                (uint[] mt, int mti) = ZodiacMemory.GetMtAndMti(MemoryData.MtAddress);

                rng.LoadState(mti, in mt);
                _rngDump = rng.Dump(Config.SearchDepth);

                for (int i = 0; i < _rngDump.Length; i++)
                {
                    uint pVal = _rngDump[i] % 100;
                    switch (percentages[0].CompareType)
                    {
                    case CompareType.Equal:
                        if (pVal != percentages[0].Percentage)
                        {
                            continue;
                        }

                        break;

                    case CompareType.LesserOrEqual:
                        if (pVal > percentages[0].Percentage)
                        {
                            continue;
                        }

                        break;

                    case CompareType.GreaterOrEqual:
                        if (pVal < percentages[0].Percentage)
                        {
                            continue;
                        }

                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }

                    if (SearchDump(percentages, i))
                    {
                        return(i);
                    }
                }
            }
            catch (Exception ex)
            {
                if (ex is OutOfMemoryException)
                {
                    MessageBox.Show("Ran out of memory, lower your search depth.");
                }
            }
            finally
            {
                _rngDump = Array.Empty <uint>();
            }

            return(-1);
        }