From d073b9ef34c08f829fbccd12c908cc207dbdb4c2 Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Fri, 2 Aug 2013 17:59:41 -0400 Subject: [PATCH] Fixed Steam3 content always downloading depots for all platforms. --- DepotDownloader/ContentDownloader.cs | 23 ++++++++++++++++++++--- DepotDownloader/Util.cs | 18 +++++++++++++++++- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/DepotDownloader/ContentDownloader.cs b/DepotDownloader/ContentDownloader.cs index 265b4669..238b1905 100644 --- a/DepotDownloader/ContentDownloader.cs +++ b/DepotDownloader/ContentDownloader.cs @@ -326,13 +326,30 @@ namespace DepotDownloader if (depots != null) { - foreach (var child in depots.Children) + foreach (var depotSection in depots.Children) { int id = -1; - if (int.TryParse(child.Name, out id) && child.Children.Count > 0 && (depotId == -1 || id == depotId)) + if (depotSection.Children.Count == 0) + continue; + + if (!int.TryParse(depotSection.Name, out id)) + continue; + + if (depotId > -1 && id != depotId) + continue; + + if (!Config.DownloadAllPlatforms) { - depotIDs.Add(id); + var depotConfig = depotSection["config"]; + if (depotConfig != KeyValue.Invalid && depotConfig["oslist"] != KeyValue.Invalid) + { + var oslist = depotSection["oslist"].Value.Split(','); + if (Array.IndexOf(oslist, Util.GetSteamOS()) == -1) + continue; + } } + + depotIDs.Add(id); } } diff --git a/DepotDownloader/Util.cs b/DepotDownloader/Util.cs index cf91cf4b..b9bbb8bb 100644 --- a/DepotDownloader/Util.cs +++ b/DepotDownloader/Util.cs @@ -18,7 +18,7 @@ namespace DepotDownloader // Environment.OSVersion.Platform returns PlatformID.Unix under Mono on OS X // Code adapted from Mono: mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUI.cs - public static bool IsMacOSX() + private static bool IsMacOSX() { if ( _isMacOSX != -1 ) return _isMacOSX == 1; @@ -54,6 +54,22 @@ namespace DepotDownloader return false; } + public static string GetSteamOS() + { + switch (Environment.OSVersion.Platform) + { + case PlatformID.Win32NT: + case PlatformID.Win32Windows: + return "windows"; + case PlatformID.MacOSX: + return "macos"; + case PlatformID.Unix: + return IsMacOSX() ? "macos" : "linux"; + } + + return "unknown"; + } + public static string ReadPassword() { ConsoleKeyInfo keyInfo;