예제 #1
0
파일: Patch.cs 프로젝트: Glain/FFTPatcher
        public void ConvertConflicts(string[] patchnames, FileWrite BIN)
        {
            if(Conflicts[0] != null)
            {
                foreach (Conflict conflict in Conflicts)
                {
                    string Conflictname = BIN.Patchname[conflict.Patchnumber];
                    int i = 1;
                    foreach (string name in patchnames)
                    {

                        if (name == Conflictname)
                        {
                            conflict.Patchnumber = i;
                        }
                        i++;
                    }
                }
            }
        }
예제 #2
0
        public void CheckforConflicts(string name, FileWrite BIN, Patch[] Patches,int k)
        {
            int patchindex = 0;
            int otherpatchindex = 0;
            int[] conflictarray = new int[1];

            for (patchindex = 0; patchindex < BIN.index; patchindex++)
            {
                if (name == BIN.Patchname[patchindex])
                {
                    Patches[k-1].AddOffset(BIN.startaddress[patchindex]);
                    Patches[k-1].AddEndaddress(BIN.endaddress[patchindex]);
                    Patches[k - 1].XMLFile = BIN.xmlfilename[patchindex];

                    for (otherpatchindex = 0; otherpatchindex < BIN.index; otherpatchindex++)
                    {  //if()

                        if (BIN.startaddress[patchindex] < BIN.startaddress[otherpatchindex] &&
                           BIN.endaddress[patchindex] > BIN.startaddress[otherpatchindex])
                        {
                            Patches[k-1].Conflictexists = true;
                            Patches[k-1].AddConflict(BIN.startaddress[patchindex],
                                                   otherpatchindex,
                                                   BIN.startaddress[otherpatchindex]);
                        }
                        else if (BIN.startaddress[patchindex] > BIN.startaddress[otherpatchindex] &&
                           BIN.startaddress[patchindex] < BIN.endaddress[otherpatchindex])
                        {
                            Patches[k-1].Conflictexists = true;
                            Patches[k-1].AddConflict(BIN.startaddress[patchindex],
                                                   otherpatchindex,
                                                   BIN.startaddress[otherpatchindex]);
                        }

                    }//scan patch vs otherpatches

                }

            }

            #region code to scan each patch vs each other patch
            //for (patchindex = 0; patchindex < BIN.index; patchindex++)
            //{
            //    if (patchindex != otherpatchindex)
            //    {
            //        if (BIN.startaddress[patchindex] < BIN.startaddress[otherpatchindex] &&
            //           BIN.endaddress[patchindex] > BIN.startaddress[otherpatchindex])
            //        {
            //            BIN.conflicts[patchindex] = true;
            //            BIN.conflictindex[patchindex] = otherpatchindex;
            //            conflictarray = otherpatchindex;
            //        }
            //        if (BIN.startaddress[patchindex] > BIN.startaddress[otherpatchindex] &&
            //           BIN.startaddress[patchindex] < BIN.endaddress[otherpatchindex])
            //        {
            //            BIN.conflicts[patchindex] = true;
            //            BIN.conflictindex[patchindex] = otherpatchindex;
            //        }

            //    }
            //}
            #endregion
        }
예제 #3
0
        private void Filelistbox_SelectedIndexChanged(object sender, EventArgs e)
        {
            long currentaddress = 0;
            long currentFreeSpaceLength = 0;
            FileWrite File = new FileWrite();
            string[] patchnames = new string[1];

            dgv_FreeSpace.Rows.Clear();

            switch(Filelistbox.SelectedIndex)
            {
                case 1:
                    File = WORLDBIN;
                    currentaddress = 0x5d400;
                    patchnames = WORLDBIN.FindAllPatchNames();
                    break;
                default:
                    File = BATTLEBIN;
                    currentaddress = 0xe92ac;
                    patchnames = BATTLEBIN.FindAllPatchNames();
                    break;
            }

            //Patches = new Patch[patchnames.Length];
            int k = 0;
            long currentendaddress = 0;
            //Array.Sort(File.startaddress);
            for (k = 0; k < File.startaddress.Length;k++ )
            {
                if (File.startaddress[k] != 0)
                {
                    //if(startaddress < currentaddress)
                    //{
                    //    if (File.endaddress[k] > currentendaddress) ;
                    //        //currentaddress = File.endaddress[k];
                    //}
                    //else
                    //{
                    //currentFreeSpaceLength = startaddress - currentaddress;

                    dgv_FreeSpace.Rows.Add(File.startaddress[k].ToString("X"), File.length[k].ToString("X"),"","",File.Patchname[k]);
                    //currentaddress = File.endaddress[k];
                    //}

                    //if (k == 0x140)
                    //    this.Focus();
                }

            }

            dgv_FreeSpace.Sort(dgv_FreeSpace.Columns[0],ListSortDirection.Ascending);

            for(int r = 0;r < dgv_FreeSpace.Rows.Count - 1; r++)
            {
                long start = Convert.ToInt64(dgv_FreeSpace.Rows[r].Cells[0].Value.ToString(),16);
                long length = Convert.ToInt64(dgv_FreeSpace.Rows[r].Cells[1].Value.ToString(),16);

                long nextstart;
                if(r != dgv_FreeSpace.Rows.Count - 2 )
                     nextstart = Convert.ToInt64(dgv_FreeSpace.Rows[r + 1].Cells[0].Value.ToString(),16);
                else
                {
                    nextstart = 0xF929B;
                }
                if(nextstart > (start + 1))
                {
                    dgv_FreeSpace.Rows[r].Cells[2].Value = String.Format("{0:X}", start + length);

                    short number = (short) (nextstart - (start + length));
                    bool isnegative = false;

                    if(nextstart - (start + length) < 0)
                    {
                        number = (short)( 0 - number);
                        isnegative = true;
                    }

                    if(isnegative)
                    {
                        dgv_FreeSpace.Rows[r].Cells[3].Value = "-" +  String.Format("{0:X}", number);
                        dgv_FreeSpace.Rows[r].Cells[3].Style.BackColor = Color.Red;
                    }
                    else
                    {
                        dgv_FreeSpace.Rows[r].Cells[3].Value = String.Format("{0:X}", number);
                    }
                    dgv_FreeSpace.Rows[r].Cells[5].Value = r.ToString();
                }

            }

            lbl_NumberOfPatches.Text = File.ShortPatchnames.Length.ToString();
            lbl_NumberOfWrites.Text = File.startaddress.Length.ToString();
        }
예제 #4
0
        private void Filelistbox_SelectedIndexChanged_1(object sender, EventArgs e)
        {
            Patcheslistview.Items.Clear();
            string[] patchnames = new string[1];
            FileWrite File = new FileWrite();
            switch(Filelistbox.SelectedIndex)
            {
                case -1:
                    patchnames = BATTLEBIN.FindAllPatchNames();
                    File = BATTLEBIN;
                    break;
                case 0:
                     patchnames = BATTLEBIN.FindAllPatchNames();
                     File = BATTLEBIN;
                    break;
                case 1:
                     patchnames = WORLDBIN.FindAllPatchNames();
                     File = WORLDBIN;
                    break;
                case 2:
                     patchnames = WLDCOREBIN.FindAllPatchNames();
                     File = WLDCOREBIN;
                    break;
                case 3:
                     patchnames = SCUS.FindAllPatchNames();
                     File = SCUS;
                    break;
                case 4:
                     patchnames = REQUIREOUT.FindAllPatchNames();
                     File = REQUIREOUT;
                    break;
                case 5:
                     patchnames = EQUIPOUT.FindAllPatchNames();
                     File = EQUIPOUT;
                    break;
            }
            int k = 1;

            Patcheslistview.View = View.Details;
            Patcheslistview.HeaderStyle = ColumnHeaderStyle.None;
            Patcheslistview.Columns.Add("");
            Patcheslistview.Columns[0].Width = 500;
            //Patcheslistview.AutoResizeColumn(0,ColumnHeaderAutoResizeStyle.ColumnContent);

            Patches = new Patch[patchnames.Length];

            foreach (string name in patchnames)
            {
                Patches[k - 1] = new Patch();
                Patches[k - 1].name = name;
                Patcheslistview.Items.Add(k + " " + name);
                CheckforConflicts(name, File, Patches, k);
                k++;
            }

            int j = 0;
            foreach(Patch patch in Patches)
            {
                patch.ConvertConflicts(patchnames, File);
                if(patch.Conflictexists)
                {
                    Patcheslistview.Items[j].BackColor = Color.Red;
                }
                j++;
            }
        }