Exemplo n.º 1
0
        public void SelectSocket_OnClientConnect(object sender, AsyncUserToken e)
        {
            DBShare.MainOutMessage("Sel连接: " + e.EndPoint.ToString());
            TSelectClient ClentSocket = new TSelectClient(e, FrmIDSoc);

            e.Tag = ClentSocket;
        }
Exemplo n.º 2
0
 private void StartService()
 {
     try
     {
         DBShare.MainOutMessage("正在启动服务器...");
         DBShare.LoadConfig();
         ServerSocket.Start(new IPEndPoint(IPAddress.Parse("0.0.0.0"), DBShare.g_nServerPort));
         SelectSocket.Start(new IPEndPoint(IPAddress.Parse("0.0.0.0"), DBShare.g_nGatePort));
         DBShare.g_boStartService = true;
         FrmIDSoc.Invoke((MethodInvoker) delegate() { FrmIDSoc.OpenConnect(); });
         this.Invoke((MethodInvoker) delegate() { MENU_CONTROL_START.Enabled = false; });
         this.Invoke((MethodInvoker) delegate() { MENU_CONTROL_STOP.Enabled = true; });
         DBShare.MainOutMessage("数据库服务器启动成功...");
         DBShare.SendGameCenterMsg(Common.SG_STARTOK, "数据库服务器启动完成...");
     }
     catch (Exception ex)
     {
         DBShare.MainOutMessage(ex.Message);
         DBShare.g_boStartService = false;
         this.Invoke((MethodInvoker) delegate() { MENU_CONTROL_START.Enabled = true; });
         this.Invoke((MethodInvoker) delegate() { MENU_CONTROL_STOP.Enabled = false; });
         FrmIDSoc.Invoke((MethodInvoker) delegate() { FrmIDSoc.CloseConnect(); });
         SelectSocket.Shutdown();
         ServerSocket.Shutdown();
     }
 }
Exemplo n.º 3
0
 public void MENU_HELP_VERSIONClick(System.Object Sender, System.EventArgs _e1)
 {
     DBShare.MainOutMessage(DBShare.g_sVersion);
     DBShare.MainOutMessage(DBShare.g_sUpDateTime);
     DBShare.MainOutMessage(DBShare.g_sProgram);
     DBShare.MainOutMessage(DBShare.g_sWebSite);
 }
Exemplo n.º 4
0
 public void SelectSocket_OnClientRead(object sender, AsyncUserToken e)
 {
     byte[] data = new byte[e.BytesReceived];
     Array.Copy(e.ReceiveBuffer, e.Offset, data, 0, e.BytesReceived);
     DBShare.MainOutMessage(System.Text.Encoding.Default.GetString(data));
     (e.Tag as TSelectClient).ExecGateBuffers(System.Text.Encoding.Default.GetString(data), e.BytesReceived);
 }
Exemplo n.º 5
0
        public void ServerSocket_OnClientConnect(object sender, AsyncUserToken e)
        {
            string      sRemoteAddress;
            TModuleInfo ModuleInfo = new TModuleInfo();

            sRemoteAddress = e.EndPoint.Address.ToString();
            DBShare.MainOutMessage("M2连接: " + e.EndPoint.ToString());
            if ((!DBShare.CheckServerIP(sRemoteAddress)))
            {
                DBShare.MainOutMessage("非法服务器连接: " + sRemoteAddress);
                e.Socket.Close();
                return;
            }
            if (!(THumDB.boDataDBReady && THumDB.boHumDBReady && DBShare.g_boStartService))
            {
                e.Socket.Close();
            }
            else
            {
                ModuleInfo.Module     = e;
                ModuleInfo.ModuleName = "游戏中心";
                ModuleInfo.Address    = string.Format("{0}:{1} → {2}:{3}", sRemoteAddress, e.EndPoint.Port, sRemoteAddress, 6000);// Format("%s:%d → %s:%d", new object[] {sRemoteAddress, Socket.RemotePort, sRemoteAddress, ServerSocket.Port});
                ModuleInfo.Buffer     = "0/0";
                ModuleInfo            = DBShare.AddModule(ModuleInfo);
            }
            TServerClient ClentSocket = new TServerClient(e, FrmIDSoc);

            e.Tag = new object[] { ClentSocket, ModuleInfo };
        }
Exemplo n.º 6
0
        /// <summary>
        /// 刷新显示用户物品
        /// </summary>
        private unsafe void RefShowUserItem()
        {
            int          i;
            ListViewItem ListItem;
            TUserItem    UserItem;
            TUserItem *  pUserItem;
            const string sItemValue = "{0}-{1}-{2}-{3}-{4}-{5}-{6}-{7}-{8}-{9}-{10}-{11}-{12}-{13}";

            ListViewUserItem.Items.Clear();
            byte[] HumItems;
            fixed(byte *buff = m_ChrRcd.Data.HumItemsBuff)
            {
                HumItems = HUtil32.BytePtrToByteArray(buff, 9 * 74);
            }

            for (i = 0; i < HumItems.Length; i = i + 74)
            {
                fixed(byte *buff = &HumItems[i])
                {
                    pUserItem = (TUserItem *)buff;
                }

                UserItem      = *pUserItem;
                ListItem      = new ListViewItem();
                ListItem.Text = (i).ToString();
                ListItem.SubItems.Add((UserItem.MakeIndex).ToString());
                ListItem.SubItems.Add((UserItem.wIndex).ToString());
                ListItem.SubItems.Add(DBShare.GetStdItemName(UserItem.wIndex));
                ListItem.SubItems.Add(string.Format("{0}/{1}", UserItem.Dura, UserItem.DuraMax));
                ListItem.SubItems.Add(string.Format(sItemValue, UserItem.btValue[0], UserItem.btValue[1], UserItem.btValue[2], UserItem.btValue[3], UserItem.btValue[4], UserItem.btValue[5], UserItem.btValue[6], UserItem.btValue[7], UserItem.btValue[8], UserItem.btValue[9], UserItem.btValue[10], UserItem.btValue[11], UserItem.btValue[12], UserItem.btValue[13]));
                ListViewUserItem.Items.Add(ListItem);
            }
            byte[] HumAddItems;//下面四个格子
            fixed(byte *buff = m_ChrRcd.Data.HumAddItemsBuff)
            {
                HumAddItems = HUtil32.BytePtrToByteArray(buff, 4 * 74);
            }

            for (i = 0; i < HumAddItems.Length; i += 74)
            {
                fixed(byte *buff = &HumAddItems[i])
                {
                    pUserItem = (TUserItem *)buff;
                }

                UserItem      = *pUserItem;
                ListItem      = new ListViewItem();
                ListItem.Text = i.ToString();
                ListItem.SubItems.Add((UserItem.MakeIndex).ToString());
                ListItem.SubItems.Add((UserItem.wIndex).ToString());
                ListItem.SubItems.Add(DBShare.GetStdItemName(UserItem.wIndex));
                ListItem.SubItems.Add(string.Format("{0}/{1}", UserItem.Dura, UserItem.DuraMax));
                ListItem.SubItems.Add(string.Format(sItemValue, UserItem.btValue[0], UserItem.btValue[1], UserItem.btValue[2], UserItem.btValue[3], UserItem.btValue[4], UserItem.btValue[5], UserItem.btValue[6], UserItem.btValue[7], UserItem.btValue[8], UserItem.btValue[9], UserItem.btValue[10], UserItem.btValue[11], UserItem.btValue[12], UserItem.btValue[13]));
                ListViewUserItem.Items.Add(ListItem);
            }
        }
Exemplo n.º 7
0
 private void StopService()
 {
     DBShare.g_boStartService = false;
     DBShare.MainOutMessage("正在停止服务器...");
     MENU_CONTROL_START.Enabled = true;
     MENU_CONTROL_STOP.Enabled  = false;
     FrmIDSoc.Invoke((MethodInvoker) delegate() { FrmIDSoc.CloseConnect(); });
     SelectSocket.Shutdown();
     ServerSocket.Shutdown();
     DBShare.MainOutMessage("服务器已停止...");
 }
Exemplo n.º 8
0
 public void TimerCloseTimer(object objState)
 {
     if (DBShare.g_boStartService)
     {
         DBShare.g_boStartService = false;
         DBShare.MainOutMessage("正在停止服务器...");
         this.Invoke((MethodInvoker) delegate() { MENU_CONTROL_START.Enabled = true; });
         this.Invoke((MethodInvoker) delegate() { MENU_CONTROL_STOP.Enabled = false; });
         FrmIDSoc.Invoke((MethodInvoker) delegate() { FrmIDSoc.CloseConnect(); });
     }
     TimerClose.Change(-1, -1);
     SelectSocket.Shutdown();
     ServerSocket.Shutdown();
     DBShare.MainOutMessage("服务器已停止...");
 }
Exemplo n.º 9
0
        public void ButtonTestClick(System.Object Sender, System.EventArgs _e1)
        {
            string sSelGateIPaddr;
            string sGameGateIPaddr;
            int    nGameGatePort = 0;

            sSelGateIPaddr  = EditSelGate.Text.Trim();
            sGameGateIPaddr = DBShare.GateRouteIP(sSelGateIPaddr, ref nGameGatePort);
            if (sGameGateIPaddr == "")
            {
                EditGameGate.Text = "ÎÞ´ËÍø¹ØÉèÖÃ";
                return;
            }
            EditGameGate.Text = string.Format("{0}:{1}", sGameGateIPaddr, nGameGatePort);
        }
Exemplo n.º 10
0
 public void FormCreate(System.Object Sender, System.EventArgs _e1)
 {
     DBShare.Initialization();
     DBShare.MainOutMessage("正在启动数据库服务器...");
     FrmIDSoc = new TFrmIDSoc(this);
     FrmIDSoc.Show();
     FrmIDSoc.Hide();
     ModuleGrid.AllowUserToAddRows = false;
     ModuleGrid.RowHeadersVisible  = false;
     ModuleGrid.ReadOnly           = true;
     ModuleGrid.Columns.Add("MKMC", "模块名称");
     ModuleGrid.Columns.Add("LJDZ", "连接地址");
     ModuleGrid.Columns.Add("SJTX", "数据通讯");
     ModuleGrid.Columns[0].Width    = 80;
     ModuleGrid.Columns[1].Width    = 468 - 80 * 2;
     ModuleGrid.Columns[2].Width    = 80;
     ModuleGrid.SelectionMode       = DataGridViewSelectionMode.FullRowSelect;
     ModuleGrid.MultiSelect         = false;
     ModuleGrid.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;
     ModuleGrid.Columns[1].SortMode = DataGridViewColumnSortMode.NotSortable;
     ModuleGrid.Columns[2].SortMode = DataGridViewColumnSortMode.NotSortable;
     ModuleGrid.RowTemplate.Height  = 18;
     ModuleGrid.Rows.Add(5);
     //M2套接字
     ServerSocket = new IServerSocket(1000, Int16.MaxValue);
     ServerSocket.OnClientConnect     += ServerSocket_OnClientConnect;
     ServerSocket.OnClientDisconnect  += ServerSocket_OnClientDisconnect;
     ServerSocket.OnClientError       += ServerSocket_OnClientError;
     ServerSocket.OnClientRead        += ServerSocket_OnClientRead;
     ServerSocket.OnDataSendCompleted += ServerSocket_OnDataSendCompleted;
     //选择服务器套接字
     SelectSocket = new IServerSocket(1000, Int16.MaxValue);
     SelectSocket.OnClientConnect     += SelectSocket_OnClientConnect;
     SelectSocket.OnClientDisconnect  += SelectSocket_OnClientDisconnect;
     SelectSocket.OnClientError       += SelectSocket_OnClientError;
     SelectSocket.OnClientRead        += SelectSocket_OnClientRead;
     SelectSocket.OnDataSendCompleted += SelectSocket_OnDataSendCompleted;
     ServerSocket.Init();
     SelectSocket.Init();
     CheckBoxShowMainLogMsg.Checked = DBShare.g_boShowLogMsg;
     //Units.Main.RankingThread = new TRankingThread(true);
     //Units.Main.RankingThread.Resume();
     DBShare.SendGameCenterMsg(Common.SG_STARTNOW, "正在启动数据库服务器...");
     TimerMain  = new System.Threading.Timer(TimerMainTimer, null, 0, 1);
     TimerStart = new System.Threading.Timer(TimerStartTimer, null, -1, -1);
     TimerClose = new System.Threading.Timer(TimerCloseTimer, null, -1, -1);
     TimerStart.Change(0, 1000);
 }
Exemplo n.º 11
0
        private void IDSocket_OnConnected(object sender, NetFramework.DSCClientConnectedEventArgs e)
        {
            m_dwCheckServerTimeMin = HUtil32.GetTickCount();
            m_dwCheckServerTimeMax = 0;
            m_dwCheckRecviceTick   = HUtil32.GetTickCount();
            string sRemoteAddress = e.socket.RemoteEndPoint.ToString();// e.EndPoint.ToString();

            //开启心跳包
            KeepAliveTimer.Change(0, 3000);
            TModuleInfo ModuleInfo = new TModuleInfo();

            ModuleInfo.Module     = this;
            ModuleInfo.ModuleName = DBShare.g_sServerName;
            ModuleInfo.Address    = string.Format("%{0}:%{1} → %{2}:%{3}", sRemoteAddress, e.socket.LocalEndPoint.AddressFamily.ToString(), sRemoteAddress, e.socket.RemoteEndPoint.AddressFamily.ToString());
            ModuleInfo.Buffer     = "0/0";
            m_Module = DBShare.AddModule(ModuleInfo);
        }
Exemplo n.º 12
0
        /// <summary>
        /// 显示窗体上网格信息
        /// </summary>
        private void ShowModule()
        {
            int         I;
            TModuleInfo ModuleInfo;

            try
            {
                if ((GameFramework.HUtil32.GetTickCount() - DBShare.g_dwShowModuleTick) > 2000)
                {
                    DBShare.g_dwShowModuleTick = GameFramework.HUtil32.GetTickCount();
                    ModuleGrid.RowCount        = HUtil32._MAX(DBShare.g_ModuleList.Count + 1, 5);
                    for (I = 0; I < ModuleGrid.RowCount; I++)
                    {
                        if (I < DBShare.g_ModuleList.Count)
                        {
                            ModuleInfo = DBShare.g_ModuleList[I];
                            ModuleGrid.Invoke((MethodInvoker) delegate()
                            {
                                ModuleGrid.Rows[I].Cells[0].Value = ModuleInfo.ModuleName;
                                ModuleGrid.Rows[I].Cells[1].Value = ModuleInfo.Address;
                                ModuleGrid.Rows[I].Cells[2].Value = ModuleInfo.Buffer;
                            });
                        }
                        else
                        {
                            ModuleGrid.Invoke((MethodInvoker) delegate()
                            {
                                ModuleGrid.Rows[I].Cells[0].Value = "";
                                ModuleGrid.Rows[I].Cells[1].Value = "";
                                ModuleGrid.Rows[I].Cells[2].Value = "";
                            });
                        }
                    }
                }
            }
            catch
            {
                DBShare.MainOutMessage("[Exception] ShowModule");
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// 刷新显示仓库信息
        /// </summary>
        private unsafe void RefShowStorage()
        {
            int          i;
            ListViewItem ListItem;
            TUserItem    UserItem;
            TUserItem *  pUserItem;

            ListViewStorage.Items.Clear();
            byte[] StorageItems;//46 * 74
            fixed(byte *buff = m_ChrRcd.Data.StorageItemsBuff)
            {
                StorageItems = HUtil32.BytePtrToByteArray(buff, 46 * 74);
            }

            for (i = 0; i <= StorageItems.Length; i += 74)
            {
                fixed(byte *buff = &StorageItems[i])
                {
                    pUserItem = (TUserItem *)buff;
                }

                UserItem = *pUserItem;
                if (UserItem.wIndex == 0)
                {
                    continue;
                }
                ListItem      = new ListViewItem();
                ListItem.Text = i.ToString();
                ListItem.SubItems.Add((UserItem.MakeIndex).ToString());
                ListItem.SubItems.Add((UserItem.wIndex).ToString());
                ListItem.SubItems.Add(DBShare.GetStdItemName(UserItem.wIndex));
                ListItem.SubItems.Add(string.Format("{0}/{1}", UserItem.Dura, UserItem.DuraMax));
                ListItem.SubItems.Add(string.Format("{0}/{1}/{2}/{3}/{4}/{5}/{6}/{7}/{8}/{9}/{10}/{11}/{12}/{13}", UserItem.btValue[0], UserItem.btValue[1], UserItem.btValue[2], UserItem.btValue[3], UserItem.btValue[4], UserItem.btValue[5], UserItem.btValue[6], UserItem.btValue[7], UserItem.btValue[8], UserItem.btValue[9], UserItem.btValue[10], UserItem.btValue[11], UserItem.btValue[12], UserItem.btValue[13]));
                ListViewStorage.Items.Add(ListItem);
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// 刷新显示魔法数据
        /// </summary>
        private unsafe void RefShowMagic()
        {
            int          i;
            ListViewItem ListItem;
            THumMagic *  pMagicInfo;
            THumMagic    MagicInfo;

            ListViewMagic.Items.Clear();
            byte[] HumMagics = new byte[30 * 8];
            fixed(byte *buff = m_ChrRcd.Data.HumMagicsBuff)
            {
                HUtil32.BytePtrToByteArray(buff, 30 * 8);
            }

            for (i = 0; i < HumMagics.Length; i = i + 8)
            {
                fixed(byte *buff = &HumMagics[i])
                {
                    pMagicInfo = (THumMagic *)buff;
                }

                MagicInfo = *pMagicInfo;
                if (MagicInfo.wMagIdx == 0)
                {
                    break;
                }
                ListItem      = new ListViewItem();
                ListItem.Text = i.ToString();
                ListItem.SubItems.Add((MagicInfo.wMagIdx).ToString());
                ListItem.SubItems.Add(DBShare.GetMagicName(MagicInfo.wMagIdx));
                ListItem.SubItems.Add((MagicInfo.btLevel).ToString());
                ListItem.SubItems.Add((MagicInfo.nTranPoint).ToString());
                ListItem.SubItems.Add((MagicInfo.btKey).ToString());
                ListViewMagic.Items.Add(ListItem);
            }
        }
Exemplo n.º 15
0
 public void SelectSocket_OnClientDisconnect(object sender, AsyncUserToken e)
 {
     DBShare.MainOutMessage("Sel断开: " + e.EndPoint.ToString());
 }
Exemplo n.º 16
0
 private void IDSocket_OnDisconnected(object sender, NetFramework.DSCClientConnectedEventArgs e)
 {
     m_Module = null;
     KeepAliveTimer.Dispose();
     DBShare.RemoveModule(this);
 }
Exemplo n.º 17
0
        /// <summary>
        /// 处理服务器包
        /// </summary>
        /// <param name="Buffer"></param>
        /// <param name="BufLen"></param>
        public void ProcessServerPacket(string Buffer, int BufLen)
        {
            bool bo25 = false;
            int  nC   = 0;
            //string sReceiveText = string.Empty;
            string          sC;
            string          s1C;
            string          s20 = string.Empty;
            string          s24 = string.Empty;
            int             n14;
            int             n18;
            ushort          wE;
            ushort          w10;
            TDefaultMessage DefMsg;

            try
            {
                m_sQueryID        = "";
                m_dwKeepAliveTick = GameFramework.HUtil32.GetTickCount();
                string sReceiveText = Buffer;
                m_sReceiveText = m_sReceiveText + sReceiveText;
#if DEBUG
                DBShare.MainOutMessage("ServerClient.m_sReceiveText:" + m_sReceiveText);
#endif
                while (true)
                {
                    if (m_sReceiveText.IndexOf('!') <= 0)
                    {
                        break;
                    }
                    //获取一条数据放入s20
                    m_sReceiveText = GameFramework.HUtil32.ArrestStringEx(m_sReceiveText, "#", "!", ref s20);
                    if (s20 != "")          //如果s20不为空
                    {
                        if (s20.Length > 2) //并且大于2
                        {
                            s20 = GameFramework.HUtil32.GetValidStr3(s20, ref s24, new string[] { "/" });
                            n14 = s20.Length;
                            if ((n14 >= Grobal2.DEFBLOCKSIZE) && (s24 != ""))
                            {
                                m_sQueryID = s24;
                                wE         = (ushort)(GameFramework.HUtil32.Str_ToInt(s24, 0) ^ 170);
                                w10        = (ushort)n14;
                                n18        = GameFramework.HUtil32.MakeLong(wE, w10);
                                sC         = EncryptUnit.EncodeBuffer(BitConverter.GetBytes(n18), 4);
                                if (HUtil32.CompareBackLStr(s20, sC))
                                {
                                    ProcessServerMsg(s20, n14);
                                    bo25           = true;
                                    m_sReceiveText = "";
                                    break;
                                }
                                else
                                {
                                    m_DefMsg = EncryptUnit.MakeDefaultMsg(Common.DBR_FAIL, 0, 0, 0, 0);
                                    SendSocket(EncryptUnit.EncodeMessage(m_DefMsg));
                                    m_sReceiveText = "";
                                    break;
                                }
                            }
                        }
                        else
                        {
                            m_sReceiveText = "";
                            break;
                        }
                    }
                    else
                    {
                        // 防止DBS溢出攻击
                        if (nC >= 1)
                        {
                            m_sReceiveText = "";
                            break;
                        }
                        nC++;
                    }
                }
                m_dwCheckServerTimeMin = GameFramework.HUtil32.GetTickCount() - m_dwCheckRecviceTick;
                if (m_dwCheckServerTimeMin > m_dwCheckServerTimeMax)
                {
                    m_dwCheckServerTimeMax = m_dwCheckServerTimeMin;
                }
                m_dwCheckRecviceTick = GameFramework.HUtil32.GetTickCount();
                if (m_Module != null)
                {
                    m_Module.Buffer = string.Format("{0}/{1}", m_dwCheckServerTimeMin, m_dwCheckServerTimeMax);
                }
            }
            catch
            {
                DBShare.MainOutMessage("[Exception] TDBSERVER::ProcessServerPacket");
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// 保存角色数据
        /// </summary>
        /// <param name="nRecog"></param>
        /// <param name="sMsg"></param>
        private unsafe void SaveHumanRcd(int nRecog, string sMsg)
        {
            string          sChrName  = string.Empty;
            string          sUserID   = string.Empty;
            string          sHumanRCD = string.Empty;
            int             I;
            int             nIndex;
            bool            bo21;
            TDefaultMessage DefMsg;
            THumDataInfo *  HumanRCD;
            THumDataInfo    HumDataInfo;

            sHumanRCD = HUtil32.GetValidStr3(sMsg, ref sUserID, new string[] { "/" });
            sHumanRCD = HUtil32.GetValidStr3(sHumanRCD, ref sChrName, new string[] { "/" });
            sUserID   = EncryptUnit.DeCodeString(sUserID);
            sChrName  = EncryptUnit.DeCodeString(sChrName);
            bo21      = false;
            HumanRCD  = (THumDataInfo *)Marshal.AllocHGlobal(sizeof(THumDataInfo));
            HUtil32.ZeroMemory((IntPtr)(&HumanRCD->Data), (IntPtr)sizeof(THumData));
            int THumDataInfoLength = DBShare.GetCodeMsgSize(sizeof(THumDataInfo) * 4 / 3) + 1;

            if (sHumanRCD.Length == THumDataInfoLength)
            {
                EncryptUnit.DecodeBuffer(sHumanRCD, HumanRCD, sizeof(THumDataInfo));
            }
            else
            {
                bo21 = true;
            }
            if (!bo21)
            {
                bo21 = true;
                try
                {
                    HumDataInfo = DBShare.g_HumDataDB.Get(sChrName);
                    //nIndex = DBShare.g_HumDataDB.Index(sChrName);
                    if (HumDataInfo.Header.NameLen <= 0)
                    {
                        HumanRCD->Header.boDeleted   = false;
                        HumanRCD->Header.dCreateDate = DateTime.Now.ToOADate();
                        //sChrName.StrToSbyte(HumanRCD->Header.sName, 15,ref HumanRCD->Header.NameLen);
                        HumanRCD->Header.sName    = sChrName;
                        HumanRCD->Header.boIsHero = false;
                        DBShare.g_HumDataDB.Add(ref *HumanRCD);
                        //nIndex = DBShare.g_HumDataDB.Index(sChrName);
                    }
                    HumDataInfo = DBShare.g_HumDataDB.Get(sChrName);
                    if (HumDataInfo.Header.NameLen > 0)
                    {
                        HumanRCD->Header = HumDataInfo.Header;
                        DBShare.g_HumDataDB.Update(sChrName, ref *HumanRCD);
                        bo21 = false;
                        DBShare.g_nSaveHumCount++;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                FrmIDSoc.SetSessionSaveRcd(sUserID);
            }
            if (!bo21)
            {
                m_DefMsg = EncryptUnit.MakeDefaultMsg(Common.DBR_SAVEHUMANRCD, 1, 0, 0, 0);
                SendSocket(EncryptUnit.EncodeMessage(m_DefMsg));
            }
            else
            {
                m_DefMsg = EncryptUnit.MakeDefaultMsg(Common.DBR_LOADHUMANRCD, 0, 0, 0, 0);
                SendSocket(EncryptUnit.EncodeMessage(m_DefMsg));
                DBShare.MainOutMessage("SaveHumanRcd Fail,UserID:sUserID,ChrName:sChrName");
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// 载入角色记录
        /// </summary>
        /// <param name="sMsg"></param>
        private unsafe void LoadHumanRcd(string sMsg)
        {
            string       sHumName;
            string       sAccount;
            string       sIPaddr;
            int          nSessionID;
            int          nCheckCode;
            THumDataInfo HumanRCD;
            bool         boFoundSession = false;
            TLoadHuman * pLoadHuman;

            pLoadHuman = (TLoadHuman * )Marshal.AllocHGlobal(sizeof(TLoadHuman));
            EncryptUnit.DecodeBuffer(sMsg, pLoadHuman, sizeof(TLoadHuman));
            sAccount   = HUtil32.SBytePtrToString(pLoadHuman->sAccount, 0, 30).TrimEnd('\0');
            sHumName   = HUtil32.SBytePtrToString(pLoadHuman->sChrName, 0, 14).TrimEnd('\0');
            sIPaddr    = HUtil32.SBytePtrToString(pLoadHuman->sUserAddr, 0, 15).TrimEnd('\0');
            nSessionID = pLoadHuman->nSessionID;
            nCheckCode = -1;
            if ((sAccount != "") && (sHumName != ""))
            {
                if ((FrmIDSoc.CheckSessionLoadRcd(sAccount, sIPaddr, nSessionID, ref boFoundSession)))
                {
                    nCheckCode = 1;
                }
                else
                {
                    if (boFoundSession)
                    {
                        DBShare.MainOutMessage("[非法重复请求] " + "帐号: " + sAccount + " IP: " + sIPaddr + " 标识: " + (nSessionID).ToString());
                    }
                    else
                    {
                        DBShare.MainOutMessage("[非法请求] " + "帐号: " + sAccount + " IP: " + sIPaddr + " 标识: " + (nSessionID).ToString());
                    }
                    // nCheckCode:= 1; //测试用,正常去掉
                }
            }
            if (nCheckCode == 1)
            {
                try
                {
                    HumanRCD = DBShare.g_HumDataDB.Get(sHumName);
                    if (HumanRCD.Header.NameLen > 0)
                    {
                        if (HumanRCD.Header.NameLen < 0)
                        {
                            nCheckCode = -2;
                        }
                    }
                    else
                    {
                        nCheckCode = -3;
                    }
                }catch
                {
                    nCheckCode = -4;
                }
            }
            if (nCheckCode == 1)
            {
                DBShare.g_nLoadHumCount++;
                m_DefMsg = EncryptUnit.MakeDefaultMsg(Common.DBR_LOADHUMANRCD, 1, 0, 0, 1);
                SendSocket(EncryptUnit.EncodeMessage(m_DefMsg) + EncryptUnit.EncodeString(sHumName) + '/' + EncryptUnit.EncodeBuffer(&HumanRCD, sizeof(THumDataInfo)));
            }
            else
            {
                m_DefMsg = EncryptUnit.MakeDefaultMsg(Common.DBR_LOADHUMANRCD, nCheckCode, 0, 0, 0);
                SendSocket(EncryptUnit.EncodeMessage(m_DefMsg));
            }
        }
Exemplo n.º 20
0
 public void G1Click(System.Object Sender, System.EventArgs _e1)
 {
     DBShare.LoadGateID();
     DBShare.LoadIPTable();
     DBShare.MainOutMessage("网关设置加载完成");
 }
Exemplo n.º 21
0
 public void C1Click(System.Object Sender, System.EventArgs _e1)
 {
     DBShare.LoadChrNameList("DenyChrName.txt");
     DBShare.LoadAICharNameList("AICharName.txt");
     DBShare.MainOutMessage("角色过滤列表加载完成");
 }