Example #1
0
File: NFC.cs Project: rommii92/ARME
 private void loadData()
 {
     try
     {
         if (File.Exists(this.fullpath))
         {
             FileStream   fileStream   = File.Open(this.fullpath, FileMode.Open, FileAccess.Read, FileShare.Read);
             BinaryReader binaryReader = new BinaryReader(fileStream, Encoding.ASCII);
             this.cnt = binaryReader.ReadInt32();
             data     = new StructNFC[this.cnt];
             for (int i = 1; i <= this.cnt; i++)
             {
                 data[i - 1]            = new StructNFC();
                 data[i - 1].id         = i;
                 data[i - 1].type       = binaryReader.ReadInt32();
                 data[i - 1].unknown1   = binaryReader.ReadInt32();
                 data[i - 1].unknown2   = binaryReader.ReadInt32();
                 data[i - 1].unknown3   = binaryReader.ReadInt32();
                 data[i - 1].unknown4   = binaryReader.ReadInt32();
                 data[i - 1].cnt_name   = binaryReader.ReadInt32();
                 data[i - 1].name       = new string(binaryReader.ReadChars(data[i - 1].cnt_name));
                 data[i - 1].cnt_script = binaryReader.ReadInt32();
                 data[i - 1].script     = new string(binaryReader.ReadChars(data[i - 1].cnt_script));
                 if (this.loadstrings && data[i - 1].script.Contains("call_lc"))
                 {
                     Match match   = Regex.Match(data[i - 1].script, @".*\((?<inner>.*)\).*");
                     int   name_id = Convert.ToInt32(match.Groups["inner"].Value);
                     data[i - 1].name = strings.get_Wname(name_id + 70000000);
                 }
                 else
                 {
                     data[i - 1].name = "No StringResource found or unable to parse script!";
                 }
                 data[i - 1].cnt_name   = data[i - 1].name.Length;
                 data[i - 1].cnt_coords = binaryReader.ReadInt32();
                 data[i - 1].coords     = new NFCCoords[data[i - 1].cnt_coords];
                 for (int k = 1; k <= data[i - 1].cnt_coords; k++)
                 {
                     data[i - 1].coords[k - 1]            = new NFCCoords();
                     data[i - 1].coords[k - 1].cnt_coords = binaryReader.ReadInt32();
                     data[i - 1].coords[k - 1].coords     = new PointF[data[i - 1].coords[k - 1].cnt_coords + 1];
                     data[i - 1].coord = data[i - 1].coord + k + ": {";
                     int stringcnt = 0;
                     for (int j = 1; j <= data[i - 1].coords[k - 1].cnt_coords; j++)
                     {
                         int x = binaryReader.ReadInt32();
                         int y = mirrory(binaryReader.ReadInt32());
                         data[i - 1].coords[k - 1].coords[j - 1].X = x;
                         data[i - 1].coords[k - 1].coords[j - 1].Y = y;
                         data[i - 1].coord = data[i - 1].coord + j + ". (" + ((x * 5.25) + Hexcnv.GetCoords(this.filename, 1)) + ", " + (((3072 - y) * 5.25) + Hexcnv.GetCoords(this.filename, 2)) + ") ";
                         if (stringcnt == 7)
                         {
                             data[i - 1].coord = data[i - 1].coord + "\n";
                             stringcnt         = 0;
                         }
                         else
                         {
                             stringcnt++;
                         }
                         if (j - 1 == 0)
                         {
                             data[i - 1].coords[k - 1].coords[data[i - 1].coords[k - 1].cnt_coords] = new Point(x, y);
                         }
                     }
                     data[i - 1].coord = data[i - 1].coord + "} ";
                     if (this.data[i - 1].cnt_coords > 1)
                     {
                         this.data[i - 1].coord = data[i - 1].coord + "\n";
                     }
                 }
             }
             binaryReader.Close();
             fileStream.Close();
         }
         this.check = true;
         this.error = false;
     }
     catch
     {
         this.error  = true;
         this.MapImg = new Bitmap(3072, 3072);
         this.check  = false;
     }
 }