diff --git a/Assets/PatchKit Patcher/Scripts/AppData/Local/ILocalMetaData.cs b/Assets/PatchKit Patcher/Scripts/AppData/Local/ILocalMetaData.cs index 02905a12..c641d941 100644 --- a/Assets/PatchKit Patcher/Scripts/AppData/Local/ILocalMetaData.cs +++ b/Assets/PatchKit Patcher/Scripts/AppData/Local/ILocalMetaData.cs @@ -44,5 +44,11 @@ public interface ILocalMetaData void SetProductKey(string productKey); string GetProductKey(); + + void SetMainExecutableAndArgs(string mainExecutable, string mainExecutableArgs); + + string GetMainExecutable(); + + string MainExecutableArgs { get; } } } \ No newline at end of file diff --git a/Assets/PatchKit Patcher/Scripts/AppData/Local/LocalMetaData.cs b/Assets/PatchKit Patcher/Scripts/AppData/Local/LocalMetaData.cs index 1c130637..185579f9 100644 --- a/Assets/PatchKit Patcher/Scripts/AppData/Local/LocalMetaData.cs +++ b/Assets/PatchKit Patcher/Scripts/AppData/Local/LocalMetaData.cs @@ -40,6 +40,12 @@ private struct Data [DefaultValue("none")] [JsonProperty("product_key_encryption", DefaultValueHandling = DefaultValueHandling.Populate)] public string ProductKeyEncryption; + + [JsonProperty("start_exe_path")] + public string MainExecutable; + + [JsonProperty("start_exe_args")] + public string MainExecutableArgs; [JsonProperty("_fileVersions")] public Dictionary FileVersionIds; } @@ -174,6 +180,24 @@ public string GetProductKey() { return _data.ProductKey; } + + public void SetMainExecutableAndArgs(string mainExecutable, string mainExecutableArgs) + { + _data.MainExecutable = mainExecutable; + _data.MainExecutableArgs = mainExecutableArgs; + + SaveData(); + } + + public string GetMainExecutable() + { + return _data.MainExecutable; + } + + public string MainExecutableArgs + { + get { return _data.MainExecutableArgs; } + } private void CreateDataDir() { diff --git a/Assets/PatchKit Patcher/Scripts/AppStarter.cs b/Assets/PatchKit Patcher/Scripts/AppStarter.cs index edef67b5..06c9c34d 100644 --- a/Assets/PatchKit Patcher/Scripts/AppStarter.cs +++ b/Assets/PatchKit Patcher/Scripts/AppStarter.cs @@ -31,13 +31,16 @@ public AppStarter(App app) private string ResolveExecutablePath(AppVersion? appVersion) { PlatformType platformType = Platform.GetPlatformType(); - - if (appVersion.HasValue && - !string.IsNullOrEmpty(appVersion.Value.MainExecutable)) + string mainExecutable = (appVersion.HasValue && + !string.IsNullOrEmpty(appVersion.Value.MainExecutable)) + ? appVersion.Value.MainExecutable + : _app.LocalMetaData.GetMainExecutable(); + + if (!string.IsNullOrEmpty(mainExecutable)) { string executablePath = Path.Combine( _app.LocalDirectory.Path, - appVersion.Value.MainExecutable); + mainExecutable); bool isOSXApp = platformType == PlatformType.OSX && executablePath.EndsWith(".app") && @@ -97,6 +100,10 @@ private void StartAppVersion(AppVersion? appVersion, string customArgs) { appArgs += " " + appVersion.Value.MainExecutableArgs; } + else if (!string.IsNullOrEmpty(_app.LocalMetaData.MainExecutableArgs)) + { + appArgs += " " + _app.LocalMetaData.MainExecutableArgs; + } if (appFilePath == null) { diff --git a/Assets/PatchKit Patcher/Scripts/Patcher.cs b/Assets/PatchKit Patcher/Scripts/Patcher.cs index 4b1ca545..863940ed 100644 --- a/Assets/PatchKit Patcher/Scripts/Patcher.cs +++ b/Assets/PatchKit Patcher/Scripts/Patcher.cs @@ -14,6 +14,7 @@ using UnityEngine; using CancellationToken = PatchKit.Unity.Patcher.Cancellation.CancellationToken; using System.IO; +using PatchKit.Api.Models.Main; using PatchKit.Network; using PatchKit.Unity.Patcher.AppData; using PatchKit.Unity.Patcher.AppData.FileSystem; @@ -899,6 +900,7 @@ private void ThreadUpdateApp(bool automatically, CancellationToken cancellationT { _appInfo.Value = _app.RemoteMetaData.GetAppInfo(!automatically, _updateAppCancellationTokenSource.Token); _remoteVersionId.Value = _app.GetLatestVersionId(!automatically, _updateAppCancellationTokenSource.Token); + if (_app.IsFullyInstalled()) { _localVersionId.Value = _app.GetInstalledVersionId(); @@ -915,6 +917,10 @@ private void ThreadUpdateApp(bool automatically, CancellationToken cancellationT appUpdater.Update(_updateAppCancellationTokenSource.Token); _wasUpdateSuccessfulOrNotNecessary = true; } + + AppVersion latestAppVersion = + _app.RemoteMetaData.GetAppVersionInfo(_remoteVersionId.Value.Value, false, cancellationToken); + _app.LocalMetaData.SetMainExecutableAndArgs(latestAppVersion.MainExecutable, latestAppVersion.MainExecutableArgs); } catch (OperationCanceledException) { diff --git a/Assets/PatchKit Patcher/Scripts/Version.cs b/Assets/PatchKit Patcher/Scripts/Version.cs index 3e5326cb..44ae30da 100644 --- a/Assets/PatchKit Patcher/Scripts/Version.cs +++ b/Assets/PatchKit Patcher/Scripts/Version.cs @@ -4,7 +4,7 @@ public static class Version { public const int Major = 3; public const int Minor = 17; - public const int Patch = 5; + public const int Patch = 6; public const int Hotfix = 0; public static string Value diff --git a/CHANGELOG.md b/CHANGELOG.md index c11075e0..36bf7068 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [3.17.6.0] +### Fixed +- Starting a valid executable in offline mode (#2146) + ## [3.17.5.0] ### Added - Debug menu (available through Ctrl + Shift + D) (#2081)