コード例 #1
0
ファイル: sample.cs プロジェクト: 15peaces/15-3athena-cs
        ////// Constructor ////////
        public SampleClass()
        {
            ////// Plugin information ////////
            info = new plugin_inc.PluginInfo();

            // change only the following area [
            info.name    = "Test";                       // Plugin name
            info.server  = plugin_inc.PLUGIN_SERVER.ALL; // Which servers is this plugin for
            info.version = "0.2";                        // Plugin version
            info.min_ver = plugin_inc.PLUGIN_VERSION;    // Minimum plugin engine version to run
            info.desc    = "A sample plugin";            // Short description of plugin
            // ]
            return;
        }
コード例 #2
0
ファイル: sample.cs プロジェクト: 15peaces/15-3athena-cs
 public static void GetPluginInfo(ref plugin_inc.PluginInfo iStruct)
 {
     iStruct = info;
     return;
 }
コード例 #3
0
        static Plugin?plugin_load(string filename)
        {
            Plugin plugin;

            plugin_inc.PluginInfo info;

            //console.debug("plugin_load("+filename+")");

            // Check if the plugin has been loaded before
            for (int i = 0; i < Plugins.Count; i++)
            {
                // returns handle to the already loaded plugin
                if (Plugins[i].plugin.state > 0 && Plugins[i].plugin.filename == filename)
                {
                    console.warning("plugin_load: not loaded (duplicate) : '" + filename + "'");
                    return(Plugins[i].plugin);
                }
            }

            plugin          = new Plugin();
            info            = new plugin_inc.PluginInfo();
            plugin.filename = filename;
            plugin.state    = -1; // not loaded

            plugin.dll = DllFunc.LoadLibrary(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), filename));
            if (plugin.dll == IntPtr.Zero)
            {
                console.warning("plugin_load: not loaded (invalid file) : '" + filename + "'");
                return(null);
            }

            // Retrieve plugin information
            plugin.state = 0;  // initialising

            IntPtr GetInfoFunc = DllFunc.GetProcAddress(plugin.dll, "GetPluginInfo");

            if (GetInfoFunc == IntPtr.Zero)
            {
                //console.debug("plugin_load: plugin_info not found");
                return(null);
            }

            GetPluginInfo GetPluginInfo = (GetPluginInfo)Marshal.GetDelegateForFunctionPointer(GetInfoFunc, typeof(GetPluginInfo));

            GetPluginInfo(ref info);

            //console.debug("plugin_load: Found plugin: "+info.name+" Version "+info.version+".");

            /*
             * // For high priority plugins (those that are explicitly loaded from the conf file)
             * // we'll ignore them even (could be a 3rd party dll file)
             * if (!info)
             * {// foreign plugin
             * //ShowDebug("plugin_open: plugin_info not found\n");
             *  if (load_priority == 0)
             *  {// not requested
             *   //ShowDebug("plugin_open: not loaded (not requested) : '"CL_WHITE"%s"CL_RESET"'\n", filename);
             *      plugin_unload(plugin);
             *      return NULL;
             *  }
             * }
             * else if (!plugin_iscompatible(info->req_version))
             * {// incompatible version
             *  ShowWarning("plugin_open: not loaded (incompatible version '%s' -> '%s') : '"CL_WHITE"%s"CL_RESET"'\n", info->req_version, PLUGIN_VERSION, filename);
             *  plugin_unload(plugin);
             *  return NULL;
             * }
             * else if ((info->type != PLUGIN_ALL && info->type != PLUGIN_CORE && info->type != SERVER_TYPE) ||
             * (info->type == PLUGIN_CORE && SERVER_TYPE != PLUGIN_LOGIN && SERVER_TYPE != PLUGIN_CHAR && SERVER_TYPE != PLUGIN_MAP))
             * {// not for this server
             * //ShowDebug("plugin_open: not loaded (incompatible) : '"CL_WHITE"%s"CL_RESET"'\n", filename);
             *  plugin_unload(plugin);
             *  return NULL;
             * }
             */

            return(plugin);
        }