Beispiel #1
0
        public sFolder Unpack(sFile file)
        {
            if (file.name.ToUpper().EndsWith(".PAC_") || file.name.ToUpper().EndsWith(".PAC"))
            {
                return(PAC.Unpack(file));
            }

            if (file.name.ToUpper().EndsWith(".SPF_"))
            {
                return(SFP.Unpack(file.path, file.path));
            }

            if (file.name.ToUpper().EndsWith(".PKB"))
            {
                sFile pkh = pluginHost.Search_File((short)(file.id + 1));
                if (Path.GetFileNameWithoutExtension(pkh.name) != Path.GetFileNameWithoutExtension(file.name))
                {
                    Console.WriteLine("Error searching header file");
                    return(new sFolder());
                }

                return(PKB.Unpack(file, pkh));
            }

            if (file.name.ToUpper().EndsWith(".SPD"))
            {
                sFile spl = pluginHost.Search_File((short)(file.id + 1));
                if (Path.GetFileNameWithoutExtension(spl.name) != Path.GetFileNameWithoutExtension(file.name))
                {
                    Console.WriteLine("Error searching header file");
                    return(new sFolder());
                }

                return(SFP.Unpack(spl.path, file.path));
            }

            if (gameCode == "BOEJ")
            {
                if (file.id == 0x110)
                {
                    return(Encryption.Decrypt(file, 0x2C, pluginHost));
                }
                else if (file.id == 0x18A)
                {
                    return(Encryption.Decrypt(file, 0x48, pluginHost));
                }
            }

            return(new sFolder());
        }
Beispiel #2
0
        public string Pack(ref sFolder unpacked, sFile file)
        {
            string fileout = pluginHost.Get_TempFile();

            if (file.name.ToUpper().EndsWith(".PAC_") || file.name.ToUpper().EndsWith(".PAC"))
            {
                Console.WriteLine("Packing to " + fileout);
                PAC.Pack(ref unpacked, fileout);
                return(fileout);
            }
            else if (file.name.ToUpper().EndsWith(".PKB"))
            {
                sFile pkh = pluginHost.Search_File((short)(file.id + 1));

                Console.WriteLine("Packing to " + fileout);
                PKB.Pack(ref unpacked, pkh, fileout, pluginHost);
                return(fileout);
            }
            else if (file.name.ToUpper().EndsWith(".SPF_"))
            {
                SFP.Pack(ref unpacked, fileout, fileout, false);
                return(fileout);
            }
            else if (file.name.ToUpper().EndsWith(".SPD"))
            {
                string spl_out = pluginHost.Get_TempFile();
                SFP.Pack(ref unpacked, spl_out, fileout, true);

                pluginHost.ChangeFile(file.id + 1, spl_out);    // Change SPL file
                return(fileout);                                // Return new SPD file
            }

            if (gameCode == "BOEJ")
            {
                if (file.id == 0x110)
                {
                    Encryption.Encrypt(unpacked.files[0].path, 0x2C, fileout);
                }
                else if (file.id == 0x18A)
                {
                    Encryption.Encrypt(unpacked.files[0].path, 0x48, fileout);
                }
                return(fileout);
            }

            return(null);
        }