Files
RRAC/RecRoomArchive/Services/AppVersionService.cs
T
splootybean 387ec7ba89 Initialize repository
Added basic info to get in game for like...August 2016 ;-;
It's not much but it's a start
2026-02-27 00:58:13 -08:00

85 lines
3.3 KiB
C#

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.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;
}
}
}