Ejemplo n.º 1
0
        private IEnumerator VersionCheck()
        {
            WWW ModapiWebsite = new WWW("https://modapi.survivetheforest.net/api/mods/");

            yield return(ModapiWebsite);

            if (string.IsNullOrEmpty(ModapiWebsite.error) && !string.IsNullOrEmpty(ModapiWebsite.text))
            {
                Regex regex1 = new Regex(@"id.:101([^}])+");
                Match match1 = regex1.Match(ModapiWebsite.text);
                if (match1.Success)
                {
                    Regex versionRegex   = new Regex("(?<=version\"..)([0-9.]+)");
                    Regex likesRegex     = new Regex("(?<=likes\".)(\\d+)");
                    Regex downloadsRegex = new Regex("(?<=downloads\".)(\\d+)");

                    Match versionMatch   = versionRegex.Match(match1.Value);
                    Match likesMatch     = likesRegex.Match(match1.Value);
                    Match downloadsMatch = downloadsRegex.Match(match1.Value);

                    if (versionMatch.Success)
                    {
                        OnlineVersion = versionMatch.Value;
                        if (ModSettings.Version == OnlineVersion)
                        {
                            checkStatus = VersionCheckStatus.UpToDate;
                        }
                        else if (CompareVersion(OnlineVersion) == Status.Outdated)
                        {
                            checkStatus = VersionCheckStatus.OutDated;
                        }
                        else
                        {
                            checkStatus = VersionCheckStatus.NewerThanOnline;
                        }
                        yield break;
                    }
                    if (likesMatch.Success)
                    {
                        Likes = likesMatch.Value;
                    }
                    if (downloadsMatch.Success)
                    {
                        Downloads = downloadsMatch.Value;
                    }
                }
            }
            if (checkStatus == VersionCheckStatus.Unchecked)
            {
                checkStatus = VersionCheckStatus.Fail;
            }
        }
Ejemplo n.º 2
0
        private VersionCheckStatus CompareVersionWithXML(XmlDocument doc, string xmlElementName, out string newVersionText)
        {
            XmlNode            serverVersionNode = doc.DocumentElement.SelectSingleNode(xmlElementName);
            string             serverVersionText = serverVersionNode.InnerText;
            VersionCheckStatus status            = CompareSoftwareVersions(serverVersionText);

            newVersionText = serverVersionText;

            if (serverVersionNode.Attributes["Name"] != null)
            {
                newVersionText = serverVersionNode.Attributes["Name"].Value;
            }

            return(status);
        }
Ejemplo n.º 3
0
        private VersionCheckStatus CompareVersionWithXML(XmlDocument doc, string xmlElVersionFull, string xmlElVersionFriendly, out string newVersionText)
        {
            XmlNode            serverVersionNode = doc.DocumentElement.SelectSingleNode(xmlElVersionFull);
            string             serverVersionText = serverVersionNode.InnerText;
            VersionCheckStatus status            = CompareSoftwareVersions(serverVersionText);

            newVersionText = serverVersionText;

            serverVersionNode = doc.DocumentElement.SelectSingleNode(xmlElVersionFriendly);
            if (serverVersionNode != null && !String.IsNullOrEmpty(serverVersionNode.InnerText))
            {
                newVersionText = serverVersionNode.InnerText;
            }

            return(status);
        }
Ejemplo n.º 4
0
        private void CheckForUpdates()
        {
            try
            {
                string dataDownload = (string)BusyDialog.Show("Please wait while we check for updates...", new BusyDialog.ProcessingHandler(DownloadUpdateStatusThread), null);

                XmlDocument doc = new XmlDocument();
                doc.LoadXml(dataDownload);
                string             newVersionName;
                VersionCheckStatus status = CompareVersionWithXML(doc, "CurrentVersion", out newVersionName);

                if (status == VersionCheckStatus.ServerNewer)
                {
                    if (_guiController.ShowQuestion("A newer version of AGS (" + newVersionName + ") is available on the AGS website. Would you like to go there now?") == DialogResult.Yes)
                    {
                        LaunchBrowserAtAGSWebsite();
                    }
                }
                else if (status == VersionCheckStatus.ThisNewer)
                {
                    // This is newer than the website version, so it must be a beta
                    // version. So, see if a newer beta is available.
                    status = CompareVersionWithXML(doc, "BetaVersion", out newVersionName);
                    if (status == VersionCheckStatus.ServerNewer)
                    {
                        if (_guiController.ShowQuestion("A newer beta version of AGS (" + newVersionName + ") is available on the AGS forums. Would you like to go there now?") == DialogResult.Yes)
                        {
                            LaunchBrowserAtAGSForums();
                        }
                    }
                    else
                    {
                        _guiController.ShowMessage("There are no further beta updates at this time.", MessageBoxIcon.Information);
                    }
                }
                else
                {
                    _guiController.ShowMessage("This version of AGS is up to date.", MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                _guiController.ShowMessage("Unable to check for updates. Your internet connection may be down.\nPlease visit the AGS website to see if an updated version is available.\n\nError details: " + ex.Message, MessageBoxIcon.Warning);
            }
        }
Ejemplo n.º 5
0
        public void Test_against_reference_implementation(int numDataBits, Mode mode, ErrorCorrectionLevel level, string encodingName)
        {
            VersionControlStruct vcStruct    = VersionControl.InitialSetup(numDataBits, mode, level, encodingName);
            VersionCheckStatus   checkStatus = VersionTest.VersionCheck(vcStruct.VersionDetail.Version, numDataBits, mode, level, encodingName);

            switch (checkStatus)
            {
            case VersionCheckStatus.LargerThanExpect:
                Assert.Fail("Version {0} size not enough", vcStruct.VersionDetail.Version);
                break;

            case VersionCheckStatus.SmallerThanExpect:
                Assert.Fail("Version{0}'s size too big", vcStruct.VersionDetail.Version);
                break;

            default:
                break;
            }
        }
Ejemplo n.º 6
0
        private IEnumerator VersionCheck()
        {
            WWW ModapiWebsite = new WWW("https://modapi.survivetheforest.net/mod/101/champions-of-the-forest");

            yield return(ModapiWebsite);

            if (string.IsNullOrEmpty(ModapiWebsite.error) && !string.IsNullOrEmpty(ModapiWebsite.text))
            {
                Regex regex1 = new Regex(@"Version+\W+([0-9.]+)");
                Match match1 = regex1.Match(ModapiWebsite.text);
                if (match1.Success)
                {
                    Regex regex2 = new Regex(@"([0-9.]+)");
                    Match match2 = regex2.Match(match1.Value);
                    if (match2.Success)
                    {
                        OnlineVersion = match2.Value;
                        if (ModSettings.Version == OnlineVersion)
                        {
                            checkStatus = VersionCheckStatus.UpToDate;
                        }
                        else if (CompareVersion(OnlineVersion) == Status.Outdated)
                        {
                            checkStatus = VersionCheckStatus.OutDated;
                        }
                        else
                        {
                            checkStatus = VersionCheckStatus.NewerThanOnline;
                        }
                        yield break;
                    }
                }
            }
            if (checkStatus == VersionCheckStatus.Unchecked)
            {
                checkStatus = VersionCheckStatus.Fail;
            }
        }
Ejemplo n.º 7
0
        private VersionCheckStatus CompareSoftwareVersions(string serverVersionText)
        {
            string[]           serverVersion = serverVersionText.Split('.');
            string[]           thisVersion   = AGS.Types.Version.AGS_EDITOR_VERSION.Split('.');
            VersionCheckStatus status        = VersionCheckStatus.Equal;

            for (int i = 0; i < serverVersion.Length; i++)
            {
                int serverVersionPart = Convert.ToInt32(serverVersion[i]);
                int thisVersionPart   = Convert.ToInt32(thisVersion[i]);
                if (serverVersionPart > thisVersionPart)
                {
                    status = VersionCheckStatus.ServerNewer;
                    break;
                }
                if (serverVersionPart < thisVersionPart)
                {
                    status = VersionCheckStatus.ThisNewer;
                    break;
                }
            }
            return(status);
        }