From d621c45a9d41c749999478bea0f20cbaf8ad9059 Mon Sep 17 00:00:00 2001 From: Nick Blakely Date: Thu, 10 Sep 2020 22:50:39 -0700 Subject: [PATCH] Misc cleanup. Handle download failures appropriately and ensure GPatch closes launcher/game. --- GPatch/CopyBinaries.bat | 1 + GPatch/GPatch.nsi | 6 ++++- Giants.EffectCompiler/Compiler/FxCompiler.cs | 2 ++ .../Decompiler/FxDecompiler.cs | 6 +++++ Giants.Launcher/ApplicationNames.cs | 2 ++ Giants.Launcher/LauncherForm.cs | 23 +++++++++++-------- Giants.Launcher/Native/RendererInterop.cs | 3 ++- .../Properties/Resources.Designer.cs | 4 ++-- Giants.Launcher/Properties/Resources.resx | 4 ++-- Giants.Launcher/Updater/Updater.cs | 6 +++-- 10 files changed, 40 insertions(+), 17 deletions(-) diff --git a/GPatch/CopyBinaries.bat b/GPatch/CopyBinaries.bat index 9afbd4e..9b290f9 100644 --- a/GPatch/CopyBinaries.bat +++ b/GPatch/CopyBinaries.bat @@ -1,5 +1,6 @@ xcopy "%GIANTS_PATH%\gg_dx7r.dll" "Files\" /Y xcopy "%GIANTS_PATH%\gg_dx9r.dll" "Files\" /Y +xcopy "%GIANTS_PATH%\gg_null.dll" "Files\" /Y xcopy "%GIANTS_PATH%\dedicated.exe" "Files\" /Y xcopy "%GIANTS_PATH%\Giants.exe" "Files\" /Y xcopy "%GIANTS_PATH%\GiantsMain.exe" "Files\" /Y diff --git a/GPatch/GPatch.nsi b/GPatch/GPatch.nsi index d466c76..eb2a5a4 100644 --- a/GPatch/GPatch.nsi +++ b/GPatch/GPatch.nsi @@ -42,7 +42,7 @@ SetCompressor /SOLID lzma ; MUI end ------ Name "${PRODUCT_NAME} ${PRODUCT_VERSION}" -OutFile "Output\GPatch1_498_206_0.exe" +OutFile "Output\GPatch1_498_209_0.exe" InstallDir "$PROGRAMFILES\Giants\" InstallDirRegKey HKCU "SOFTWARE\PlanetMoon\Giants" "DestDir" ShowInstDetails hide @@ -55,6 +55,9 @@ Section SectionIn RO SetOverwrite on + nsExec::Exec "taskkill /F /IM Giants.exe" + nsExec::Exec "taskkill /F /IM GiantsMain.exe" + ; Install DX redist for DX9 renderer SetOutPath "$INSTDIR\Redist" File /r "Files\Redist\*.*" @@ -76,6 +79,7 @@ Section Delete $INSTDIR\gg_dx7r.dll Delete $INSTDIR\gg_dx8r.dll Delete $INSTDIR\gg_dx9r.dll + Delete $INSTDIR\gg_null.dll Delete $INSTDIR\Giants.exe Delete $INSTDIR\BugTrap.dll Delete $INSTDIR\GiantsMain.exe diff --git a/Giants.EffectCompiler/Compiler/FxCompiler.cs b/Giants.EffectCompiler/Compiler/FxCompiler.cs index c0db85d..e3f743a 100644 --- a/Giants.EffectCompiler/Compiler/FxCompiler.cs +++ b/Giants.EffectCompiler/Compiler/FxCompiler.cs @@ -137,6 +137,8 @@ Offset = checked((int)binaryWriter.BaseStream.Position) }; + logger.Info($"Compiling {tokens[1]}"); + tableOfContentsSize += contentEntry.Name.Length + 1 + sizeof(int); tableOfContents.Add(contentEntry); diff --git a/Giants.EffectCompiler/Decompiler/FxDecompiler.cs b/Giants.EffectCompiler/Decompiler/FxDecompiler.cs index a6f057a..807eb81 100644 --- a/Giants.EffectCompiler/Decompiler/FxDecompiler.cs +++ b/Giants.EffectCompiler/Decompiler/FxDecompiler.cs @@ -94,6 +94,7 @@ { foreach (var kvp in this.tableOfContents) { + this.WriteHeader(fileStream); this.ProcessEffect(binaryReader, fileStream, kvp.Key, kvp.Value); } } @@ -104,6 +105,11 @@ } } + private void WriteHeader(IndentedTextWriter fileStream) + { + fileStream.WriteLine("; Generated by FX Compiler. Comments will be lost."); + } + private void ProcessEffect( BinaryReader reader, IndentedTextWriter fileStream, diff --git a/Giants.Launcher/ApplicationNames.cs b/Giants.Launcher/ApplicationNames.cs index 645bd34..0bd027c 100644 --- a/Giants.Launcher/ApplicationNames.cs +++ b/Giants.Launcher/ApplicationNames.cs @@ -4,6 +4,8 @@ { public const string Giants = nameof(Giants); + public const string GiantsBeta = nameof(GiantsBeta); + public const string GiantsLauncher = nameof(GiantsLauncher); } } diff --git a/Giants.Launcher/LauncherForm.cs b/Giants.Launcher/LauncherForm.cs index be6eaa7..a1cab51 100644 --- a/Giants.Launcher/LauncherForm.cs +++ b/Giants.Launcher/LauncherForm.cs @@ -40,13 +40,20 @@ namespace Giants.Launcher // Set window title this.Text = GameName; - this.httpClient = new HttpClient(); - this.versionHttpClient = new VersionClient(this.httpClient); - this.versionHttpClient.BaseUrl = BaseUrl; - - this.communityHttpClient = new CommunityClient(this.httpClient); - this.communityHttpClient.BaseUrl = BaseUrl; - } + this.httpClient = new HttpClient( + new HttpClientHandler() + { + UseProxy = false + }); + this.versionHttpClient = new VersionClient(this.httpClient) + { + BaseUrl = BaseUrl + }; + this.communityHttpClient = new CommunityClient(this.httpClient) + { + BaseUrl = BaseUrl + }; + } private void btnExit_Click(object sender, EventArgs e) { @@ -153,7 +160,6 @@ namespace Giants.Launcher } } - private async Task CheckForUpdates(Dictionary appVersions) { this.updater = new Updater( @@ -202,7 +208,6 @@ namespace Giants.Launcher NativeMethods.ReleaseCapture(); NativeMethods.SendMessage(this.Handle, NativeMethods.WM_NCLBUTTONDOWN, NativeMethods.HT_CAPTION, 0); } - } private void LauncherForm_Shown(object sender, EventArgs e) diff --git a/Giants.Launcher/Native/RendererInterop.cs b/Giants.Launcher/Native/RendererInterop.cs index 698f9b3..772fd6e 100644 --- a/Giants.Launcher/Native/RendererInterop.cs +++ b/Giants.Launcher/Native/RendererInterop.cs @@ -16,6 +16,7 @@ namespace Giants.Launcher public int priority; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] public string rendererName; + public int interfaceVersion; }; #pragma warning restore 649 @@ -60,7 +61,7 @@ namespace Giants.Launcher // Make interop call to native renderer DLLs to get capability info var interopCaps = new RendererInterop.GFXCapabilityInfo(); string path = Path.Combine(file.DirectoryName, file.Name); - if (GetRendererCapabilities(path, ref interopCaps)) + if (GetRendererCapabilities(path, ref interopCaps) && interopCaps.priority >= 0) { RendererInfo caps = new RendererInfo(path, ref interopCaps); capabilities.Add(caps); diff --git a/Giants.Launcher/Properties/Resources.Designer.cs b/Giants.Launcher/Properties/Resources.Designer.cs index 2bdf402..6da43b4 100644 --- a/Giants.Launcher/Properties/Resources.Designer.cs +++ b/Giants.Launcher/Properties/Resources.Designer.cs @@ -287,7 +287,7 @@ namespace Giants.Launcher { } /// - /// Looks up a localized string similar to An update is available: version {0}. Download it?. + /// Looks up a localized string similar to An update is available to version {0}. Download it?. /// internal static string UpdateAvailableText { get { @@ -305,7 +305,7 @@ namespace Giants.Launcher { } /// - /// Looks up a localized string similar to Failed to download update. Please visit www.giantswd.org and download the update manually. The error was: {0}. + /// Looks up a localized string similar to Failed to download update. Please visit www.giantswd.org and download the update manually.\nThe error was: {0}. /// internal static string UpdateDownloadFailedText { get { diff --git a/Giants.Launcher/Properties/Resources.resx b/Giants.Launcher/Properties/Resources.resx index d36cf7f..88f5efa 100644 --- a/Giants.Launcher/Properties/Resources.resx +++ b/Giants.Launcher/Properties/Resources.resx @@ -155,13 +155,13 @@ Could not locate an installation of {0}. The launcher will now exit. - An update is available: version {0}. Download it? + An update is available to version {0}. Download it? Update Available - Failed to download update. Please visit www.giantswd.org and download the update manually. The error was: {0} + Failed to download update. Please visit www.giantswd.org and download the update manually.\nThe error was: {0} Update Failed diff --git a/Giants.Launcher/Updater/Updater.cs b/Giants.Launcher/Updater/Updater.cs index 87c856d..a5891ca 100644 --- a/Giants.Launcher/Updater/Updater.cs +++ b/Giants.Launcher/Updater/Updater.cs @@ -34,8 +34,10 @@ namespace Giants.Launcher this.StartApplicationUpdate(applicationType, versionInfo); } } - catch (Exception) + catch (Exception e) { + string errorMsg = string.Format(Resources.UpdateDownloadFailedText, e.Message); + MessageBox.Show(errorMsg, Resources.UpdateDownloadFailedTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } return Task.CompletedTask; @@ -66,7 +68,7 @@ namespace Giants.Launcher string.Format(Resources.UpdateAvailableText, this.ToVersion(versionInfo.Version).ToString()) : string.Format(Resources.LauncherUpdateAvailableText, this.ToVersion(versionInfo.Version).ToString()); - if (MessageBox.Show(updateMsg, Resources.UpdateAvailableTitle, MessageBoxButtons.YesNo) == DialogResult.No) + if (MessageBox.Show(updateMsg, Resources.UpdateAvailableTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No) { return; // User declined update }