コード例 #1
0
        internal ConfigFile(string Filename, ConfigEngine Engine)
        {
            if (!File.Exists(Filename))
            {
                throw new FileNotFoundException("Configuration file '" + Filename + "' could not be found.", Filename);
            }

            m_Filename = Filename;
            m_Engine   = Engine;

            Reload();
        }
コード例 #2
0
 internal ConfigSet(string Name, ConfigEngine Engine)
 {
     m_Name   = Name;
     m_Engine = Engine;
 }
コード例 #3
0
        public ScriptEngine(ConfigEngine ConfigEngine, string[] PathList)
        {
            Console.WriteLine("* Loading Server Script packages:\n");
            m_ConfigEngine = ConfigEngine;

            #region Loading of Package List

            ArrayList PackageList = new ArrayList();
            foreach (string Path in PathList)
            {
                string[] TempFiles = Utilities.FindFiles(Path, "Package.xml", true);

                foreach (string File in TempFiles)
                {
                    //We don't want duplicate files.
                    if (!PackageList.Contains(File))
                    {
                        PackageList.Add(File);
                    }
                }
            }

            #endregion

            uint ScriptCount = 0;
            #region Loading of Packages in Package List

            foreach (string Package in PackageList)
            {
                ScriptCount += LoadPackage(Package);
            }

            #endregion

            if (ScriptCount > 0)
            {
                #region Script Compilation

                Console.WriteLine("  {0} Packages loaded containing {1} source files, compiling...", PackageList.Count, ScriptCount);
                CompilerResults Result = Compile();

                int ErrorCount   = 0;
                int WarningCount = 0;
                foreach (CompilerError Error in Result.Errors)
                {
                    if (!Error.IsWarning)
                    {
                        ErrorCount++;
                    }
                    else
                    {
                        WarningCount++;
                    }
                }

                if (ErrorCount > 0)
                {
                    Console.WriteLine("  [Compilation failed, errors: {0}, warnings: {1}]", ErrorCount, WarningCount);

                    StringBuilder ErrorString = new StringBuilder();
                    ErrorString.Append("One or more errors or warnings occured during the script compilation process, please rectify them and restart Maelstrom:\n\n");

                    foreach (CompilerError Error in Result.Errors)
                    {
                        if (!Error.IsWarning)
                        {
                            if (Error.FileName == "")
                            {
                                ErrorString.Append("File: Server Core\n");
                            }
                            else
                            {
                                ErrorString.Append("File: " + Error.FileName + "\n");
                                ErrorString.Append("Location: " + Error.Column + ", " + Error.Line + "\n");
                            }

                            ErrorString.Append("Error: " + Error.ErrorText + "\n");
                        }
                    }

                    throw new Exception(ErrorString.ToString());
                }
                else
                {
                    Console.WriteLine("  [Compilation completed successfully, warnings: {0}]", WarningCount);
                }

                #endregion
            }
            else
            {
                Console.WriteLine("  {0} Packages loaded containing no scripts.", PackageList.Count);
            }
        }