private bool UpdateWar(string WarhammerDirectory) { FileStream fs = new FileStream(Application.StartupPath + "\\mythloginserviceconfig.xml", FileMode.Open, FileAccess.Read); Directory.SetCurrentDirectory(WarhammerDirectory); HashDictionary hashDictionary = new HashDictionary(); hashDictionary.AddHash(0x3FE03665, 0x349E2A8C, "mythloginserviceconfig.xml", 0); MYPHandler.MYPHandler mypHandler = new MYPHandler.MYPHandler("data.myp", null, null, hashDictionary); mypHandler.GetFileTable(); FileInArchive theFile = mypHandler.SearchForFile("mythloginserviceconfig.xml"); if (theFile == null) { MessageBox.Show("Can not find config file in data.myp"); return(false); } if (File.Exists(Application.StartupPath + "\\mythloginserviceconfig.xml") == false) { MessageBox.Show("Missing file : mythloginserviceconfig.xml"); return(false); } mypHandler.ReplaceFile(theFile, fs); fs.Close(); return(true); }
public void AddFia(FileInArchive fia) { fiaList.Add(fia); if (Parent != null && Parent.GetType() == typeof(FiaTreeNode)) { ((FiaTreeNode)Parent).AddFia(fia); } }
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) { if (e.Node.Tag is FileInArchive) { FileInArchive file = (FileInArchive)e.Node.Tag; WorldBuilder.MYPHash.Asset asset = new MYPHash.Asset(); asset.File = file; if (OnAssetSelected != null) { long key = ((long)file.Descriptor.ph << 32) + file.Descriptor.sh; byte[] data = MYPHash.GetAssetData(frmBuilder.WarFolder, key, 0); asset.Hash = key; asset.Filename = key.ToString() + "." + GetExtension(data); asset.Name = asset.Filename; OnAssetSelected(asset); } } }
public static void UpdateWarData() { if (ApocLauncher.Acc.AllowServerPatch) { try { _logger.Info("Updating mythloginserviceconfig.xml and data.myp"); FileStream fs = new FileStream(Application.StartupPath + "\\mythloginserviceconfig.xml", FileMode.Open, FileAccess.Read); Directory.SetCurrentDirectory(Directory.GetCurrentDirectory() + "\\..\\"); HashDictionary hashDictionary = new HashDictionary(); hashDictionary.AddHash(0x3FE03665, 0x349E2A8C, "mythloginserviceconfig.xml", 0); MYPHandler.MYPHandler mypHandler = new MYPHandler.MYPHandler("data.myp", null, null, hashDictionary); mypHandler.GetFileTable(); FileInArchive theFile = mypHandler.SearchForFile("mythloginserviceconfig.xml"); if (theFile == null) { _logger.Error("Can not find config file in data.myp"); return; } if (File.Exists(Application.StartupPath + "\\mythloginserviceconfig.xml") == false) { _logger.Error("Missing file : mythloginserviceconfig.xml"); return; } mypHandler.ReplaceFile(theFile, fs); fs.Close(); } catch (Exception e) { Print(e.ToString()); } } else { _logger.Info("Not Patching data.myp"); } }
private void updateMYP() { FileStream fs = new FileStream(Application.StartupPath + "\\PortalSettings.xml", FileMode.Open, FileAccess.Read); Directory.SetCurrentDirectory(path); HashDictionary hashDictionary = new HashDictionary(); hashDictionary.AddHash(0x3FE03665, 0x349E2A8C, "F4FCD464_3FE03665349E2A8C.xml", 0); MYPHandler.MYPHandler mypHandler = new MYPHandler.MYPHandler("data.myp", null, null, hashDictionary); mypHandler.GetFileTable(); FileInArchive theFile = mypHandler.SearchForFile("F4FCD464_3FE03665349E2A8C.xml"); mypHandler.ReplaceFile(theFile, fs); fs.Close(); if (theFile != null) { MessageBox.Show("patch success!"); } }
private void FileListing_Add(FileInArchive file) { fileInArchiveBindingSource.Add(file); }
public static FiaTreeNode ArchiveNodeAdd(FiaTreeNode parentNode, string[] pathes, int pathDepth, FileInArchive fia) { FiaTreeNode childNode = null; if (pathes.Length > pathDepth + 1) //means we are not yet at filelevel { //We search the child nodes for the path part for (int j = 0; j < parentNode.Nodes.Count; j++) { if (parentNode.Nodes[j].Text == pathes[pathDepth]) { //If the node is found we get to the next level childNode = ArchiveNodeAdd((FiaTreeNode)parentNode.Nodes[j], pathes, pathDepth + 1, fia); } } } else { //We are at file level, we create the node childNode = new FiaTreeNode(pathes[pathDepth]); parentNode.Nodes.Add(childNode); childNode.ImageIndex = 4; childNode.SelectedImageIndex = 4; childNode.AddFia(fia); } if (childNode == null) { //If we did not find a node, we create one childNode = new FiaTreeNode(pathes[pathDepth]); childNode.ImageIndex = 1; childNode.SelectedImageIndex = 1; parentNode.Nodes.Add(childNode); //we add the node to the parent node //We keep going deeper ArchiveNodeAdd(childNode, pathes, pathDepth + 1, fia); } return(childNode); }
public static void PopulateArchiveTreeNode(string sourceFileName, List <FileInArchive> FIAList, TreeView tv) { FiaTreeNode root = new FiaTreeNode(sourceFileName.Substring(sourceFileName.LastIndexOf('\\') + 1)); root.Tag = sourceFileName; tv.Nodes.Add(root); for (int i = 0; i < FIAList.Count; i++) { FileInArchive fia = FIAList[i]; string filename = fia.Filename; if (!filename.Contains('.')) { filename = fia.Extension + "/" + filename; } string[] pathes = filename.Split('/'); FiaTreeNode tn = null; for (int j = 0; j < root.Nodes.Count && tn == null; j++) { //Check if the level 0 node already exists if (root.Nodes[j].Text == pathes[0]) { if (pathes.Length > 1) //Check that this node has childs nodes { //we assign the correct icon //we recursively go down the pathes. tn = ArchiveNodeAdd((FiaTreeNode)root.Nodes[j], pathes, 1, fia); } } } //If no node where found if (tn == null) { //We create the level 0 node tn = new FiaTreeNode(pathes[0]); tn.Tag = sourceFileName; root.Nodes.Add(tn); // add it to the treview if (pathes.Length > 1) //Check that this node has childs nodes { //we assign the correct icon tn.ImageIndex = 1; tn.SelectedImageIndex = 1; //we recursively go down the pathes. ArchiveNodeAdd(tn, pathes, 1, fia); } else { // this means it is actually a file at level 0, we change the icon tn.ImageIndex = 4; tn.SelectedImageIndex = 4; tn.AddFia(fia); } } } //tv.Sort(); //Thread t = new Thread(new ThreadStart(tv.Sort)); //t.Start(); }