Beispiel #1
0
        private static void CopyResources(string siteBase, SpringPaths paths, List <Resource> resources, PlasmaDownloader.PlasmaDownloader downloader)
        {
            var destMaps   = Path.Combine(paths.WritableDirectory, "maps");
            var sourceMaps = Path.Combine(siteBase, "autoregistrator", "maps");

            foreach (var res in resources)
            {
                Trace.TraceInformation("Copying {0}", res.InternalName);
                if (res.TypeID == ResourceType.Map)
                {
                    var fileName = res.ResourceContentFiles.ToList().Where(x => File.Exists(Path.Combine(sourceMaps, x.FileName))).OrderByDescending(x => x.LinkCount).FirstOrDefault()?.FileName; // get registered file names

                    fileName = fileName ?? res.ResourceContentFiles
                               .Where(x => x.Links != null).SelectMany(x => x.Links.Split('\n'))
                               .Where(x => x != null).Select(x => x.Substring(x.LastIndexOf('/') + 1, x.Length - x.LastIndexOf('/') - 1)).FirstOrDefault(x => !string.IsNullOrEmpty(x) && File.Exists(Path.Combine(sourceMaps, x))); // get filenames from url

                    if (fileName == null)
                    {
                        var prog = new DummyProgress();
                        if (!downloader.DownloadFile(DownloadType.MAP, res.InternalName, prog).Result)
                        {
                            Trace.TraceError("Cannot find map file: {0}", res.InternalName);
                        }
                        continue;
                    }


                    if (!File.Exists(Path.Combine(destMaps, fileName)))
                    {
                        File.Copy(Path.Combine(sourceMaps, fileName), Path.Combine(destMaps, fileName));
                    }
                }
                else if (res.MissionID != null)
                {
                    File.WriteAllBytes(Path.Combine(paths.WritableDirectory, "games", res.Mission.SanitizedFileName), res.Mission.Mutator);
                }
                else
                {
                    downloader.GetResource(DownloadType.RAPID, res.InternalName)?.WaitHandle.WaitOne();
                }
            }
        }
Beispiel #2
0
        private void Generate()
        {
            Utils.CheckPath(targetFolder);
            try
            {
                Directory.Delete(Path.Combine(targetFolder, "packages"), true);
                Directory.Delete(Path.Combine(targetFolder, "engine"), true);
                Directory.Delete(Path.Combine(targetFolder, "games"), true);
                Directory.Delete(Path.Combine(targetFolder, "rapid"), true);
                Directory.Delete(Path.Combine(targetFolder, "cache"), true);
                Directory.Delete(Path.Combine(targetFolder, "temp"), true);
                File.Delete(Path.Combine(targetFolder, "missions", "missions.json"));
            }
            catch { }

            var paths      = new SpringPaths(targetFolder, false, false);
            var downloader = new PlasmaDownloader.PlasmaDownloader(null, paths);
            var prog       = new DummyProgress();


            foreach (var plat in Enum.GetValues(typeof(SpringPaths.PlatformType)).Cast <SpringPaths.PlatformType>())
            {
                var sp = new SpringPaths(targetFolder, false, false, plat);
                var dn = new PlasmaDownloader.PlasmaDownloader(null, sp);

                if (!dn.DownloadFile(DownloadType.ENGINE, MiscVar.DefaultEngine, prog).Result)
                {
                    throw new ApplicationException("SteamDepot engine download failed: " + prog.Status);
                }
            }

            downloader.PackageDownloader.DoMasterRefresh();

            var chobbyName = downloader.PackageDownloader.GetByTag(GlobalConst.DefaultChobbyTag).InternalName;

            downloader.RapidHandling = RapidHandling.SdzNameTagForceDownload;

            if (!downloader.DownloadFile(DownloadType.RAPID, chobbyName, prog).Result)
            {
                throw new ApplicationException("SteamDepot chobby download failed: " + prog.Status);
            }
            if (!downloader.DownloadFile(DownloadType.RAPID, GlobalConst.DefaultZkTag, prog).Result)
            {
                throw new ApplicationException("SteamDepot zk download failed: " + prog.Status);
            }

            downloader.RapidHandling = RapidHandling.DefaultSdp;


            var campaignMaps = RegistratorRes.campaignMaps.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim())
                               .ToArray();

            CopyResources(siteBase, paths, GetMapList(campaignMaps), downloader);

            if (!downloader.UpdateMissions(prog).Result)
            {
                throw new ApplicationException("SteamDepot Error updating missions! " + prog.Status);
            }
            if (!downloader.UpdatePublicCommunityInfo(prog))
            {
                throw new ApplicationException("SteamDepot Error updating public community info! " + prog.Status);
            }


            CopyLobbyProgram();
            CopyExtraImages();

            downloader.PackageDownloader.DoMasterRefresh();


            File.WriteAllText(Path.Combine(paths.WritableDirectory, "steam_chobby.txt"), chobbyName);
            File.WriteAllText(Path.Combine(paths.WritableDirectory, "steam_engine.txt"), MiscVar.DefaultEngine);
            File.WriteAllText(Path.Combine(paths.WritableDirectory, "steam_deletesdp.txt"), "1");
        }
        /// <summary>
        /// Installs the listed haks (defined by hif files) on the module.
        /// </summary>
        /// <param name="hifs">The list of haks to add</param>
        /// <param name="moduleFile">The module to add the haks to</param>
        /// <param name="progress">An interface used to an object used to display
        /// progress information, or null if no progress information is desired</param>
        public static void InstallHaks(HakInfo[] hifs, string moduleFile,
			IHakInstallProgress progress)
        {
            // Force the thread to use the invariant culture to make the install
            // code work on foreign language versions of windows.
            CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture;
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
            try
            {
                // If no progress was given then use a dummy one which does nothing.
                if (null == progress) progress = new DummyProgress();

                // Invoke the private method on the singleton to do all the real work.
                Singleton.DoInstall(hifs, new string[] { moduleFile }, progress);
            }
            finally
            {
                Thread.CurrentThread.CurrentCulture = currentCulture;
            }
        }
Beispiel #4
0
        private void Generate()
        {
            Utils.CheckPath(targetFolder);
            try
            {
                Directory.Delete(Path.Combine(targetFolder, "pool"), true);
                Directory.Delete(Path.Combine(targetFolder, "packages"), true);
                Directory.Delete(Path.Combine(targetFolder, "engine"), true);
                Directory.Delete(Path.Combine(targetFolder, "games"), true);
                Directory.Delete(Path.Combine(targetFolder, "rapid"), true);
                File.Delete(Path.Combine(targetFolder, "missions", "missions.json"));
                File.Delete(Path.Combine(targetFolder, "cache", "repositories.json"));
            }
            catch { }

            var paths      = new SpringPaths(targetFolder, false, false);
            var downloader = new PlasmaDownloader.PlasmaDownloader(null, paths);
            var prog       = new DummyProgress();


            foreach (var plat in Enum.GetValues(typeof(SpringPaths.PlatformType)).Cast <SpringPaths.PlatformType>())
            {
                var sp = new SpringPaths(targetFolder, false, false, plat);
                var dn = new PlasmaDownloader.PlasmaDownloader(null, sp);

                if (!dn.DownloadFile(DownloadType.ENGINE, MiscVar.DefaultEngine, prog).Result)
                {
                    throw new ApplicationException("SteamDepot engine download failed: " + prog.Status);
                }
            }

            downloader.PackageDownloader.DoMasterRefresh();

            var chobbyName = downloader.PackageDownloader.GetByTag(GlobalConst.DefaultChobbyTag).InternalName;

            if (!downloader.DownloadFile(DownloadType.RAPID, chobbyName, prog).Result)
            {
                throw new ApplicationException("SteamDepot chobby download failed: " + prog.Status);
            }
            if (!downloader.DownloadFile(DownloadType.RAPID, GlobalConst.DefaultZkTag, prog).Result)
            {
                throw new ApplicationException("SteamDepot zk download failed: " + prog.Status);
            }


            File.WriteAllText(Path.Combine(paths.WritableDirectory, "steam_chobby.txt"), chobbyName);
            File.WriteAllText(Path.Combine(paths.WritableDirectory, "steam_engine.txt"), MiscVar.DefaultEngine);


            CopyResources(siteBase, paths, GetResourceList(), downloader);

            if (!downloader.UpdateMissions(prog).Result)
            {
                throw new ApplicationException("SteamDepot Error updating missions! " + prog.Status);
            }


            CopyLobbyProgram();
            CopyExtraImages();

            Utils.CheckPath(targetFolder);

            downloader.PackageDownloader.DoMasterRefresh();
        }