From bfe267e194404f415d14780ed6f55329adacc6d8 Mon Sep 17 00:00:00 2001 From: Scott Ehlert Date: Fri, 1 Jul 2011 02:00:49 -0500 Subject: [PATCH] Actually download working server installs for GoldSrc/HL1 games. --- DepotDownloader/CDRManager.cs | 70 +++++++++++++++++++++++++++-------- 1 file changed, 54 insertions(+), 16 deletions(-) diff --git a/DepotDownloader/CDRManager.cs b/DepotDownloader/CDRManager.cs index 87600601..9a9e1163 100644 --- a/DepotDownloader/CDRManager.cs +++ b/DepotDownloader/CDRManager.cs @@ -123,6 +123,14 @@ namespace DepotDownloader public static string GetDepotName( int depotId ) { + // Match hardcoded names from hldsupdatetool for certain HL1 depots + if ( depotId == 1 ) + return "Half-Life Base Content"; + else if ( depotId == 4 ) + return "Linux Server Engine"; + else if ( depotId == 5 ) + return "Win32 Server Engine"; + App app = GetAppBlob( depotId ); if ( app == null ) @@ -208,32 +216,59 @@ namespace DepotDownloader App serverAppInfoBlob = GetAppBlob( 4 ); PlatformID platform = Environment.OSVersion.Platform; - string platformSuffix = ""; - - if ( platform == PlatformID.Win32NT ) - platformSuffix = "-win32"; - else if ( platform == PlatformID.Unix && !Util.IsMacOSX() ) - platformSuffix = "-linux"; - - int gameLen = gameName.Length; + bool goldSrc = false; - foreach ( var blobField in serverAppInfoBlob.FileSystems ) + if ( gameName.Equals( "valve", StringComparison.OrdinalIgnoreCase ) ) + goldSrc = true; + else { - string mountName = blobField.Name; + string platformSuffix = ""; + int gameLen = gameName.Length; + + if (platform == PlatformID.Win32NT) + platformSuffix = "-win32"; + else if (platform == PlatformID.Unix && !Util.IsMacOSX()) + platformSuffix = "-linux"; - if ( String.Compare(mountName, 0, gameName, 0, gameLen, true) == 0 ) + foreach (var blobField in serverAppInfoBlob.FileSystems) { - string suffix = mountName.Substring( gameLen ); + string mountName = blobField.Name; - if (suffix == "" || - suffix == platformSuffix || - allPlatforms && ( suffix == "-win32" || suffix == "-linux" ) ) + if (String.Compare(mountName, 0, gameName, 0, gameLen, true) == 0) { - appIDs.Add( blobField.AppID ); + string suffix = mountName.Substring(gameLen); + + if (suffix == "" || + suffix == platformSuffix || + allPlatforms && (suffix == "-win32" || suffix == "-linux")) + { + if ( blobField.AppID < 200 ) + goldSrc = true; + + appIDs.Add( blobField.AppID ); + } } } } + // For HL1 server installs, this is hardcoded in hldsupdatetool + if ( goldSrc ) + { + // Win32 or Linux Server Engine + if ( allPlatforms ) + { + appIDs.Add( 4 ); + appIDs.Add( 5 ); + } + else if ( platform == PlatformID.Win32NT ) + appIDs.Add( 5 ); + else if ( platform == PlatformID.Unix && !Util.IsMacOSX() ) + appIDs.Add( 4 ); + + // Half-Life Base Content + appIDs.Add( 1 ); + } + return appIDs; } @@ -263,6 +298,9 @@ namespace DepotDownloader List hl1Games = new List(); List thirdPartyGames = new List(); + // Hardcoded in hldsupdatetool + hl1Games.Add( "valve" ); + foreach ( var blobField in serverAppInfoBlob.FileSystems ) { int id = blobField.AppID;