Beispiel #1
0
        public void ButtonServerInfoSaveClick(object sender, EventArgs e)
        {
            string GameName;
            int    ServerIndex;
            int    ServerNumber;
            int    TestLevel;
            int    TestGold;
            int    TestUserLimit;
            int    UserFull;
            bool   TestServer;
            bool   ServiceMode;

            GameName      = EditGameName.Text.Trim();
            ServerIndex   = HUtil32.Str_ToInt(EditServerIndex.Text.Trim(), -1);
            ServerNumber  = HUtil32.Str_ToInt(EditServerNumber.Text.Trim(), -1);
            ServiceMode   = CheckBoxServiceMode.Checked;
            TestServer    = CheckBoxTestServer.Checked;
            TestLevel     = HUtil32.Str_ToInt(EditTestLevel.Text.Trim(), -1);
            TestGold      = HUtil32.Str_ToInt(EditTestGold.Text.Trim(), -1);
            TestUserLimit = HUtil32.Str_ToInt(EditTestUserLimit.Text.Trim(), -1);
            UserFull      = HUtil32.Str_ToInt(EditUserFull.Text.Trim(), -1);
            if (GameName == "")
            {
                System.Windows.Forms.MessageBox.Show("ÓÎÏ·Ãû³ÆÉèÖôíÎ󣡣¡£¡", "´íÎóÐÅÏ¢", System.Windows.Forms.MessageBoxButtons.OK);
                EditGameName.Focus();
                return;
            }
            if ((ServerIndex < 0) || (ServerIndex > 255))
            {
                System.Windows.Forms.MessageBox.Show("·þÎñÆ÷ºÅÉèÖôíÎ󣡣¡£¡", "´íÎóÐÅÏ¢", System.Windows.Forms.MessageBoxButtons.OK);
                EditServerIndex.Focus();
                return;
            }
            if ((ServerNumber < 0) || (ServerNumber > 255))
            {
                System.Windows.Forms.MessageBox.Show("·þÎñÆ÷ÊýÉèÖôíÎ󣡣¡£¡", "´íÎóÐÅÏ¢", System.Windows.Forms.MessageBoxButtons.OK);
                EditServerNumber.Focus();
                return;
            }
            if ((TestLevel < 0) || (TestLevel > 65535))
            {
                System.Windows.Forms.MessageBox.Show("¿ªÊ¼µÈ¼¶ÉèÖôíÎ󣡣¡£¡", "´íÎóÐÅÏ¢", System.Windows.Forms.MessageBoxButtons.OK);
                EditTestLevel.Focus();
                return;
            }
            if ((TestGold < 0) || (TestGold > Int32.MaxValue / 2))
            {
                System.Windows.Forms.MessageBox.Show("¿ªÊ¼½ð±ÒÉèÖôíÎ󣡣¡£¡", "´íÎóÐÅÏ¢", System.Windows.Forms.MessageBoxButtons.OK);
                EditTestGold.Focus();
                return;
            }
            if ((TestUserLimit < 0) || (TestUserLimit > 10000))
            {
                System.Windows.Forms.MessageBox.Show("²âÊÔÈËÊýÉèÖôíÎ󣡣¡£¡", "´íÎóÐÅÏ¢", System.Windows.Forms.MessageBoxButtons.OK);
                EditTestUserLimit.Focus();
                return;
            }
            if ((UserFull < 0) || (UserFull > 10000))
            {
                System.Windows.Forms.MessageBox.Show("ÉÏÏÞÈËÊýÉèÖôíÎ󣡣¡£¡", "´íÎóÐÅÏ¢", System.Windows.Forms.MessageBoxButtons.OK);
                EditUserFull.Focus();
                return;
            }
            M2Share.g_Config.sServerName    = GameName;
            M2Share.g_Config.nServerNumber  = (ushort)ServerNumber;
            M2Share.g_Config.boServiceMode  = ServiceMode;
            M2Share.g_Config.boTestServer   = TestServer;
            M2Share.g_Config.nTestLevel     = (ushort)TestLevel;
            M2Share.g_Config.nTestGold      = TestGold;
            M2Share.g_Config.nTestUserLimit = (ushort)TestUserLimit;
            M2Share.g_Config.nUserFull      = UserFull;
            M2Share.Config.WriteString("Server", "ServerName", M2Share.g_Config.sServerName);
            M2Share.Config.WriteInteger("Server", "ServerIndex", M2Share.nServerIndex);
            M2Share.Config.WriteInteger("Server", "ServerNumber", M2Share.g_Config.nServerNumber);
            M2Share.Config.WriteString("Server", "TestServer", HUtil32.BoolToStr(M2Share.g_Config.boTestServer));
            M2Share.Config.WriteInteger("Server", "TestLevel", M2Share.g_Config.nTestLevel);
            M2Share.Config.WriteInteger("Server", "TestGold", M2Share.g_Config.nTestGold);
            M2Share.Config.WriteInteger("Server", "TestServerUserLimit", M2Share.g_Config.nTestUserLimit);
            M2Share.Config.WriteInteger("Server", "UserFull", M2Share.g_Config.nUserFull);
            M2Share.Config.WriteBool("Server", "Minimize", M2Share.g_boMinimize);
            uModValue();
        }