From bfebf5178731e226034899ca7ccdb0dd4b96854c Mon Sep 17 00:00:00 2001 From: Starkku Date: Fri, 28 Jan 2022 22:16:25 +0200 Subject: [PATCH 1/5] Handle system spec fetch exceptions separately. Prevents no info displaying if one type of information failed to retrieve. --- DXMainClient/Startup.cs | 49 +++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/DXMainClient/Startup.cs b/DXMainClient/Startup.cs index 21c707280..ddd742521 100644 --- a/DXMainClient/Startup.cs +++ b/DXMainClient/Startup.cs @@ -91,7 +91,7 @@ public void Execute() if (CUpdater.CustomComponents != null) { Logger.Log("Removing partial custom component downloads."); - foreach (CustomComponent component in CUpdater.CustomComponents) + foreach (var component in CUpdater.CustomComponents) { try { @@ -133,7 +133,7 @@ private void PruneFiles(string directoryPath, DateTime pruneThresholdTime) { foreach (string fsEntry in Directory.EnumerateFileSystemEntries(directoryPath)) { - FileAttributes attr = File.GetAttributes(fsEntry); + var attr = File.GetAttributes(fsEntry); if ((attr & FileAttributes.Directory) == FileAttributes.Directory) PruneFiles(fsEntry, pruneThresholdTime); else @@ -220,37 +220,53 @@ private static void MigrateLogFiles(string currentDirectory, string newDirectory } /// - /// Writes processor and graphics card info to the log file. + /// Writes processor, graphics card and memory info to the log file. /// private void CheckSystemSpecifications() { + string cpu = string.Empty; + string videoController = string.Empty; + string memory = string.Empty; + + ManagementObjectSearcher searcher; + try { - string cpu = string.Empty; - string videoController = string.Empty; - string memory = string.Empty; - - ManagementObjectSearcher searcher = - new ManagementObjectSearcher("SELECT * FROM Win32_Processor"); + searcher = new ManagementObjectSearcher("SELECT * FROM Win32_Processor"); foreach (var proc in searcher.Get()) { cpu = cpu + proc["Name"].ToString().Trim() + " (" + proc["NumberOfCores"] + " cores) "; } + } + catch + { + cpu = "CPU info not found"; + } + + try + { searcher = new ManagementObjectSearcher("SELECT * FROM Win32_VideoController"); foreach (ManagementObject mo in searcher.Get()) { - PropertyData currentBitsPerPixel = mo.Properties["CurrentBitsPerPixel"]; - PropertyData description = mo.Properties["Description"]; + var currentBitsPerPixel = mo.Properties["CurrentBitsPerPixel"]; + var description = mo.Properties["Description"]; if (currentBitsPerPixel != null && description != null) { if (currentBitsPerPixel.Value != null) videoController = videoController + "Video controller: " + description.Value.ToString().Trim() + " "; } } + } + catch + { + cpu = "Video controller info not found"; + } + try + { searcher = new ManagementObjectSearcher("Select * From Win32_PhysicalMemory"); ulong total = 0; @@ -261,14 +277,13 @@ private void CheckSystemSpecifications() if (total != 0) memory = "Total physical memory: " + (total >= 1073741824 ? total / 1073741824 + "GB" : total / 1048576 + "MB"); - - Logger.Log(string.Format("Hardware info: {0} | {1} | {2}", cpu.Trim(), videoController.Trim(), memory)); - } - catch (Exception ex) + catch { - Logger.Log("Checking system specifications failed. Message: " + ex.Message); + cpu = "Memory info not found"; } + + Logger.Log(string.Format("Hardware info: {0} | {1} | {2}", cpu.Trim(), videoController.Trim(), memory)); } @@ -289,7 +304,7 @@ private static void GenerateOnlineId() } ManagementObjectSearcher mos = new ManagementObjectSearcher("SELECT * FROM Win32_BaseBoard"); - ManagementObjectCollection moc = mos.Get(); + var moc = mos.Get(); string mbid = ""; foreach (ManagementObject mo in moc) { From 998de4440c181853e33bfa1b321e42fc83713d3a Mon Sep 17 00:00:00 2001 From: Starkku Date: Fri, 28 Jan 2022 22:55:14 +0200 Subject: [PATCH 2/5] Add current culture name & exception types to debug logging. --- DXMainClient/PreStartup.cs | 2 ++ DXMainClient/Startup.cs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/DXMainClient/PreStartup.cs b/DXMainClient/PreStartup.cs index 5a541fc8b..d3736dcd6 100644 --- a/DXMainClient/PreStartup.cs +++ b/DXMainClient/PreStartup.cs @@ -101,6 +101,7 @@ static void HandleExcept(object sender, UnhandledExceptionEventArgs e) Exception ex = (Exception)e.ExceptionObject; Logger.Log("KABOOOOOOM!!! Info:"); + Logger.Log("Type: " + ex.GetType().Name); Logger.Log("Message: " + ex.Message); Logger.Log("Source: " + ex.Source); Logger.Log("TargetSite.Name: " + ex.TargetSite.Name); @@ -108,6 +109,7 @@ static void HandleExcept(object sender, UnhandledExceptionEventArgs e) if (ex.InnerException != null) { Logger.Log("InnerException info:"); + Logger.Log("Type: " + ex.InnerException.GetType().Name); Logger.Log("Message: " + ex.InnerException.Message); Logger.Log("Stacktrace: " + ex.InnerException.StackTrace); } diff --git a/DXMainClient/Startup.cs b/DXMainClient/Startup.cs index ddd742521..569e78cbf 100644 --- a/DXMainClient/Startup.cs +++ b/DXMainClient/Startup.cs @@ -14,6 +14,7 @@ using DTAClient.Online; using ClientCore.INIProcessing; using System.Threading.Tasks; +using System.Globalization; namespace DTAClient { @@ -47,6 +48,7 @@ public void Execute() Logger.Log("Operating system: " + Environment.OSVersion.VersionString); Logger.Log("Selected OS profile: " + MainClientConstants.OSId.ToString()); + Logger.Log("Current culture: " + CultureInfo.CurrentCulture?.ToString()); // The query in CheckSystemSpecifications takes lots of time, // so we'll do it in a separate thread to make startup faster From 768b5a023fb624265aa9ea14141accca43cabc36 Mon Sep 17 00:00:00 2001 From: Starkku Date: Fri, 28 Jan 2022 23:29:05 +0200 Subject: [PATCH 3/5] Revert inclusion of exception types in debug logs. --- DXMainClient/PreStartup.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/DXMainClient/PreStartup.cs b/DXMainClient/PreStartup.cs index d3736dcd6..5a541fc8b 100644 --- a/DXMainClient/PreStartup.cs +++ b/DXMainClient/PreStartup.cs @@ -101,7 +101,6 @@ static void HandleExcept(object sender, UnhandledExceptionEventArgs e) Exception ex = (Exception)e.ExceptionObject; Logger.Log("KABOOOOOOM!!! Info:"); - Logger.Log("Type: " + ex.GetType().Name); Logger.Log("Message: " + ex.Message); Logger.Log("Source: " + ex.Source); Logger.Log("TargetSite.Name: " + ex.TargetSite.Name); @@ -109,7 +108,6 @@ static void HandleExcept(object sender, UnhandledExceptionEventArgs e) if (ex.InnerException != null) { Logger.Log("InnerException info:"); - Logger.Log("Type: " + ex.InnerException.GetType().Name); Logger.Log("Message: " + ex.InnerException.Message); Logger.Log("Stacktrace: " + ex.InnerException.StackTrace); } From 3fdbbc790b290db1c5296eeceff664ca8e07dc76 Mon Sep 17 00:00:00 2001 From: devo1929 Date: Mon, 31 Jan 2022 10:27:26 -0500 Subject: [PATCH 4/5] Fix issue with game modes not being handled on guest sides --- .../Multiplayer/GameLobby/CnCNetGameLobby.cs | 23 ++++--------------- 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/DXMainClient/DXGUI/Multiplayer/GameLobby/CnCNetGameLobby.cs b/DXMainClient/DXGUI/Multiplayer/GameLobby/CnCNetGameLobby.cs index 5712eb2c6..50fc9f0e6 100644 --- a/DXMainClient/DXGUI/Multiplayer/GameLobby/CnCNetGameLobby.cs +++ b/DXMainClient/DXGUI/Multiplayer/GameLobby/CnCNetGameLobby.cs @@ -1028,15 +1028,14 @@ private void ApplyGameOptions(string sender, string message) } string mapName = parts[partIndex + 8]; - GameMode currentGameMode = GameMode; - Map currentMap = Map; + GameModeMap currentGameModeMap = GameModeMap; lastGameMode = gameMode; lastMapSHA1 = mapSHA1; lastMapName = mapName; - GameModeMap = GameModeMaps.Find(gmm => gmm.GameMode.UIName == gameMode); - if (GameMode == null) + GameModeMap = GameModeMaps.Find(gmm => gmm.GameMode.UIName == gameMode && gmm.Map.SHA1 == mapSHA1); + if (GameModeMap == null) { ChangeMap(null); @@ -1045,21 +1044,9 @@ private void ApplyGameOptions(string sender, string message) else ShowOfficialMapMissingMessage(mapSHA1); } - else + else if (GameModeMap != currentGameModeMap) { - GameModeMap = GameModeMaps.Find(gmm => gmm.Map.SHA1 == mapSHA1); - - if (Map == null) - { - ChangeMap(null); - - if (!isMapOfficial) - RequestMap(mapSHA1); - else - ShowOfficialMapMissingMessage(mapSHA1); - } - else if (GameMode != currentGameMode || Map != currentMap) - ChangeMap(GameModeMap); + ChangeMap(GameModeMap); } // By changing the game options after changing the map, we know which From 3873ee4ac7f200fd4f5ae8544616d2cc9e2835a2 Mon Sep 17 00:00:00 2001 From: Kerbiter Date: Tue, 1 Feb 2022 17:38:28 +0200 Subject: [PATCH 5/5] Bump version --- DXMainClient/Properties/AssemblyInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DXMainClient/Properties/AssemblyInfo.cs b/DXMainClient/Properties/AssemblyInfo.cs index 521c8adf8..66f71b9d5 100644 --- a/DXMainClient/Properties/AssemblyInfo.cs +++ b/DXMainClient/Properties/AssemblyInfo.cs @@ -32,4 +32,4 @@ // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("2.6.11.0")] -[assembly: AssemblyFileVersion("2.6.11.0")] +[assembly: AssemblyFileVersion("2.6.11.1")]