From 7a539acfcfabdb034259bdf76caf81cfe7f498ab Mon Sep 17 00:00:00 2001 From: bluepilledgreat <97983689+bluepilledgreat@users.noreply.github.com> Date: Tue, 11 Mar 2025 22:32:21 +0000 Subject: [PATCH] add version and channel arguments --- Bloxstrap/Bootstrapper.cs | 44 ++++++++++++++++++++++++------------- Bloxstrap/LaunchSettings.cs | 11 ++++++++++ 2 files changed, 40 insertions(+), 15 deletions(-) diff --git a/Bloxstrap/Bootstrapper.cs b/Bloxstrap/Bootstrapper.cs index db84862..3133c06 100644 --- a/Bloxstrap/Bootstrapper.cs +++ b/Bloxstrap/Bootstrapper.cs @@ -288,12 +288,17 @@ namespace Bloxstrap using var key = Registry.CurrentUser.CreateSubKey($"SOFTWARE\\ROBLOX Corporation\\Environments\\{AppData.RegistryName}\\Channel"); var match = Regex.Match( - App.LaunchSettings.RobloxLaunchArgs, - "channel:([a-zA-Z0-9-_]+)", + App.LaunchSettings.RobloxLaunchArgs, + "channel:([a-zA-Z0-9-_]+)", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant ); - if (match.Groups.Count == 2) + if (App.LaunchSettings.ChannelFlag.Active && !string.IsNullOrEmpty(App.LaunchSettings.ChannelFlag.Data)) + { + App.Logger.WriteLine(LOG_IDENT, $"Channel set to {App.LaunchSettings.ChannelFlag.Data} from arguments"); + Deployment.Channel = App.LaunchSettings.ChannelFlag.Data.ToLowerInvariant(); + } + else if (match.Groups.Count == 2) { Deployment.Channel = match.Groups[1].Value.ToLowerInvariant(); } @@ -310,23 +315,32 @@ namespace Bloxstrap if (!Deployment.IsDefaultChannel) App.SendStat("robloxChannel", Deployment.Channel); - ClientVersion clientVersion; - - try + if (!App.LaunchSettings.VersionFlag.Active || string.IsNullOrEmpty(App.LaunchSettings.VersionFlag.Data)) { - clientVersion = await Deployment.GetInfo(); + ClientVersion clientVersion; + + try + { + clientVersion = await Deployment.GetInfo(); + } + catch (InvalidChannelException ex) + { + App.Logger.WriteLine(LOG_IDENT, $"Resetting channel from {Deployment.Channel} because {ex.StatusCode}"); + + Deployment.Channel = Deployment.DefaultChannel; + clientVersion = await Deployment.GetInfo(); + } + + key.SetValueSafe("www.roblox.com", Deployment.IsDefaultChannel ? "" : Deployment.Channel); + + _latestVersionGuid = clientVersion.VersionGuid; } - catch (InvalidChannelException ex) + else { - App.Logger.WriteLine(LOG_IDENT, $"Resetting channel from {Deployment.Channel} because {ex.StatusCode}"); - - Deployment.Channel = Deployment.DefaultChannel; - clientVersion = await Deployment.GetInfo(); + App.Logger.WriteLine(LOG_IDENT, $"Version set to {App.LaunchSettings.VersionFlag.Data} from arguments"); + _latestVersionGuid = App.LaunchSettings.VersionFlag.Data; } - key.SetValueSafe("www.roblox.com", Deployment.IsDefaultChannel ? "" : Deployment.Channel); - - _latestVersionGuid = clientVersion.VersionGuid; _latestVersionDirectory = Path.Combine(Paths.Versions, _latestVersionGuid); string pkgManifestUrl = Deployment.GetLocation($"/{_latestVersionGuid}-rbxPkgManifest.txt"); diff --git a/Bloxstrap/LaunchSettings.cs b/Bloxstrap/LaunchSettings.cs index f8492f7..1bb312f 100644 --- a/Bloxstrap/LaunchSettings.cs +++ b/Bloxstrap/LaunchSettings.cs @@ -32,6 +32,10 @@ namespace Bloxstrap public LaunchFlag StudioFlag { get; } = new("studio"); + public LaunchFlag VersionFlag { get; } = new("version"); + + public LaunchFlag ChannelFlag { get; } = new("channel"); + #if DEBUG public bool BypassUpdateCheck => true; #else @@ -87,6 +91,13 @@ namespace Bloxstrap RobloxLaunchArgs = arg; startIdx = 1; } + else if (arg.StartsWith("version-")) + { + App.Logger.WriteLine(LOG_IDENT, "Got version argument"); + VersionFlag.Active = true; + VersionFlag.Data = arg; + startIdx = 1; + } } // parse