Esempio n. 1
0
        public static ArchiveBase Load(Memory.Archive archive)
        {
            if (archive.IsDir)
            {
                return(ArchiveWorker.Load(archive));
            }

            if (archive.IsFile)
            {
                if (archive.IsFileArchive || archive.IsFileIndex || archive.IsFileList)
                {
                    var a = new Memory.Archive(Path.GetFileNameWithoutExtension(archive), Path.GetDirectoryName(archive));
                    return(ArchiveWorker.Load(a));
                }

                if (archive.IsZZZ)
                {
                    return(ArchiveZzz.Load(archive));
                }

                return(ArchiveWorker.Load(archive));
            }

            return(null);
        }
Esempio n. 2
0
        //Splash is 640x400 16BPP typical TIM with palette of ggg bbbbb a rrrrr gg
        private void ReadSplash()
        {
            if (string.IsNullOrWhiteSpace(filename))
            {
                return;
            }
            string fn = Path.GetFileNameWithoutExtension(filename);
            //Debug.Assert(!fn.Equals("ff8", StringComparison.OrdinalIgnoreCase));
            ArchiveBase aw = ArchiveWorker.Load(Memory.Archives.A_MAIN);

            byte[] buffer = aw.GetBinaryFile(filename);

            TIM_OVERTURE tim = new TIM_OVERTURE(buffer);

            if ((fn.Equals("ff8", StringComparison.OrdinalIgnoreCase)) || (fn.IndexOf("loop", StringComparison.OrdinalIgnoreCase) >= 0))
            {
                tim.IgnoreAlpha = true;
            }

            tex = TextureHandler.Create(fn, tim, 0);//TIM2.Overture(buffer);
            //using (FileStream fs = File.Create(Path.Combine("D:\\main", Path.GetFileNameWithoutExtension(filename) + ".png")))
            //    splashTex.SaveAsPng(fs, splashTex.Width, splashTex.Height);

            GC.Collect();
            GC.WaitForPendingFinalizers();
        }
Esempio n. 3
0
        //Splash is 640x400 16BPP typical TIM with palette of ggg bbbbb a rrrrr gg
        public static void ReadSplash(bool bLogo = false)
        {
            string[] lof = aw.GetListOfFiles();
            string   filename;

            if (splashName > 0x0f)
            {
                return;
            }
            filename = !bLogo
                ? bNames
                    ? lof.First(x => x.ToLower().Contains($"{names}{splashName.ToString("D2")}"))
                    : lof.First(x => x.ToLower().Contains($"{loops}{splashLoop.ToString("D2")}"))
                : lof.First(x => x.ToLower().Contains($"ff8.lzs"));

            byte[] buffer     = ArchiveWorker.GetBinaryFile(Memory.Archives.A_MAIN, filename);
            uint   uncompSize = BitConverter.ToUInt32(buffer, 0);

            buffer = buffer.Skip(4).ToArray(); //hotfix for new LZSS
            buffer = LZSS.DecompressAllNew(buffer);

            if (splashTex != null && !splashTex.IsDisposed)
            {
                splashTex.Dispose();
            }

            splashTex = TIM2.Overture(buffer);
            //using (FileStream fs = File.Create(Path.Combine("D:\\main", Path.GetFileNameWithoutExtension(filename) + ".png")))
            //    splashTex.SaveAsPng(fs, splashTex.Width, splashTex.Height);

            GC.Collect();
            GC.WaitForPendingFinalizers();
        }
Esempio n. 4
0
 protected override void InitEntries(ArchiveWorker aw = null)
 {
     if (Entries == null)
     {
         //read from icon.sp1
         using (MemoryStream ms = new MemoryStream(ArchiveWorker.GetBinaryFile(ArchiveString,
                                                                               aw.GetListOfFiles().First(x => x.IndexOf(IndexFilename, StringComparison.OrdinalIgnoreCase) >= 0))))
         {
             using (BinaryReader br = new BinaryReader(ms))
             {
                 Loc[] locs = new Loc[br.ReadUInt32()];
                 for (int i = 0; i < locs.Length; i++)
                 {
                     locs[i].seek   = br.ReadUInt16();
                     locs[i].length = br.ReadUInt16();
                 }
                 Entries = new Dictionary <ID, EntryGroup>(locs.Length + 10);
                 for (int i = 0; i < locs.Length; i++)
                 {
                     ms.Seek(locs[i].seek, SeekOrigin.Begin);
                     byte c = (byte)locs[i].length;
                     Entries[(ID)i] = new EntryGroup(c);
                     for (int e = 0; e < c; e++)
                     {
                         Entry tmp = new Entry();
                         tmp.LoadfromStreamSP1(br);
                         tmp.Part = (byte)e;
                         tmp.SetLoc(locs[i]);
                         Entries[(ID)i].Add(tmp);
                     }
                 }
             }
         }
     }
 }
Esempio n. 5
0
            protected override void LoadArchiveFiles()
            {
                StringFiles = new StringFile(118);
                GetFileLocations();
                var aw     = ArchiveWorker.Load(Archive, true);
                var buffer = aw.GetBinaryFile(FileNames[0], true);

                if (buffer == null)
                {
                    return;
                }
                using (var br = new BinaryReader(new MemoryStream(buffer)))
                {
                    for (var key = 0; key < StringFiles.SubPositions.Count; key++)
                    {
                        var pad = (Array.IndexOf(StringsPadLoc, key) >= 0);
                        if (pad || Array.IndexOf(StringsLoc, key) >= 0)
                        {
                            Get_Strings_Offsets(br, FileNames[0], key, pad);
                        }
                        else if (BinMsg.ContainsKey(key))
                        {
                            Get_Strings_BinMSG(br, FileNames[0], key, StringFiles.SubPositions[(int)BinMsg[key]].Seek, 1, 6);
                        }
                        else if (ComplexStr.ContainsKey(key))
                        {
                            Get_Strings_ComplexStr(br, FileNames[0], key, ComplexStr[key]);
                        }
                    }
                }
            }
Esempio n. 6
0
 protected override void InitTextures(ArchiveWorker aw = null)
 {
     Textures = new List <TextureHandler>();
     for (int t = 0; t < Props.Count; t++)
     {
         TEX tex;
         tex = new TEX(ArchiveWorker.GetBinaryFile(ArchiveString,
                                                   aw.GetListOfFiles().First(x => x.IndexOf(Props[t].Filename, StringComparison.OrdinalIgnoreCase) >= 0)));
         if (Props[t].Colors == null || Props[t].Colors.Length == 0)
         {
             for (ushort i = 0; i < tex.GetClutCount; i++)
             {
                 if (FORCE_ORIGINAL == false && Props[t].Big != null && Props[t].Big.Count > 0)
                 {
                     Textures.Add(TextureHandler.Create(Props[t].Big[0].Filename, tex, 2, Props[t].Big[0].Split / 2, i));
                 }
                 else
                 {
                     Textures.Add(TextureHandler.Create(Props[t].Filename, tex, 1, 1, i));
                 }
             }
         }
         else
         {
             if (FORCE_ORIGINAL == false && Props[t].Big != null && Props[t].Big.Count > 0)
             {
                 Textures.Add(TextureHandler.Create(Props[t].Big[0].Filename, tex, 2, Props[t].Big[0].Split / 2, (ushort)Textures.Count, colors: Props[t].Big[0].Colors ?? Props[t].Colors));
             }
             else
             {
                 Textures.Add(TextureHandler.Create(Props[t].Filename, tex, 1, 1, (ushort)Textures.Count, colors: Props[t].Colors));
             }
         }
     }
 }
        public static void Init()
        {
            Memory.Log.WriteLine($"{nameof(Init_debugger_battle)} :: {nameof(Init)}");
            ArchiveWorker aw = new ArchiveWorker(Memory.Archives.A_BATTLE);

            byte[] sceneOut = aw.GetBinaryFile("scene.out");
            Memory.Encounters = Battle.Encounters.Read(sceneOut);
            //Memory.Encounters.CurrentIndex = 87;
        }
Esempio n. 8
0
            /// <summary>
            /// Fetch strings from kernel.bin
            /// </summary>
            /// <see cref="http://www.balamb.pl/qh/kernel-pointers.htm"/>
            protected override void LoadArchiveFiles()
            {
                Settings = (FF8StringReference.Settings.MultiCharByte | FF8StringReference.Settings.Namedic);
                ArchiveWorker aw = new ArchiveWorker(Archive);

                Files = new StringFile(56);
                MemoryStream ms = null;

                byte[] buffer = aw.GetBinaryFile(Filenames[0], true);
                if (buffer != null)
                {
                    using (BinaryReader br = new BinaryReader(ms = new MemoryStream(buffer)))
                    {
                        GetFileLocations(br);
                        //index, grab, skip
                        StringLocations = new Dictionary <uint, Tuple <uint, uint, uint> > {
                            //working
                            { 0, new Tuple <uint, uint, uint>(31, 2, 4) },
                            { 1, new Tuple <uint, uint, uint>(32, 2, 56) },
                            { 2, new Tuple <uint, uint, uint>(33, 2, 128) },
                            { 3, new Tuple <uint, uint, uint>(34, 1, 18) },//38,58,178, or 78
                            { 4, new Tuple <uint, uint, uint>(35, 1, 10) },
                            { 5, new Tuple <uint, uint, uint>(36, 2, 20) },
                            { 6, new Tuple <uint, uint, uint>(37, 1, 34) },//+1interval 70 //character names here.
                            { 7, new Tuple <uint, uint, uint>(38, 2, 20) },
                            { 8, new Tuple <uint, uint, uint>(39, 1, 0) },
                            { 9, new Tuple <uint, uint, uint>(40, 1, 18) },
                            { 11, new Tuple <uint, uint, uint>(41, 2, 4) },
                            { 12, new Tuple <uint, uint, uint>(42, 2, 4) },
                            { 13, new Tuple <uint, uint, uint>(43, 2, 4) },
                            { 14, new Tuple <uint, uint, uint>(44, 2, 4) },
                            { 15, new Tuple <uint, uint, uint>(45, 2, 4) },
                            { 16, new Tuple <uint, uint, uint>(46, 2, 4) },
                            { 17, new Tuple <uint, uint, uint>(47, 2, 4) },
                            { 18, new Tuple <uint, uint, uint>(48, 2, 20) },
                            { 19, new Tuple <uint, uint, uint>(49, 2, 12) },
                            { 21, new Tuple <uint, uint, uint>(50, 2, 20) },
                            { 22, new Tuple <uint, uint, uint>(51, 2, 28) },
                            { 24, new Tuple <uint, uint, uint>(52, 2, 4) },
                            { 25, new Tuple <uint, uint, uint>(53, 1, 18) },
                            { 28, new Tuple <uint, uint, uint>(54, 1, 10) },
                            { 30, new Tuple <uint, uint, uint>(55, 1, 0) },
                        };

                        for (uint key = 0; key < Files.subPositions.Count; key++)
                        {
                            Loc fpos = Files.subPositions[(int)key];
                            if (StringLocations.ContainsKey(key))
                            {
                                Get_Strings_BinMSG(br, Filenames[0], key, Files.subPositions[(int)(StringLocations[key].Item1)].seek, StringLocations[key].Item2, StringLocations[key].Item3);
                            }
                        }
                        ms = null;
                    }
                }
            }
Esempio n. 9
0
 protected virtual void Init()
 {
     if (Entries == null)
     {
         var aw = ArchiveWorker.Load(ArchiveString);
         InitEntries(aw);
         InsertCustomEntries();
         InitTextures <TEX>(aw);
     }
 }
Esempio n. 10
0
 protected virtual void Init()
 {
     if (Entries == null)
     {
         ArchiveWorker aw = new ArchiveWorker(ArchiveString);
         InitEntries(aw);
         InsertCustomEntries();
         InitTextures(aw);
     }
 }
Esempio n. 11
0
 public Splash(int splashNum, bool bNames = true, bool bLogo = false)
 {
     if (splashNum > 0x0f)
     {
         return;
     }
     aw = new ArchiveWorker(Memory.Archives.A_MAIN);
     GetName(splashNum, bNames, bLogo);
     ReadSplash();
 }
Esempio n. 12
0
            protected void GetFileLocations()
            {
                ArchiveWorker aw = new ArchiveWorker(Archive, true);

                using (MemoryStream ms = new MemoryStream(aw.GetBinaryFile(Filenames[1], true)))
                    using (BinaryReader br = new BinaryReader(ms))
                    {
                        GetFileLocations(br);
                    }
            }
Esempio n. 13
0
            protected override void LoadArchiveFiles()
            {
                Files = new StringFile(118);
                GetFileLocations();
                ArchiveWorker aw = new ArchiveWorker(Archive, true);
                MemoryStream  ms = null;

                byte[] buffer = aw.GetBinaryFile(Filenames[0], true);
                if (buffer != null)
                {
                    using (BinaryReader br = new BinaryReader(ms = new MemoryStream(buffer)))
                    {
                        //string contain padding values at start of file
                        //then location data before strings
                        StringsPadLoc = new uint[] { (uint)SectionID.tkmnmes1, (uint)SectionID.tkmnmes2, (uint)SectionID.tkmnmes3 };
                        //only location data before strings
                        StringsLoc = new uint[] { 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
                                                  55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70,
                                                  71, 72, 73, 81, 82, 83, 84, 85, 86, 87, 88, 116 };
                        //complexstr has locations in first file,
                        //and they have 8 bytes of stuff at the start of each entry, 6 bytes UNK and ushort length?
                        //also can have multiple null ending strings per entry.
                        ComplexStr = new Dictionary <uint, List <uint> > {
                            { 74, new List <uint> {
                                  75, 76, 77, 78, 79, 80
                              } }
                        };
                        //these files come in pairs. the bin has string offsets and 6 bytes of other data
                        //msg is where the strings are.
                        BinMSG = new Dictionary <uint, uint>
                        {
                            { 106, 111 }, { 107, 112 }, { 108, 113 }, { 109, 114 }, { 110, 115 }
                        };

                        for (uint key = 0; key < Files.subPositions.Count; key++)
                        {
                            Loc  fpos = Files.subPositions[(int)key];
                            bool pad  = (Array.IndexOf(StringsPadLoc, key) >= 0);
                            if (pad || Array.IndexOf(StringsLoc, key) >= 0)
                            {
                                Get_Strings_Offsets(br, Filenames[0], key, pad);
                            }
                            else if (BinMSG.ContainsKey(key))
                            {
                                Get_Strings_BinMSG(br, Filenames[0], key, Files.subPositions[(int)BinMSG[key]].seek, 1, 6);
                            }
                            else if (ComplexStr.ContainsKey(key))
                            {
                                Get_Strings_ComplexStr(br, Filenames[0], key, ComplexStr[key]);
                            }
                        }
                        ms = null;
                    }
                }
            }
Esempio n. 14
0
 public override ArchiveBase GetArchive(Memory.Archive archive)
 {
     lock (GetArchiveLock)
     {
         if (!CacheTryGetValue(archive, out ArchiveBase value))
         {
             return(ArchiveWorker.Load(archive, GetStreamWithRangeValues(archive.FI), this, GetStreamWithRangeValues(archive.FL)));
         }
         return(value);
     }
 }
Esempio n. 15
0
        public void LoadFonts()
        {
            ArchiveWorker aw = new ArchiveWorker(Memory.Archives.A_MENU);
            string        sysfntTdwFilepath = aw.GetListOfFiles().First(x => x.ToLower().Contains("sysfnt.tdw"));
            string        sysfntFilepath    = aw.GetListOfFiles().First(x => x.ToLower().Contains("sysfnt.tex"));
            TEX           tex = new TEX(ArchiveWorker.GetBinaryFile(Memory.Archives.A_MENU, sysfntFilepath));

            sysfnt    = tex.GetTexture((int)ColorID.White);
            sysfntbig = new TextureHandler("sysfld{0:00}.tex", tex, 2, 1, (int)ColorID.White);

            ReadTdw(ArchiveWorker.GetBinaryFile(Memory.Archives.A_MENU, sysfntTdwFilepath));
        }
Esempio n. 16
0
        public Splash(int splashNum, bool bNames = true, bool bLogo = false)
        {
            if (splashNum > 0x0f)
            {
                return;
            }
            ArchiveBase aw = ArchiveWorker.Load(Memory.Archives.A_MAIN);

            InitNames(aw);
            GetName(splashNum, bNames, bLogo);
            ReadSplash();
        }
Esempio n. 17
0
 public TextureHandler(string filename, uint cols, uint rows)
 {
     if (cols == 1 && rows == 1)
     {
         ArchiveWorker aw = new ArchiveWorker(Memory.Archives.A_MENU);
         filename = aw.GetListOfFiles().First(x => x.IndexOf(filename, StringComparison.OrdinalIgnoreCase) >= 0);
         TEX tex = new TEX(aw.GetBinaryFile(filename));
         Init(filename, tex, cols, rows);
     }
     else
     {
         Init(filename, null, cols, rows);
     }
 }
Esempio n. 18
0
            protected void simple_init()
            {
                ArchiveWorker aw = new ArchiveWorker(Archive, true);

                using (MemoryStream ms = new MemoryStream(aw.GetBinaryFile(Filenames[0], true)))
                    using (BinaryReader br = new BinaryReader(ms))
                    {
                        Files = new StringFile(1);
                        Files.subPositions.Add(new Loc {
                            seek = 0, length = uint.MaxValue
                        });
                        Get_Strings_Offsets(br, Filenames[0], 0);
                    }
            }
Esempio n. 19
0
            private void GetFileLocations()
            {
                var aw     = ArchiveWorker.Load(Archive, true);
                var buffer = aw.GetBinaryFile(FileNames[1], true);

                if (buffer == null)
                {
                    return;
                }
                using (var br = new BinaryReader(new MemoryStream(buffer)))
                {
                    GetFileLocations(br);
                }
            }
Esempio n. 20
0
            protected void GetFileLocations()
            {
                ArchiveWorker aw = new ArchiveWorker(Archive, true);
                MemoryStream  ms = null;

                byte[] buffer = aw.GetBinaryFile(Filenames[1], true);
                if (buffer != null)
                {
                    using (BinaryReader br = new BinaryReader(ms = new MemoryStream(buffer)))
                    {
                        GetFileLocations(br);
                        ms = null;
                    }
                }
            }
Esempio n. 21
0
        //Splash is 640x400 16BPP typical TIM with palette of ggg bbbbb a rrrrr gg
        private void ReadSplash()
        {
            byte[] buffer     = ArchiveWorker.GetBinaryFile(Memory.Archives.A_MAIN, filename);
            uint   uncompSize = BitConverter.ToUInt32(buffer, 0);

            buffer = buffer.Skip(4).ToArray(); //hotfix for new LZSS
            buffer = LZSS.DecompressAllNew(buffer);

            tex = TIM2.Overture(buffer);
            //using (FileStream fs = File.Create(Path.Combine("D:\\main", Path.GetFileNameWithoutExtension(filename) + ".png")))
            //    splashTex.SaveAsPng(fs, splashTex.Width, splashTex.Height);

            GC.Collect();
            GC.WaitForPendingFinalizers();
        }
Esempio n. 22
0
        public void LoadFonts()
        {
            ArchiveWorker aw = new ArchiveWorker(Memory.Archives.A_MENU);
            string        sysfntTdwFilepath = aw.GetListOfFiles().First(x => x.ToLower().Contains("sysfnt.tdw"));
            string        sysfntFilepath    = aw.GetListOfFiles().First(x => x.ToLower().Contains("sysfnt.tex"));
            TEX           tex = new TEX(ArchiveWorker.GetBinaryFile(Memory.Archives.A_MENU, sysfntFilepath));

            sysfnt    = tex.GetTexture((int)ColorID.White);
            sysfntbig = TextureHandler.Create("sysfld{0:00}.tex", tex, 2, 1, (int)ColorID.White);

            TDW tim = new TDW(ArchiveWorker.GetBinaryFile(Memory.Archives.A_MENU, sysfntTdwFilepath), 0);

            charWidths = tim.CharWidths;
            menuFont   = tim.GetTexture((ushort)ColorID.White);
        }
Esempio n. 23
0
 public static void ResetModule()
 {
     publicModule   = 0;
     publicTimer    = 0.0f;
     bFadingIn      = true;
     bWaitingSplash = false;
     fSplashWait    = 0.0f;
     bFadingOut     = false;
     Fade           = 0;
     Memory.spriteBatch.GraphicsDevice.Clear(Color.Black);
     Memory.module = Memory.MODULE_OVERTURE_DEBUG;
     publicModule  = OverturepublicModule._4Squaresoft;
     Module_movie_test.ReturnState = Memory.MODULE_OVERTURE_DEBUG;
     aw = null; // was getting exception when running the overture again as the aw target changed.
 }
Esempio n. 24
0
            protected void LoadArchiveFiles_Simple()
            {
                var aw     = ArchiveWorker.Load(Archive, true);
                var buffer = aw.GetBinaryFile(FileNames[0], true);

                if (buffer == null)
                {
                    return;
                }
                using (var br = new BinaryReader(new MemoryStream(buffer, true)))
                {
                    StringFiles = new StringFile(1);
                    StringFiles.SubPositions.Add(Loc.CreateInstance(0, uint.MaxValue));
                    Get_Strings_Offsets(br, FileNames[0], 0);
                }
            }
Esempio n. 25
0
        public void LoadFonts()
        {
            Memory.Log.WriteLine($"{nameof(Font)} :: {nameof(LoadFonts)} ");
            var aw        = ArchiveWorker.Load(Memory.Archives.A_MENU);
            var bufferTex = aw.GetBinaryFile("sysfnt.tex");
            var tex       = new TEX(bufferTex);

            sysfnt    = tex.GetTexture((int)ColorID.White);
            sysfntbig = TextureHandler.Create("sysfld{0:00}.tex", tex, 2, 1, (int)ColorID.White);

            var bufferTDW = aw.GetBinaryFile("sysfnt.tdw");
            var tim       = new TDW(bufferTDW);

            charWidths = tim.CharWidths;
            menuFont   = tim.GetTexture((ushort)ColorID.White);
        }
Esempio n. 26
0
        protected virtual void InitEntries(ArchiveBase aw = null)
        {
            if (Entries != null)
            {
                return;
            }
            if (aw == null)
            {
                aw = ArchiveWorker.Load(ArchiveString);
            }
            MemoryStream ms;

            var buffer = aw.GetBinaryFile(IndexFilename);

            if (buffer == null)
            {
                return;
            }
            using (var br = new BinaryReader(ms = new MemoryStream(buffer)))
            {
                Count = br.ReadUInt32();
                var locations = new ushort[Count];
                Entries = new Dictionary <uint, Entry>((int)Count);
                for (uint i = 0; i < Count; i++)
                {
                    locations[i] = br.ReadUInt16();
                    ms.Seek(2, SeekOrigin.Current);
                }
                byte  fid  = 0;
                Entry last = null;
                for (uint i = 0; i < Count; i++)
                {
                    ms.Seek(locations[i] + 6, SeekOrigin.Begin);
                    var t = br.ReadByte();
                    if (t == 0 || t == 96) // known invalid entries in sp2 files have this value. there might be more to it.
                    {
                        Count = i;
                        break;
                    }

                    Entries[i] = new Entry();
                    Entries[i].LoadfromStreamSP2(br, locations[i], last, ref fid);

                    last = Entries[i];
                }
            }
        }
Esempio n. 27
0
            public static Data LoadInitOut()
            {
                Memory.Log.WriteLine($"{nameof(Saves)} :: {nameof(Data)} :: {nameof(LoadInitOut)} ");
                ArchiveBase aw = ArchiveWorker.Load(Memory.Archives.A_MAIN, true);

                byte[] buffer = aw.GetBinaryFile("init.out");
                if (buffer != null && buffer.Length > 0)
                {
                    using (BinaryReader br = new BinaryReader(new MemoryStream(buffer)))
                    {
                        Data data = new Data();
                        data.ReadInitOut(br);
                        return(data);
                    }
                }
                return(null);
            }
Esempio n. 28
0
        protected virtual void InitEntries(ArchiveWorker aw = null)
        {
            if (Entries == null)
            {
                if (aw == null)
                {
                    aw = new ArchiveWorker(ArchiveString);
                }
                MemoryStream ms = null;

                ushort[] locs;
                byte[]   buffer = aw.GetBinaryFile(IndexFilename);
                if (buffer != null)
                {
                    using (BinaryReader br = new BinaryReader(ms = new MemoryStream(buffer)))
                    {
                        Count   = br.ReadUInt32();
                        locs    = new ushort[Count];//br.ReadUInt32(); 32 valid values in face.sp2 rest is invalid
                        Entries = new Dictionary <uint, Entry>((int)Count);
                        for (uint i = 0; i < Count; i++)
                        {
                            locs[i] = br.ReadUInt16();
                            ms.Seek(2, SeekOrigin.Current);
                        }
                        byte  fid  = 0;
                        Entry Last = null;
                        for (uint i = 0; i < Count; i++)
                        {
                            ms.Seek(locs[i] + 6, SeekOrigin.Begin);
                            byte t = br.ReadByte();
                            if (t == 0 || t == 96) // known invalid entries in sp2 files have this value. there might be more to it.
                            {
                                Count = i;
                                break;
                            }

                            Entries[i] = new Entry();
                            Entries[i].LoadfromStreamSP2(br, locs[i], Last, ref fid);

                            Last = Entries[i];
                        }
                        ms = null;
                    }
                }
            }
        }
Esempio n. 29
0
        /// <summary>
        /// Load Archive with out storing FS in byte[] works for archive that aren't compressed.
        /// </summary>
        /// <param name="path">Archive file archive.</param>
        /// <param name="fI">Stream containing the FI file</param>
        /// <param name="fS">Archive where the FS file is.</param>
        /// <param name="fL">Stream containing the FL file</param>
        /// <param name="skipList">Skip generating list of files</param>
        /// <returns>ArchiveWorker</returns>
        public static ArchiveBase Load(Memory.Archive path, StreamWithRangeValues fI, ArchiveBase fS, StreamWithRangeValues fL, bool skipList = false)
        {
            if (CacheTryGetValue(path, out var value))
            {
                return(value);
            }

            value = new ArchiveWorker(path, fI, fS, fL, skipList);
            if (!value.IsOpen)
            {
                value = null;
            }
            if (CacheTryAdd(path, value))
            {
            }
            return(value);
        }
Esempio n. 30
0
        protected virtual void InitTextures <T>(ArchiveBase aw = null) where T : Texture_Base, new()
        {
            var count = (int)Props.Sum(x => x.Count);

            if (Textures == null)
            {
                Textures = new List <TextureHandler>(count);
            }
            if (Textures.Count <= 0)
            {
                if (aw == null)
                {
                    aw = ArchiveWorker.Load(ArchiveString);
                }
                T tex;
                Scale = new Dictionary <uint, Vector2>(count);
                var b = 0;
                for (var j = 0; j < Props.Count; j++)
                {
                    for (uint i = 0; i < Props[j].Count; i++)
                    {
                        tex = new T();
                        var buffer = aw.GetBinaryFile(string.Format(Props[j].Filename, i + TextureStartOffset));
                        if (buffer != null)
                        {
                            tex.Load(buffer);

                            if (Props[j].Big != null && ForceOriginal == false && b < Props[j].Big.Count)
                            {
                                var th = TextureHandler.Create(Props[j].Big[b].Filename, tex, 2, Props[j].Big[b++].Split / 2);

                                Textures.Add(th);
                                Scale[i] = Vector2.One;
                            }
                            else
                            {
                                var th = TextureHandler.Create(Props[j].Filename, tex);
                                Textures.Add(th);
                                Scale[i] = th.GetScale(); //scale might not be used outside of texturehandler.
                            }
                        }
                    }
                }
            }
        }