add !VERSION

This commit is contained in:
Bluzume 2021-10-25 07:11:34 -04:00
parent 1204d586bd
commit 7122d978a6
8 changed files with 99 additions and 26 deletions

View file

@ -7,30 +7,24 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HorseIsleServer", "HorseIsl
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|ARM = Debug|ARM
Debug|ARM64 = Debug|ARM64
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Linux|Any CPU = Linux|Any CPU
Linux|ARM = Linux|ARM
Linux|ARM64 = Linux|ARM64
Linux|x64 = Linux|x64
Linux|x86 = Linux|x86
MacOS|Any CPU = MacOS|Any CPU
MacOS|ARM = MacOS|ARM
MacOS|ARM64 = MacOS|ARM64
MacOS|x64 = MacOS|x64
MacOS|x86 = MacOS|x86
Windows|Any CPU = Windows|Any CPU
Windows|ARM = Windows|ARM
Windows|ARM64 = Windows|ARM64
Windows|x64 = Windows|x64
Windows|x86 = Windows|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C48CBD82-AB30-494A-8FFA-4DE7069B5827}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C48CBD82-AB30-494A-8FFA-4DE7069B5827}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C48CBD82-AB30-494A-8FFA-4DE7069B5827}.Debug|ARM.ActiveCfg = Debug|ARM
{C48CBD82-AB30-494A-8FFA-4DE7069B5827}.Debug|ARM.Build.0 = Debug|ARM
{C48CBD82-AB30-494A-8FFA-4DE7069B5827}.Debug|ARM64.ActiveCfg = Debug|ARM64
@ -39,8 +33,6 @@ Global
{C48CBD82-AB30-494A-8FFA-4DE7069B5827}.Debug|x64.Build.0 = Debug|x64
{C48CBD82-AB30-494A-8FFA-4DE7069B5827}.Debug|x86.ActiveCfg = Debug|x86
{C48CBD82-AB30-494A-8FFA-4DE7069B5827}.Debug|x86.Build.0 = Debug|x86
{C48CBD82-AB30-494A-8FFA-4DE7069B5827}.Linux|Any CPU.ActiveCfg = Linux|Any CPU
{C48CBD82-AB30-494A-8FFA-4DE7069B5827}.Linux|Any CPU.Build.0 = Linux|Any CPU
{C48CBD82-AB30-494A-8FFA-4DE7069B5827}.Linux|ARM.ActiveCfg = Linux|ARM
{C48CBD82-AB30-494A-8FFA-4DE7069B5827}.Linux|ARM.Build.0 = Linux|ARM
{C48CBD82-AB30-494A-8FFA-4DE7069B5827}.Linux|ARM64.ActiveCfg = Linux|ARM64
@ -49,22 +41,13 @@ Global
{C48CBD82-AB30-494A-8FFA-4DE7069B5827}.Linux|x64.Build.0 = Linux|x64
{C48CBD82-AB30-494A-8FFA-4DE7069B5827}.Linux|x86.ActiveCfg = Linux|x86
{C48CBD82-AB30-494A-8FFA-4DE7069B5827}.Linux|x86.Build.0 = Linux|x86
{C48CBD82-AB30-494A-8FFA-4DE7069B5827}.MacOS|Any CPU.ActiveCfg = MacOS|Any CPU
{C48CBD82-AB30-494A-8FFA-4DE7069B5827}.MacOS|Any CPU.Build.0 = MacOS|Any CPU
{C48CBD82-AB30-494A-8FFA-4DE7069B5827}.MacOS|ARM.ActiveCfg = MacOS|ARM
{C48CBD82-AB30-494A-8FFA-4DE7069B5827}.MacOS|ARM.Build.0 = MacOS|ARM
{C48CBD82-AB30-494A-8FFA-4DE7069B5827}.MacOS|ARM64.ActiveCfg = MacOS|ARM64
{C48CBD82-AB30-494A-8FFA-4DE7069B5827}.MacOS|ARM64.Build.0 = MacOS|ARM64
{C48CBD82-AB30-494A-8FFA-4DE7069B5827}.MacOS|x64.ActiveCfg = MacOS|x64
{C48CBD82-AB30-494A-8FFA-4DE7069B5827}.MacOS|x64.Build.0 = MacOS|x64
{C48CBD82-AB30-494A-8FFA-4DE7069B5827}.MacOS|x86.ActiveCfg = MacOS|x86
{C48CBD82-AB30-494A-8FFA-4DE7069B5827}.MacOS|x86.Build.0 = MacOS|x86
{C48CBD82-AB30-494A-8FFA-4DE7069B5827}.Windows|Any CPU.ActiveCfg = Windows|Any CPU
{C48CBD82-AB30-494A-8FFA-4DE7069B5827}.Windows|Any CPU.Build.0 = Windows|Any CPU
{C48CBD82-AB30-494A-8FFA-4DE7069B5827}.Windows|ARM.ActiveCfg = Windows|ARM
{C48CBD82-AB30-494A-8FFA-4DE7069B5827}.Windows|ARM.Build.0 = Windows|ARM
{C48CBD82-AB30-494A-8FFA-4DE7069B5827}.Windows|ARM64.ActiveCfg = Windows|ARM64
{C48CBD82-AB30-494A-8FFA-4DE7069B5827}.Windows|ARM64.Build.0 = Windows|ARM64
{C48CBD82-AB30-494A-8FFA-4DE7069B5827}.Windows|x64.ActiveCfg = Windows|x64
{C48CBD82-AB30-494A-8FFA-4DE7069B5827}.Windows|x64.Build.0 = Windows|x64
{C48CBD82-AB30-494A-8FFA-4DE7069B5827}.Windows|x86.ActiveCfg = Windows|x86

View file

@ -177,6 +177,9 @@ namespace HISP.Game.Chat
else if (message.ToUpper().StartsWith("!DANCE"))
return Command.Dance(message, args, user);
else if (message.ToUpper().StartsWith("!VERSION"))
return Command.Version(message, args, user);
}
return false;
}

View file

@ -160,6 +160,17 @@ namespace HISP.Game.Chat
return true;
}
public static bool Version(string message, string[] args, User user)
{
// Get current version and send to client
byte[] versionPacket = PacketBuilder.CreateChat(ServerVersion.GetBuildString(), PacketBuilder.CHAT_BOTTOM_RIGHT);
user.LoggedinClient.SendPacket(versionPacket);
// Send Command complete message to client.
byte[] versionCommandCompletePacket = PacketBuilder.CreateChat(Messages.FormatPlayerCommandCompleteMessage(message.Substring(1)), PacketBuilder.CHAT_BOTTOM_LEFT);
user.LoggedinClient.SendPacket(versionCommandCompletePacket);
return true;
}
public static bool Ban(string message, string[] args, User user)
{
if (args.Length <= 0)

View file

@ -3,7 +3,7 @@
<OutputType>Exe</OutputType>
<RootNamespace>HISP</RootNamespace>
<LangVersion>8.0</LangVersion>
<Platforms>x64;x86;ARM;ARM64;AnyCPU</Platforms>
<Platforms>x64;x86;ARM;ARM64</Platforms>
<Configurations>Windows;Debug;Linux;MacOS</Configurations>
</PropertyGroup>
<ItemGroup>
@ -39,6 +39,8 @@
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<NoWin32Manifest>true</NoWin32Manifest>
<ApplicationIcon>icon.ico</ApplicationIcon>
<StartupObject>HISP.Program</StartupObject>
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Windows|x86'">
<ApplicationIcon>icon.ico</ApplicationIcon>
@ -46,6 +48,7 @@
<RuntimeIdentifier>win-x86</RuntimeIdentifier>
<Optimize>true</Optimize>
<PlatformTarget>x86</PlatformTarget>
<DefineConstants>OS_WINDOWS;ARCH_X86</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Windows|x64'">
<ApplicationIcon>icon.ico</ApplicationIcon>
@ -53,34 +56,37 @@
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<Optimize>true</Optimize>
<PlatformTarget>x64</PlatformTarget>
<DefineConstants>OS_WINDOWS;ARCH_X86_64</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Linux|x64'">
<TargetFramework>net5.0</TargetFramework>
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
<Optimize>true</Optimize>
<PlatformTarget>x64</PlatformTarget>
<PlatformTarget>x64</PlatformTarget>
<DefineConstants>OS_LINUX;ARCH_X86_64</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='MacOS|x64'">
<TargetFramework>net5.0</TargetFramework>
<RuntimeIdentifier>osx-x64</RuntimeIdentifier>
<Optimize>true</Optimize>
<PlatformTarget>x64</PlatformTarget>
<PlatformTarget>x64</PlatformTarget>
<DefineConstants>OS_MACOS;ARCH_x86_64</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Linux|ARM'">
<TargetFramework>net5.0</TargetFramework>
<RuntimeIdentifier>linux-arm</RuntimeIdentifier>
<Optimize>true</Optimize>
<PlatformTarget>ARM</PlatformTarget>
<DefineConstants>OS_LINUX;ARCH_ARM</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Linux|ARM64'">
<TargetFramework>net5.0</TargetFramework>
<RuntimeIdentifier>linux-arm64</RuntimeIdentifier>
<Optimize>true</Optimize>
<PlatformTarget>ARM64</PlatformTarget>
<DefineConstants>OS_LINUX;ARCH_ARM64</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='All|Any CPU'">
<TargetFramework>net5.0</TargetFramework>
<RuntimeIdentifiers>win-x86;win-x64;win-arm;win-arm64;linux-x64;linux-arm;linux-arm64;osx-x64</RuntimeIdentifiers>
<Optimize>true</Optimize>
</PropertyGroup>
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="git rev-parse --verify HEAD&gt;&quot;$(ProjectDir)Resources\GitCommit&quot;" />
</Target>
</Project>

View file

@ -104,5 +104,15 @@ namespace HISP.Properties {
return ResourceManager.GetString("DefaultServerProperties", resourceCulture);
}
}
/// <summary>
/// UNKNOWN COMMIT HASH
/// </summary>
internal static string GitCommit {
get {
return ResourceManager.GetString("GitCommit", resourceCulture);
}
}
}
}

View file

@ -124,4 +124,7 @@
<data name="DefaultServerProperties" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\server.properties;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
</data>
</root>
<data name="GitCommit" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\GitCommit;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
</data>
</root>

View file

@ -0,0 +1 @@
1204d586bd47400b2a091e9906481f46da33a22a

View file

@ -0,0 +1,56 @@
using HISP.Properties;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HISP.Server
{
public class ServerVersion
{
public static int MAJOR = 1;
public static int MINOR = 3;
public static string PRODUCT = "HISP";
public static string GetArchitecture()
{
#if ARCH_X86_64
return "x86_64";
#elif ARCH_X86
return "x86";
#elif ARCH_ARM
return "ARM";
#elif ARCH_ARM64
return "ARM64"
#else
return "UNK_ARCH";
#endif
}
public static string GetPlatform()
{
#if OS_WINDOWS
return "WINDOWS";
#elif OS_LINUX
return "LINUX";
#elif OS_MACOS
return "MACOS";
#else
return "UNK_PLATFORM";
#endif
}
public static string GetVersionString()
{
return "v" + MAJOR.ToString() + "." + MINOR.ToString();
}
public static string GetCommitHash(int TotalBytes)
{
return Resources.GitCommit.Substring(0, TotalBytes * 2);
}
public static string GetBuildString()
{
return PRODUCT + " " + GetVersionString() + " " + GetCommitHash(4) + "; (" + GetArchitecture() + "; " + GetPlatform() + ")";
}
}
}