Beispiel #1
0
        public void deleteNFS(int id)
        {
            NFS_MONSTER_LOCATION[] tmpdata = new NFS_MONSTER_LOCATION[this.data.Length - 1];
            int j = 0;

            for (int i = 0; i < this.data.Length; i++)
            {
                if (i != id)
                {
                    tmpdata[j]             = new NFS_MONSTER_LOCATION();
                    tmpdata[j]             = data[i];
                    tmpdata[j].RegionIndex = j;
                    j++;
                }
                else
                {
                    if (string.IsNullOrEmpty(data[i].ScriptText))
                    {
                        this.cnt2 -= 1;
                    }
                }
            }
            this.data    = tmpdata;
            this.cnt     = cnt - 1;
            this.editNFS = true;
        }
Beispiel #2
0
 private void brn_qpfsave_Click(object sender, EventArgs e)
 {
     try
     {
         NFS_MONSTER_LOCATION tmp = new NFS_MONSTER_LOCATION();
         tmp.RegionIndex  = Convert.ToInt32(txt_id.Text);
         tmp.Top          = this.top;
         tmp.Bottom       = this.bottom;
         tmp.Left         = this.left;
         tmp.Right        = this.right;
         tmp.ScriptText   = txt_script.Text;
         tmp.ScriptLength = txt_script.Text.Length;
         tmp.MonsterCount = Convert.ToInt32(txt_type.Text);
         tmp.Trigger      = 0;
         main.updateNFS(tmp);
         this.Close();
     }
     catch
     {
         MessageBox.Show("Please check if all values are filled in in the correct format!");
     }
 }
Beispiel #3
0
 public void updateNFSRes(NFS_MONSTER_LOCATION tmp)
 {
     NFS_MONSTER_LOCATION[] tmpdata;
     if (this.data.Length == 0)
     {
         tmpdata    = new NFS_MONSTER_LOCATION[1];
         tmpdata[0] = tmp;
     }
     else
     {
         tmpdata = new NFS_MONSTER_LOCATION[this.data.Length + 1];
         for (int i = 0; i < this.data.Length; i++)
         {
             tmpdata[i] = new NFS_MONSTER_LOCATION();
             tmpdata[i] = data[i];
         }
         tmpdata[this.data.Length] = new NFS_MONSTER_LOCATION();
         tmpdata[this.data.Length] = tmp;
     }
     this.data    = tmpdata;
     this.cnt     = cnt + 1;
     this.cnt2    = cnt2 + 1;
     this.editNFS = true;
 }
Beispiel #4
0
        private void loadData()
        {
            try
            {
                if (File.Exists(this.fullpath))
                {
                    using (FileStream fileStream = File.Open(this.fullpath, FileMode.Open, FileAccess.Read, FileShare.Read))
                    {
                        using (BinaryReader binaryReader = new BinaryReader(fileStream, Encoding.ASCII))
                        {
                            this.Header.Signature      = Encoding.Default.GetString(binaryReader.ReadBytes(16));
                            this.Header.Version        = binaryReader.ReadInt32();
                            this.Header.LocationOffset = binaryReader.ReadInt32();
                            this.Header.MonsterOffset  = binaryReader.ReadInt32();
                            this.Header.NPCOffset      = binaryReader.ReadInt32();
                            this.Header.RowCount       = binaryReader.ReadInt32();
                            this.cnt = Header.RowCount;
                            data     = new NFS_MONSTER_LOCATION[cnt];

                            for (int i = 1; i <= cnt; i++)
                            {
                                data[i - 1]        = new NFS_MONSTER_LOCATION();
                                data[i - 1].Left   = ((Convert.ToInt32((binaryReader.ReadInt32() * 8) * 5.25)) + Hexcnv.GetCoords(this.filename, 1));
                                data[i - 1].Top    = ((Convert.ToInt32((binaryReader.ReadInt32() * 8) * 5.25)) + Hexcnv.GetCoords(this.filename, 2));
                                data[i - 1].Right  = ((Convert.ToInt32((binaryReader.ReadInt32() * 8) * 5.25)) + Hexcnv.GetCoords(this.filename, 1));
                                data[i - 1].Bottom = ((Convert.ToInt32((binaryReader.ReadInt32() * 8) * 5.25)) + Hexcnv.GetCoords(this.filename, 2));
                                binaryReader.ReadInt32();
                            }

                            cnt2 = binaryReader.ReadInt32();
                            for (int i = 1; i <= cnt2; i++)
                            {
                                data[i - 1].RegionIndex  = binaryReader.ReadInt32();
                                data[i - 1].MonsterCount = binaryReader.ReadInt32();
                                data[i - 1].Trigger      = binaryReader.ReadInt32();
                                data[i - 1].ScriptLength = binaryReader.ReadInt32();
                                data[i - 1].ScriptText   = new string(binaryReader.ReadChars(data[i - 1].ScriptLength));
                            }

                            cnt_npcinit = binaryReader.ReadInt32();
                            npcdata     = new StructNFSNPC[cnt_npcinit];
                            for (int i = 1; i <= cnt_npcinit; i++)
                            {
                                npcdata[i - 1]          = new StructNFSNPC();
                                npcdata[i - 1].id       = binaryReader.ReadInt16();
                                npcdata[i - 1].unknown1 = binaryReader.ReadInt16();
                                //npcdata[i - 1].x = (int)(binaryReader.ReadSingle() / (float)5.25);
                                //npcdata[i - 1].y = mirrory((int)(binaryReader.ReadSingle() / (float)5.25));
                                npcdata[i - 1].x      = (int)(binaryReader.ReadSingle() + Hexcnv.GetCoords(this.filename, 1));
                                npcdata[i - 1].y      = (int)(binaryReader.ReadSingle() + Hexcnv.GetCoords(this.filename, 2));
                                npcdata[i - 1].propID = binaryReader.ReadInt16();         //14
                                //binaryReader.ReadBytes(2);
                                npcdata[i - 1].unknown2 = binaryReader.ReadInt32();       //18
                                npcdata[i - 1].unknown4 = binaryReader.ReadInt32();       //22
                                //binaryReader.ReadBytes(4);
                                npcdata[i - 1].cnt_initscript = binaryReader.ReadInt32(); //26

                                npcdata[i - 1].initscript = new string(binaryReader.ReadChars(npcdata[i - 1].cnt_initscript));

                                if (this.loadstrings && npcdata[i - 1].initscript.Contains("init_npc"))
                                {
                                    Match  match    = Regex.Match(npcdata[i - 1].initscript, @".*\((?<inner>.*)\,.*");
                                    Match  replace  = Regex.Match(npcdata[i - 1].initscript, "\"([^\"]*)\"");
                                    int    name_id  = Convert.ToInt32(match.Groups["inner"].Value);
                                    string replacer = replace.ToString();
                                    string name     = strings.get_NPCname(name_id + 100000000);
                                    npcdata[i - 1].name = name;
                                    name = "\"" + name + "\"";
                                    npcdata[i - 1].initscript = npcdata[i - 1].initscript.Replace(replacer, name);
                                }
                                else
                                {
                                    npcdata[i - 1].name = "No StringResource found!";
                                }
                                npcdata[i - 1].cnt_initscript = npcdata[i - 1].initscript.Length;
                                if (npcdata[i - 1].unknown2 == 2)
                                {
                                    npcdata[i - 1].type        = binaryReader.ReadInt32();
                                    npcdata[i - 1].cnt_contact = binaryReader.ReadInt32();
                                    npcdata[i - 1].contact     = new string(binaryReader.ReadChars(npcdata[i - 1].cnt_contact));
                                }
                            }
                        }
                    }
                }
                this.error = false;
                this.check = true;
            }
            catch //(Exception ex)
            {
                //throw new Exception(ex.ToString());
                this.error  = true;
                this.MapImg = new Bitmap(3072, 3072);
                this.check  = false;
            }
        }