Пример #1
0
        /// <summary>
        /// 删除英雄数据
        /// </summary>
        /// <param name="sMsg"></param>
        private void DeleteHeroRcd(string sMsg)
        {
            string       sData;
            string       sAccount = string.Empty;
            string       sChrName = string.Empty;
            bool         boCheck;
            int          n10;
            int          n12;
            HumInfo      HumRecord;
            THumDataInfo HumanRCD;

            n12     = 0;
            sData   = EncryptUnit.DeCodeString(sMsg);
            sData   = HUtil32.GetValidStr3(sData, ref sAccount, new string[] { "/" });
            sData   = HUtil32.GetValidStr3(sData, ref sChrName, new string[] { "/" });
            boCheck = false;
            try
            {
                HumRecord = DBShare.g_HumCharDB.FindObjectByChrName(sChrName);
                if (HumRecord != null)
                {
                    //HumRecord = DBShare.g_HumCharDB.FindObjectByChrName(sChrName);
                    if (HumRecord != null && HumRecord.boIsHero.Value)
                    {
                        if (DBShare.g_HumCharDB.Delete(sChrName))
                        {
                            n12 = 1;
                        }
                        DBShare.g_nDeleteHeroCount++;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            if (n12 == 1)
            {
                try
                {
                    HumanRCD = DBShare.g_HumDataDB.Get(sChrName);
                    if (HumanRCD.Header.NameLen > 0)
                    {
                        if (HumanRCD.Header.NameLen > 0 && HumanRCD.Header.boIsHero)
                        {
                            if (DBShare.g_HumDataDB.Delete(sChrName))
                            {
                                n12 = 1;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            m_DefMsg = EncryptUnit.MakeDefaultMsg(Common.DBR_DELHERORCD, n12, 0, 0, 0);
            SendSocket(EncryptUnit.EncodeMessage(m_DefMsg));
        }
Пример #2
0
        public unsafe static TDefaultMessage MakeDefaultMsg(int wIdent, int nRecog, int wParam, int wTag, int wSeries, int wSessionID)
        {
            TDefaultMessage result = new TDefaultMessage();

            result.Recog      = nRecog;
            result.Ident      = (ushort)wIdent;
            result.Param      = (uint)wParam;
            result.Tag        = (uint)wTag;
            result.Series     = (uint)wSeries;
            result.nSessionID = wSessionID;
            return(result);
        }
Пример #3
0
        unsafe static void Main(string[] args)
        {
            GameBaseTest g1 = new GameBaseTest();
            int          n1 = g1.Parse(g1.GameConfig);

            Console.WriteLine(n1);
            Console.ReadKey();
            return;

            GameBaseTest g = new GameBaseTest();

            g.test();
            Thread.Sleep(1000);
            g = new GameBaseTest();
            g.test();
            Console.ReadKey();
            return;

            Console.Write(int.MaxValue);
            Console.ReadKey();
            return;

            int sasdasdasdasd = sizeof(TUnbindInfo);//4491
            int asdasd        = Marshal.SizeOf(typeof(THumDataInfo));


            Console.ReadLine();


            DbSession dbsession = new DbSession("MyTest");


            TDefaultMessage hun     = new TDefaultMessage();
            int             HumSize = Marshal.SizeOf(hun);



            TStdItem a = new TStdItem();

            MyRefTest(a);

            // Console.WriteLine(a.Name);

            IClientScoket socket = new IClientScoket();

            socket.OnConnected      += socket_OnConnected;
            socket.ReceivedDatagram += socket_ReceivedDatagram;
            socket.Connect("127.0.0.1", 6000);

            TDefaultMessage DefMsg = EncryptUnit.MakeDefaultMsg(1000, 0, 0, 0, 0, 0);


            TLoadHuman sLoadHuman   = new TLoadHuman();
            int        aaaaaaaaaaaa = Marshal.SizeOf(sLoadHuman);

            sLoadHuman.sAccount   = "123123";
            sLoadHuman.sChrName   = "啊啊啊啊";
            sLoadHuman.sUserAddr  = "127.0.0.1";
            sLoadHuman.nSessionID = 15;
            byte[] sdata = StructToBytes(sLoadHuman);

            // string sDBMsg = EncryptUnit.EncodeMessage(DefMsg) + EncryptUnit.EncodeBuffer<TLoadHuman>(sLoadHuman);
            //  socket.Send(SendDBSockMsg(0, sDBMsg));

            Console.WriteLine("ok");
            Console.ReadKey();


            //TStdItem a = new TStdItem();
            // MyRefTest(a);
            // Console.WriteLine(a.Name);

            TUnbindInfo abc    = new TUnbindInfo();
            int         MySize = Marshal.SizeOf(abc);

            HUtil32._MIN(Int32.MaxValue, 14 + (int)Math.Floor(1 / (double)6 + 2.5 * 1));

            Math.Round(Math.Round((double)50 / 100, 1), 1);

            decimal aaaaaaaaa = Round((decimal)Round((decimal)50.0 / 100, 1) * 368, 2);



            //string strss=  EncryptUnit.EncodeBuffer(StructToBytes(a, Marshal.SizeOf(typeof(Struct1))), Marshal.SizeOf(typeof(Struct1)));

            Class1 b = new Class1();

            b.Id   = 1;
            b.Name = "张三";

            string strbb = EncryptUnit.EncodeBuffer(ObjectToBytes(b), 8);

            b.Name = "张三";
            //string a = "你好吗";

            //sbyte[] by = new sbyte[StringToSBytePtr(a, null, 1) + 1];
            //fixed (sbyte* pb = by)
            //{
            //    StringToSBytePtr(a, pb, 1);
            //    string b = SBytePtrToString(pb, 1, by.Length - 1);
            //    Console.WriteLine(b);
            //}

            //int nLen = StringToIntPtrPlusLen(a, (IntPtr)0, 0);
            //byte[] byy = new byte[nLen + 1];
            //fixed (byte* pb = byy)
            //{
            //    StringToIntPtrPlusLen(a, (IntPtr)pb, 1);
            //    string b = IntPtrPlusLenToString((IntPtr)pb, 1);
            //    Console.WriteLine(b);
            //}



            Test t = new Test();

            t.Main();

            // THumDataInfo* HumanRcd = (THumDataInfo*)Marshal.AllocHGlobal(Marshal.SizeOf(typeof(THumDataInfo)));

            //byte[] data=new byte[sizeof(THumDataInfo)];
            //fixed (byte* pb = data)
            //{
            //    *(THumDataInfo*)pb = *HumanRcd;
            //}

            TProcessMessage msg = new TProcessMessage();



            int aaaaaaaaaaa = Marshal.SizeOf(typeof(TProcessMessage));



            var arrayDouble = Enumerable.Range(1, 1024)
                              .Select(i => (int)i)
                              .ToArray();

            fixed(int *p = arrayDouble)
            {
                var array2 = ToByte <int>(p, 1);

                //Assert.AreEqual(arrayDouble, array2);
            }

            int[,] arr4 = new int[2, 3] {
                { 1, 2, 3 }, { 4, 5, 6 }
            };


            //byte[, ,] arr = new byte[8,4,4]
            //{
            //    {
            //        {1,2},{1,2}
            //    },
            //    {
            //        {1,2},{1,2}
            //    }
            //};

            byte[, ,] arr = new byte[, , ]
            {
                {
                    { 1, 2 }, { 1, 2 }
                },
                {
                    { 21, 22 }, { 21, 22 }
                },
                {
                    { 31, 32 }, { 31, 32 }
                }
            };


            string sText  = "G73";
            int    nValNo = 0;

            nValNo = HUtil32.Str_ToInt(sText.Substring(1, 2), -1);

            byte[] buff = System.Text.Encoding.GetEncoding("gb2312").GetBytes("我是测试字符串");;
            string str2 = string.Empty;

            for (int i = 0; i < 14; i++)
            {
                str2 += String.Format("{0:X2}", buff[i]) + ",";
            }

            string aa = System.Text.Encoding.GetEncoding("gb2312").GetString(buff);

            Console.WriteLine(str2);
            Console.WriteLine(aa);


            //Console.WriteLine(sizeof(TStdItem));

            //Console.WriteLine(Marshal, sizeof(PTDealOffInfo));

            string str    = string.Empty;
            string FColor = string.Empty;
            string BColor = string.Empty;
            string nTime  = string.Empty;
            string sMsg   = "{180,251} 3 战斗区域";

            sMsg = HUtil32.ArrestStringEx(sMsg, "{", "}", ref str);
            str  = HUtil32.GetValidStrCap(str, ref FColor, new string[] { "," });
            str  = HUtil32.GetValidStrCap(str, ref BColor, new string[] { "," });
            str  = HUtil32.GetValidStrCap(str, ref nTime, new string[] { "," });


            Console.WriteLine(MakeWord((byte)255, (byte)56));

            //m_CanJmpScriptLableList = new List<string>();
            //string msg = @"欢迎,我能为你做点什么?\ \<买/@buy>  物品\<卖/@sell>  物品\<特修毒符/@s_repair>\<询问/@questionprize> 物品详细情况 \<离 开/@exit>\";

            //GetScriptLabel(msg);

            //Console.WriteLine(sizeof(TClientMagic));

            //Console.WriteLine(Marshal.SizeOf(typeof(TClientMagic)));

            //int ccc = sizeof(TClientMagic);

            //@@rmst

            //strLen = sLabel.Substring(0, sLabel.Length - 1);

            //s18 = sLabel.Substring(strLen.Length + 1, sLabel.Length - strLen.Length);

            //Console.WriteLine(m_CanJmpScriptLableList.Count);

            //string aaaa= sub_49ADB8("<$USERNAME>加入游戏,<$SERVERNAME>又多了一份力量!", "<$USERNAME>", "1234");

            //aaaa = sub_49ADB8(aaaa, "<$SERVERNAME>", "12345");



            Console.ReadKey();
        }
Пример #4
0
 public override void SendSocket(TDefaultMessage DefMsg, string sMsg)
 {
 }
Пример #5
0
        /// <summary>
        /// 载入排行
        /// </summary>
        /// <param name="sMsg"></param>
        /// <param name="Msg"></param>
        private void LoadRanking(string sMsg, TDefaultMessage Msg)
        {
//            int I;
//            int nIndex;
//            int nCount;
//            string sHumName;
//            string sSendText;
//            // S: string;
//            int nCheckCode;
//            TDefaultMessage DefMsg;
//            List<string> RankingList;
//            TUserLevelRanking HumRanking;
//            THeroLevelRanking HeroRanking;
//            TUserMasterRanking MasterRanking;
//            TUserLevelRanking UserLevelRanking;
//            THeroLevelRanking HeroLevelRanking;
//            TUserMasterRanking UserMasterRanking;
//            //@ Unsupported function or procedure: 'EnterCriticalSection'
//            EnterCriticalSection(DBShare.Units.DBShare.g_Ranking_CS);
//            try {
//                nCheckCode =  -1;
//                sSendText = "";
//                nIndex = 0;
//                nCount = 0;
//                RankingList = null;
//                // S := '';
//                sHumName = EncryptUnit.Units.EncryptUnit.DeCodeString(sMsg);
//                if (Msg.Param >= 0 && Msg.Param<= 2)
//                {
//                    if (Msg.Param < 2)
//                    {
//                        if (Msg.Tag >= 0 && Msg.Tag<= 4)
//                        {
//                            nCheckCode = 0;
//                            RankingList = DBShare.Units.DBShare.GetRankingList(Msg.Param, Msg.Tag);
//                            if (RankingList.Count > 0)
//                            {
//                                if (sHumName == "")
//                                {
//                                    // 为空不是查找自己
//                                    //@ Undeclared identifier(3): '_MIN'
//                                    //@ Undeclared identifier(3): '_MAX'
//                                    nIndex = _MAX(_MIN(RankingList.Count - 1, Msg.Recog), 0);
////#if HEROVERSION = 1
////                                    //@ Undeclared identifier(3): '_MIN'
////                                    nCount = _MIN(RankingList.Count - 1, nIndex + 9);
////#else
//                                    //@ Undeclared identifier(3): '_MIN'
//                                    nCount = _MIN(RankingList.Count - 1, nIndex + 7);
////#endif
//                                    if (Msg.Param == 0)
//                                    {
//                                        for (I = nIndex; I <= nCount; I ++ )
//                                        {
//                                            //@ Unsupported property or method(A): 'Values'
//                                            HumRanking = ((TUserLevelRanking)(RankingList.Values[I]));
//                                            UserLevelRanking = HumRanking;
//                                            UserLevelRanking.nIndex = I + 1;
//                                            // S:=S+HumRanking.sChrName+'/';
//                                            sSendText = sSendText + EncryptUnit.Units.EncryptUnit.EncodeBuffer(UserLevelRanking, sizeof(TUserLevelRanking)) + '/';
//                                        }
//                                    }
//                                    else
//                                    {
//                                        for (I = nIndex; I <= nCount; I ++ )
//                                        {
//                                            //@ Unsupported property or method(A): 'Values'
//                                            HeroRanking = ((THeroLevelRanking)(RankingList.Values[I]));
//                                            HeroLevelRanking = HeroRanking;
//                                            HeroLevelRanking.nIndex = I + 1;
//                                            sSendText = sSendText + EncryptUnit.Units.EncryptUnit.EncodeBuffer(HeroLevelRanking, sizeof(THeroLevelRanking)) + '/';
//                                        }
//                                    }
//                                }
//                                else
//                                {
//                                    if (Msg.Param == 0)
//                                    {
//                                        for (I = 0; I < RankingList.Count; I ++ )
//                                        {
//                                            //@ Unsupported property or method(A): 'Values'
//                                            HumRanking = ((TUserLevelRanking)(RankingList.Values[I]));
//                                            if (HumRanking.sChrName == sHumName)
//                                            {
//                                                UserLevelRanking = HumRanking;
//                                                UserLevelRanking.nIndex = I + 1;
//                                                sSendText = EncryptUnit.Units.EncryptUnit.EncodeBuffer(UserLevelRanking, sizeof(TUserLevelRanking));
//                                                // S:=S+HumRanking.sChrName+'/';
//                                                break;
//                                            }
//                                        }
//                                    }
//                                    else
//                                    {
//                                        for (I = 0; I < RankingList.Count; I ++ )
//                                        {
//                                            //@ Unsupported property or method(A): 'Values'
//                                            HeroRanking = ((THeroLevelRanking)(RankingList.Values[I]));
//                                            if (HeroRanking.sChrName == sHumName)
//                                            {
//                                                HeroLevelRanking = HeroRanking;
//                                                HeroLevelRanking.nIndex = I + 1;
//                                                sSendText = EncryptUnit.Units.EncryptUnit.EncodeBuffer(HeroLevelRanking, sizeof(THeroLevelRanking));
//                                                break;
//                                            }
//                                        }
//                                    }
//                                }
//                            }
//                        }
//                    }
//                    else
//                    {
//                        nCheckCode = 0;
//                        RankingList = DBShare.Units.DBShare.GetRankingList(Msg.Param, Msg.Tag);
//                        if (RankingList.Count > 0)
//                        {
//                            if (sHumName == "")
//                            {
//                                // 为空不是查找自己
//                                //@ Undeclared identifier(3): '_MIN'
//                                //@ Undeclared identifier(3): '_MAX'
//                                nIndex = _MAX(_MIN(RankingList.Count - 1, Msg.Recog), 0);
////#if HEROVERSION = 1
////                                //@ Undeclared identifier(3): '_MIN'
////                                nCount = _MIN(RankingList.Count - 1, nIndex + 9);
////#else
//                                //@ Undeclared identifier(3): '_MIN'
//                                nCount = _MIN(RankingList.Count - 1, nIndex + 7);
////#endif
//                                for (I = nIndex; I <= nCount; I ++ )
//                                {
//                                    //@ Unsupported property or method(A): 'Values'
//                                    MasterRanking = ((TUserMasterRanking)(RankingList.Values[I]));
//                                    UserMasterRanking = MasterRanking;
//                                    UserMasterRanking.nIndex = I + 1;
//                                    sSendText = sSendText + EncryptUnit.Units.EncryptUnit.EncodeBuffer(UserMasterRanking, sizeof(TUserMasterRanking)) + '/';
//                                }
//                            }
//                            else
//                            {
//                                for (I = 0; I < RankingList.Count; I ++ )
//                                {
//                                    //@ Unsupported property or method(A): 'Values'
//                                    MasterRanking = ((TUserMasterRanking)(RankingList.Values[I]));
//                                    if (MasterRanking.sChrName == sHumName)
//                                    {
//                                        UserMasterRanking = MasterRanking;
//                                        UserMasterRanking.nIndex = I + 1;
//                                        sSendText = EncryptUnit.Units.EncryptUnit.EncodeBuffer(UserMasterRanking, sizeof(TUserMasterRanking));
//                                        break;
//                                    }
//                                }
//                            }
//                        }
//                    }
//                }
//                if (nCheckCode == 0)
//                {
//                    DefMsg = EncryptUnit.Units.EncryptUnit.MakeDefaultMsg(Common.DBR_LOADRANKING, Msg.Tag, Msg.Param, nIndex, RankingList.Count);
//                    SendSocket(EncryptUnit.Units.EncryptUnit.EncodeMessage(DefMsg) + sSendText);
//                }
//                else
//                {
//                    DefMsg = EncryptUnit.Units.EncryptUnit.MakeDefaultMsg(Common.DBR_LOADRANKING, Msg.Tag, Msg.Param, nIndex, 0);
//                    SendSocket(EncryptUnit.Units.EncryptUnit.EncodeMessage(DefMsg) + sSendText);
//                }
//            } finally {
//                //@ Unsupported function or procedure: 'LeaveCriticalSection'
//                LeaveCriticalSection(DBShare.Units.DBShare.g_Ranking_CS);
//            }
        }
Пример #6
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");
            }
        }
Пример #7
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");
            }
        }
Пример #8
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));
            }
        }
Пример #9
0
        /// <summary>
        /// 处理服务器消息
        /// </summary>
        /// <param name="sMsg"></param>
        /// <param name="nLen"></param>
        private void ProcessServerMsg(string sMsg, int nLen)
        {
            string          sDefMsg;//消息头
            string          sData;
            TDefaultMessage DefMsg;

            if (nLen == Grobal2.DEFBLOCKSIZE)
            {
                sDefMsg = sMsg;
                sData   = "";
            }
            else
            {
                sDefMsg = sMsg.Substring(1 - 1, Grobal2.DEFBLOCKSIZE);
                sData   = sMsg.Substring(Grobal2.DEFBLOCKSIZE + 1 - 1, sMsg.Length - Grobal2.DEFBLOCKSIZE - 6);
            }
            DefMsg = EncryptUnit.DecodeMessage(sDefMsg);
            DBShare.g_nWorkStatus = DefMsg.Ident;
            switch (DefMsg.Ident)
            {
            case Common.DB_LOADHUMANRCD:
                LoadHumanRcd(sData);
                break;

            case Common.DB_SAVEHUMANRCD:
                SaveHumanRcd(DefMsg.Recog, sData);
                break;

            case Common.DB_LOADHERORCD:
                // DB_SAVEHUMANRCDEX: begin
                // SaveHumanRcdEx(sData, DefMsg.Recog, Socket);
                // end;
                // 读取英雄数据
                LoadHeroRcd(sData);
                break;

            case Common.DB_NEWHERORCD:
                // 新建英雄
                NewHeroRcd(sData);
                break;

            case Common.DB_DELHERORCD:
                // 删除英雄
                DeleteHeroRcd(sData);
                break;

            case Common.DB_SAVEHERORCD:
                // 保存英雄数据
                SaveHeroRcd(DefMsg.Recog, sData);
                break;

            case Common.DB_LOADRANKING:
                // 排行榜
                LoadRanking(sData, DefMsg);
                break;

            case Common.DB_SAVEMAGICLIST:
                SaveMagicList(DefMsg.Recog, sData);
                break;

            case Common.DB_SAVESTDITEMLIST:
                SaveStdItemList(DefMsg.Recog, sData);
                break;

            case Common.DB_CLOSESOCKET:
                break;

            case Common.DB_SENDKEEPALIVE:
                break;

            default:
                m_DefMsg = EncryptUnit.MakeDefaultMsg(Common.DBR_FAIL, 0, 0, 0, 0, 0);
                SendSocket(EncryptUnit.EncodeMessage(m_DefMsg));
                break;
            }
        }