Example #1
0
        // Rick has 2 exports as of today
        //      - CID_A_112_Athena_Commando_M_Ruckus
        //      - FortCosmeticCharacterPartVariant_0
        //
        // this example will show you how to get them all or just one of them

        public static void Main(string[] args)
        {
            var provider = new DefaultFileProvider(_gameDirectory, SearchOption.TopDirectoryOnly, true);

            provider.Initialize();                                 // will scan local files and read them to know what it has to deal with (PAK/UTOC/UCAS/UASSET/UMAP)
            provider.SubmitKey(new FGuid(), new FAesKey(_aesKey)); // decrypt basic info (1 guid - 1 key)

            provider.LoadMappings();                               // needed to read Fortnite assets
            provider.LoadLocalization(ELanguage.French);           // explicit enough

            // these 2 lines will load all exports the asset has and transform them in a single Json string
            var allExports = provider.LoadObjectExports(_objectPath);
            var fullJson   = JsonConvert.SerializeObject(allExports, Formatting.Indented);

            // each exports have a name, these 2 lines will load only one export the asset has
            // you must use "LoadObject" and provide the full path followed by a dot followed by the export name
            var variantExport = provider.LoadObject(_objectPath + "." + _objectName);
            var variantJson   = JsonConvert.SerializeObject(variantExport, Formatting.Indented);
        }
Example #2
0
        public static bool SwapZlib(api.Item item, bool Converting)
        {
            const string ProSwapperPakFolder = "Pro Swapper Lobby";
            string       PaksLocation        = global.CurrentConfig.Paks;
            //Load the exporter
            List <string> thesefiles = new List <string>();

            foreach (var Asset in item.Asset)
            {
                thesefiles.Add(Path.GetFileNameWithoutExtension(Asset.UcasFile));
            }

            List <string> UsingFiles = thesefiles.Distinct().ToList();

            if (!global.CanSwap(UsingFiles))
            {
                return(false);
            }

            foreach (string file in UsingFiles)
            {
                string BaseFileName = $"{PaksLocation}\\{ProSwapperPakFolder}\\{file}";


                //Check if it may be old game version
                string OriginalSig = global.FileToMd5($"{PaksLocation}\\{file}.sig");
                string ModifiedSig = global.FileToMd5(BaseFileName + ".sig");
                if (OriginalSig != ModifiedSig)
                {
                    Lobby.RevertAllLobbySwaps();
                }


                if (!File.Exists(BaseFileName + ".pak"))
                {
                    Directory.CreateDirectory(PaksLocation + $"\\{ProSwapperPakFolder}");
                    File.Copy($"{PaksLocation}\\{file}.sig", BaseFileName + ".sig", true);
                    File.Copy($"{PaksLocation}\\{file}.utoc", BaseFileName + ".utoc", true);
                    File.Copy($"{PaksLocation}\\{file}.ucas", BaseFileName + ".ucas", true);
                    File.Copy($"{PaksLocation}\\{file}.pak", BaseFileName + ".pak", true);
                }
            }

            var Provider = new DefaultFileProvider($"{PaksLocation}\\{ProSwapperPakFolder}", SearchOption.TopDirectoryOnly);

            Provider.Initialize(UsingFiles);


            //Load all aes keys for required files, cleaner in linq than doing a loop
            Provider.UnloadedVfs.All(x => { Provider.SubmitKey(x.EncryptionKeyGuid, api.AESKey); return(true); });


            List <FinalPastes> finalPastes = new List <FinalPastes>();

            foreach (api.Asset asset in item.Asset)
            {
                string ucasfile = $"{PaksLocation}\\{ProSwapperPakFolder}\\{asset.UcasFile}";

                //Checking if file is readonly coz we wouldn't be able to do shit with it
                File.SetAttributes(ucasfile, global.RemoveAttribute(File.GetAttributes(ucasfile), FileAttributes.ReadOnly));

                foreach (string srch in asset.Search)
                {
                    SearchString = srch;

                    Fortnite.FortniteExport.ExportAsset(Provider, asset.UcasFile, asset.AssetPath);

                    byte[] edited = EditAsset(zlibblock.decompressed, asset, Converting, out bool Compress); //Compressed edited path

                    byte[] towrite = ByteCompression.Compress(edited);                                       //Compress to zlib

                    towrite = FillEnd(towrite, zlibblock.compressed.Length);

                    finalPastes.Add(new FinalPastes(ucasfile, towrite, zlibblock.BlockStart));
                }

                //                if (Converting)
                //                    SearchString = asset.Search[0];
                //                else
                //                    SearchString = asset.Replace[0];
                //                //Use this to define zlibblock var
                //                Fortnite.FortniteExport.ExportAsset(Provider, asset.UcasFile, asset.AssetPath);
                //#if DEBUG
                //                Directory.CreateDirectory("Exports");

                //                string smallname = Path.GetFileName(asset.AssetPath);
                //                File.WriteAllBytes($"Exports\\Exported_{smallname}.pak", zlibblock.decompressed);//Just simple export
                //                                                                                                 // File.WriteAllBytes($"Exports\\RawExport_{smallname}.pak", RawExported);//Uncompress exported by CUE4Parse

                //#endif
                //                //edit files and compress with oodle and replace
                //                byte[] edited = EditAsset(zlibblock.decompressed, asset, Converting, out bool Compress);//Compressed edited path
                //                if (!Compress)//File hasnt gotten any changes, no need to edit files that havent changed
                //                    continue;


                //                byte[] towrite = ByteCompression.Compress(edited);//Compress to zlib

                //                towrite = FillEnd(towrite, zlibblock.compressed.Length);
                //#if DEBUG
                //                //Logging stuff for devs hehe
                //                File.WriteAllBytes($"Exports\\Edited_{smallname}.pak", edited);//Edited export
                //                File.WriteAllBytes($"Exports\\Compressed{smallname}.pak", towrite);//Compressed edited export

                //#endif
                //                finalPastes.Add(new FinalPastes(ucasfile, towrite, zlibblock.BlockStart));
            }

            Provider.Dispose();
            foreach (FinalPastes pastes in finalPastes)
            {
                PasteInLocationBytes(pastes);
            }

            return(true);
        }
Example #3
0
        public static bool SwapItem(api.Item item, bool Converting)
        {
            const string  ProSwapperPakFolder = ".ProSwapper";
            List <string> UsingFiles          = new List <string>();

            UsingFiles.AddRange(item.Asset.Select(x => Path.GetFileNameWithoutExtension(x.UcasFile)).Distinct());
            if (!global.CanSwap(UsingFiles))
            {
                return(false);
            }

            foreach (string file in UsingFiles)
            {
                string BaseFileName = $"{PaksLocation}\\{ProSwapperPakFolder}\\{file}";

                //Check if it may be old game version
                string OriginalSig = global.FileToMd5($"{PaksLocation}\\{file}.sig");
                string ModifiedSig = global.FileToMd5(BaseFileName + ".sig");
                if (OriginalSig != ModifiedSig)
                {
                    global.DeleteFile(BaseFileName + ".sig");
                    global.DeleteFile(BaseFileName + ".utoc");
                    global.DeleteFile(BaseFileName + ".ucas");
                    global.DeleteFile(BaseFileName + ".pak");
                }


                if (!File.Exists(BaseFileName + ".ucas"))
                {
                    Directory.CreateDirectory(PaksLocation + $"\\{ProSwapperPakFolder}");
                    File.Copy($"{PaksLocation}\\{file}.sig", BaseFileName + ".sig", true);
                    File.Copy($"{PaksLocation}\\{file}.utoc", BaseFileName + ".utoc", true);
                    File.Copy($"{PaksLocation}\\{file}.ucas", BaseFileName + ".ucas", true);
                    File.Copy($"{PaksLocation}\\{file}.pak", BaseFileName + ".pak", true);
                }
            }

            var Provider = new DefaultFileProvider($"{PaksLocation}\\{ProSwapperPakFolder}", SearchOption.TopDirectoryOnly);

            Provider.Initialize(UsingFiles);

            //Load all aes keys for required files, cleaner in linq than doing a loop
            Provider.UnloadedVfs.All(x => { Provider.SubmitKey(x.EncryptionKeyGuid, api.AESKey); return(true); });

            List <FinalPastes> finalPastes = new List <FinalPastes>();

            foreach (api.Asset asset in item.Asset)
            {
                string ucasfile = $"{PaksLocation}\\{ProSwapperPakFolder}\\{asset.UcasFile}";
                File.SetAttributes(ucasfile, global.RemoveAttribute(File.GetAttributes(ucasfile), FileAttributes.ReadOnly));
                byte[] exportasset = Fortnite.FortniteExport.ExportAsset(Provider, asset.UcasFile, asset.AssetPath);
                // Directory.CreateDirectory("Exports");

                string smallname = Path.GetFileName(asset.AssetPath);
#if DEBUG
                File.WriteAllBytes($"Exports\\Exported_{smallname}.pak", exportasset);//Just simple export
#endif
                if (EditAsset(ref exportasset, asset, Converting))
                {
#if DEBUG
                    File.WriteAllBytes($"Exports\\Edited_{smallname}.pak", exportasset);//Edited export
#endif
                    exportasset = Oodle.OodleClass.Compress(exportasset);
                    //Logging stuff for devs hehe
                    // File.WriteAllBytes($"Exports\\Compressed{smallname}.pak", exportasset);//Compressed edited export
                    finalPastes.Add(new FinalPastes(ucasfile, exportasset, Fortnite.FortniteExport.Offset));
                }
            }
            Provider.Dispose();
            foreach (FinalPastes pastes in finalPastes)
            {
                PasteInLocationBytes(pastes);
            }

            return(true);
        }