From d7c0abdfc24cd5bf8ff6f0deed017e58d53b0b34 Mon Sep 17 00:00:00 2001 From: sardelka9515 Date: Sat, 15 Oct 2022 15:54:46 +0800 Subject: [PATCH] Bump version --- Client/Scripts/Menus/Sub/UpdateMenu.cs | 6 ++++++ Client/Scripts/Properties/AssemblyInfo.cs | 4 ++-- Core/CoreUtils.cs | 8 ++++++++ Server/Networking/Server.Background.cs | 6 +----- Server/Properties/AssemblyInfo.cs | 4 ++-- 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/Client/Scripts/Menus/Sub/UpdateMenu.cs b/Client/Scripts/Menus/Sub/UpdateMenu.cs index cb462e1..d7209f9 100644 --- a/Client/Scripts/Menus/Sub/UpdateMenu.cs +++ b/Client/Scripts/Menus/Sub/UpdateMenu.cs @@ -1,6 +1,7 @@ using ICSharpCode.SharpZipLib.Zip; using LemonUI.Menus; using RageCoop.Client.Scripting; +using RageCoop.Core; using System; using System.Drawing; using System.IO; @@ -31,6 +32,11 @@ namespace RageCoop.Client.Menus private static void StartUpdate(object sender, EventArgs e) { + if (CoreUtils.GetLatestVersion() < Main.Version) + { + GTA.UI.Notification.Show("Local version is newer than remote version, update can't continue"); + return; + } IsUpdating = true; Menu.Clear(); Menu.Add(_updatingItem); diff --git a/Client/Scripts/Properties/AssemblyInfo.cs b/Client/Scripts/Properties/AssemblyInfo.cs index 8a1ec3e..6a92e52 100644 --- a/Client/Scripts/Properties/AssemblyInfo.cs +++ b/Client/Scripts/Properties/AssemblyInfo.cs @@ -16,7 +16,7 @@ using System.Resources; // Version informationr( -[assembly: AssemblyVersion("1.5.4.333")] -[assembly: AssemblyFileVersion("1.5.4.333")] +[assembly: AssemblyVersion("1.5.4.334")] +[assembly: AssemblyFileVersion("1.5.4.334")] [assembly: NeutralResourcesLanguageAttribute( "en-US" )] diff --git a/Core/CoreUtils.cs b/Core/CoreUtils.cs index c114089..7925e31 100644 --- a/Core/CoreUtils.cs +++ b/Core/CoreUtils.cs @@ -34,6 +34,14 @@ namespace RageCoop.Core "ScriptHookVDotNet3", "ScriptHookVDotNet" }; + public static Version GetLatestVersion(string branch = "dev-nightly") + { + var url = $"https://raw.githubusercontent.com/RAGECOOP/RAGECOOP-V/{branch}/RageCoop.Server/Properties/AssemblyInfo.cs"; + var versionLine = HttpHelper.DownloadString(url).Split(new char[] {'\n'}, StringSplitOptions.RemoveEmptyEntries).Where(x => x.Contains("[assembly: AssemblyVersion(")).First(); + var start = versionLine.IndexOf('\"') + 1; + var end = versionLine.LastIndexOf('\"'); + return Version.Parse(versionLine.Substring(start, end - start)); + } public static bool CanBeIgnored(this string name) { return ToIgnore.Contains(Path.GetFileNameWithoutExtension(name)); diff --git a/Server/Networking/Server.Background.cs b/Server/Networking/Server.Background.cs index d372408..4b3aa5e 100644 --- a/Server/Networking/Server.Background.cs +++ b/Server/Networking/Server.Background.cs @@ -17,7 +17,6 @@ namespace RageCoop.Server { public partial class Server { - private const string _versionURL = "https://raw.githubusercontent.com/RAGECOOP/RAGECOOP-V/main/RageCoop.Server/Properties/AssemblyInfo.cs"; private void SendPlayerUpdate() { foreach (var c in ClientsByNetHandle.Values.ToArray()) @@ -148,10 +147,7 @@ namespace RageCoop.Server { try { - var versionLine = HttpHelper.DownloadString(_versionURL).Split('\n', StringSplitOptions.RemoveEmptyEntries).Where(x => x.Contains("[assembly: AssemblyVersion(")).First(); - var start = versionLine.IndexOf('\"') + 1; - var end = versionLine.LastIndexOf('\"'); - var latest = Version.Parse(versionLine.AsSpan(start, end - start)); + var latest = CoreUtils.GetLatestVersion(); if (latest <= Version) { return; } // wait ten minutes for the build to complete diff --git a/Server/Properties/AssemblyInfo.cs b/Server/Properties/AssemblyInfo.cs index 034e73d..b3d4551 100644 --- a/Server/Properties/AssemblyInfo.cs +++ b/Server/Properties/AssemblyInfo.cs @@ -15,7 +15,7 @@ using System.Resources; [assembly: AssemblyCulture("")] // Version information -[assembly: AssemblyVersion("1.5.4.105")] -[assembly: AssemblyFileVersion("1.5.4.105")] +[assembly: AssemblyVersion("1.5.4.106")] +[assembly: AssemblyFileVersion("1.5.4.106")] [assembly: NeutralResourcesLanguageAttribute( "en-US" )]