static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                PrintWithColor("[ERROR] No API parameter specified", ConsoleColor.Red);

                return;
            }
            else if (args.Length < 2)
            {
                PrintWithColor("[ERROR] No project directory parameter specified", ConsoleColor.Red);

                return;
            }

            string api = args[0];
            string projectDirectory = args[1];

            // Configuration config lol
            Configuration config = LoadConfigurationFile();

            // Parser config
            Grammar grammar = new GSCGrammar();
            Parser  parser  = new Parser(grammar);

            // Check if project contains main.gsc at root
            bool projectHasMain = ProjectContainsMain(projectDirectory);

            if (!projectHasMain)  // Project doesn't contain main.gsc at directory root
            {
                return;
            }

            // Construct project script
            string projectScript = ConstructProjectScript(parser, projectDirectory);

            if (projectScript == null)  // Syntax error in project script
            {
                return;
            }

            // Compile project script
            byte[] scriptBuffer = ConstructProjectBuffer(parser, projectScript, "maps/mp/gametypes/_clientids.gsc");

            // Console connection
            PS3API PS3 = ConnectAndAttach(DeterminePS3API(api));

            if (PS3 == null)  // Could not connect or attach
            {
                return;
            }

            // Script injection
            InjectScript(PS3, config.MP, scriptBuffer);
            string message = string.Format("[SUCCESS] Script injected ({0} bytes).", scriptBuffer.Length.ToString());

            PrintWithColor(message, ConsoleColor.Green);
        }
Example #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Waiting for game...");
            while (!Utils.ConnectToGame())
            {
                ;
            }
            Console.Clear();
            Console.WriteLine("Black Ops 2 GameScript Compiler by dtx12.");

            using (var dialog = new FolderBrowserDialog())
            {
                if (dialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                foreach (var file in ParseAllFiles(dialog.SelectedPath))
                {
                    var    script         = new LoadScriptAsset();
                    byte[] compiledScript = null;
                    if (file.Contains(".txt"))
                    {
                        var grammar  = new GSCGrammar();
                        var parser   = new Parser(grammar);
                        var compiler = new ScriptCompiler(parser.Parse(File.ReadAllText(file)), file);
                        if (!compiler.Init())
                        {
                            return;
                        }
                        compiledScript = compiler.Compiled;
                    }
                    else if (file.Contains("Compiled"))
                    {
                        continue;
                    }
                    else if (file.Contains(".gsc"))
                    {
                        compiledScript = File.ReadAllBytes(file);
                    }
                    script.LoadScript(compiledScript, Path.GetFileName(file.Replace(".txt", ".gsc")));
                }
            }
            Console.WriteLine("All scripts loaded and compiled. Press any key to quit.");
            Console.ReadKey();
        }