Esempio n. 1
0
        internal AScriptHandler(OMOD omod, string script, OMODScriptSettings settings, string?extractionFolder)
        {
            ScriptSettings = settings;

            OMOD   = omod;
            Script = script;

            var guid = Guid.NewGuid();

            ExtractionFolder = extractionFolder ?? Path.Combine(Path.GetTempPath(), "OMODFramework", guid.ToString("D"));

            DataFolder    = Path.Combine(ExtractionFolder, "data");
            PluginsFolder = Path.Combine(ExtractionFolder, "plugins");

            if (!settings.DryRun)
            {
                Directory.CreateDirectory(DataFolder);
                Directory.CreateDirectory(PluginsFolder);

                omod.ExtractFilesParallel(DataFolder, 4);
                if (omod.HasEntryFile(OMODEntryFileType.Plugins))
                {
                    omod.ExtractFiles(false, PluginsFolder);
                }
            }

            ScriptReturnData = new ScriptReturnData(DataFolder, PluginsFolder);
            ScriptFunctions  = new ScriptFunctions(ScriptSettings, omod, ScriptReturnData);
        }
Esempio n. 2
0
        public CSharpScriptHandler(OMOD omod, string script, OMODScriptSettings settings, string?extractionFolder)
            : base(omod, script, settings, extractionFolder)
        {
            var scriptBytes = Encoding.UTF8.GetBytes(script);

            ScriptCRC = Crc32Algorithm.Compute(scriptBytes, 0, scriptBytes.Length);
        }
Esempio n. 3
0
        public void TestScriptExecution(string fileName, long expectedFileLength)
        {
            /*
             * Get the mods listed above and put them into the OMODFramework.Test/files/obmm-scripting folder. They
             * will be copied to the output folder post build. I don't want to download those mods in the CI so this
             * test can only be run locally.
             */

            //TODO: make this run on the CI without having to download the mods (use data+plugin files index)

            var file = Path.Combine("files", "obmm-scripting", fileName);

            if (!File.Exists(file))
            {
                return;
            }

            var fi = new FileInfo(file);
            var actualFileLength = fi.Length;

            Assert.Equal(expectedFileLength, actualFileLength);

            var resultsFile = Path.Combine("files", "obmm-scripting", fileName + "-Results.txt");

            Assert.True(File.Exists(resultsFile));

            using var omod = new OMOD(file);

            var externalScriptFunctions = new ExternalScriptFunctionsForTesting(resultsFile, fileName);
            var settings = new OMODScriptSettings(externalScriptFunctions)
            {
                DryRun             = true,
                UseBitmapOverloads = false
            };

            var srd = OMODScriptRunner.RunScript(omod, settings);

            VerifyFiles(externalScriptFunctions.DataFiles, srd.DataFiles);
            VerifyFiles(externalScriptFunctions.PluginFiles, srd.PluginFiles);
        }
Esempio n. 4
0
 internal ScriptFunctions(OMODScriptSettings settings, OMOD omod, ScriptReturnData srd)
 {
     _settings = settings;
     _omod     = omod;
     _srd      = srd;
 }