Exemple #1
0
        /// <summary>
        /// 保存人物数据
        /// </summary>
        /// <param name="sAccount"></param>
        /// <param name="sCharName"></param>
        /// <param name="nSessionID"></param>
        /// <param name="HumanRcd"></param>
        /// <returns></returns>
        public unsafe static bool SaveRcd(string sAccount, string sCharName, int nSessionID, THumDataInfo HumanRcd)
        {
            bool   result   = false;
            int    nQueryID = GetQueryID(M2Share.g_Config);
            int    nIdent   = 0;
            int    nRecog   = 0;
            string sStr     = string.Empty;

            SendDBSockMsg(nQueryID, EncryptUnit.EncodeMessage(EncryptUnit.MakeDefaultMsg(Common.DB_SAVEHUMANRCD, nSessionID, 0, 0, 0, 0)) + EncryptUnit.EncodeString(sAccount) + "/"
                          + EncryptUnit.EncodeString(sCharName) + "/" + EncryptUnit.EncodeBuffer(&HumanRcd, sizeof(THumDataInfo)));
            if (GetDBSockMsg(nQueryID, ref nIdent, ref nRecog, ref sStr, M2Share.g_Config.dwGetDBSockMsgTime, false, "SaveRcd(" + sAccount + "/" + sCharName + ")"))
            {
                if ((nIdent == Common.DBR_SAVEHUMANRCD) && (nRecog == 1))
                {
                    result = true;
                }
            }
            return(result);
        }
Exemple #2
0
        /// <summary>
        /// 新建英雄数据
        /// </summary>
        /// <param name="sChrName"></param>
        /// <param name="sMsg"></param>
        /// <returns></returns>
        public static int NewHeroRcd(string sChrName, string sMsg)
        {
            int             result = 0;
            TDefaultMessage DefMsg;
            int             nQueryID;
            int             nIdent       = 0;
            int             nRecog       = 0;
            string          sHumanRcdStr = string.Empty;
            string          sDBMsg;
            string          sDBCharName;

            nQueryID = GetQueryID(M2Share.g_Config);
            DefMsg   = EncryptUnit.MakeDefaultMsg(Common.DB_NEWHERORCD, 0, 0, 0, 0, 0);
            sDBMsg   = EncryptUnit.EncodeMessage(DefMsg) + EncryptUnit.EncodeString(sMsg);
            SendDBSockMsg(nQueryID, sDBMsg);
            if (GetDBSockMsg(nQueryID, ref nIdent, ref nRecog, ref sHumanRcdStr, M2Share.g_Config.dwGetDBSockMsgTime, true, "NewHeroRcd(" + sChrName + ")"))
            {
                result = -1;
                if (nIdent == Common.DB_NEWHERORCD)
                {
                    sDBCharName = EncryptUnit.DeCodeString(sHumanRcdStr);
                    if (sDBCharName == sChrName)
                    {
                        result = nRecog;
                    }
                    else
                    {
                        result = -1;
                    }
                }
                else
                {
                    result = -1;
                }
            }
            else
            {
                result = -1;
            }
            return(result);
        }
Exemple #3
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));
            }
        }