// 加入函数名 以方便查错 public static bool MakeHumRcdFromLocal(ref THumDataInfo HumanRcd) { bool result; HumanRcd = new THumDataInfo(); HumanRcd.Data.Abil.Level = 30; result = true; return(result); }
private unsafe bool ChangeUserGoldInDB(TGoldChangeInfo GoldChangeInfo) { bool result = false; THumDataInfo HumanRcd = new THumDataInfo(); byte nCode = 0; try { if (GoldChangeInfo != null) { nCode = 4; if (RunDB.LoadHumRcdFromDB("1", GoldChangeInfo.sGetGoldUser, "1", &HumanRcd, 1)) { nCode = 1; if (((HumanRcd.Data.nGold + GoldChangeInfo.nGold) > 0) && ((HumanRcd.Data.nGold + GoldChangeInfo.nGold) < 2000000000)) { HumanRcd.Data.nGold += GoldChangeInfo.nGold; nCode = 2; if (RunDB.SaveHumRcdToDB(new TSaveRcd() { sAccount = "1", sChrName = GoldChangeInfo.sGetGoldUser, nSessionID = 1, boIsHero = false, boisDoubleHero = false, btJob = 0, HumanRcd = HumanRcd })) { nCode = 3; UserEngine.sub_4AE514(GoldChangeInfo); result = true; } } } } } catch { M2Share.MainOutMessage("{异常} TFrontEngine.ChangeUserGoldInDB Code:" + nCode); } return(result); }
static unsafe void socket_ReceivedDatagram(object sender, NetFramework.DSCClientDataInEventArgs e) { var HumanRcd = new THumDataInfo(); int a = 0, b = 0; string c = string.Empty; GetDBSockMsg(e.Data, 0, ref a, ref b, ref c, 0, true, ""); string sDBMsg = string.Empty; c = HUtil32.GetValidStr3(c, ref sDBMsg, new string[] { "/" }); int DataSize = Marshal.SizeOf(HumanRcd); MyTestInfo testinfo = new MyTestInfo(); EncryptUnit.DecodeBuffer(c, ref HumanRcd); //TUserItem* bbbbbbbb= (TUserItem*)testinfo.UserItem; }
static unsafe void socket_ReceivedDatagram(object sender, NetFramework.DSCClientDataInEventArgs e) { var HumanRcd = new THumDataInfo(); int a = 0, b = 0; string c = string.Empty; GetDBSockMsg(e.Data, 0, ref a, ref b, ref c, 0, true, ""); string sDBMsg = string.Empty; c = HUtil32.GetValidStr3(c, ref sDBMsg, new string[] { "/" }); int DataSize = Marshal.SizeOf(HumanRcd); if (HUtil32.GetCodeMsgSize(DataSize * 4 / 3) == c.Length) { EncryptUnit.DecodeBuffer <THumDataInfo>(c, ref HumanRcd); } //if (HumanRcd.Data.BagItems[0] != null) //{ // TUserItem hun = new TUserItem(); // int HumSize = Marshal.SizeOf(hun); //} }
public bool Add(THumInfo objHumInfo, THumDataInfo objHumDataInfo) { string sGuid = HUtil32.GetGuid(); string sAccount = objHumInfo.sAccount; string sChrName = objHumInfo.sChrName; int boIsHero = objHumInfo.boIsHero ? 1 : 0; int boSelected = objHumInfo.boSelected ? 1 : 0; int nSelectID = objHumInfo.Header.nSelectID; int boDeleted = objHumInfo.boDeleted?1:0; DateTime dCreateDate = DateTime.FromOADate(objHumInfo.dCreateDate); DateTime dModDate = objHumInfo.dModDate; int btCount = objHumInfo.btCount; DataSet dsCustom = new DataSet(); IDataParameter[] SqlParams = new IDataParameter[] { new System.Data.SqlClient.SqlParameter("@sGuid", sGuid), new System.Data.SqlClient.SqlParameter("@sAccount", sAccount), new System.Data.SqlClient.SqlParameter("@sChrName", sChrName), new System.Data.SqlClient.SqlParameter("@boIsHero", boIsHero), new System.Data.SqlClient.SqlParameter("@boSelected", boSelected), new System.Data.SqlClient.SqlParameter("@nSelectID", nSelectID), new System.Data.SqlClient.SqlParameter("@boDeleted", boDeleted), new System.Data.SqlClient.SqlParameter("@dCreateDate", dCreateDate), new System.Data.SqlClient.SqlParameter("@dModDate", dModDate), new System.Data.SqlClient.SqlParameter("@btCount", btCount), }; if (!(dbClient.ExecuteProcedure("CreateHumInfo", SqlParams, ref dsCustom) > 0)) { return(false); } if (!(dbClient.ExecuteSql(string.Format("INSERT INTO HumDataInfo(Guid,btSex,btJob,btHair) VALUES('{0}',{1},{2},{3})", sGuid, objHumDataInfo.Data.btSex, objHumDataInfo.Data.btJob, objHumDataInfo.Data.btHair )) > 0)) { return(false); } return(true); }
/// <summary> /// 取玩家数据 /// </summary> /// <param name="LoadUser"></param> /// <param name="boReTry"></param> /// <returns></returns> private unsafe bool LoadHumFromDB(TLoadDBInfo LoadUser, ref bool boReTry) { bool result = false; THumDataInfo HumanRcd; TUserOpenInfo UserOpenInfo; int nOpenStatus; boReTry = false; if ((!LoadUser.boIsHero) || ((LoadUser.boIsHero) && (LoadUser.btLoadDBType == 0))) { if (InSaveRcdList(LoadUser.sAccount, LoadUser.sCharName)) { boReTry = true;// 反回TRUE,则重新加入队列 return(result); } } if (!LoadUser.boIsHero) { if ((UserEngine.GetPlayObjectEx(LoadUser.sAccount, LoadUser.sCharName) != null)) { UserEngine.KickPlayObjectEx(LoadUser.sAccount, LoadUser.sCharName); boReTry = true;// 反回TRUE,则重新加入队列 return(result); } } if (!LoadUser.boIsHero) { HumanRcd = new THumDataInfo(); if (!RunDB.LoadHumRcdFromDB(LoadUser.sAccount, LoadUser.sCharName, LoadUser.sIPaddr, &HumanRcd, LoadUser.nSessionID)) { M2Share.RunSocket.SendOutConnectMsg(LoadUser.nGateIdx, LoadUser.nSocket, LoadUser.nGSocketIdx); // 强迫用户下线 } else { UserOpenInfo = new TUserOpenInfo(); UserOpenInfo.sAccount = LoadUser.sAccount; UserOpenInfo.sChrName = LoadUser.sCharName; UserOpenInfo.LoadUser = LoadUser; UserOpenInfo.HumanRcd = HumanRcd; UserEngine.AddUserOpenInfo(UserOpenInfo); result = true; } } else { nOpenStatus = -1; HumanRcd = new THumDataInfo(); switch (LoadUser.btLoadDBType) { case 0: if (RunDB.LoadHeroRcdFromDB(LoadUser.sAccount, LoadUser.sCharName, LoadUser.sIPaddr, &HumanRcd, LoadUser.nSessionID)) { nOpenStatus = 1; } break; case 1: nOpenStatus = RunDB.NewHeroRcd(LoadUser.sCharName, LoadUser.sMsg); break; case 2: if (RunDB.DelHeroRcd(LoadUser.sAccount, LoadUser.sCharName, LoadUser.sIPaddr, LoadUser.nSessionID)) { nOpenStatus = 1; } break; case 3: LoadUser.sMsg = RunDB.QueryHeroRcdFromDB(LoadUser.sAccount, LoadUser.sCharName, LoadUser.sIPaddr, LoadUser.sMsg, LoadUser.nSessionID); break; case 4: if (RunDB.LoadDoubleHeroRcdFromDB(LoadUser.sAccount, LoadUser.sCharName, LoadUser.sIPaddr, LoadUser.btJob, &HumanRcd, LoadUser.nSessionID)) { nOpenStatus = 1; } break; case 5: nOpenStatus = RunDB.AssessDoubleHeroRcd(LoadUser.sCharName, LoadUser.sMsg, 0); break; case 6: break; case 7: LoadUser.sMsg = RunDB.QueryHeroRcdFromDB(LoadUser.sAccount, LoadUser.sCharName, LoadUser.sIPaddr, LoadUser.sMsg, LoadUser.nSessionID); break; default: nOpenStatus = 0; break; } UserOpenInfo = new TUserOpenInfo(); UserOpenInfo.sAccount = LoadUser.sAccount; UserOpenInfo.sChrName = LoadUser.sCharName; UserOpenInfo.LoadUser = LoadUser; UserOpenInfo.HumanRcd = HumanRcd; UserOpenInfo.nOpenStatus = nOpenStatus; UserEngine.AddUserOpenInfo(UserOpenInfo); result = true; } return(result); }
public static bool LoadDoubleHeroRcd(string sAccount, string sCharName, string sStr, int nCertCode, byte btJob, ref THumDataInfo HumanRcd) { bool result = false; TDefaultMessage DefMsg; TLoadDoubleHero LoadDoubleHero = null; int nQueryID; int nIdent; int nRecog; string sHumanRcdStr; string sDBMsg; string sDBCharName; nQueryID = GetQueryID(M2Share.g_Config); //DefMsg = EDcode.Units.EDcode.MakeDefaultMsg(Common.DB_LOADDOUBLEHERORCD, 0, 0, 0, 0, 0); LoadDoubleHero.sAccount = sAccount; LoadDoubleHero.sChrName = sCharName; LoadDoubleHero.sUserAddr = sStr; LoadDoubleHero.btJob = btJob; LoadDoubleHero.nSessionID = nCertCode; //sDBMsg = EDcode.Units.EDcode.EncodeMessage(DefMsg) + EDcode.Units.EDcode.EncryptUnit.EncodeBuffer(LoadDoubleHero, sizeof(TLoadDoubleHero)); // 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_LOADDOUBLEHERORCD) // { // if (nRecog == 1) // { // sHumanRcdStr = HUtil32.GetValidStr3(sHumanRcdStr, ref sDBMsg, new string[] { "/" }); // sDBCharName = EDcode.Units.EDcode.DeCodeString(sDBMsg); // if (sDBCharName == sCharName) // { // if (HUtil32.GetCodeMsgSize(sizeof(THumDataInfo) * 4 / 3) == sHumanRcdStr.Length) // { // EDcode.Units.EDcode.DecodeBuffer(sHumanRcdStr, HumanRcd, sizeof(THumDataInfo)); // result = true; // } // } // else // { // result = false; // } // } // else // { // result = false; // } // } // else // { // result = false; // } //} //else //{ // result = false; //} return(result); }
public static bool SaveDoubleHeroRcd(string sAccount, string sCharName, int nSessionID, byte btJob, THumDataInfo HumanRcd) { bool result; int nQueryID = 0; int nIdent = 0; int nRecog = 0; string sStr = string.Empty; nQueryID = GetQueryID(M2Share.g_Config); result = false; //SendDBSockMsg(nQueryID, EDcode.Units.EDcode.EncodeMessage(EDcode.Units.EDcode.MakeDefaultMsg(Common.DB_SAVEDOUBLEHERORCD, nSessionID, 0, 0, 0, 0)) + EDcode.Units.EDcode.EncodeString(sAccount) + "/" + EDcode.Units.EDcode.EncodeString(sCharName) + "/" + EDcode.Units.EDcode.EncodeString((btJob).ToString()) + "/" + EDcode.Units.EDcode.EncryptUnit.EncodeBuffer(HumanRcd, sizeof(THumDataInfo))); //if (GetDBSockMsg(nQueryID, ref nIdent, ref nRecog, ref sStr, M2Share.g_Config.dwGetDBSockMsgTime, false, "SaveHeroRcd(" + sAccount + "/" + sCharName + ")")) //{ // if ((nIdent == Common.DB_SAVEDOUBLEHERORCD) && (nRecog == 1)) // { // result = true; // } //} return(result); }
/// <summary> /// 保存英雄数据 /// </summary> /// <param name="sAccount"></param> /// <param name="sCharName"></param> /// <param name="nSessionID"></param> /// <param name="HumanRcd"></param> /// <returns></returns> public unsafe static bool SaveHeroRcd(string sAccount, string sCharName, int nSessionID, THumDataInfo HumanRcd) { bool result = false; int nQueryID = 0; int nIdent = 0; int nRecog = 0; string sStr = string.Empty; nQueryID = GetQueryID(M2Share.g_Config); result = false; SendDBSockMsg(nQueryID, EncryptUnit.EncodeMessage(EncryptUnit.MakeDefaultMsg(Common.DB_SAVEHERORCD, 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, "SaveHeroRcd(" + sAccount + "/" + sCharName + ")")) { if ((nIdent == Common.DB_SAVEHERORCD) && (nRecog == 1)) { result = true; } } return(result); }