public unsafe static bool LoadDoubleHeroRcdFromDB(string sAccount, string sCharName, string sStr, byte btJob, THumDataInfo *HumanRcd, int nCertCode) { bool result; result = false; //FillChar(HumanRcd, sizeof(THumDataInfo), '\0'); //if (LoadDoubleHeroRcd(sAccount, sCharName, sStr, nCertCode, btJob, ref HumanRcd)) //{ // if ((HumanRcd.Data.sChrName == sCharName) && ((HumanRcd.Data.sAccount == "") || (HumanRcd.Data.sAccount == sAccount))) // { // result = true; // } //} M2Share.g_Config.nLoadDBCount++; return(result); }
/// <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); }
/// <summary> /// 从DB库中读出英雄数据 /// </summary> /// <param name="sAccount"></param> /// <param name="sCharName"></param> /// <param name="sStr"></param> /// <param name="HumanRcd"></param> /// <param name="nCertCode"></param> /// <returns></returns> public unsafe static bool LoadHeroRcdFromDB(string sAccount, string sCharName, string sStr, THumDataInfo *HumanRcd, int nCertCode) { bool result = false; if (LoadHeroRcd(sAccount, sCharName, sStr, nCertCode, HumanRcd)) { string sName = HUtil32.SBytePtrToString(HumanRcd->Data.sChrName, 0, HumanRcd->Data.ChrNameLen); string sDataAccount = HUtil32.SBytePtrToString(HumanRcd->Data.sAccount, 0, HumanRcd->Data.AccountLen); if (string.Compare(sName, sCharName, true) == 0 && sDataAccount == "" || sDataAccount == sAccount) { result = true; } } M2Share.g_Config.nLoadDBCount++; return(result); }