コード例 #1
0
        private void CheckInvalidSpeeds(string fileName)
        {
            Cursor = Cursors.WaitCursor;
            Application.DoEvents();

            List <string>       filterList       = new List <string>(new string[] { "SMSG_UPDATE_OBJECT", "SMSG_COMPRESSED_UPDATE_OBJECT" });
            List <string>       createObjectList = filter.FilterSniffFile(fileName, false, filterList);
            List <SniffedSpeed> speeds           = filter.GetSniffedSpeedList(createObjectList);

            foreach (var item in speeds)
            {
                string oldSpeedWalk = "";
                string oldSpeedRun  = "";

                double w         = Convert.ToDouble(item.SpeedWalk, new CultureInfo("en-US"));
                double speedWalk = w / 2.5f;

                double r        = Convert.ToDouble(item.SpeedRun, new CultureInfo("en-US"));
                double speedRun = r / 7f;

                double roundedSpeedWalk;
                double roundedSpeedRun;
                if (speedWalk > 1)
                {
                    roundedSpeedWalk = Math.Round(speedWalk, 5);
                }
                else
                {
                    roundedSpeedWalk = Math.Round(speedWalk, 6);
                }

                if (speedRun > 1)
                {
                    roundedSpeedRun = Math.Round(speedRun, 5);
                }
                else
                {
                    roundedSpeedRun = Math.Round(speedRun, 6);
                }

                string name    = "";
                bool   addItem = false;

                for (int i = 0; i < models.Count; i++)
                {
                    if (models[i].ModelId == item.ModelId)
                    {
                        //name = creatures[i].Name;

                        if (roundedSpeedWalk != double.Parse(models[i].SpeedWalk) || roundedSpeedRun != double.Parse(models[i].SpeedRun))
                        {
                            bool exists = false;
                            addItem = false;

                            if (int.Parse(models[i].ModelId) > 25958)
                            {
                                addItem = false;
                            }

                            for (int k = 0; k < dgv_grid.Rows.Count; k++)
                            {
                                if (dgv_grid.Rows[k].Cells[1].Value != null && item.ModelId == dgv_grid.Rows[k].Cells[1].Value.ToString())
                                {
                                    if (roundedSpeedWalk.ToString() != dgv_grid.Rows[k].Cells[4].Value.ToString() || roundedSpeedRun.ToString() != dgv_grid.Rows[k].Cells[5].Value.ToString())
                                    {
                                        //MessageBox.Show("The value already existed in DataGridView. ModelId: (" + item.ModelId + ")\n First Sniffed SpeedWalk: " + roundedSpeedWalk + " Second Sniffed SpeedWalk: " + dgv_grid.Rows[k].Cells[4].Value.ToString()
                                        //+ "\n First Sniffed SpeedRun: " + roundedSpeedRun + " Second Sniffed SpeedRun: " + dgv_grid.Rows[k].Cells[5].Value.ToString() + "\n Sniffs are showing different speeds for the same model!!\n" + fileName);
                                        rtxt_duplicateResults.Text += item.UnitGUID + ", " + fileName + " vs " + dgv_grid.Rows[k].Cells[7].Value.ToString() + ", " + dgv_grid.Rows[k].Cells[6].Value.ToString() + ",\n";
                                        // Add to ignore list
                                        ignoreList.Add(item.ModelId);
                                    }
                                    exists = true;
                                }
                            }
                            if (exists == false)
                            {
                                oldSpeedWalk = models[i].SpeedWalk;
                                oldSpeedRun  = models[i].SpeedRun;

                                addItem = true;
                            }
                        }
                    }
                }

                if (addItem)
                {
                    dgv_grid.Rows.Add(name, int.Parse(item.ModelId), oldSpeedWalk, oldSpeedRun, roundedSpeedWalk, roundedSpeedRun, fileName, item.UnitGUID);
                }
            }

            Cursor        = Cursors.Default;
            lbl_rows.Text = "Rows: " + dgv_grid.RowCount;
        }