Example #1
0
        /// <summary>
        /// Loads all extensions in the given directory
        /// </summary>
        /// <param name="directory"></param>
        public void LoadAllExtensions(string directory)
        {
            var coreExtensions      = Directory.GetFiles(directory, coreExtSearchPattern);
            var gameExtensions      = Directory.GetFiles(directory, gameExtSearchPattern);
            var communityExtensions = Directory.GetFiles(directory, communitySearchPattern);
            var allExtensions       = coreExtensions.Concat(gameExtensions).Concat(communityExtensions);

            foreach (var ext in allExtensions)
            {
                if (ext.Contains(".Ext.") && Array.IndexOf(coreExtensions, ext.Replace(".Ext.", ".Core.")) != -1)
                {
                    Cleanup.Add(ext);
                    continue;
                }
                LoadExtension(Path.Combine(directory, ext));
            }

            foreach (var ext in extensions.ToArray())
            {
                try
                {
                    ext.OnModLoad();
                }
                catch (Exception ex)
                {
                    extensions.Remove(ext);
                    Logger.WriteException($"Failed OnModLoad extension {ext.Name} v{ext.Version}", ex);
                    RemoteLogger.Exception($"Failed OnModLoad extension {ext.Name} v{ext.Version}", ex);
                }
            }
        }
Example #2
0
        /// <summary>
        /// Loads all extensions in the given directory
        /// </summary>
        /// <param name="directory"></param>
        public void LoadAllExtensions(string directory)
        {
            var foundExtensions = Directory.GetFiles(directory, extSearchPattern);

            foreach (var ext in foundExtensions.Where(e => !e.Equals("Oxide.Core.dll")))
            {
                if (ext.Contains(".Core.") && Array.IndexOf(foundExtensions, ext.Replace(".Core.", "")) != -1)
                {
                    Cleanup.Add(ext);
                    continue;
                }

                if (ext.Contains(".Ext.") && Array.IndexOf(foundExtensions, ext.Replace(".Ext.", "")) != -1)
                {
                    Cleanup.Add(ext);
                    continue;
                }

                LoadExtension(Path.Combine(directory, ext));
            }

            foreach (var ext in extensions.ToArray())
            {
                try
                {
                    ext.OnModLoad();
                }
                catch (Exception ex)
                {
                    extensions.Remove(ext);
                    Logger.WriteException($"Failed OnModLoad extension {ext.Name} v{ext.Version}", ex);
                    RemoteLogger.Exception($"Failed OnModLoad extension {ext.Name} v{ext.Version}", ex);
                }
            }
        }
Example #3
0
        /// <summary>
        /// Loads all extensions in the given directory
        /// </summary>
        /// <param name="directory"></param>
        public void LoadAllExtensions(string directory)
        {
            var gameFiles = Directory.GetFiles(directory, GameFileSearchPattern);
            var files     = Directory.GetFiles(directory, ExtFileSearchPattern).Concat(gameFiles);

            foreach (var file in files)
            {
                if (file.Contains(".Ext.") && Array.IndexOf(gameFiles, file.Replace(".Ext.", ".Game.")) != -1)
                {
                    //Logger.Write(LogType.Warning, "Found old game extension '{0}'. Please remove it!", Path.GetFileName(file));
                    Cleanup.Add(file);
                    continue;
                }
                LoadExtension(Path.Combine(directory, file));
            }
            foreach (var ext in extensions.ToArray())
            {
                try
                {
                    ext.OnModLoad();
                }
                catch (Exception ex)
                {
                    extensions.Remove(ext);
                    Logger.WriteException($"Failed OnModLoad extension {ext.Name} v{ext.Version}", ex);
                    RemoteLogger.Exception($"Failed OnModLoad extension {ext.Name} v{ext.Version}", ex);
                }
            }
        }
Example #4
0
        /// <summary>
        /// Loads this extension
        /// </summary>
        public override void Load()
        {
            // Setup Lua instance
            InitializeLua();

            // Register the loader
            loader = new LuaPluginLoader(LuaEnvironment, this);
            Manager.RegisterPluginLoader(loader);

            Cleanup.Add(Path.Combine(Interface.Oxide.ExtensionDirectory, "x64/lua51.dll"));
            Cleanup.Add(Path.Combine(Interface.Oxide.ExtensionDirectory, "x86/lua51.dll"));
        }
Example #5
0
        /// <summary>
        /// Loads this extension
        /// </summary>
        public override void Load()
        {
            // Register our loader
            loader = new CSharpPluginLoader(this);
            Manager.RegisterPluginLoader(loader);

            // Register engine frame callback
            Interface.Oxide.OnFrame(OnFrame);

            Cleanup.Add(Path.Combine(Interface.Oxide.RootDirectory, "mono-2.0.dll"));
            Cleanup.Add(Path.Combine(Interface.Oxide.RootDirectory, "msvcr120.dll"));
        }
        public CSharpExtension(ExtensionManager manager) : base(manager)
        {
            string str  = Path.Combine(Interface.Oxide.RootDirectory, "CSharpCompiler");
            string str1 = Path.Combine(Interface.Oxide.RootDirectory, "Compiler");

            if (Environment.OSVersion.Platform != PlatformID.Unix)
            {
                str = string.Concat(str, ".exe");
                if (File.Exists(str))
                {
                    str1 = string.Concat(str1, ".exe");
                    if (!File.Exists(str1))
                    {
                        File.Move(str, str1);
                    }
                    Cleanup.Add(str);
                }
                return;
            }
            Cleanup.Add(Path.Combine(Interface.Oxide.ExtensionDirectory, "Mono.Posix.dll.config"));
            str = string.Concat(str, ".x86");
            if (File.Exists(str))
            {
                str1 = string.Concat(str1, ".x86");
                if (!File.Exists(str1))
                {
                    File.Move(str, str1);
                }
                Cleanup.Add(str);
            }
            str = string.Concat(str, "_x64");
            if (File.Exists(str))
            {
                str1 = string.Concat(str1, "_x64");
                if (!File.Exists(str1))
                {
                    File.Move(str, str1);
                }
                Cleanup.Add(str);
            }
            string extensionDirectory = Interface.Oxide.ExtensionDirectory;
            string str2 = Path.Combine(extensionDirectory, "Oxide.References.dll.config");

            if (File.Exists(str2))
            {
                if (!(new string[] { "target=\"x64", "target=\"./x64" }).Any <string>(new Func <string, bool>(File.ReadAllText(str2).Contains)))
                {
                    return;
                }
            }
            File.WriteAllText(str2, string.Concat(new string[] { "<configuration>\n<dllmap dll=\"MonoPosixHelper\" target=\"", extensionDirectory, "/x86/libMonoPosixHelper.so\" os=\"!windows,osx\" wordsize=\"32\" />\n<dllmap dll=\"MonoPosixHelper\" target=\"", extensionDirectory, "/x64/libMonoPosixHelper.so\" os=\"!windows,osx\" wordsize=\"64\" />\n</configuration>" }));
        }
Example #7
0
        /// <summary>
        /// Loads this extension
        /// </summary>
        public override void Load()
        {
            // Register our loader
            loader = new CSharpPluginLoader(this);
            Manager.RegisterPluginLoader(loader);

            // Register engine frame callback
            Interface.Oxide.OnFrame(OnFrame);

            // Cleanup old files and/or file locations
            Cleanup.Add(Path.Combine(Interface.Oxide.RootDirectory, Environment.OSVersion.Platform == PlatformID.Unix ? "CSharpCompiler.exe" : "CSharpCompiler.x86"));
            Cleanup.Add(Path.Combine(Interface.Oxide.RootDirectory, "CSharpCompiler"));
        }
Example #8
0
        /// <summary>
        /// Loads this extension
        /// </summary>
        public override void Load()
        {
            Manager.RegisterLibrary("Rust", new Libraries.Rust());
            Manager.RegisterLibrary("Command", new Libraries.Command());
            Manager.RegisterLibrary("Item", new Libraries.Item());
            Manager.RegisterLibrary("Player", new Libraries.Player());
            Manager.RegisterLibrary("Server", new Libraries.Server());
            Manager.RegisterPluginLoader(new RustPluginLoader());

            if (Environment.OSVersion.Platform == PlatformID.Unix)
            {
                Cleanup.Add("Facepunch.Steamworks.Win64.dll"); // TODO: Remove after a few updates
            }
        }
        internal ReignOfKingsPlayerManager()
        {
            // Load player data
            Utility.DatafileToProto <Dictionary <string, PlayerRecord> >("oxide.covalence");
            playerData = ProtoStorage.Load <Dictionary <string, PlayerRecord> >("oxide.covalence") ?? new Dictionary <string, PlayerRecord>();
            allPlayers = new Dictionary <string, ReignOfKingsPlayer>();
            foreach (var pair in playerData)
            {
                allPlayers.Add(pair.Key, new ReignOfKingsPlayer(pair.Value.Id, pair.Value.Name));
            }
            connectedPlayers = new Dictionary <string, ReignOfKingsPlayer>();

            // Cleanup old .data
            Cleanup.Add(ProtoStorage.GetFileDataPath("oxide.covalence.playerdata.data"));
        }
Example #10
0
        internal void Initialize()
        {
            // Load player data
            Utility.DatafileToProto <Dictionary <string, PlayerRecord> >("oxide.covalence");
            playerData = ProtoStorage.Load <Dictionary <string, PlayerRecord> >("oxide.covalence") ?? new Dictionary <string, PlayerRecord>();
            players    = new Dictionary <string, RustPlayer>();
            foreach (var pair in playerData)
            {
                players.Add(pair.Key, new RustPlayer(pair.Value.Id, pair.Value.Name));
            }
            livePlayers = new Dictionary <string, RustLivePlayer>();

            // Cleanup old .data
            Cleanup.Add(ProtoStorage.GetFileDataPath("oxide.covalence.playerdata.data"));
        }
Example #11
0
        /// <summary>
        /// Initializes a new instance of the CSharpExtension class
        /// </summary>
        /// <param name="manager"></param>
        public CSharpExtension(ExtensionManager manager) : base(manager)
        {
            if (Environment.OSVersion.Platform == PlatformID.Unix)
            {
                Cleanup.Add(Path.Combine(Interface.Oxide.ExtensionDirectory, "Mono.Posix.dll.config"));

                var configPath = Path.Combine(Interface.Oxide.ExtensionDirectory, "Oxide.References.dll.config");
                if (File.Exists(configPath))
                {
                    return;
                }

                File.WriteAllText(configPath, $"<configuration>\n<dllmap dll=\"MonoPosixHelper\" target=\"./x86/libMonoPosixHelper.so\" os=\"!windows,osx\" wordsize=\"32\" />\n" +
                                  $"<dllmap dll=\"MonoPosixHelper\" target=\"./x64/libMonoPosixHelper.so\" os=\"!windows,osx\" wordsize=\"64\" />\n</configuration>");
            }
        }
Example #12
0
        private void RenderToAsfWriter(
            string file,
            string profileData,
            ICallbackParticipant[] videoParticipants,
            ICallbackParticipant[] audioParticipants)
        {
            int hr;

            if (file == null)
            {
                throw new SplicerException(Resources.ErrorInvalidOutputFileName);
            }

            // Contains useful routines for creating the graph
            var graphBuilder = (ICaptureGraphBuilder2) new CaptureGraphBuilder2();

            try
            {
                hr = graphBuilder.SetFiltergraph(Graph);
                DESError.ThrowExceptionForHR(hr);

                IBaseFilter pMux = StandardFilters.RenderAsfWriterWithProfile(Cleanup, Graph, profileData, file);

                ValidateAsfWriterIsSuitable(pMux);

                Cleanup.Add(pMux);

                try
                {
                    RenderGroups(graphBuilder, null, null, pMux, audioParticipants, videoParticipants);
                }
                finally
                {
                    Marshal.ReleaseComObject(pMux);
                }

                DisableClock();
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                Marshal.ReleaseComObject(graphBuilder);
            }
        }
        public WavFileRenderer(ITimeline timeline, string outputFile, AudioFormat format,
                               ICallbackParticipant[] audioParticipants)
            : base(timeline)
        {
            AudioCompressor compressor = null;

            try
            {
                compressor = AudioCompressorFactory.Create(format);

                Cleanup.Add(compressor.Filter);

                RenderToWavDest(outputFile, compressor.Filter, compressor.MediaType, audioParticipants);

                ChangeState(RendererState.Initialized);
            }
            finally
            {
                if ((compressor != null) && (compressor.MediaType != null))
                {
                    DsUtils.FreeAMMediaType(compressor.MediaType);
                }
            }
        }
Example #14
0
        /// <summary>
        /// Loads all extensions in the given directory
        /// </summary>
        /// <param name="directory"></param>
        public void LoadAllExtensions(string directory)
        {
            List <string> foundCore  = new List <string>();
            List <string> foundGame  = new List <string>();
            List <string> foundOther = new List <string>();

            string[] coreExtensions =
            {
                "Oxide.CSharp", "Oxide.JavaScript", "Oxide.Lua", "Oxide.MySql", "Oxide.Python", "Oxide.SQLite", "Oxide.Unity"
            };
            string[] gameExtensions =
            {
                "Oxide.Blackwake",        "Oxide.Blockstorm",        "Oxide.FortressCraft",  "Oxide.FromTheDepths",   "Oxide.GangBeasts",   "Oxide.Hurtworld",
                "Oxide.InterstellarRift", "Oxide.MedievalEngineers", "Oxide.Nomad",          "Oxide.PlanetExplorers", "Oxide.ReignOfKings", "Oxide.Rust",
                "Oxide.RustLegacy",       "Oxide.SavageLands",       "Oxide.SevenDaysToDie", "Oxide.SpaceEngineers",  "Oxide.TheForest",    "Oxide.Terraria",
                "Oxide.Unturned"
            };
            string[] foundExtensions = Directory.GetFiles(directory, extSearchPattern);

            foreach (string extPath in foundExtensions.Where(e => !e.EndsWith("Oxide.Core.dll") && !e.EndsWith("Oxide.References.dll")))
            {
                if (extPath.Contains("Oxide.Core.") && Array.IndexOf(foundExtensions, extPath.Replace(".Core", "")) != -1)
                {
                    Cleanup.Add(extPath);
                    continue;
                }

                if (extPath.Contains("Oxide.Ext.") && Array.IndexOf(foundExtensions, extPath.Replace(".Ext", "")) != -1)
                {
                    Cleanup.Add(extPath);
                    continue;
                }

                if (extPath.Contains("Oxide.Game."))
                {
                    Cleanup.Add(extPath);
                    continue;
                }

                if (coreExtensions.Contains(extPath.Basename()))
                {
                    foundCore.Add(extPath);
                }
                else if (gameExtensions.Contains(extPath.Basename()))
                {
                    foundGame.Add(extPath);
                }
                else
                {
                    foundOther.Add(extPath);
                }
            }

            foreach (string extPath in foundCore)
            {
                LoadExtension(Path.Combine(directory, extPath), true);
            }

            foreach (string extPath in foundGame)
            {
                LoadExtension(Path.Combine(directory, extPath), true);
            }

            foreach (string extPath in foundOther)
            {
                LoadExtension(Path.Combine(directory, extPath), true);
            }

            foreach (Extension ext in extensions.ToArray())
            {
                try
                {
                    ext.OnModLoad();
                }
                catch (Exception ex)
                {
                    extensions.Remove(ext);
                    Logger.WriteException($"Failed OnModLoad extension {ext.Name} v{ext.Version}", ex);
                    RemoteLogger.Exception($"Failed OnModLoad extension {ext.Name} v{ext.Version}", ex);
                }
            }
        }
        private void RenderToWavDest(
            string outputFile,
            IBaseFilter audioCompressor,
            AMMediaType mediaType,
            ICallbackParticipant[] audioParticipants)
        {
            if (audioCompressor != null)
            {
                Cleanup.Add(audioCompressor);
            }

            int hr;

            if (FirstAudioGroup == null)
            {
                throw new SplicerException(Resources.ErrorNoAudioStreamToRender);
            }

            if (outputFile == null)
            {
                throw new SplicerException(Resources.ErrorInvalidOutputFileName);
            }

            // Contains useful routines for creating the graph
            var graphBuilder = (ICaptureGraphBuilder2) new CaptureGraphBuilder2();

            Cleanup.Add(graphBuilder);

            try
            {
                hr = graphBuilder.SetFiltergraph(Graph);
                DESError.ThrowExceptionForHR(hr);

                IBaseFilter wavDestFilter = StandardFilters.RenderWavDestination(Cleanup, Graph);
                IBaseFilter fileSink      = StandardFilters.RenderFileDestination(Cleanup, Graph, outputFile);

                try
                {
                    RenderGroups(graphBuilder, audioCompressor, null, wavDestFilter, audioParticipants, null);

                    FilterGraphTools.ConnectFilters(Graph, wavDestFilter, fileSink, true);

                    // if supplied, apply the media type to the filter
                    if (mediaType != null)
                    {
                        FilterGraphTools.SetFilterFormat(mediaType, audioCompressor);
                    }

                    DisableClock();
                }
                finally
                {
                    if (wavDestFilter != null)
                    {
                        Marshal.ReleaseComObject(wavDestFilter);
                    }
                    if (fileSink != null)
                    {
                        Marshal.ReleaseComObject(fileSink);
                    }
                }
            }
            finally
            {
                Marshal.ReleaseComObject(graphBuilder);
            }
        }
Example #16
0
        public void LoadAllExtensions(string directory)
        {
            List <string> strs  = new List <string>();
            List <string> strs1 = new List <string>();
            List <string> strs2 = new List <string>();

            string[] strArrays  = new string[] { "Oxide.CSharp", "Oxide.JavaScript", "Oxide.Lua", "Oxide.MySql", "Oxide.Python", "Oxide.SQLite", "Oxide.Unity" };
            string[] strArrays1 = new string[] { "Oxide.Blackwake", "Oxide.Blockstorm", "Oxide.FortressCraft", "Oxide.FromTheDepths", "Oxide.GangBeasts", "Oxide.Hurtworld", "Oxide.InterstellarRift", "Oxide.MedievalEngineers", "Oxide.Nomad", "Oxide.PlanetExplorers", "Oxide.ReignOfKings", "Oxide.Rust", "Oxide.RustLegacy", "Oxide.SavageLands", "Oxide.SevenDaysToDie", "Oxide.SpaceEngineers", "Oxide.TheForest", "Oxide.Terraria", "Oxide.Unturned" };
            string[] files      = Directory.GetFiles(directory, "Oxide.*.dll");
            foreach (string str in files.Where <string>((string e) => {
                if (e.EndsWith("Oxide.Core.dll"))
                {
                    return(false);
                }
                return(!e.EndsWith("Oxide.References.dll"));
            }))
            {
                if (str.Contains("Oxide.Core.") && Array.IndexOf <string>(files, str.Replace(".Core", "")) != -1)
                {
                    Cleanup.Add(str);
                }
                else if (str.Contains("Oxide.Ext.") && Array.IndexOf <string>(files, str.Replace(".Ext", "")) != -1)
                {
                    Cleanup.Add(str);
                }
                else if (str.Contains("Oxide.Game."))
                {
                    Cleanup.Add(str);
                }
                else if (strArrays.Contains <string>(str.Basename(null)))
                {
                    strs.Add(str);
                }
                else if (!strArrays1.Contains <string>(str.Basename(null)))
                {
                    strs2.Add(str);
                }
                else
                {
                    strs1.Add(str);
                }
            }
            foreach (string str1 in strs)
            {
                this.LoadExtension(Path.Combine(directory, str1), true);
            }
            foreach (string str2 in strs1)
            {
                this.LoadExtension(Path.Combine(directory, str2), true);
            }
            foreach (string str3 in strs2)
            {
                this.LoadExtension(Path.Combine(directory, str3), true);
            }
            Extension[] array = this.extensions.ToArray <Extension>();
            for (int i = 0; i < (int)array.Length; i++)
            {
                Extension extension = array[i];
                try
                {
                    extension.OnModLoad();
                }
                catch (Exception exception1)
                {
                    Exception exception = exception1;
                    this.extensions.Remove(extension);
                    this.Logger.WriteException(string.Format("Failed OnModLoad extension {0} v{1}", extension.Name, extension.Version), exception);
                    RemoteLogger.Exception(string.Format("Failed OnModLoad extension {0} v{1}", extension.Name, extension.Version), exception);
                }
            }
        }