Ejemplo n.º 1
0
        public static TES3 TES3Load(string filePath, List <string> filteredGrops = null)
        {
            if (filteredGrops == null)
            {
                filteredGrops = new List <string>();
            }

            var TES3 = new TES3()
            {
                Path = filePath
            };
            var fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read);

            var         header = new byte[HeaderSize];
            List <Task> tasks  = new List <Task>();

            while (fileStream.Read(header, 0, HeaderSize) != 0)
            {
                fileStream.Position -= HeaderSize;

                var reader = new ByteReader();
                var name   = reader.ReadBytes <string>(header, 4);
                var size   = reader.ReadBytes <int>(header);

                if (!name.Equals("TES3") && filteredGrops.Count > 0 && !filteredGrops.Contains(name))
                {
                    fileStream.Position += +HeaderSize + size;
                    continue;
                }

                var data = new byte[HeaderSize + size];
                fileStream.Read(data, 0, HeaderSize + size);


                TES3.Records.Add(null);
                int index = TES3.Records.Count - 1;
                tasks.Add(new Task(() => RecordBuildTask(name, data, TES3.Records, index)));
                tasks[index].Start();
            }

            Task.WaitAll(tasks.ToArray());
            return(TES3);
        }
Ejemplo n.º 2
0
        public static TES3 TES3Load(string filePath)
        {
            var TES3       = new TES3();
            var fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read);

            var header = new byte[HeaderSize];

            while (fileStream.Read(header, 0, HeaderSize) != 0)
            {
                fileStream.Position -= HeaderSize;

                var reader = new ByteReader();
                var name   = reader.ReadBytes <string>(header, 4);
                var size   = reader.ReadBytes <int>(header);

                var data = new byte[HeaderSize + size];
                fileStream.Read(data, 0, HeaderSize + size);

                TES3.Records.Add(BuildRecord(name, data));
                Console.WriteLine(name);
            }

            return(TES3);
        }
Ejemplo n.º 3
0
 internal static TES3Lib.Base.Record?FindRecord(this TES3Lib.TES3 plugin, string id)
 {
     return(plugin.Records.FirstOrDefault(r => r.GetEditorId() == $"{id}\0"));
 }