Example #1
0
 public GameServer(ref Config uc, ref GameData gd, ref Plugin[] plugs, ref ExtensionHandler ext)
 {
     UserConfig = uc;
     gameData = gd;
     Plugins = plugs;
     extensions = ext;
 }
Example #2
0
        public LoginServer(string configFile)
        {
            UserConfig = new Config(configFile + ".xml");
            Console.Title = "[" + UserConfig.Username + "] L2Script - version " + L2Script.version_string;

            Debug.Information("Loading plugins...");
            Plugins = Manager.GetPlugins(this.GetType().Assembly);
            Debug.Information("Sucessfully loaded " + Plugins.Length.ToString() + " plugins.");

            Debug.Information("Loading Extensions from plugins...");
            int largeCount = 0;
            for (int i = 0; i < Plugins.Length; i++)
            {
                PluginInfo pi = Plugins[i].GetInfo();
                int count = 0;
                try
                {
                    Extension[] ext = Plugins[i].GetExtensions();

                    for (int x = 0; x < ext.Length; x++)
                    {
                        if (ext[x].ShortName == "Events" && Plugins[i].GetInfo().Author == "Peter Corcoran (R4000)")
                            for (int z = 0; z < Plugins.Length; z++)
                                Plugins[z].RegisterEvents(ext[x].Resource);
                        Extensions.Add(ext[x]);
                    }

                    count = ext.Length;
                    largeCount += count;
                }
                catch (Exception ex)
                {
                    Debug.Exception(" - Error loading extensions from '" + pi.ShortName + "'.", ex);
                    continue;
                }
                Debug.Information(" - Loaded " + count + " extensions from '" + pi.ShortName + "'.");
            }
            Debug.Information("Loaded " + largeCount + " extensions from all plugins.");

            Debug.Information("Connecting to login server...");
            try
            {
                Connect(UserConfig.LoginIP, ushort.Parse(UserConfig.LoginPort));
            }
            catch (Exception ex)
            {
                Debug.Exception("Error connecting to server.", ex);
                return;
            }
            Debug.Information("Connected to login server.");

            gameData.commands = new Commands(gameData);
        }