Ejemplo n.º 1
0
        private static void CompileThreaded()
        {
            try
            {
                ProgressManager.SetProgress(0);

                var mapErrors = new List <MapErrors>();


                foreach (string mapFile in MapFiles)
                {
                    string cleanMapName = Path.GetFileNameWithoutExtension(mapFile);

                    var compileErrors = new List <Error>();
                    CompilePalLogger.LogLine($"Starting compilation of {cleanMapName}");

                    //Update the grid so we have the most up to date order
                    OrderManager.UpdateOrder();

                    GameConfigurationManager.BackupCurrentContext();
                    foreach (var compileProcess in OrderManager.CurrentOrder)
                    {
                        currentCompileProcess = compileProcess;
                        compileProcess.Run(GameConfigurationManager.BuildContext(mapFile));

                        if (compileProcess is CompileExecutable executable)
                        {
                            compileErrors.AddRange(executable.CompileErrors);

                            //Portal 2 cannot work with leaks, stop compiling if we do get a leak.
                            if (GameConfigurationManager.GameConfiguration.Name == "Portal 2")
                            {
                                if (executable.Name == "VBSP" && executable.CompileErrors.Count > 0)
                                {
                                    //we have a VBSP error, aka a leak -> stop compiling;
                                    break;
                                }
                            }
                        }

                        ProgressManager.Progress += (1d / ConfigurationManager.CompileProcesses.Count(c => c.Metadata.DoRun &&
                                                                                                      c.PresetDictionary.ContainsKey(ConfigurationManager.CurrentPreset))) / MapFiles.Count;
                    }

                    mapErrors.Add(new MapErrors {
                        MapName = cleanMapName, Errors = compileErrors
                    });

                    GameConfigurationManager.RestoreCurrentContext();
                }

                MainWindow.ActiveDispatcher.Invoke(() => postCompile(mapErrors));
            }
            catch (ThreadAbortException) { ProgressManager.ErrorProgress(); }
        }