Exemplo n.º 1
0
        public override async Task BuildLightmap(string scenario, string bsp, LightmapArgs args, ICancellableProgress <int>?progress)
        {
            if (progress is not null)
            {
                progress.DisableCancellation();
                progress.MaxValue += 1;
            }
            await RunTool(ToolType.Tool, new() { "lightmaps", scenario, bsp, Convert.ToInt32(args.radiosity_quality).ToString(), args.Threshold.ToString() });

            if (progress is not null)
            {
                progress.Report(1);
            }
        }
Exemplo n.º 2
0
        public override async Task BuildLightmap(string scenario, string bsp, LightmapArgs args, ICancellableProgress <int>?progress)
        {
            string quality = GetLightmapQuality(args);

            if (args.instanceCount > 1 && (Profile.BuildType == build_type.release_mcc || Profile.CommunityTools)) // multi instance?
            {
                if (progress is not null)
                {
                    progress.MaxValue += 1 + args.instanceCount;
                }

                async Task RunInstance(int index)
                {
                    if (index == 0 && !Profile.IsH2Codez()) // not needed for H2Codez
                    {
                        if (progress is not null)
                        {
                            progress.Status = "Delaying launch of zeroth instance";
                        }
                        await Task.Delay(1000 * 70, progress.GetCancellationToken());
                    }
                    Utility.Process.Result result = await RunLightmapWorker(
                        scenario,
                        bsp,
                        quality,
                        args.instanceCount,
                        index,
                        args.NoAssert,
                        progress.GetCancellationToken(),
                        args.instanceOutput
                        );

                    if (result is not null && result.HasErrorOccured)
                    {
                        progress.Cancel($"Tool worker {index} has failed - exit code {result.ReturnCode}");
                    }
                    if (progress is not null)
                    {
                        progress.Report(1);
                    }
                }

                var instances = new List <Task>();
                for (int i = args.instanceCount - 1; i >= 0; i--)
                {
                    instances.Add(RunInstance(i));
                }
                if (progress is not null)
                {
                    progress.Status = $"Running {args.instanceCount} instances";
                }
                await Task.WhenAll(instances);

                if (progress is not null)
                {
                    progress.Status = "Merging output";
                }

                await RunMergeLightmap(scenario, bsp, args.instanceCount, args.NoAssert);

                if (progress is not null)
                {
                    progress.Report(1);
                }
            }
            else
            {
                Debug.Assert(args.instanceCount == 1); // should be one, otherwise we got bad args
                if (progress is not null)
                {
                    progress.DisableCancellation();
                    progress.MaxValue += 1;
                }
                await RunTool((args.NoAssert && Profile.BuildType == build_type.release_mcc)?ToolType.ToolFast : ToolType.Tool, new() { "lightmaps", scenario, bsp, quality });

                if (progress is not null)
                {
                    progress.Report(1);
                }
            }
        }