Beispiel #1
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");
            }
        }