mirror of
https://git.recroomarchive.org/RecRoomArchive/RRAC.git
synced 2026-09-08 14:41:25 -07:00
89 lines
3.5 KiB
C#
89 lines
3.5 KiB
C#
using RecRoomArchive.Models.Common;
|
|
|
|
namespace RecRoomArchive.Services
|
|
{
|
|
/// <summary>
|
|
/// Used to get the appVersion from the client to determine how to run the server
|
|
/// </summary>
|
|
public class AppVersionService
|
|
{
|
|
/// <summary>
|
|
/// AppVersion reference
|
|
/// </summary>
|
|
private static string? AppVersion { get; set; }
|
|
|
|
/// <summary>
|
|
/// The AppVersion as it would want to be seen by the game
|
|
/// </summary>
|
|
private static string? FullAppVersion { get; set; }
|
|
|
|
/// <summary>
|
|
/// The BuildTimestamp of the build, this is a long that when converted to ticks, will be the accurate time at which the game was built.
|
|
/// This only exists on some builds so I wouldn't rely on it too much
|
|
/// </summary>
|
|
private static DateTime? BuildTimestamp { get; set; }
|
|
/// <summary>
|
|
/// The BuildTimestamp as it would want to be seen by the game
|
|
/// </summary>
|
|
private static long? FullBuildTimestamp { get; set; }
|
|
|
|
/// <summary>
|
|
/// To store the AppVersion of the current build
|
|
/// </summary>
|
|
/// <param name="appVersion">The version of the game</param>
|
|
/// <returns>If the operation was a success</returns>
|
|
public async Task<bool> StoreAppVersion(string appVersion)
|
|
{
|
|
if (appVersion == null)
|
|
return false;
|
|
|
|
// To remove any _EA's or .01's or just any weird Rec Room bullshit from the build's name
|
|
var standardizedAppVersion = await ParseAppVersion(appVersion);
|
|
|
|
// idrk if storing both of these is overkill
|
|
FullAppVersion = appVersion;
|
|
AppVersion = standardizedAppVersion;
|
|
|
|
Console.WriteLine($"appVersion: {FullAppVersion}, standardizedAppVersion: {AppVersion}");
|
|
|
|
return true;
|
|
}
|
|
|
|
/// <summary>
|
|
/// To store the BuildTimestamp of the current build
|
|
/// </summary>
|
|
/// <param name="buildTimestamp">The BuildTimestamp of the game</param>
|
|
/// <returns>If the operation was a success</returns>
|
|
public async Task<bool> StoreBuildTimestamp(long buildTimestamp)
|
|
{
|
|
if (buildTimestamp == 0)
|
|
return false;
|
|
|
|
DateTime buildTimestampDateTime = new(buildTimestamp);
|
|
|
|
// same here
|
|
FullBuildTimestamp = buildTimestamp;
|
|
BuildTimestamp = buildTimestampDateTime;
|
|
|
|
Console.Title = $"RRAC {Constants.Version} - ({BuildTimestamp.Value.Year}) {BuildTimestamp.Value}";
|
|
Console.WriteLine ($"RRAC {Constants.Version} - ({BuildTimestamp.Value.Year}) {BuildTimestamp.Value}");
|
|
Console.WriteLine($"buildTimestamp: {FullBuildTimestamp}, buildTimestampDateTime: {BuildTimestamp}");
|
|
|
|
return true;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Parses the appVersion to "remove any _EA's or .01's or just any weird Rec Room bullshit from the build's name"
|
|
/// </summary>
|
|
/// <param name="appVersion">The version of the game</param>
|
|
/// <returns>The standardized string of the appVersion</returns>
|
|
public async Task<string> ParseAppVersion(string appVersion)
|
|
{
|
|
// To remove any _EA's or .01's or just any weird Rec Room bullshit from the build's name
|
|
int index = appVersion.IndexOfAny(['_', '.']);
|
|
string standardizedAppVersion = index >= 0 ? appVersion[..index] : appVersion;
|
|
|
|
return standardizedAppVersion;
|
|
}
|
|
}
|
|
} |