diff --git a/RageCoop.Client/Main.cs b/RageCoop.Client/Main.cs index d8b510f..04e39f8 100644 --- a/RageCoop.Client/Main.cs +++ b/RageCoop.Client/Main.cs @@ -21,7 +21,7 @@ namespace RageCoop.Client internal class Main : Script { private bool _gameLoaded = false; - internal static readonly string CurrentVersion = "V0_5_0"; + internal static Version Version=typeof(Main).Assembly.GetName().Version; internal static int LocalPlayerID = 0; diff --git a/RageCoop.Client/Menus/CoopMenu.cs b/RageCoop.Client/Menus/CoopMenu.cs index de52321..71e5220 100644 --- a/RageCoop.Client/Menus/CoopMenu.cs +++ b/RageCoop.Client/Menus/CoopMenu.cs @@ -36,7 +36,7 @@ namespace RageCoop.Client.Menus private static readonly NativeItem _aboutItem = new NativeItem("About", "~y~SOURCE~s~~n~" + "https://github.com/RAGECOOP~n~" + "~y~VERSION~s~~n~" + - Main.CurrentVersion.Replace("_", ".")) + Main.Version) { LeftBadge = new LemonUI.Elements.ScaledTexture("commonmenu", "shop_new_star") }; diff --git a/RageCoop.Client/Networking/Networking.cs b/RageCoop.Client/Networking/Networking.cs index 811ca23..60bc98e 100644 --- a/RageCoop.Client/Networking/Networking.cs +++ b/RageCoop.Client/Networking/Networking.cs @@ -100,7 +100,7 @@ namespace RageCoop.Client { PedID = Main.LocalPlayerID, Username =username, - ModVersion = Main.CurrentVersion, + ModVersion = Main.Version.ToString(), PasswordEncrypted=Security.Encrypt(password.GetBytes()), InternalEndPoint = new System.Net.IPEndPoint(CoreUtils.GetLocalAddress(ip[0]), Peer.Port) }; diff --git a/RageCoop.Client/Properties/AssemblyInfo.cs b/RageCoop.Client/Properties/AssemblyInfo.cs index c405379..707b5ea 100644 --- a/RageCoop.Client/Properties/AssemblyInfo.cs +++ b/RageCoop.Client/Properties/AssemblyInfo.cs @@ -1,32 +1,21 @@ -using System.Reflection; + +using System.Reflection; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; +using System.Resources; -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("RageCoop.Client")] -[assembly: AssemblyDescription("RageCoop.Client")] +// General Information +[assembly: AssemblyTitle("Insert title here")] +[assembly: AssemblyDescription("Insert description here")] [assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("RAGECOOP")] -[assembly: AssemblyProduct("RageCoop.Client")] -[assembly: AssemblyCopyright("Copyright © 2022")] -[assembly: AssemblyTrademark("")] +[assembly: AssemblyCompany("Insert company here")] +[assembly: AssemblyProduct("Insert product here")] +[assembly: AssemblyCopyright("Insert copyright here")] +[assembly: AssemblyTrademark("Insert trademark here")] [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] +// Version informationr( +[assembly: AssemblyVersion("1.5.3.8")] +[assembly: AssemblyFileVersion("1.5.3.8")] +[assembly: NeutralResourcesLanguageAttribute( "en-US" )] -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("8e5f008b-e391-4b50-9ce1-4564fd0735ba")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -[assembly: AssemblyVersion("0.5.0.0")] -[assembly: AssemblyFileVersion("0.5.0.0")] diff --git a/RageCoop.Client/Properties/AssemblyInfo.tt b/RageCoop.Client/Properties/AssemblyInfo.tt new file mode 100644 index 0000000..a604b89 --- /dev/null +++ b/RageCoop.Client/Properties/AssemblyInfo.tt @@ -0,0 +1,45 @@ +<#@ template debug="true" hostspecific="true" language="C#" #> +<#@ output extension=".cs" #> +<#@ import namespace="System.IO" #> +<#@ import namespace="System.Text.RegularExpressions" #> +<# + string output = File.ReadAllText(this.Host.ResolvePath("AssemblyInfo.cs")); + Regex pattern = new Regex("AssemblyVersion\\(\"(?\\d+)\\.(?\\d+)\\.(?\\d+)\\.(?\\d+)\"\\)"); + MatchCollection matches = pattern.Matches(output); + if( matches.Count == 1 ) + { + major = Convert.ToInt32(matches[0].Groups["major"].Value); + minor = Convert.ToInt32(matches[0].Groups["minor"].Value); + build = Convert.ToInt32(matches[0].Groups["build"].Value) + 1; + revision = Convert.ToInt32(matches[0].Groups["revision"].Value); + if( this.Host.ResolveParameterValue("-","-","BuildConfiguration") == "Release" ) + revision++; + } +#> + +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Resources; + +// General Information +[assembly: AssemblyTitle("Insert title here")] +[assembly: AssemblyDescription("Insert description here")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Insert company here")] +[assembly: AssemblyProduct("Insert product here")] +[assembly: AssemblyCopyright("Insert copyright here")] +[assembly: AssemblyTrademark("Insert trademark here")] +[assembly: AssemblyCulture("")] + +// Version informationr( +[assembly: AssemblyVersion("<#= this.major #>.<#= this.minor #>.<#= this.revision #>.<#= this.build #>")] +[assembly: AssemblyFileVersion("<#= this.major #>.<#= this.minor #>.<#= this.revision #>.<#= this.build #>")] +[assembly: NeutralResourcesLanguageAttribute( "en-US" )] + +<#+ + int major = 1; + int minor = 0; + int revision = 0; + int build = 0; +#> \ No newline at end of file diff --git a/RageCoop.Client/RageCoop.Client.csproj b/RageCoop.Client/RageCoop.Client.csproj index 2f3b9ac..71daea8 100644 --- a/RageCoop.Client/RageCoop.Client.csproj +++ b/RageCoop.Client/RageCoop.Client.csproj @@ -44,7 +44,11 @@ - + + True + True + AssemblyInfo.tt + @@ -278,6 +282,13 @@ + + TextTemplatingFileGenerator + AssemblyInfo.cs + + + + @@ -291,7 +302,6 @@ - - + "$(DevEnvDir)TextTransform.exe" -a !!BuildConfiguration!$(Configuration) "$(ProjectDir)Properties\AssemblyInfo.tt" \ No newline at end of file diff --git a/RageCoop.Client/Scripting/API.cs b/RageCoop.Client/Scripting/API.cs index fae0ed6..5fba22b 100644 --- a/RageCoop.Client/Scripting/API.cs +++ b/RageCoop.Client/Scripting/API.cs @@ -202,9 +202,9 @@ namespace RageCoop.Client.Scripting /// /// Get the version of RAGECOOP /// - public static string CurrentVersion + public static Version CurrentVersion { - get { return Main.CurrentVersion; } + get { return Main.Version; } } diff --git a/RageCoop.Server/Networking/Server.Connections.cs b/RageCoop.Server/Networking/Server.Connections.cs index 9cfac8f..7ed8e5f 100644 --- a/RageCoop.Server/Networking/Server.Connections.cs +++ b/RageCoop.Server/Networking/Server.Connections.cs @@ -23,10 +23,9 @@ namespace RageCoop.Server private void GetHandshake(NetConnection connection, Packets.Handshake packet) { Logger?.Debug("New handshake from: [Name: " + packet.Username + " | Address: " + connection.RemoteEndPoint.Address.ToString() + "]"); - - if (!packet.ModVersion.StartsWith(_compatibleVersion)) + if (!packet.ModVersion.StartsWith(Version.ToString(2))) { - connection.Deny($"RAGECOOP version {_compatibleVersion.Replace('_', '.')}.x required!"); + connection.Deny($"RAGECOOP version {Version.ToString(2)} required!"); return; } if (string.IsNullOrWhiteSpace(packet.Username)) diff --git a/RageCoop.Server/Networking/Server.cs b/RageCoop.Server/Networking/Server.cs index 3056b42..d310c30 100644 --- a/RageCoop.Server/Networking/Server.cs +++ b/RageCoop.Server/Networking/Server.cs @@ -53,7 +53,10 @@ namespace RageCoop.Server private HashSet _allowedCharacterSet; private Dictionary> PendingResponses=new(); internal Dictionary> RequestHandlers=new(); - private readonly string _compatibleVersion = "V0_5"; + /// + /// Get the current server version + /// + public static readonly Version Version = typeof(Server).Assembly.GetName().Version; /// /// Instantiate a server. /// @@ -135,7 +138,7 @@ namespace RageCoop.Server port=Settings.Port.ToString(), country=info.Country, name=Settings.Name, - version=_compatibleVersion.Replace("_", "."), + version=Version.ToString(), players=MainNetServer.ConnectionsCount.ToString(), maxPlayers=Settings.MaxPlayers.ToString(), description=Settings.Description, @@ -212,8 +215,8 @@ namespace RageCoop.Server { Logger?.Info("================"); Logger?.Info($"Server bound to: 0.0.0.0:{Settings.Port}"); - Logger?.Info($"Server version: {Assembly.GetCallingAssembly().GetName().Version}"); - Logger?.Info($"Compatible RAGECOOP versions: {_compatibleVersion.Replace('_', '.')}.x"); + Logger?.Info($"Server version: {Version}"); + Logger?.Info($"Compatible RAGECOOP versions: {Version.ToString(2)}"); Logger?.Info("================"); if (Settings.UseZeroTier) diff --git a/RageCoop.Server/Properties/AssemblyInfo.cs b/RageCoop.Server/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..862b9a0 --- /dev/null +++ b/RageCoop.Server/Properties/AssemblyInfo.cs @@ -0,0 +1,21 @@ + +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Resources; + +// General Information +[assembly: AssemblyTitle("Insert title here")] +[assembly: AssemblyDescription("Insert description here")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Insert company here")] +[assembly: AssemblyProduct("Insert product here")] +[assembly: AssemblyCopyright("Insert copyright here")] +[assembly: AssemblyTrademark("Insert trademark here")] +[assembly: AssemblyCulture("")] + +// Version informationr( +[assembly: AssemblyVersion("1.5.0.8")] +[assembly: AssemblyFileVersion("1.5.0.8")] +[assembly: NeutralResourcesLanguageAttribute( "en-US" )] + diff --git a/RageCoop.Server/Properties/AssemblyInfo.tt b/RageCoop.Server/Properties/AssemblyInfo.tt new file mode 100644 index 0000000..a604b89 --- /dev/null +++ b/RageCoop.Server/Properties/AssemblyInfo.tt @@ -0,0 +1,45 @@ +<#@ template debug="true" hostspecific="true" language="C#" #> +<#@ output extension=".cs" #> +<#@ import namespace="System.IO" #> +<#@ import namespace="System.Text.RegularExpressions" #> +<# + string output = File.ReadAllText(this.Host.ResolvePath("AssemblyInfo.cs")); + Regex pattern = new Regex("AssemblyVersion\\(\"(?\\d+)\\.(?\\d+)\\.(?\\d+)\\.(?\\d+)\"\\)"); + MatchCollection matches = pattern.Matches(output); + if( matches.Count == 1 ) + { + major = Convert.ToInt32(matches[0].Groups["major"].Value); + minor = Convert.ToInt32(matches[0].Groups["minor"].Value); + build = Convert.ToInt32(matches[0].Groups["build"].Value) + 1; + revision = Convert.ToInt32(matches[0].Groups["revision"].Value); + if( this.Host.ResolveParameterValue("-","-","BuildConfiguration") == "Release" ) + revision++; + } +#> + +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Resources; + +// General Information +[assembly: AssemblyTitle("Insert title here")] +[assembly: AssemblyDescription("Insert description here")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Insert company here")] +[assembly: AssemblyProduct("Insert product here")] +[assembly: AssemblyCopyright("Insert copyright here")] +[assembly: AssemblyTrademark("Insert trademark here")] +[assembly: AssemblyCulture("")] + +// Version informationr( +[assembly: AssemblyVersion("<#= this.major #>.<#= this.minor #>.<#= this.revision #>.<#= this.build #>")] +[assembly: AssemblyFileVersion("<#= this.major #>.<#= this.minor #>.<#= this.revision #>.<#= this.build #>")] +[assembly: NeutralResourcesLanguageAttribute( "en-US" )] + +<#+ + int major = 1; + int minor = 0; + int revision = 0; + int build = 0; +#> \ No newline at end of file diff --git a/RageCoop.Server/RageCoop.Server.csproj b/RageCoop.Server/RageCoop.Server.csproj index fa2a73e..8673d48 100644 --- a/RageCoop.Server/RageCoop.Server.csproj +++ b/RageCoop.Server/RageCoop.Server.csproj @@ -1,10 +1,11 @@  + false Exe net6.0 - 0.5 - 0.5 + + https://github.com/RAGECOOP/RAGECOOP-V https://ragecoop.online/ True @@ -12,7 +13,7 @@ $(AssemblyName) RageCoop.Server RAGECOOP - 0.5 + embedded True An library for hosting a RAGECOOP server or API reference for developing a resource. @@ -36,6 +37,11 @@ True \ + + True + True + AssemblyInfo.tt + @@ -70,5 +76,28 @@ + + + TextTemplatingFileGenerator + AssemblyInfo.cs + + + + + + + + + + True + True + AssemblyInfo.tt + + + + + + + diff --git a/RageCoop.Server/Updater.cs b/RageCoop.Server/Updater.cs new file mode 100644 index 0000000..6f3f9f7 --- /dev/null +++ b/RageCoop.Server/Updater.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Reflection; +namespace RageCoop.Server +{ + internal static class Updater + { + } +}