Beispiel #1
0
        private void loadLSDBProperties(JProperties props)
        {
            loginDBUrl = props.getValue("database.url");                // get JDBC URL
            if (loginDBUrl == null || !loginDBUrl.StartsWith("jdbc"))
            {
                loginDBUrl = null;
                return;
            }
            // jdbc:mysql://127.0.0.1:3306/ac47_server_ls?useUnicode=true&characterEncoding=UTF-8
            int    i    = loginDBUrl.IndexOf("//");
            string host = loginDBUrl.Substring(i + 2);

            i = host.IndexOf(":");
            int    i2    = i + 1;
            string sport = host.Substring(i2);

            i = sport.IndexOf("/");
            int    i3     = i + 1;
            string dbname = sport.Substring(i3);
            int    i4     = dbname.IndexOf("?") + 1;

            dbname = dbname.Substring(0, i4 - 1);
            sport  = sport.Substring(0, i3 - 1);
            host   = host.Substring(0, i2 - 1);
            string uid = props.getValue("database.user");
            string pwd = props.getValue("database.password");

            // output as .NET URL
            loginDBUrl = String.Format("server={0};uid={1};pwd={2};database={3};Allow User Variables=True", host, uid, pwd, dbname);
        }
Beispiel #2
0
        private void loadGSDBProperties(JProperties props)
        {
            gameDBUrl = props.getValue("database.url");
            if (gameDBUrl == null || !gameDBUrl.StartsWith("jdbc"))
            {
                gameDBUrl = null;
                return;
            }
            // jdbc:mysql://127.0.0.1:3306/ac47_server_gs?useUnicode=true&characterEncoding=UTF-8
            int    i    = gameDBUrl.IndexOf("//");
            string host = gameDBUrl.Substring(i + 2);

            i = host.IndexOf(":");
            int    i2    = i + 1;
            string sport = host.Substring(i2);

            i = sport.IndexOf("/");
            int    i3     = i + 1;
            string dbname = sport.Substring(i3);
            int    i4     = dbname.IndexOf("?") + 1;

            dbname = dbname.Substring(0, i4 - 1);
            sport  = sport.Substring(0, i3 - 1);
            host   = host.Substring(0, i2 - 1);
            string uid = props.getValue("database.user");
            string pwd = props.getValue("database.password");

            gameDBUrl = String.Format("server={0};uid={1};pwd={2};database={3};Allow User Variables=True", host, uid, pwd, dbname);
            dbHost    = host;
            if (!Int32.TryParse(sport, out dbPort))
            {
                dbPort = 3306;
            }
        }
Beispiel #3
0
        private void loadLSNETProperties(JProperties props)
        {
            loginHost = props.getValue("loginserver.network.client.host");
            if (loginHost == null || loginHost.StartsWith("*"))
            {
                loginHost = "127.0.0.1";
            }
            string sgp = props.getValue("loginserver.network.client.port");

            if (sgp == null)
            {
                sgp = "2106";             //  default port
            }
            if (!Int32.TryParse(sgp, out loginPort))
            {
                loginPort = 2106;
            }
        }
Beispiel #4
0
        private void loadGSNETProperties(JProperties props)
        {
            gameHost = props.getValue("gameserver.network.client.host");
            if (gameHost == null || gameHost.StartsWith("*"))
            {
                gameHost = "127.0.0.1";
            }
            string sgp = props.getValue("gameserver.network.client.port");

            if (sgp == null)
            {
                sgp = "7777";             //  default port
            }
            if (!Int32.TryParse(sgp, out gamePort))
            {
                gamePort = 7777;
            }
        }
Beispiel #5
0
        private void loadServerProperties()
        {
            // 1st up = game server (need database, network and game version info)
            string      path  = Properties.Settings.Default.gamePath + "\\config\\network\\database.properties";
            JProperties props = new JProperties(path);

            if (!props.isEmpty())
            {
                loadGSDBProperties(props);
            }
            props.clear();

            path  = Properties.Settings.Default.gamePath + "\\config\\network\\network.properties";
            props = new JProperties(path);
            if (!props.isEmpty())
            {
                loadGSNETProperties(props);
            }
            props.clear();

            path  = Properties.Settings.Default.gamePath + "\\config\\main\\gameserver.properties";
            props = new JProperties(path);
            if (!props.isEmpty())
            {
                gameVersion = props.getValue("gameserver.version");
            }
            props.clear();

            // 2nd up = login server (need network and database info)
            path  = Properties.Settings.Default.loginPath + "\\config\\network\\database.properties";
            props = new JProperties(path);
            if (!props.isEmpty())
            {
                loadLSDBProperties(props);
            }
            props.clear();

            path  = Properties.Settings.Default.loginPath + "\\config\\network\\network.properties";
            props = new JProperties(path);
            if (!props.isEmpty())
            {
                loadLSNETProperties(props);
            }
            props.clear();

            // finally che chat server
            path  = Properties.Settings.Default.chatPath + "\\config\\chatserver.properties";
            props = new JProperties(path);
            if (!props.isEmpty())
            {
                loadCSNETProperties(props);
            }
            props.clear();
        }
Beispiel #6
0
        private void loadCSNETProperties(JProperties props)
        {
            string host = props.getValue("chatserver.network.client.address");

            string[] bits = host.Split(new char[] { ':' });
            if (bits.Length < 2)
            {
                chatHost = "127.0.0.1";
                chatPort = 10241;
                return;
            }
            chatHost = bits[0];
            if (!Int32.TryParse(bits[1], out chatPort))
            {
                loginPort = 10241;
            }
        }