Example #1
0
 private void asdfToolStripMenuItem_Click(object sender, EventArgs e)
 {
     WzFile f = new WzFile(@"C:\Mob.wz", WzMapleVersion.BMS);
     //WzFile f = new WzFile(@"C:\Nexon\MapleStoryExt\Skill.wz", WzMapleVersion.BMS);
     f.ParseWzFile();
     foreach (WzImage mob in f.WzDirectory.WzImages)
     {
         mob.ParseImage();
         WzSubProperty info = (WzSubProperty)mob["info"];
         if (info != null)
         {
             WzCompressedIntProperty bodyatt = (WzCompressedIntProperty)info["bodyAttack"];
             if (bodyatt != null)
             {
                 bodyatt.Value = 0;
                 mob.Changed = true;
             }
         }
     }
     f.SaveToDisk(@"C:\Mob2.wz");
 }
Example #2
0
        public void Patch()
        {
            string curVTxt = "(Current V" + Patcher_UserSettings.CurrentVersion + ")";
            AppendStatus(curVTxt + " Checking for updates...");
            ProgressStyle(ProgressBarStyle.Marquee);
            WebClient download = new WebClient();
            //MessageBox.Show("hai");
            if (!CheckPath(Patcher_AppSettings.PatchURL)) //Check if the website directory actually exists. -DeathRight
            {
                download.Dispose();
                MessageBox.Show("The specified URL cannot be found, please contact the server owner or post in the help section of the server forum.", "Unreachable URL");
                Application.Exit();
            }

            //MessageBox.Show("hai2");

            if (!CheckPath(Patcher_AppSettings.PatchURL + "/" + (Patcher_UserSettings.CurrentVersion + 1).ToString()))
            {
                download.Dispose();
                Application.Exit(); //If there isn't a folder with a version 1 higher than the current, we can't update, so exit. -DeathRight
            }

            Dictionary<string, WzFile> WzFiles = new Dictionary<string, WzFile>();
            AppendStatus(curVTxt + " Downloading patch files...");
            ProgressValue(0);
            ProgressStyle(ProgressBarStyle.Marquee);
            RefreshStuff();
            Directory.CreateDirectory(Application.StartupPath + @"\Patches");
            foreach (string wzFile in WzTypes)
            {
                if (CheckFile(Patcher_AppSettings.PatchURL + "/" + (Patcher_UserSettings.CurrentVersion + 1).ToString() + "/" + wzFile))
                {
                    download.DownloadFile(Patcher_AppSettings.PatchURL + "/" + (Patcher_UserSettings.CurrentVersion + 1).ToString() + "/" + wzFile, Application.StartupPath + @"\Patches\" + wzFile);
                    short version = -1;
                    WzMapleVersion nWzFV = WzTool.DetectMapleVersion(Application.StartupPath + @"\Patches\" + wzFile, out version);
                    WzFile nWzF = new WzFile(Application.StartupPath + @"\Patches\" + wzFile, nWzFV);
                    nWzF.ParseWzFile();
                    nWzF.WzDirectory.ParseImages(); //Just to be safe -DeathRight
                    WzFiles.Add(wzFile, nWzF);
                }
            }
            download.Dispose();

            if (WzFiles.Count <= 0)
            {
                return;
            }

            string slTxt = curVTxt + " Patching files...";
            AppendStatus(slTxt);
            ProgressStyle(ProgressBarStyle.Continuous);
            //ProgressMax(WzFiles.Count);
            RefreshStuff();
            Directory.CreateDirectory(Application.StartupPath + @"\Patches\TEMP");
            foreach (WzFile wzFile in WzFiles.Values)
            {
                if (wzFile.WzDirectory["PatchInfo"] != null)
                    wzFile.WzDirectory["PatchInfo"].Remove();

                if (!File.Exists(Application.StartupPath + @"\" + wzFile.Name))
                {
                    MessageBox.Show("Unable to find WZ '" + wzFile.Name + "' in path '" + Application.StartupPath + "'","Unable to find WZ file");
                    Application.Exit();
                }

                ProgressValue(0);
                ProgressStyle(ProgressBarStyle.Marquee);
                RefreshStuff();
                AppendStatus(slTxt + " [" + wzFile.Name + "]");
                RefreshStuff();

                short version = -1;
                WzFile origWz = new WzFile(Application.StartupPath + @"\" + wzFile.Name, WzTool.DetectMapleVersion(Application.StartupPath + @"\" + wzFile.Name, out version));
                origWz.ParseWzFile();
                origWz.WzDirectory.ParseImages();
                try
                {
                    ReplaceDirs(wzFile.WzDirectory, origWz);
                    origWz.SaveToDisk(Application.StartupPath + @"\Patches\TEMP\" + wzFile.Name);
                }
                catch
                {
                    MessageBox.Show("Error while trying to save WZ file '" + wzFile.Name + "'", "Error saving WZ file");
                    wzFile.Dispose();
                    origWz.Dispose();
                    File.Delete(Application.StartupPath + @"\Patches\" + wzFile);
                    Application.Exit();
                }
                string wzName = wzFile.Name;
                wzFile.Dispose();
                origWz.Dispose();
                File.Delete(Application.StartupPath + @"\Patches\" + wzName);
                File.Delete(Application.StartupPath + @"\" + wzName);
                File.Move(Application.StartupPath + @"\Patches\TEMP\" + wzName, Application.StartupPath + @"\" + wzName);

                //ProgressValue();

                //RefreshStuff();
            }

            Patcher_UserSettings.CurrentVersion++;
            Patch();
        }
Example #3
0
 void loadDifferences()
 {
     // here we would query a website for latest patch rev.
     WzMapleVersion vrs = WzMapleVersion.GMS; // is classic old GMS??
     string imgPath = textBox1.Text;
     string wzPath = textBox2.Text;
     Console.WriteLine("imgPath: " + imgPath + ", wzPath: " + wzPath);
     WzFile affected = new WzFile(wzPath, vrs);
     affected.ParseWzFile();
     char[] split = { '\\', '/'};
     string imgName = imgPath.Split(split)[imgPath.Split(split).Length - 1].Trim();
     Console.WriteLine("imgName: " + imgName);
     WzImage toPatch = affected.WzDirectory.GetImageByName(imgName);
     FileStream stream = File.OpenRead(imgPath);
     WzImage img = new WzImage("-" + imgName, stream, vrs);
     img.ParseImage();
     toPatch.ParseImage();
     toPatch.ClearProperties();
     toPatch.AddProperties(img.WzProperties);
     affected.WzDirectory.GetImageByName(imgName).changed = true;
     affected.SaveToDisk(wzPath + ".new");
     affected.Dispose();
     stream.Close();
     while (!tryDelete(wzPath))
     {
         Thread.Sleep(1000); // ensure that we can rename the file
     }
     File.Move(wzPath + ".new", wzPath); // rewrite w/ patched file
     button1.Text = "Done!";
 }