public static void DownloadDepotsForGame(string game, string branch)
        {
            var        infos2   = new List <DepotDownloadInfo2>();
            var        infos3   = new List <DepotDownloadInfo3>();
            List <int> depotIDs = CDRManager.GetDepotIDsForGameserver(game, ContentDownloader.Config.DownloadAllPlatforms);

            foreach (var depot in depotIDs)
            {
                int depotVersion = CDRManager.GetLatestDepotVersion(depot, ContentDownloader.Config.PreferBetaVersions);
                if (depotVersion == -1)
                {
                    Console.WriteLine("Error: Unable to find DepotID {0} in the CDR!", depot);
                    ContentDownloader.ShutdownSteam3();
                    continue;
                }

                IDepotDownloadInfo info = GetDepotInfo(depot, depotVersion, 0, branch);
                if (info.GetDownloadType() == DownloadSource.Steam2)
                {
                    infos2.Add((DepotDownloadInfo2)info);
                }
                else if (info.GetDownloadType() == DownloadSource.Steam3)
                {
                    infos3.Add((DepotDownloadInfo3)info);
                }
            }

            if (infos2.Count() > 0)
            {
                DownloadSteam2(infos2);
            }

            if (infos3.Count() > 0)
            {
                DownloadSteam3(infos3);
            }
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                PrintUsage();
                return;
            }

            DebugLog.Enabled = false;

            ServerCache.Build();
            CDRManager.Update();

            if (HasParameter(args, "-list"))
            {
                CDRManager.ListGameServers();
                return;
            }

            bool bGameserver   = true;
            bool bApp          = false;
            bool bListDepots   = HasParameter(args, "-listdepots");
            bool bDumpManifest = HasParameter(args, "-manifest");

            int    appId    = -1;
            int    depotId  = -1;
            string gameName = GetStringParameter(args, "-game");

            if (gameName == null)
            {
                appId       = GetIntParameter(args, "-app");
                bGameserver = false;

                depotId = GetIntParameter(args, "-depot");

                if (depotId == -1 && appId == -1)
                {
                    Console.WriteLine("Error: -game, -app, or -depot not specified!");
                    return;
                }
                else if (appId >= 0)
                {
                    bApp = true;
                }
            }

            ContentDownloader.Config.DownloadManifestOnly = bDumpManifest;

            int cellId = GetIntParameter(args, "-cellid");

            if (cellId == -1)
            {
                cellId = 0;
                Console.WriteLine(
                    "Warning: Using default CellID of 0! This may lead to slow downloads. " +
                    "You can specify the CellID using the -cellid parameter");
            }

            ContentDownloader.Config.CellID = cellId;

            int depotVersion = GetIntParameter(args, "-version");

            ContentDownloader.Config.PreferBetaVersions = HasParameter(args, "-beta");

            // this is a Steam2 option
            if (!bGameserver && !bApp && depotVersion == -1)
            {
                int latestVer = CDRManager.GetLatestDepotVersion(depotId, ContentDownloader.Config.PreferBetaVersions);

                if (latestVer == -1)
                {
                    Console.WriteLine("Error: Unable to find DepotID {0} in the CDR!", depotId);
                    return;
                }

                string strVersion = GetStringParameter(args, "-version");
                if (strVersion != null && strVersion.Equals("latest", StringComparison.OrdinalIgnoreCase))
                {
                    Console.WriteLine("Using latest version: {0}", latestVer);
                    depotVersion = latestVer;
                }
                else if (strVersion == null)
                {
                    // this could probably be combined with the above
                    Console.WriteLine("No version specified.");
                    Console.WriteLine("Using latest version: {0}", latestVer);
                    depotVersion = latestVer;
                }
                else
                {
                    Console.WriteLine("Available depot versions:");
                    Console.WriteLine("  Oldest: 0");
                    Console.WriteLine("  Newest: {0}", latestVer);
                    return;
                }
            }

            string fileList = GetStringParameter(args, "-filelist");

            string[] files = null;

            if (fileList != null)
            {
                try
                {
                    string fileListData = File.ReadAllText(fileList);
                    files = fileListData.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);

                    ContentDownloader.Config.UsingFileList        = true;
                    ContentDownloader.Config.FilesToDownload      = new List <string>();
                    ContentDownloader.Config.FilesToDownloadRegex = new List <Regex>();

                    foreach (var fileEntry in files)
                    {
                        try
                        {
                            Regex rgx = new Regex(fileEntry, RegexOptions.Compiled | RegexOptions.IgnoreCase);
                            ContentDownloader.Config.FilesToDownloadRegex.Add(rgx);
                        }
                        catch
                        {
                            ContentDownloader.Config.FilesToDownload.Add(fileEntry);
                            continue;
                        }
                    }

                    Console.WriteLine("Using filelist: '{0}'.", fileList);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Warning: Unable to load filelist: {0}", ex.ToString());
                }
            }

            string username = GetStringParameter(args, "-username");
            string password = GetStringParameter(args, "-password");

            ContentDownloader.Config.InstallDirectory = GetStringParameter(args, "-dir");
            bool bNoExclude = HasParameter(args, "-no-exclude");

            ContentDownloader.Config.DownloadAllPlatforms = HasParameter(args, "-all-platforms");

            if (username != null && password == null)
            {
                Console.Write("Enter account password: "******"Error: No depots for specified game '{0}'", gameName);
                    return;
                }

                if (bListDepots)
                {
                    Console.WriteLine("\n  '{0}' Depots:", gameName);

                    foreach (var depot in depotIDs)
                    {
                        var depotName = CDRManager.GetDepotName(depot);
                        Console.WriteLine("{0} - {1}", depot, depotName);
                    }

                    return;
                }

                foreach (int currentDepotId in depotIDs)
                {
                    depotVersion = CDRManager.GetLatestDepotVersion(currentDepotId, ContentDownloader.Config.PreferBetaVersions);
                    if (depotVersion == -1)
                    {
                        Console.WriteLine("Error: Unable to find DepotID {0} in the CDR!", currentDepotId);
                        ContentDownloader.ShutdownSteam3();
                        return;
                    }

                    ContentDownloader.DownloadDepot(currentDepotId, depotVersion);
                }
            }

            ContentDownloader.ShutdownSteam3();
        }