Esempio n. 1
0
        static void Main(string[] args)
        {
            string[] files = args.Where(x => Path.GetExtension(x) == ".wpg" && File.Exists(x)).ToArray();

            Console.WriteLine("");
            Console.WriteLine("IronSight Model,Texture & Audio Ripper by JariK (With a lot of help from Scobalula & DTZxPorter)");
            Console.WriteLine("To export sounds from fsb files use the following program: http://aluigi.altervista.org/papers.htm#fsbext");
            Console.WriteLine("");

            if (files.Length < 1)
            {
                Console.WriteLine("No valid WPG Files given.");
            }

            foreach (var file in files)
            {
                if (!ScobUtil.CanAccessFile(file))
                {
                    Console.WriteLine(string.Format("File {0} is in-use or permissions were denied", Path.GetFileName(file)));
                    continue;
                }

                try
                {
                    WPGFile.Decode(file);
                }
                catch (Exception e)
                {
                    Console.Write(e);
                }
            }

            Console.WriteLine("");
            Console.WriteLine(string.Format("{0} WPG File(s) Processed.", files.Length));
            Console.WriteLine("");
            Console.WriteLine("Press enter to exit");
            Console.ReadLine();
        }
Esempio n. 2
0
        static private void SearchWPGAsset(int startIndex, int AssetCount, BinaryReader streamReader)
        {
            // Go through all assets
            for (int i = startIndex; i < AssetCount + 1; i += 1)
            {
                // Go to the first byte of the assetinfo
                streamReader.Seek(i * 140, SeekOrigin.Begin);

                // Get all the needed info
                string AssetName     = streamReader.ReadFixedString(128);
                int    Assetlocation = streamReader.ReadInt32();
                int    AssetLength   = streamReader.ReadInt32();
                int    AssetFlag     = streamReader.ReadInt32();
                string AssetFileType = Path.GetExtension(AssetName.Replace("-", "_"));

                // Only export models, textures or sound files
                if (AssetFileType == ".msh" || AssetFileType == ".dds" || AssetFileType == ".fsb" /*|| AssetFileType == ".bea" || AssetFileType == ".gad"*/)
                {
                    // Go to the asset data
                    streamReader.Seek(Assetlocation, SeekOrigin.Begin);

                    Console.WriteLine("Exporting file  : " + AssetName);

                    int    unpackedSize     = streamReader.ReadInt32();
                    byte[] EncryptionNumber = streamReader.ReadBytes(2);
                    // Checking if the asset uses zlib as encryption
                    if (EncryptionNumber[0] == 0x78 && EncryptionNumber[1] == 0x9C)
                    {
                        // Get the location to export the asset
                        string ProgramPath  = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
                        string OutputFolder = ProgramPath + "\\exported_files\\" + AssetName;
                        ScobUtil.CreateFilePath(ProgramPath + "\\exported_files\\" + AssetName);

                        // Skip the files that already are exported
                        if (File.Exists(ProgramPath + "\\exported_files\\" + AssetName))
                        {
                            if (new FileInfo(ProgramPath + "\\exported_files\\" + AssetName).Length == unpackedSize)
                            {
                                continue;
                            }
                        }

                        // Decode the data
                        MemoryStream DecodedCodeStream = DeflateUtil.Decode(streamReader.ReadBytes(AssetLength - 6));

                        // Export raw data for files
                        using (var outputStream = new FileStream(OutputFolder, FileMode.Create))
                        {
                            DecodedCodeStream.CopyTo(outputStream);
                            // Check if its a model that needs to be parsed
                            if (AssetFileType == ".msh")
                            {
                                outputStream.Close();
                                MshFile.Decode(OutputFolder);
                            }
                            // Animations arent parsed right yet (Joint rotations on anims arent working correctly)

                            /*// Check if its an animation that needs to be parsed
                             * else if(AssetFileType == ".bea" || AssetFileType == ".gad")
                             * {
                             *  outputStream.Close();
                             *  BeaFile.Decode(OutputFolder);
                             * }*/
                        }
                    }
                }
            }
        }