示例#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
        /// <summary>
        /// 加载英雄数据
        /// </summary>
        /// <param name="sAccount"></param>
        /// <param name="sCharName"></param>
        /// <param name="sStr"></param>
        /// <param name="nCertCode"></param>
        /// <param name="HumanRcd"></param>
        /// <returns></returns>
        public unsafe static bool LoadHeroRcd(string sAccount, string sCharName, string sStr, int nCertCode, THumDataInfo *HumanRcd)
        {
            bool            result;
            TDefaultMessage DefMsg;
            int             nQueryID     = 0;
            int             nIdent       = 0;
            int             nRecog       = 0;
            string          sHumanRcdStr = string.Empty;
            string          sDBMsg       = string.Empty;
            string          sDBCharName;

            nQueryID = GetQueryID(M2Share.g_Config);
            DefMsg   = EncryptUnit.MakeDefaultMsg(Common.DB_LOADHERORCD, 0, 0, 0, 0, 0);
            TLoadHuman LoadHuman = new TLoadHuman();

            LoadHuman.sAccount   = sAccount;
            LoadHuman.sChrName   = sCharName;
            LoadHuman.sUserAddr  = sStr;
            LoadHuman.nSessionID = nCertCode;
            byte[] data = HUtil32.StructToBytes(LoadHuman);
            sDBMsg = EncryptUnit.EncodeMessage(DefMsg) + EncryptUnit.EncodeBuffer(data, Marshal.SizeOf(LoadHuman));
            SendDBSockMsg(nQueryID, sDBMsg);
            if (GetDBSockMsg(nQueryID, ref nIdent, ref nRecog, ref sHumanRcdStr, M2Share.g_Config.dwGetDBSockMsgTime, true, "LoadHeroRcd(" + sAccount + "/" + sCharName + ")"))
            {
                result = false;
                if (nIdent == Common.DB_LOADHERORCD)
                {
                    if (nRecog == 1)
                    {
                        sHumanRcdStr = HUtil32.GetValidStr3(sHumanRcdStr, ref sDBMsg, new string[] { "/" });
                        sDBCharName  = EncryptUnit.DeCodeString(sDBMsg);
                        if (sDBCharName == sCharName)
                        {
                            if (HUtil32.GetCodeMsgSize(sizeof(THumDataInfo) * 4 / 3) == sHumanRcdStr.Length)
                            {
                                EncryptUnit.DecodeBuffer(sHumanRcdStr, HumanRcd, sizeof(THumDataInfo));
                                result = true;
                            }
                        }
                        else
                        {
                            result = false;
                        }
                    }
                    else
                    {
                        result = false;
                    }
                }
                else
                {
                    result = false;
                }
            }
            else
            {
                result = false;
            }
            return(result);
        }
示例#3
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);
        }
示例#4
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");
            }
        }