public void DeleteHuman(int nGateIndex, int nSocket) { TLoadDBInfo LoadRcdInfo = null; HUtil32.EnterCriticalSection(m_UserCriticalSection); try { for (int I = m_LoadRcdList.Count - 1; I >= 0; I--) { if (m_LoadRcdList.Count <= 0) { break; } LoadRcdInfo = m_LoadRcdList[I]; if ((LoadRcdInfo.nGateIdx == nGateIndex) && (LoadRcdInfo.nSocket == nSocket)) { m_LoadRcdList.RemoveAt(I); Dispose(LoadRcdInfo); break; } } } finally { HUtil32.LeaveCriticalSection(m_UserCriticalSection); } }
/// <summary> /// 添加到加载角色队列里面 /// </summary> /// <param name="sAccount"></param> /// <param name="sChrName"></param> /// <param name="sIPaddr"></param> /// <param name="boFlag"></param> /// <param name="nSessionID"></param> /// <param name="nPayMent"></param> /// <param name="nPayMode"></param> /// <param name="nSoftVersionDate"></param> /// <param name="nSocket"></param> /// <param name="nGSocketIdx"></param> /// <param name="nGateIdx"></param> public void AddToLoadRcdList(string sAccount, string sChrName, string sIPaddr, bool boFlag, int nSessionID, int nPayMent, int nPayMode, int nSoftVersionDate, int nSocket, int nGSocketIdx, int nGateIdx) { TLoadDBInfo LoadRcdInfo = new TLoadDBInfo(); LoadRcdInfo.sAccount = sAccount; LoadRcdInfo.sCharName = sChrName; LoadRcdInfo.sIPaddr = sIPaddr; LoadRcdInfo.boClinetFlag = boFlag; LoadRcdInfo.nSessionID = nSessionID; LoadRcdInfo.nSoftVersionDate = nSoftVersionDate; LoadRcdInfo.nPayMent = nPayMent; LoadRcdInfo.nPayMode = nPayMode; LoadRcdInfo.nSocket = nSocket; LoadRcdInfo.nGSocketIdx = nGSocketIdx; LoadRcdInfo.nGateIdx = nGateIdx; LoadRcdInfo.dwNewUserTick = HUtil32.GetTickCount(); LoadRcdInfo.PlayObject = null; LoadRcdInfo.nReLoadCount = 0; LoadRcdInfo.boIsHero = false; HUtil32.EnterCriticalSection(m_UserCriticalSection); try { m_LoadRcdList.Add(LoadRcdInfo); } finally { HUtil32.LeaveCriticalSection(m_UserCriticalSection); } }
/// <summary> /// btLoadType 0-召唤 1-新建 2-删除 3-查询数据 4-召唤副将英雄 5-新建副将英雄 6-删除副将英雄 /// </summary> /// <param name="sCharName"></param> /// <param name="sMsg"></param> /// <param name="PlayObject"></param> /// <param name="btLoadType"></param> public void AddToLoadHeroRcdList(string sCharName, string sMsg, TPlayObject PlayObject, byte btLoadType) { TLoadDBInfo LoadRcdInfo = new TLoadDBInfo(); PlayObject.m_boWaitHeroDate = true; LoadRcdInfo.sAccount = PlayObject.m_sUserID; LoadRcdInfo.sCharName = sCharName; LoadRcdInfo.sIPaddr = PlayObject.m_sIPaddr; LoadRcdInfo.boClinetFlag = PlayObject.m_boClientFlag; LoadRcdInfo.nSessionID = PlayObject.m_nSessionID; LoadRcdInfo.nSoftVersionDate = PlayObject.m_nSoftVersionDate; LoadRcdInfo.nPayMent = PlayObject.m_nPayMent; LoadRcdInfo.nPayMode = PlayObject.m_nPayMode; LoadRcdInfo.nSocket = PlayObject.m_nSocket; LoadRcdInfo.nGSocketIdx = PlayObject.m_nGSocketIdx; LoadRcdInfo.nGateIdx = PlayObject.m_nGateIdx; LoadRcdInfo.dwNewUserTick = HUtil32.GetTickCount(); LoadRcdInfo.PlayObject = PlayObject; LoadRcdInfo.nReLoadCount = 0; LoadRcdInfo.boIsHero = true; LoadRcdInfo.btLoadDBType = btLoadType; LoadRcdInfo.sMsg = sMsg; LoadRcdInfo.btJob = PlayObject.m_btDeputyHeroJob; HUtil32.EnterCriticalSection(m_UserCriticalSection); try { m_LoadRcdList.Add(LoadRcdInfo); } finally { HUtil32.LeaveCriticalSection(m_UserCriticalSection); } }
/// <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); }