public override bool Operate(TProcessMessage ProcessMsg) { bool result = false; try { result = false; if ((ProcessMsg.wIdent == Grobal2.RM_STRUCK) || (ProcessMsg.wIdent == Grobal2.RM_MAGSTRUCK)) { if ((TTrainer)HUtil32.IntToObject <TTrainer>(ProcessMsg.BaseObject) == this) { n56C += ProcessMsg.wParam; m_dw568 = HUtil32.GetTickCount(); n570++; this.ProcessSayMsg("破坏力为 " + ProcessMsg.wParam + ",平均值为 " + (n56C / n570).ToString()); } } if (ProcessMsg.wIdent == Grobal2.RM_MAGSTRUCK) { result = base.Operate(ProcessMsg); } } catch { M2Share.MainOutMessage("{异常} TTrainer.Operate"); } return(result); }
/// <summary> /// 攻击怪物会执行此方法 /// </summary> /// <param name="ProcessMsg"></param> /// <returns></returns> public override bool Operate(TProcessMessage ProcessMsg) { bool result = false; byte nCode = 0; try { if (ProcessMsg.wIdent == Grobal2.RM_STRUCK) // 打击 { nCode = 1; TBaseObject BaseObject = HUtil32.IntToObject <TBaseObject>(ProcessMsg.nParam3); if ((HUtil32.IntToObject <TBaseObject>(ProcessMsg.BaseObject) == this) && (BaseObject != null)) { nCode = 2; this.SetLastHiter(BaseObject); nCode = 3; this.Struck(BaseObject); nCode = 4; this.BreakHolySeizeMode(); nCode = 10; if ((this.m_Master != null) && (!BaseObject.m_boDeath)) { nCode = 9; if (((BaseObject != this.m_Master) && (((BaseObject.m_btRaceServer == Grobal2.RC_PLAYOBJECT) || ((BaseObject.m_btRaceServer == Grobal2.RC_HEROOBJECT)))))) { nCode = 6; if (this.m_Master.m_Master != null) { nCode = 7; if (this.m_Master.m_Master != BaseObject) { this.m_Master.SetPKFlag(BaseObject); } } else { this.m_Master.SetPKFlag(BaseObject); } } } nCode = 8; if (GameConfig.boMonSayMsg) { this.MonsterSayMsg(BaseObject, TMonStatus.s_UnderFire); } } result = true; } else { result = base.Operate(ProcessMsg); } } catch { M2Share.MainOutMessage("{异常} TAnimalObject.Operate Code:" + nCode); } return(result); }
/// <summary> /// 处理游戏数据 /// </summary> private void ProcessGameDate() { IList <TLoadDBInfo> TempList; IList <TGoldChangeInfo> ChangeGoldList; TLoadDBInfo LoadDBInfo; TSaveRcd SaveRcd; TGoldChangeInfo GoldChangeInfo; bool boReTryLoadDB = true; bool boSaveRcd; byte nCode = 0; const string sExceptionMsg = "{异常} TFrontEngine::ProcessGameDate Code:{0}"; const string sSaveExceptionMsg = "数据库服务器出现异常,请重新启动数据库服务器(DBServer.exe)!!!"; try { ChangeGoldList = null; nCode = 17; if (M2Share.g_nSaveRcdErrorCount >= 10) { nCode = 18; if (HUtil32.GetTickCount() - M2Share.g_dwShowSaveRcdErrorTick > 5000)//修改秒触发 { nCode = 19; M2Share.g_dwShowSaveRcdErrorTick = HUtil32.GetTickCount(); M2Share.MainOutMessage(sSaveExceptionMsg); } } HUtil32.EnterCriticalSection(m_UserCriticalSection); try { nCode = 20; if (m_SaveRcdList.Count > 0) { nCode = 21; for (int I = 0; I < m_SaveRcdList.Count; I++) { m_SaveRcdTempList.Add(m_SaveRcdList[I]); } } nCode = 1; TempList = m_LoadRcdTempList; nCode = 2; m_LoadRcdTempList = m_LoadRcdList; nCode = 3; m_LoadRcdList = TempList; nCode = 4; if (m_ChangeGoldList.Count > 0) { nCode = 22; ChangeGoldList = new List <TGoldChangeInfo>(); nCode = 23; for (int I = 0; I < m_ChangeGoldList.Count; I++) { if (m_ChangeGoldList[I] != null) { ChangeGoldList.Add(m_ChangeGoldList[I]); } } } } finally { HUtil32.LeaveCriticalSection(m_UserCriticalSection); } if (m_SaveRcdTempList.Count > 0) { for (int I = 0; I < m_SaveRcdTempList.Count; I++) { SaveRcd = m_SaveRcdTempList[I]; if ((!RunDB.DBSocketConnected()) || (M2Share.g_nSaveRcdErrorCount >= 10))// DBSERVER关闭 不保存 { if ((SaveRcd.PlayObject != 0) && (!SaveRcd.boIsHero)) { HUtil32.IntToObject <TPlayObject>(SaveRcd.PlayObject).m_boRcdSaved = true; } HUtil32.EnterCriticalSection(m_UserCriticalSection); try { for (int II = m_SaveRcdList.Count - 1; II >= 0; II--) { if (m_SaveRcdList.Count <= 0) { break; } if (m_SaveRcdList[II] == SaveRcd) { m_SaveRcdList.RemoveAt(II); nCode = 5; SaveRcd = null; nCode = 6; break; } } } finally { HUtil32.LeaveCriticalSection(m_UserCriticalSection); } } else { boSaveRcd = false; if (SaveRcd.nReTryCount == 0) { boSaveRcd = true; } else if ((SaveRcd.nReTryCount < 50) && (HUtil32.GetTickCount() - SaveRcd.dwSaveTick > 5000))// 保存错误等待5秒后在保存 { boSaveRcd = true; } else if (SaveRcd.nReTryCount >= 50) // 失败50次后不在保存 { if ((SaveRcd.PlayObject != 0) && (!SaveRcd.boIsHero)) { HUtil32.IntToObject <TPlayObject>(SaveRcd.PlayObject).m_boRcdSaved = true; } HUtil32.EnterCriticalSection(m_UserCriticalSection); try { for (int II = m_SaveRcdList.Count - 1; II >= 0; II--) { if (m_SaveRcdList.Count <= 0) { break; } if (m_SaveRcdList[II] == SaveRcd) { m_SaveRcdList.RemoveAt(II); nCode = 7; SaveRcd = null; nCode = 8; break; } } } finally { HUtil32.LeaveCriticalSection(m_UserCriticalSection); } } if (boSaveRcd)// 保存人物 英雄 双英雄数据 { if (RunDB.SaveHumRcdToDB(SaveRcd)) { if ((SaveRcd.PlayObject != 0) && (!SaveRcd.boIsHero)) { HUtil32.IntToObject <TPlayObject>(SaveRcd.PlayObject).m_boRcdSaved = true; } HUtil32.EnterCriticalSection(m_UserCriticalSection); try { for (int II = m_SaveRcdList.Count - 1; II >= 0; II--) { if (m_SaveRcdList.Count <= 0) { break; } if (m_SaveRcdList[II] == SaveRcd) { m_SaveRcdList.RemoveAt(II); nCode = 9; SaveRcd = null; nCode = 10; break; } } } finally { HUtil32.LeaveCriticalSection(m_UserCriticalSection); } } else { SaveRcd.nReTryCount++;// 保存失败 SaveRcd.dwSaveTick = HUtil32.GetTickCount(); } } } } m_SaveRcdTempList.Clear(); nCode = 11; } if (m_LoadRcdTempList.Count > 0) { nCode = 17; for (int I = 0; I < m_LoadRcdTempList.Count; I++) { nCode = 18; LoadDBInfo = m_LoadRcdTempList[I]; nCode = 19; if ((!LoadHumFromDB(LoadDBInfo, ref boReTryLoadDB)) && (!LoadDBInfo.boIsHero))// 加载人物 英雄 双英雄数据 { M2Share.RunSocket.CloseUser(LoadDBInfo.nGateIdx, LoadDBInfo.nSocket); } if (!boReTryLoadDB) { Dispose(LoadDBInfo); LoadDBInfo = null; } else { // 如果读取人物数据失败(数据还没有保存),则重新加入队列 HUtil32.EnterCriticalSection(m_UserCriticalSection); try { m_LoadRcdList.Add(LoadDBInfo); } finally { HUtil32.LeaveCriticalSection(m_UserCriticalSection); } } } } m_LoadRcdTempList.Clear(); nCode = 12; if (ChangeGoldList != null) { nCode = 121; try { if (ChangeGoldList.Count > 0) { nCode = 122; for (int I = 0; I < ChangeGoldList.Count; I++) { nCode = 123; GoldChangeInfo = ChangeGoldList[I]; nCode = 125; if (GoldChangeInfo != null) { nCode = 126; ChangeUserGoldInDB(GoldChangeInfo); nCode = 13; Dispose(GoldChangeInfo); nCode = 14; } } } } finally { nCode = 15; Dispose(ChangeGoldList); ChangeGoldList = null; } } } catch { M2Share.MainOutMessage(string.Format(sExceptionMsg, nCode)); } }
/// <summary> /// Int32转对象 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="src"></param> /// <returns></returns> public static T ToObject <T>(this int src) { return(HUtil32.IntToObject <T>(src)); }
/// <summary> /// 根据HashCode取对象 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="HaseCode"></param> /// <returns></returns> public virtual T GetObject <T>(int HaseCode) { return(HUtil32.IntToObject <T>(HaseCode)); }