コード例 #1
0
 public static void Initialize()
 {
     ModuleMgr  = ModuleManager.GetInstance();
     PatchMgr   = PatchManager.GetInstance();
     RealmMgr   = RealmManager.GetInstance();
     SessionMgr = SessionManager.GetInstance();
 }
コード例 #2
0
    public GUIterrainPatch(int patchSize)
    {
        pm = new PatchManager(patchSize);
        this.patchSize = patchSize;

        UpdatePatchAttributes();
        SetDefaultPatch(DefaultTerrain.hillGrid);
    }
コード例 #3
0
    public TerrainGenerator(int patchSize)
    {
        //initialize(64,3);
        ds = new DiamondSquare(this, patchSize);
        rt = new RandomTerrain(this);
        this.patchSize = patchSize;
        try
        {
            GUIterrainPlannerMenu tpMenu = GameObject.Find("TerrainPlanner").GetComponent<GUIterrainPlannerMenu>();
            pm = tpMenu.patch.pm;
            gtp = tpMenu.patch;
            extraPatchCount = tpMenu.patch.extraPatchCount;
        }
        catch (Exception e)
        {
            Debug.Log("TerrainPlanner not found");
            //pm = new PatchManager(patchSize);
            gtp = new GUIterrainPatch(patchSize);
            gtp.SetDefaultPatch(DefaultTerrain.valleys);
            pm = gtp.pm;

            extraPatchCount = 0;
        }
    }
コード例 #4
0
 /// <summary>
 /// updates patchSize
 /// resets PatchManager
 /// </summary>
 public void UpdatePatchSize(int patchSize)
 {
     this.patchSize = patchSize;
     UpdatePatchAttributes();
     pm = new PatchManager(patchSize);
     SetRandomPatchLevel(patchCount);
 }
コード例 #5
0
ファイル: Program.cs プロジェクト: GovanifY/KH1FM_Toolkit
        private static void PatchISO(KH1ISOReader input, KH1ISOWriter output, PatchManager files, bool ocompress,
            string oextHead)
        {
            int number = 1;
            output.writeHeader(oextHead);//Let's copy the header
            //Console.WriteLine("Adding header using {0} source",  ? "external" : "internal");//TODO: Delete this Console.WriteLine
            for (int i = 0, idxC = input.idxEntries.Count; i < idxC; ++i)
            {
                IDXEntry entry = input.idxEntries[i];
                if (entry.hash == 0x0392ebe4)
                {
                    continue;
                } //kingdom.img

                if (entry.hash == 0x0393eba4) //kingdom.idx
                {
                    Console.WriteLine("[KINGDOM: {0}/{1}]\tKINGDOM.IDX", number, input.idxEntries.Count - 1);
                        //-1 'cause of the file KINGDOM.IMG
                    number++;
                    output.writeDummyIDX(idxC);
                    continue;
                }

                //Loading the patch
                UInt32 flags = 0;
                PatchManager.Patch patch;
                Stream s = null;
                uint h = 0;
                // Could make sure the parents match perfectly, but there's only 1 of every name anyway.
                // So I'll settle for just making sure the file isn't made for the ISO.
                if (Patches.patches.TryGetValue(entry.hash, out patch) && /*patch.Parent == parenthash*/!patch.IsinISO) {s = patch.Stream; h = patch.Hash; }
                    string name;
                    if (!HashList.pairs.TryGetValue(entry.hash, out name))
                    {
                        name = String.Format("@noname/{0:x8}.bin", entry.hash);
                    }
                    if (s == null)
                    {
                    flags = entry.flags;//FLAGS NEEDS TO BE OR 0 IF NOTHING, OR 1 IF COMPRESSED, OR THE NAME TO RELINK TO IF IT NEEDS TO

                    if (h != 0)
                    {
                        if (patch.Compressed) { flags = 1; }
                        else if (patch.IsRelink) { flags = patch.Relink; }
                    }

                    if (flags > 1)
                        {
                            Console.WriteLine("[KINGDOM: {0}/{1}]\t{2}\tRelinking...", number, input.idxEntries.Count - 1, name); //-1 'cause of the file KINGDOM.IMG
                            number++;
                            /*if (!HashList.pairs.TryGetValue(flags, out name))
                            {
                                name = String.Format("@noname/{0:x8}.bin", flags);
                            }
                            Console.WriteLine("{0}", name);*///Err...what is this crappy code? No but srsly
                            output.addRelink(entry.hash, flags);
                        }
                        else
                        {
                            Console.WriteLine("[KINGDOM: {0}/{1}]\t{2}", number, input.idxEntries.Count - 1, name);
                                //-1 'cause of the file KINGDOM.IMG
                            number++;
                            output.copyFile(entry);
                        }
                    }
                    else
                    {
                        Console.WriteLine("[KINGDOM: {0}/{1}]\t{2}\tPatching...", number, input.idxEntries.Count - 1, name); //-1 'cause of the file KINGDOM.IMG
                        number++;
                            output.importFile(s, entry.hash, flags);
                    }
            }
            output.finalize();
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("New ISO finished!");
            Console.ResetColor();
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: GovanifY/KH1FM_Toolkit
        private static void Main(string[] args)
        {
            bool obatch = false;
            try
            {
                // Some functions work with raw bits, so we HAVE to be using little endian.
                // .NET, however, supports running the same code on both types.
                if (BitConverter.IsLittleEndian != true)
                {
                    throw new PlatformNotSupportedException(
                        "Platform not supported, not using a little endian bitconverter");
                }
                HashList.loadHashPairs();
                Console.Title = KH1ISOReader.program.ProductName + " " + KH1ISOReader.program.FileVersion + " [" +
                                KH1ISOReader.program.CompanyName + "]";
                bool ocompress = true, oupdateHeads = true, extract = false;
                string iso = "", oextHead = "", NewIso;

                #region Arguments

                for (int i = 0, argc = args.Length; i < argc; ++i)
                {
                    switch (args[i].ToLower())
                    {
                        case "-batch":
                            obatch = true;
                            break;
                        case "-nocompress":
                            ocompress = false;
                            break;
                        case "-extractor":
                            extract = true;
                            break;
                        case "-advancedinfo":
                            _advanced = true;
                            break;
            #if DEBUG
                        case "-noupisohead":
                            oupdateHeads = false;
                            break;
                        case "-externalhead":
                            if (++i < argc && (oextHead = args[i]).Length != 0)
                            {
                                break;
                            }
                            oextHead = "KH1ISOMake-head.bin";
                            break;
            #endif
                        case "-patchmaker":
                            KH1_Patch_Maker.Program.Mainp(args);
                            break;
                        default:
                            if (File.Exists(args[i]))
                            {
                                if (args[i].EndsWith(".iso", StringComparison.InvariantCultureIgnoreCase))
                                {
                                    iso = args[i];
                                }
                                else if (args[i].EndsWith(".kh1patch", StringComparison.InvariantCultureIgnoreCase))
                                {
                                    Patches.AddPatch(args[i]);
                                }
                            }
                            break;
                    }
                }

                #endregion

                #region Description
                using (var files = new PatchManager())
                {
                    if (iso.Length == 0)
                    {
                        iso = "KHFM.ISO";
                    }
                    Console.ForegroundColor = ConsoleColor.Gray;
                    DateTime Builddate = RetrieveLinkerTimestamp();
                    Console.Write("{0}\nBuild Date: {2}\nVersion {1}", KH1ISOReader.program.ProductName,
                        KH1ISOReader.program.FileVersion, Builddate);
                    Console.ResetColor();
            #if DEBUG
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.Write("\nPRIVATE RELEASE\n");
                    Console.ResetColor();
            #else
                Console.Write("\nPUBLIC RELEASE\n");
            #endif

                    Console.ForegroundColor = ConsoleColor.DarkMagenta;
                    Console.Write(
                        "\nProgrammed by {0}\nhttp://www.govanify.com\nhttp://www.twitter.com/GovanifY",
                        KH1ISOReader.program.CompanyName);
                    Console.ForegroundColor = ConsoleColor.Gray;
                    if (extract)
                    {
                        Console.Write(
                            "\n\nThis tool is able to extract the files of the game Kingdom Hearts 1(Final Mix).\nHe's using a list for extracting files with their real name which isn't completeBut this is the most complete one for now.\nHe can extract the files stored which got a reference into KINGDOM.IDX.\n\n");
                    }
                    else
                    {
                        Console.Write(
                            "\n\nThis tool is able to patch the game Kingdom Hearts 1(Final Mix).\nHe can modify iso files, like the elf and internal files,\nwich are stored inside the hidden file KINGDOM.IMG\nThis tool is recreating too new hashes into the idx files for avoid\na corrupted game. He can add some files too.\n\n");
                    }
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.Write("\nPress enter to run using the file:");
                    Console.ResetColor();
                    Console.Write(" {0}", iso);
                    Console.ReadLine();

                    #endregion

                    NewIso = Path.ChangeExtension(iso, "NEW.ISO");
                    using (var input = new KH1ISOReader(iso))
                    {
                        if (extract)
                        {
                            ExtractISO(iso, input);
                        }
                        else
                        {
                            if (Patches.patches.Count == 0)
                            {
                                WriteWarning("No patches loaded!");
                            }
                            else
                            {
                                try
                                {
                                    using (var output = new KH1ISOWriter(NewIso, input, oupdateHeads))
                                    {
                                        PatchISO(input, output, files, ocompress, oextHead);
                                    }
                                }
                                catch (Exception)
                                {
                                    //Delete the new "incomplete" iso
                                    File.Delete(NewIso);
                                    throw;
                                }
                            }
                        }
                    }
                }
            }
            catch (FileNotFoundException e)
            {
                WriteWarning("Failed to open file: " + e.Message);
            }
            catch (Exception e)
            {
                WriteWarning(
                    "An error has occured when trying to open your iso:\n{1}: {0}\n{2}",
                    e.Message, e.GetType().FullName, e.StackTrace);
            }
            Patches.Dispose();
            if (!obatch)
            {
                Console.Write("Press enter to exit..."); Console.ReadLine();
            }
        }
コード例 #7
0
        private void InstallGamePatch(Launcher.LoginResult loginResult, bool gateStatus)
        {
            var mutex = new Mutex(false, "XivLauncherIsPatching");

            if (mutex.WaitOne(0, false))
            {
                if (Util.CheckIsGameOpen())
                {
                    MessageBox.Show(
                        Loc.Localize("GameIsOpenError", "The game and/or the official launcher are open. XIVLauncher cannot patch the game if this is the case.\nPlease close the official launcher and try again."),
                        "XIVLauncher", MessageBoxButton.OK, MessageBoxImage.Exclamation);

                    this.Dispatcher.Invoke(() =>
                    {
                        this.Show();
                        _isLoggingIn = false;
                    });
                }
                else
                {
                    Debug.Assert(loginResult.State == Launcher.LoginState.NeedsPatchGame,
                                 "loginResult.State == Launcher.LoginState.NeedsPatchGame ASSERTION FAILED");

                    var patcher = new PatchManager(Repository.Ffxiv, loginResult.PendingPatches, App.Settings.GamePath, App.Settings.PatchPath, _installer);

                    var progressDialog = new PatchDownloadDialog(patcher);
                    progressDialog.Show();
                    this.Hide();

                    patcher.OnFinish += async(sender, args) =>
                    {
                        progressDialog.Dispatcher.Invoke(() => progressDialog.Close());

                        if (args)
                        {
                            await this.Dispatcher.Invoke(() => StartGameAndAddon(loginResult, gateStatus));

                            _installer.Stop();
                        }
                        else
                        {
                            this.Dispatcher.Invoke(() =>
                            {
                                this.Show();
                                _isLoggingIn = false;
                            });
                        }

                        mutex.Close();
                        mutex = null;
                    };

                    patcher.Start();
                }
            }
            else
            {
                MessageBox.Show(Loc.Localize("PatcherAlreadyInProgress", "XIVLauncher is already patching your game in another instance. Please check if XIVLauncher is still open."), "XIVLauncher", MessageBoxButton.OK, MessageBoxImage.Error);
                Environment.Exit(0);
            }
        }
コード例 #8
0
        private void HandleBootCheck(Action whenFinishAction)
        {
            try
            {
                App.Settings.PatchPath ??= new DirectoryInfo(Path.Combine(Paths.RoamingPath, "patches"));

                Game.Patch.PatchList.PatchListEntry[] bootPatches = null;
                try
                {
                    bootPatches = _launcher.CheckBootVersion(App.Settings.GamePath);
                }
                catch (Exception ex)
                {
                    Log.Error(ex, "Unable to check boot version.");
                    MessageBox.Show(Loc.Localize("CheckBootVersionError", "XIVLauncher was not able to check the boot version for the select game installation. This can happen if a maintenance is currently in progress or if your connection to the version check server is not available. Please report this error if you are able to login with the official launcher, but not XIVLauncher."), "XIVLauncher", MessageBoxButton.OK, MessageBoxImage.Error);

                    _isLoggingIn = false;

                    Task.Run(SetupHeadlines);
                    Show();
                    Activate();
                    return;
                }

                if (bootPatches != null)
                {
                    var mutex = new Mutex(false, "XivLauncherIsPatching");
                    if (mutex.WaitOne(0, false))
                    {
                        if (Util.CheckIsGameOpen())
                        {
                            MessageBox.Show(
                                Loc.Localize("GameIsOpenError",
                                             "The game and/or the official launcher are open. XIVLauncher cannot patch the game if this is the case.\nPlease close the official launcher and try again."),
                                "XIVLauncher", MessageBoxButton.OK, MessageBoxImage.Exclamation);

                            Environment.Exit(0);
                            return;
                        }

                        var patcher = new PatchManager(Repository.Boot, bootPatches, App.Settings.GamePath,
                                                       App.Settings.PatchPath, _installer);

                        var progressDialog = new PatchDownloadDialog(patcher);
                        progressDialog.Show();
                        this.Hide();

                        patcher.OnFinish += (sender, args) =>
                        {
                            if (args)
                            {
                                progressDialog.Dispatcher.Invoke(() => progressDialog.Close());
                                whenFinishAction?.Invoke();
                            }
                            else
                            {
                                this.Dispatcher.Invoke(() =>
                                {
                                    this.Show();
                                    _isLoggingIn = false;
                                });
                            }

                            mutex.Close();
                            mutex = null;
                        };

                        patcher.Start();
                    }
                    else
                    {
                        MessageBox.Show(Loc.Localize("PatcherAlreadyInProgress", "XIVLauncher is already patching your game in another instance. Please check if XIVLauncher is still open."), "XIVLauncher", MessageBoxButton.OK, MessageBoxImage.Error);
                        Environment.Exit(0);
                    }
                }
                else
                {
                    whenFinishAction?.Invoke();
                }
            }
            catch (Exception ex)
            {
                new ErrorWindow(ex, "Could not patch boot.", nameof(HandleBootCheck)).ShowDialog();
                Environment.Exit(0);
            }
        }
コード例 #9
0
        public void PatchingExec_SkipPatch_MoreFaultyChains()
        {
            // Faulty execution blocks the following patches on the same component.
            var packages = new List <Package[]>();
            var log      = new List <PatchExecutionLogRecord>();

            void LogMessage(PatchExecutionLogRecord record)
            {
                packages.Add(LoadPackages());
                log.Add(record);
            }

            var executed = new List <ISnPatch>();

            void Execute(PatchExecutionContext peContext) => executed.Add(peContext.CurrentPatch);

            var patches = new ISnPatch[]
            {
                // Problem in the installer
                Patch("C1", "2.0 <= v < 3.0", "v3.0", Execute),
                Patch("C1", "1.0 <= v < 2.0", "v2.0", Execute),
                Inst("C1", "v1.0", null, Error),
                // Problem in a middle patch
                Patch("C2", "2.0 <= v < 3.0", "v3.0", Execute),
                Patch("C2", "1.0 <= v < 2.0", "v2.0", Error),
                Inst("C2", "v1.0", null, Execute),
                // There is no problem
                Patch("C3", "2.0 <= v < 3.0", "v3.0", Execute),
                Patch("C3", "1.0 <= v < 2.0", "v2.0", Execute),
                Inst("C3", "v1.0", null, Execute),
            };

            // ACTION
            var context = new PatchExecutionContext(null, LogMessage);
            var pm      = new PatchManager(context);

            pm.ExecuteRelevantPatches(patches, context);

            // ASSERT
            Assert.AreEqual(5, context.Errors.Count);
            Assert.AreEqual("ErrorInExecution C1: 1.0, " +
                            "MissingVersion C1: 1.0 <= v < 2.0 --> 2.0, " +
                            "MissingVersion C1: 2.0 <= v < 3.0 --> 3.0, " +
                            "ErrorInExecution C2: 1.0 <= v < 2.0 --> 2.0, " +
                            "MissingVersion C2: 2.0 <= v < 3.0 --> 3.0",
                            ErrorsToString(context));

            Assert.AreEqual("C2i1.0 C3i1.0 C3p2.0 C3p3.0", PatchesToString(executed.ToArray()));
            Assert.AreEqual(17, log.Count);
            Assert.AreEqual("[C1: 1.0] ExecutionStart.", log[0].ToString());
            Assert.AreEqual("[C1: 1.0] ExecutionError. Err", log[1].ToString());
            Assert.AreEqual("[C1: 1.0] ExecutionFinished. Faulty", log[2].ToString());
            Assert.AreEqual("[C1: 1.0 <= v < 2.0 --> 2.0] CannotExecuteMissingVersion.", log[3].ToString());
            Assert.AreEqual("[C1: 2.0 <= v < 3.0 --> 3.0] CannotExecuteMissingVersion.", log[4].ToString());
            Assert.AreEqual("[C2: 1.0] ExecutionStart.", log[5].ToString());
            Assert.AreEqual("[C2: 1.0] ExecutionFinished. Successful", log[6].ToString());
            Assert.AreEqual("[C3: 1.0] ExecutionStart.", log[7].ToString());
            Assert.AreEqual("[C3: 1.0] ExecutionFinished. Successful", log[8].ToString());
            Assert.AreEqual("[C2: 1.0 <= v < 2.0 --> 2.0] ExecutionStart.", log[9].ToString());
            Assert.AreEqual("[C2: 1.0 <= v < 2.0 --> 2.0] ExecutionError. Err", log[10].ToString());
            Assert.AreEqual("[C2: 1.0 <= v < 2.0 --> 2.0] ExecutionFinished. Faulty", log[11].ToString());
            Assert.AreEqual("[C2: 2.0 <= v < 3.0 --> 3.0] CannotExecuteMissingVersion.", log[12].ToString());
            Assert.AreEqual("[C3: 1.0 <= v < 2.0 --> 2.0] ExecutionStart.", log[13].ToString());
            Assert.AreEqual("[C3: 1.0 <= v < 2.0 --> 2.0] ExecutionFinished. Successful", log[14].ToString());
            Assert.AreEqual("[C3: 2.0 <= v < 3.0 --> 3.0] ExecutionStart.", log[15].ToString());
            Assert.AreEqual("[C3: 2.0 <= v < 3.0 --> 3.0] ExecutionFinished. Successful", log[16].ToString());
            Assert.AreEqual(17, packages.Count);
            Assert.AreEqual("1, C1: Install Faulty, 1.0|" +
                            "2, C2: Install Successful, 1.0|" +
                            "3, C3: Install Successful, 1.0|" +
                            "4, C2: Patch Faulty, 2.0|" +
                            "5, C3: Patch Successful, 2.0|" +
                            "6, C3: Patch Unfinished, 3.0", PackagesToString(packages[15]));
            Assert.AreEqual("1, C1: Install Faulty, 1.0|" +
                            "2, C2: Install Successful, 1.0|" +
                            "3, C3: Install Successful, 1.0|" +
                            "4, C2: Patch Faulty, 2.0|" +
                            "5, C3: Patch Successful, 2.0|" +
                            "6, C3: Patch Successful, 3.0", PackagesToString(packages[16]));
        }
コード例 #10
0
        public void TestPatchManagerInstanceNotNull()
        {
            PatchManager manager = NewManager();

            Assert.IsNotNull(manager);
        }
コード例 #11
0
 public async Task <List <string> > Get(int leftX, int rightX, int topY, int bottomY)
 {
     return(PatchManager.GetPatchIdsInRange(_context, leftX, rightX, topY, bottomY));
 }