From d7dc198a8ba2c1765b64a0b09e23e664e3b3e70b Mon Sep 17 00:00:00 2001 From: pizzaboxer Date: Wed, 12 Apr 2023 11:06:27 +0200 Subject: [PATCH] Check if player executable exists (#128) --- Bloxstrap/Bootstrapper.cs | 36 +++++++++++------------- Bloxstrap/Helpers/FastFlagManager.cs | 13 +++------ Bloxstrap/Helpers/IntegrationMigrator.cs | 2 -- 3 files changed, 20 insertions(+), 31 deletions(-) diff --git a/Bloxstrap/Bootstrapper.cs b/Bloxstrap/Bootstrapper.cs index 8013ab9..41cd7c8 100644 --- a/Bloxstrap/Bootstrapper.cs +++ b/Bloxstrap/Bootstrapper.cs @@ -68,6 +68,7 @@ namespace Bloxstrap private static bool FreshInstall => String.IsNullOrEmpty(App.State.Prop.VersionGuid); private static string DesktopShortcutLocation => Path.Combine(Directories.Desktop, "Play Roblox.lnk"); + private string _playerLocation => Path.Combine(_versionFolder, "RobloxPlayerBeta.exe"); private string? _launchCommandLine; @@ -144,8 +145,9 @@ namespace Bloxstrap CheckInstallMigration(); - // if roblox needs updating but is running and we have multiple instances open, ignore update for now - if (App.IsFirstRun || _versionGuid != App.State.Prop.VersionGuid && !Utilities.CheckIfRobloxRunning()) + // only update roblox if we're running for the first time, or if + // roblox isn't running and our version guid is out of date, or the player exe doesn't exist + if (App.IsFirstRun || !Utilities.CheckIfRobloxRunning() && (_versionGuid != App.State.Prop.VersionGuid || !File.Exists(_playerLocation))) await InstallLatestVersion(); // last time the version folder was set, it was set to the latest version guid @@ -153,10 +155,10 @@ namespace Bloxstrap _versionFolder = Path.Combine(Directories.Versions, App.State.Prop.VersionGuid); if (App.IsFirstRun) - { App.ShouldSaveConfigs = true; - App.FastFlags.Save(); - } + + IntegrationMigrator.Execute(); + App.FastFlags.Save(); if (App.Settings.Prop.UseReShade) SetStatus("Configuring/Downloading ReShade..."); @@ -170,8 +172,6 @@ namespace Bloxstrap CheckInstall(); - IntegrationMigrator.Execute(); - // at this point we've finished updating our configs App.Settings.Save(); App.State.Save(); @@ -336,7 +336,7 @@ namespace Bloxstrap // whether we should wait for roblox to exit to handle stuff in the background or clean up after roblox closes bool shouldWait = false; - Process gameClient = Process.Start(Path.Combine(_versionFolder, "RobloxPlayerBeta.exe"), _launchCommandLine); + Process gameClient = Process.Start(_playerLocation, _launchCommandLine); List autocloseProcesses = new(); GameActivityWatcher? activityWatcher = null; DiscordRichPresence? richPresence = null; @@ -708,23 +708,20 @@ namespace Bloxstrap string oldVersionFolder = Path.Combine(Directories.Versions, App.State.Prop.VersionGuid); + // and also to delete our old version folder if (_versionGuid != App.State.Prop.VersionGuid && Directory.Exists(oldVersionFolder)) - { - // and also to delete our old version folder Directory.Delete(oldVersionFolder, true); - } // move old compatibility flags for the old location using (RegistryKey appFlagsKey = Registry.CurrentUser.CreateSubKey($"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers")) { string oldGameClientLocation = Path.Combine(oldVersionFolder, "RobloxPlayerBeta.exe"); - string newGameClientLocation = Path.Combine(_versionFolder, "RobloxPlayerBeta.exe"); string? appFlags = (string?)appFlagsKey.GetValue(oldGameClientLocation); if (appFlags is not null) { - App.Logger.WriteLine($"[Bootstrapper::InstallLatestVersion] Migrating app compatibility flags from {oldGameClientLocation} to {newGameClientLocation}..."); - appFlagsKey.SetValue(newGameClientLocation, appFlags); + App.Logger.WriteLine($"[Bootstrapper::InstallLatestVersion] Migrating app compatibility flags from {oldGameClientLocation} to {_playerLocation}..."); + appFlagsKey.SetValue(_playerLocation, appFlags); appFlagsKey.DeleteValue(oldGameClientLocation); } } @@ -747,23 +744,22 @@ namespace Bloxstrap using (RegistryKey appFlagsKey = Registry.CurrentUser.CreateSubKey($"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers")) { const string flag = " DISABLEDXMAXIMIZEDWINDOWEDMODE"; - string gameClientLocation = Path.Combine(_versionFolder, "RobloxPlayerBeta.exe"); - string? appFlags = (string?)appFlagsKey.GetValue(gameClientLocation); + string? appFlags = (string?)appFlagsKey.GetValue(_playerLocation); if (App.Settings.Prop.DisableFullscreenOptimizations) { if (appFlags is null) - appFlagsKey.SetValue(gameClientLocation, $"~{flag}"); + appFlagsKey.SetValue(_playerLocation, $"~{flag}"); else if (!appFlags.Contains(flag)) - appFlagsKey.SetValue(gameClientLocation, appFlags + flag); + appFlagsKey.SetValue(_playerLocation, appFlags + flag); } else if (appFlags is not null && appFlags.Contains(flag)) { // if there's more than one space, there's more flags set we need to preserve if (appFlags.Split(' ').Length > 2) - appFlagsKey.SetValue(gameClientLocation, appFlags.Remove(appFlags.IndexOf(flag), flag.Length)); + appFlagsKey.SetValue(_playerLocation, appFlags.Remove(appFlags.IndexOf(flag), flag.Length)); else - appFlagsKey.DeleteValue(gameClientLocation); + appFlagsKey.DeleteValue(_playerLocation); } } diff --git a/Bloxstrap/Helpers/FastFlagManager.cs b/Bloxstrap/Helpers/FastFlagManager.cs index 1341731..170e6b9 100644 --- a/Bloxstrap/Helpers/FastFlagManager.cs +++ b/Bloxstrap/Helpers/FastFlagManager.cs @@ -69,29 +69,24 @@ namespace Bloxstrap.Helpers { base.Load(); - // set to 99999 by default if it doesnt immediately exist + // set to 9999 by default if it doesnt already exist if (GetValue("DFIntTaskSchedulerTargetFps") is null) - { SetValue("DFIntTaskSchedulerTargetFps", 9999); - - if (!App.IsFirstRun) - Save(); - } } public override void Save() { App.Logger.WriteLine($"[FastFlagManager::Save] Attempting to save JSON to {FileLocation}..."); + // reload for any changes made while the menu was open + Load(); + if (Changes.Count == 0) { App.Logger.WriteLine($"[FastFlagManager::Save] No changes to apply, aborting."); return; } - // reload for any changes made while the menu was open - Load(); - foreach (var change in Changes) { if (change.Value is null) diff --git a/Bloxstrap/Helpers/IntegrationMigrator.cs b/Bloxstrap/Helpers/IntegrationMigrator.cs index 4d3b4f7..e073719 100644 --- a/Bloxstrap/Helpers/IntegrationMigrator.cs +++ b/Bloxstrap/Helpers/IntegrationMigrator.cs @@ -6,8 +6,6 @@ namespace Bloxstrap.Helpers { public static void Execute() { - App.FastFlags.Load(); - // v2.2.0 - remove rbxfpsunlocker string rbxfpsunlocker = Path.Combine(Directories.Integrations, "rbxfpsunlocker");