예제 #1
0
        public static PatchDirectory FromXml(PatchList list, PatchDirectory parent, XmlNode node)
        {
            var name = node.Attributes["Name"];
            var removeUnpatchedFiles = node.Attributes["RemoveUnpatchedFiles"];

            if (name != null)
            {
                var directory = new PatchDirectory(parent, name.Value);

                foreach (XmlNode child in node.ChildNodes)
                {
                    if (child.Name == "Directory")
                    {
                        directory.Subdirectories.AddLast(PatchDirectory.FromXml(list, directory, child));
                    }
                    else if (child.Name == "File")
                    {
                        directory.Files.AddLast(PatchFile.FromXml(directory, child));
                    }
                }

                if (removeUnpatchedFiles != null &&
                    removeUnpatchedFiles.Value == "false")
                {
                    directory.RemoveUnpatchedFiles = true;
                    list.IgnoredDirectories.Add(directory.RelativePhysicalPath.ToLower());
                }

                return(directory);
            }

            return(null);
        }
예제 #2
0
 public ProgressFile(PatchFile patchfile)
 {
     Status    = UpdateStatus.Idle;
     PatchFile = patchfile;
     do
     {
         TempFile = "mcpatcher_temp/" + Program.Random.Next() + ".tmp";
     }while (File.Exists(TempFile));
 }
예제 #3
0
        public PatchFile FindFile(string filename)
        {
            filename = filename.ToLower();
            PatchFile file = null;

            /*if (ConfigHashTree.TryGetValue(filename, out file))
             *  return file;*/
            if (JarModsHashTree.TryGetValue(filename, out file))
            {
                return(file);
            }
            if (ModsHashTree.TryGetValue(filename, out file))
            {
                return(file);
            }
            if (FlanHashTree.TryGetValue(filename, out file))
            {
                return(file);
            }

            return(file);
        }
예제 #4
0
        public static PatchList FromXml(XmlNode root)
        {
            var list = new PatchList(0);

            foreach (XmlNode node in root.ChildNodes)
            {
                if (node.Name == "Patcher")
                {
                    uint         _crc;
                    XmlAttribute crc = node.Attributes["Crc"];
                    if (crc != null &&
                        uint.TryParse(crc.Value, out _crc))
                    {
                        list.PatcherCrc = _crc;

                        if (_crc != Program.ExecutableCrc)
                        {
                            if (MessageBox.Show(
                                    "A newer version of the MCPatcher is available, do you want to go to the website to download?\n" +
                                    "If you click No, MCPatcher will continue but may or may not be stable.",
                                    "MCPatcher", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                            {
                                Process.Start(Program.PatchUrl);
                                Environment.Exit(0);
                            }
                        }
                    }
                }

                /*if (node.Name == "Config")
                 * {
                 *  XmlAttribute _mode = node.Attributes["Mode"];
                 *  PatchListMode mode = PatchListMode.Partial;
                 *  if (_mode != null &&
                 *      Enum.TryParse(_mode.Value, out mode))
                 *  {
                 *      list.ConfigMode = mode;
                 *      foreach (XmlNode child in node.ChildNodes)
                 *      {
                 *          if (child.Name == "File")
                 *          {
                 *              list.Config.Files.AddLast(PatchFile.FromXml(list.Config, child));
                 *          }
                 *          else if (child.Name == "Directory")
                 *          {
                 *              list.Config.Subdirectories.AddLast(PatchDirectory.FromXml(list, list.Config, child));
                 *          }
                 *      }
                 *  }
                 * }
                 * else */
                if (node.Name == "JarMods")
                {
                    XmlAttribute  _mode = node.Attributes["Mode"];
                    PatchListMode mode  = PatchListMode.Partial;
                    if (_mode != null &&
                        Enum.TryParse(_mode.Value, out mode))
                    {
                        list.JarModsMode = mode;
                        foreach (XmlNode child in node.ChildNodes)
                        {
                            if (child.Name == "File")
                            {
                                list.JarMods.Files.AddLast(PatchFile.FromXml(list.JarMods, child));
                            }
                            else if (child.Name == "Directory")
                            {
                                list.JarMods.Subdirectories.AddLast(PatchDirectory.FromXml(list, list.JarMods, child));
                            }
                        }
                    }
                }
                else if (node.Name == "Mods")
                {
                    XmlAttribute  _mode = node.Attributes["Mode"];
                    PatchListMode mode  = PatchListMode.Partial;
                    if (_mode != null &&
                        Enum.TryParse(_mode.Value, out mode))
                    {
                        list.ModsMode = mode;
                        foreach (XmlNode child in node.ChildNodes)
                        {
                            if (child.Name == "File")
                            {
                                list.Mods.Files.AddLast(PatchFile.FromXml(list.Mods, child));
                            }
                            else if (child.Name == "Directory")
                            {
                                list.Mods.Subdirectories.AddLast(PatchDirectory.FromXml(list, list.Mods, child));
                            }
                        }
                    }
                }
                else if (node.Name == "Flan")
                {
                    var _mode = node.Attributes["Mode"];
                    var mode  = PatchListMode.Partial;
                    if (_mode != null &&
                        Enum.TryParse(_mode.Value, out mode))
                    {
                        list.FlanMode = mode;
                        foreach (XmlNode child in node.ChildNodes)
                        {
                            if (child.Name == "File")
                            {
                                list.FlanMods.Files.AddLast(PatchFile.FromXml(list.FlanMods, child));
                            }
                            else if (child.Name == "Directory")
                            {
                                list.FlanMods.Subdirectories.AddLast(PatchDirectory.FromXml(list, list.FlanMods, child));
                            }
                        }
                    }
                }
            }

            list.CreateVirtualHashTree();
            return(list);
        }