示例#1
0
        /// <summary>
        /// Checks if any current wz files are not set to the latest version number.
        /// </summary>
        /// <returns>
        /// Returns a List<Tuple<string, int>> array with the file name and detected version.
        /// </returns>
        protected List<Tuple<string, int>> outDatedFiles()
        {
            BinaryReader verificationWz;
            wzSignature vs;
            var outOfDateFiles = new List<Tuple<string, int>>();
            if (haveFiles())
            {
                for (int i = 0; i < wzFiles.Length; i++)
                {
                    try
                    {
                        verificationWz = new BinaryReader(new FileStream(wzFiles[i], FileMode.Open));
                        vs = new wzSignature(verificationWz, currentLauncherVersion);
                        if (!(vs.WzVersion == latestWZVersion) || !(vs.UIAdded && vs.EssenceAdded))
                            outOfDateFiles.Add(new Tuple<string, int>(wzFiles[i], vs.WzVersion));

                        verificationWz.Close();
                    }
                    catch (Exception)
                    {
                        updateLabel("Please close any program using " + wzFiles[0] + ".");
                        setStateWrapper(3);
                        backgroundWorker.ReportProgress(100);
                        //throw new Exception("Please close any program using " + wzFiles[0] + ".");
                    }
                }
            }

            List<string> toCheck = new List<string>();
            foreach (WzPatcherEntry patch in WzPatcher.customPatches) {
                if (!toCheck.Contains(patch.WzFileName)) {
                    toCheck.Add(patch.WzFileName);
                }
            }

            //Check for hardcoded changes.
            foreach (string i in toCheck) {
                WzFile wz = new WzFile(i, (short)mapleVersion, WzMapleVersion.BMS);
                wz.ParseWzFile();
                allWzFiles.Add(wz);
                foreach (WzPatcherEntry patch in WzPatcher.customPatches) {
                    WzPatcherEntry newPatch = patch;
                    newPatch.wzFile = wz;
                    if (newPatch.WzFileName.Equals(i)) {
                        if (!WzPatcher.checkSingleNode(newPatch)) {
                            bool found = false;
                            foreach (Tuple<string, int> toPatch in outOfDateFiles) {
                                if (toPatch.Item1.Equals(i)) {
                                    found = true;
                                }
                            }
                            if (!found) {
                                outOfDateFiles.Add(new Tuple<string, int>(i, latestWZVersion));
                            }
                        }
                    }
                }
            }
            return outOfDateFiles;
        }
示例#2
0
        protected void checkForLatest()
        {
            //outDatedFiles() Returns any files that are not up to date with List<Tuple<filename (string), fileversion (int)>>
            //sigCheck() returns an array; 0 means custom features need to be added, 1 meaning that all features are currently added.
            //haveFiles() returns true if all 15? wz files are present, false otherwise. On false, locks up the launcher and displays an error.
            //checkResources() Checks to ensure all resources needed to run exist, if not, adds them.
            //integrityCheck() returns an array; 0 means clean wz file, 1 means valid MC file, 2 means invalid file; On 0 and 1, check and update accordingly; on 2, lockout.
            if (haveFiles())
            {
                updateLabel("(1/6) Receiving latest version info. (Size: " + getFileSize(updatePath + "versionv159.txt") + ")");

                BinaryReader verificationWz = null;
                try
                {
                    verificationWz = new BinaryReader(new FileStream(wzFiles[0], FileMode.Open));
                }
                catch (Exception)
                {
                    updateLabel("Please close any program using " + wzFiles[0] + ".");
                    setStateWrapper(3);
                    backgroundWorker.ReportProgress(100);
                    return;
                }
                verificationSignature = new wzSignature(verificationWz, latestLauncherVersion);
                verificationWz.Close();

                short runningMapleVersion = -1;
                MapleLib.WzLib.Util.WzTool.DetectMapleVersion("TamingMob.wz", out runningMapleVersion);
                if (runningMapleVersion != mapleVersion) {
                    setStateWrapper(11);
                    backgroundWorker.ReportProgress(100);
                    return;
                }

                int[] integCheck = integrityCheck();
                string invalidFiles = "";
                if (integCheck.Contains(2))//Invalid MC file, detect tampering, lockout;
                {
                    for (int i = 0; i < integCheck.Length; i++)
                        if (integCheck[i].Equals(2))
                            invalidFiles += wzFiles[i] + ", ";

                    MessageBox.Show("Tampering detected on the following files: " + invalidFiles);
                    updateLabel("Tampering detected, please redownload MapleCrystal.");
                    setStateWrapper(3);
                    backgroundWorker.ReportProgress(100);
                    return;
                }
                else if (integCheck.Contains(1) || integCheck.Contains(0)) //Patch per normal means.
                {
                    //Launcher is outdated, need to download the latest launcher.
                    if ((verificationSignature.LauncherVersion > currentLauncherVersion) || (currentLauncherVersion < latestLauncherVersion))
                    {
                        setStateWrapper(5);
                    }
                    else //Launcher is up to date, check the version.
                    {
                        List<Tuple<string, int>> outOfDate = outDatedFiles(); //Obtains any file that isn't matching the remote version or have every custom feature true in sig.
                        if (true == false)//outOfDate.Any()) //Otherwise, there are outdated files detected.
                        {
                            int localCurVersion = outOfDate[0].Item2;

                            foreach (Tuple<string, int> i in outOfDate) //Obtains the lowest local version to patch up from.
                                if (localCurVersion > i.Item2)
                                    localCurVersion = (ushort)i.Item2;
                            currentVersion = (ushort)localCurVersion; //currentVersion becomes the lowest local version we have.

                            if (latestWZVersion - currentVersion > 1) //If a file is more than 2 visions out of date
                            {
                                //If we need to update to a patch 2 or more revisions higher, just merge the xmls.
                                doIMergeXMLs = true;
                                setStateWrapper(6);
                            }
                            else if (latestWZVersion < currentVersion) //Local version is higher than the server version (most likely the server went back a revision.)
                            {
                                doIMergeXMLs = true;
                                setStateWrapper(7);
                            }
                            else //Otherwise, update like normal to the next version.
                                setStateWrapper(4);

                        }
                        else// No files have returned as having a version less than the remote version.
                        {
                            updateLabel("No updates found, ready to play!");
                            setStateWrapper(2);
                            backgroundWorker.ReportProgress(100);

                        }
                    }
                }
            }
        }
示例#3
0
        /// <summary>
        /// Checks the signature for all WZ files.
        /// </summary>
        /// <returns>0 for a Signature missing custom features, 1 for a Signature having all features. One value per WZ file.</returns>
        private int[] sigCheck()
        {
            BinaryReader verificationWz;
            wzSignature vs;
            int[] retValues = new int[wzFiles.Length];
            retValues.Initialize();

            if (haveFiles())
            {
                for (int i = 0; i < wzFiles.Length; i++)
                {
                    try
                    {
                        verificationWz = new BinaryReader(new FileStream(wzFiles[i], FileMode.Open));
                        vs = new wzSignature(verificationWz, currentLauncherVersion);

                        // If the values are all true, then the signature is up to date.
                        if (vs.UIAdded && vs.EssenceAdded)
                        {
                            retValues[i] = 1;
                        }
                        else
                        {//Otherwise, some of the custom features have not been added, set to 0.
                            retValues[i] = 0;
                        }

                        verificationWz.Close();
                    }
                    catch (Exception)
                    {
                        updateLabel("Please close any program using " + wzFiles[0] + ".");
                        setStateWrapper(3);
                        backgroundWorker.ReportProgress(100);
                        //throw new Exception("Please close any program using " + wzFiles[0] + ".");
                    }
                }
            }
            return retValues;
        }
示例#4
0
        private void startMapleStory()
        {
            if (Process.GetProcessesByName("MapleStory").Length > 0) //Error: Unable to dual client.
            {
                updateLabel("You can only have one MapleStory open at a time.");
                timer1.Enabled = false;
                setStateWrapper(3);
                backgroundWorker.ReportProgress(100);
                return;
            }

            BinaryReader verificationWz = null;
            try
            {
                verificationWz = new BinaryReader(new FileStream(wzFiles[0], FileMode.Open));
            }
            catch (Exception)
            {
                updateLabel("Please close any program using " + wzFiles[0] + ".");
                setStateWrapper(3);
                backgroundWorker.ReportProgress(100);
                return;
            }
            verificationSignature = new wzSignature(verificationWz, latestLauncherVersion);
            verificationWz.Close();

            if (ushort.Parse(readFileFromURL(updatePath + "versionv159.txt")[0]) > verificationSignature.WzVersion)
            {
                //timer1.Enabled = false;
                //setStateWrapper(4);
                //return;
            }

            if (ushort.Parse(readFileFromURL(updatePath + "versionv159.txt")[1]) > latestLauncherVersion)
            {
                //timer1.Enabled = false;
                //setStateWrapper(5);
                //return;
            }

            Process p = new Process();
            p.StartInfo.Arguments = "GameLaunching";
            p.StartInfo.FileName = Application.StartupPath + @"\MapleStory.exe";
            p.Start();

            // NOTE: Starting MapleStory with 'WebStart' argument launches it directly without 'play' screen.
        }
示例#5
0
        protected void timer1_Tick(object sender, EventArgs e)
        {
            //We only need this to loop once. (Prevents multiple MapleStorys from launching)

            if (Process.GetProcessesByName("MapleStory").Length > 0) //Error: Unable to dual client.
            {
                updateLabel("You can only have one MapleStory open at a time.");
                timer1.Stop();
                setStateWrapper(2);
                backgroundWorker.ReportProgress(100);
                return;
            }

            BinaryReader verificationWz = null;
            try
            {
                verificationWz = new BinaryReader(new FileStream(wzFiles[0], FileMode.Open));
            }
            catch (Exception)
            {
                updateLabel("Please close any program using " + wzFiles[0] + ".");
                timer1.Stop();
                setStateWrapper(3);
                backgroundWorker.ReportProgress(100);
                return;
            }
            verificationSignature = new wzSignature(verificationWz, latestLauncherVersion);
            verificationWz.Close();

            if (latestWZVersion > verificationSignature.WzVersion)
            {
                //timer1.Stop();
                //setStateWrapper(4);
                //return;
            }

            if (latestLauncherVersion > currentLauncherVersion)
            {
                //timer1.Stop();
                //setStateWrapper(5);
                //return;
            }
            timer1.Stop();

            StartMS();
        }