Ejemplo n.º 1
0
        static void LoadExistingSettings()
        {
            try
            {
                if (!File.Exists(Application.StartupPath + Path.DirectorySeparatorChar + "config" + Path.DirectorySeparatorChar + "serverconfig.xml"))
                    return;

                ConfigFile = new FileInfo(Application.StartupPath + Path.DirectorySeparatorChar + "config" + Path.DirectorySeparatorChar + "serverconfig.xml");
                Config = new GameServerConfiguration();

                if (ConfigFile.Exists)
                {
                    Config.LoadFromXMLFile(ConfigFile);
                    MainForm.serverTypeComboBox.Text = Config.ServerType.ToString().Replace("GST_", "");
                    MainForm.shortNameTextBox.Text = Config.ServerNameShort;
                    MainForm.FullNameTextBox.Text = Config.ServerName;
                }
                else
                {
                    Config.SaveToXMLFile(ConfigFile);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
Ejemplo n.º 2
0
        private static bool StartServer()
        {
            //TODO parse args for -config parameter!
            FileInfo dolserver = new FileInfo(Assembly.GetExecutingAssembly().Location);

            Directory.SetCurrentDirectory(dolserver.DirectoryName);
            FileInfo configFile            = new FileInfo("./config/serverconfig.xml");
            GameServerConfiguration config = new GameServerConfiguration();

            if (configFile.Exists)
            {
                config.LoadFromXMLFile(configFile);
            }
            else
            {
                if (!configFile.Directory.Exists)
                {
                    configFile.Directory.Create();
                }
                config.SaveToXMLFile(configFile);
            }

            GameServer.CreateInstance(config);

            return(GameServer.Instance.Start());
        }
Ejemplo n.º 3
0
        static void LoadExistingSettings()
        {
            try
            {
                if (!File.Exists(Application.StartupPath + Path.DirectorySeparatorChar + "config" + Path.DirectorySeparatorChar + "serverconfig.xml"))
                {
                    return;
                }

                ConfigFile = new FileInfo(Application.StartupPath + Path.DirectorySeparatorChar + "config" + Path.DirectorySeparatorChar + "serverconfig.xml");
                Config     = new GameServerConfiguration();

                if (ConfigFile.Exists)
                {
                    Config.LoadFromXMLFile(ConfigFile);
                    MainForm.serverTypeComboBox.Text = Config.ServerType.ToString().Replace("GST_", "");
                    MainForm.shortNameTextBox.Text   = Config.ServerNameShort;
                    MainForm.FullNameTextBox.Text    = Config.ServerName;
                }
                else
                {
                    Config.SaveToXMLFile(ConfigFile);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
Ejemplo n.º 4
0
        [TestFixtureSetUp] public virtual void Init()
        {
            Directory.SetCurrentDirectory("../../debug");
            string CD = Directory.GetCurrentDirectory();

            Console.WriteLine(CD);
            if (GameServer.Instance == null)
            {
                FileInfo configFile            = new FileInfo("./config/serverconfig.xml");
                GameServerConfiguration config = new GameServerConfiguration();
                if (!configFile.Exists)
                {
                    config.SaveToXMLFile(configFile);
                }
                else
                {
                    config.LoadFromXMLFile(configFile);
                }
                GameServer.CreateInstance(config);
                Directory.SetCurrentDirectory(CD);
            }
            if (!GameServer.Instance.IsRunning)
            {
                Language.LanguageMgr.SetLangPath(Path.Combine(CD, "languages"));
                Console.WriteLine("Starting GameServer");
                if (!GameServer.Instance.Start())
                {
                    Console.WriteLine("Error init GameServer");
                }
            }
            else
            {
                Console.WriteLine("GameServer already running, skip init of Gameserver...");
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Save the GameServer configuration
 /// </summary>
 /// <param name="gsc">The GameServer configuration which should be saved.</param>
 /// <returns></returns>
 public static void saveCurrentConfiguration(GameServerConfiguration gsc)
 {
     try
     {
         FileInfo configFileInfo = new FileInfo(getCurrentConfigFile());
         gsc.SaveToXMLFile(configFileInfo);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Ejemplo n.º 6
0
 public static void SaveSettings()
 {
     try
     {
         switch (MainForm.serverTypeComboBox.Text)
         {
         case "Normal": Config.ServerType = eGameServerType.GST_Normal; break;
         }
         Config.ServerNameShort    = MainForm.shortNameTextBox.Text;
         Config.ServerName         = MainForm.FullNameTextBox.Text;
         Config.DBConnectionString = string.Format("Data Source={0};Initial Catalog={1};Persist Security Info=True;User ID={2};Password={3};Asynchronous Processing=true", MainForm.mysqlHostTextBox.Text, MainForm.mysqlDatabaseTextBox.Text, MainForm.mysqlUsernameTextBox.Text, MainForm.mysqlPasswordTextBox.Text);
         Config.SaveToXMLFile(ConfigFile);
         MessageBox.Show("Settings saved successfully");
     }
     catch (Exception e)
     {
         MessageBox.Show("Cannot save settings: " + e.Message);
     }
 }
Ejemplo n.º 7
0
        // ReSharper disable once FunctionNeverReturns
        public void OnAction(Hashtable parameters)
        {
            Console.WriteLine("Starting GameServer ... please wait a moment!");
            FileInfo configFile;
            FileInfo currentAssembly = null;

            if (parameters["-config"] != null)
            {
                Console.WriteLine("Using config file: " + parameters["-config"]);
                configFile = new FileInfo((String)parameters["-config"]);
            }
            else
            {
                currentAssembly = new FileInfo(Assembly.GetEntryAssembly().Location);
                configFile      = new FileInfo(currentAssembly.DirectoryName + Path.DirectorySeparatorChar + "config" + Path.DirectorySeparatorChar + "serverconfig.xml");
            }

            GameServerConfiguration config = new GameServerConfiguration();

            if (configFile.Exists)
            {
                config.LoadFromXMLFile(configFile);
            }
            else
            {
                if (!configFile.Directory.Exists)
                {
                    configFile.Directory.Create();
                }
                config.SaveToXMLFile(configFile);
                if (File.Exists(currentAssembly.DirectoryName + Path.DirectorySeparatorChar + "DOLConfig.exe"))
                {
                    Console.WriteLine("No config file found, launching with default config and embedded database... (SQLite)");
                }
            }

            GameServer.CreateInstance(config);
            StartServer();

            while (true)
            {
            }
        }
Ejemplo n.º 8
0
        public void OnAction(Hashtable parameters)
        {
            Console.WriteLine("Starting GameServer ... please wait a moment!");
            FileInfo configFile;
            FileInfo currentAssembly = null;

            if (parameters["-config"] != null)
            {
                Console.WriteLine("Using config file: " + parameters["-config"]);
                configFile = new FileInfo((string)parameters["-config"]);
            }
            else
            {
                currentAssembly = new FileInfo(Assembly.GetEntryAssembly().Location);
                configFile      = new FileInfo(currentAssembly.DirectoryName + Path.DirectorySeparatorChar + "config" + Path.DirectorySeparatorChar + "serverconfig.xml");
            }

            GameServerConfiguration config = new GameServerConfiguration();

            if (configFile.Exists)
            {
                config.LoadFromXMLFile(configFile);
            }
            else
            {
                if (!configFile.Directory.Exists)
                {
                    configFile.Directory.Create();
                }

                config.SaveToXMLFile(configFile);
                if (File.Exists(currentAssembly.DirectoryName + Path.DirectorySeparatorChar + "DOLConfig.exe"))
                {
                    Console.WriteLine("No config file found, launching with default config and embedded database... (SQLite)");

                    /*
                     * // Removed to allow the auto config on embedded SQLite
                     * Console.WriteLine("No config file found, launching DOLConfig.exe...");
                     * System.Diagnostics.Process.Start(currentAssembly.DirectoryName + Path.DirectorySeparatorChar + "DOLConfig.exe");
                     * return;
                     */
                }
            }

            GameServer.CreateInstance(config);
            StartServer();

            bool run = true;

            while (run)
            {
                Console.Write("> ");
                string line = Console.ReadLine();

                switch (line.ToLower())
                {
                case "exit":
                    run = false;
                    break;

                case "stacktrace":
                    log.Debug(PacketProcessor.GetConnectionThreadpoolStacks());
                    break;

                case "clear":
                    Console.Clear();
                    break;

                default:
                    if (line.Length <= 0)
                    {
                        break;
                    }

                    if (line[0] == '/')
                    {
                        line = line.Remove(0, 1);
                        line = line.Insert(0, "&");
                    }

                    GameClient client = new GameClient(null);
                    client.Out = new ConsolePacketLib();
                    try
                    {
                        bool res = ScriptMgr.HandleCommandNoPlvl(client, line);
                        if (!res)
                        {
                            Console.WriteLine("Unknown command: " + line);
                        }
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.ToString());
                    }

                    break;
                }
            }

            if (GameServer.Instance != null)
            {
                GameServer.Instance.Stop();
            }
        }
Ejemplo n.º 9
0
        public void OnAction(Hashtable parameters)
        {
            if (Environment.OSVersion.Platform == PlatformID.Win32NT && Environment.OSVersion.Version.Major >= 10)
            {
                // enable VT100 emulation
                var handle = GetStdHandle(-11);                 // STD_OUTPUT_HANDLE
                if (handle != IntPtr.Zero)
                {
                    uint mode;
                    if (GetConsoleMode(handle, out mode) != 0)
                    {
                        SetConsoleMode(handle, mode | 0x0004);                         // ENABLE_VIRTUAL_TERMINAL_PROCESSING
                    }
                }
            }

            Console.WriteLine("Starting GameServer ... please wait a moment!");
            FileInfo configFile;
            FileInfo currentAssembly = null;

            if (parameters["-config"] != null)
            {
                Console.WriteLine("Using config file: " + parameters["-config"]);
                configFile = new FileInfo((String)parameters["-config"]);
            }
            else
            {
                currentAssembly = new FileInfo(Assembly.GetEntryAssembly().Location);
                configFile      = new FileInfo(currentAssembly.DirectoryName + Path.DirectorySeparatorChar + "config" + Path.DirectorySeparatorChar + "serverconfig.xml");
            }
            if (parameters.ContainsKey("-crashonfail"))
            {
                crashOnFail = true;
            }

            var config = new GameServerConfiguration();

            if (configFile.Exists)
            {
                config.LoadFromXMLFile(configFile);
            }
            else
            {
                if (!configFile.Directory.Exists)
                {
                    configFile.Directory.Create();
                }
                config.SaveToXMLFile(configFile);
                if (File.Exists(currentAssembly.DirectoryName + Path.DirectorySeparatorChar + "DOLConfig.exe"))
                {
                    Console.WriteLine("No config file found, launching with default config and embedded database... (SQLite)");
                }
            }

            GameServer.CreateInstance(config);
            StartServer();

            if (crashOnFail && GameServer.Instance.ServerStatus == eGameServerStatus.GSS_Closed)
            {
                throw new ApplicationException("Server did not start properly.");
            }

            bool run = true;

            while (run)
            {
                Console.Write("> ");
                string line = Console.ReadLine();

                switch (line.ToLower())
                {
                case "exit":
                    run = false;
                    break;

                case "stacktrace":
                    log.Debug(PacketProcessor.GetConnectionThreadpoolStacks());
                    break;

                case "clear":
                    Console.Clear();
                    break;

                default:
                    if (line.Length <= 0)
                    {
                        break;
                    }
                    if (line[0] == '/')
                    {
                        line = line.Remove(0, 1);
                        line = line.Insert(0, "&");
                    }
                    GameClient client = new GameClient(null);
                    client.Out = new ConsolePacketLib();
                    try
                    {
                        bool res = ScriptMgr.HandleCommandNoPlvl(client, line);
                        if (!res)
                        {
                            Console.WriteLine("Unknown command: " + line);
                        }
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.ToString());
                    }
                    break;
                }
            }
            if (GameServer.Instance != null)
            {
                GameServer.Instance.Stop();
            }
        }