public TCPProcessCmdResults transmission(TMSKSocket socket, int nID, byte[] data, int count) { try { string cmdData = new UTF8Encoding().GetString(data, 0, count); } catch (Exception) { LogManager.WriteLog(LogTypes.Error, string.Format("解析指令字符串错误, CMD={0}, Client={1}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket, false)), null, true); return(TCPProcessCmdResults.RESULT_FAILED); } try { byte[] bytesData = Global.SendAndRecvData <byte[]>(nID, data, socket.ServerId, 0); if (null == bytesData) { LogManager.WriteLog(LogTypes.Error, string.Format("与DBServer通讯失败, CMD={0}", (TCPGameServerCmds)nID), null, true); return(TCPProcessCmdResults.RESULT_FAILED); } int length = BitConverter.ToInt32(bytesData, 0); ushort cmd = BitConverter.ToUInt16(bytesData, 4); TCPOutPacket tcpOutPacket = TCPOutPacketPool.getInstance().Pop(); tcpOutPacket.PacketCmdID = cmd; tcpOutPacket.FinalWriteData(bytesData, 6, length - 2); TCPManager.getInstance().MySocketListener.SendData(socket, tcpOutPacket, true); return(TCPProcessCmdResults.RESULT_OK); } catch (Exception ex) { DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(socket), false, false); } return(TCPProcessCmdResults.RESULT_FAILED); }
public TCPProcessCmdResults AttchFun(TCPManager tcpMgr, TMSKSocket socket, TCPClientPool tcpClientPool, TCPRandKey tcpRandKey, TCPOutPacketPool pool, int nID, byte[] data, int count, out TCPOutPacket tcpOutPacket) { TCPProcessCmdResults result = TCPProcessCmdResults.RESULT_FAILED; tcpOutPacket = null; try { if (m_FunInsinuate.ContainsKey(nID)) { result = m_FunInsinuate[nID](tcpMgr, socket, tcpClientPool, tcpRandKey, pool, nID, data, count, out tcpOutPacket); } else { SysConOut.WriteLine("收到APP数据,但没找到隐射函数"); } GameClient client = GameManager.ClientMgr.FindClient(socket); if (null != client) { client.ClientData.LastClientHeartTicks = TimeUtil.NOW(); } } catch (Exception ex) { SysConOut.WriteLine("AttchFun****************" + ex.ToString()); } return(result); }
public void SendMarryPartyList(GameClient client, MarryPartyData partyData, int roleID = -1) { if (partyData != null || roleID > 0) { if (partyData == null) { partyData = this.m_MarryPartyDataCache.GetParty(roleID); if (partyData == null) { int SpouseID = MarryLogic.GetSpouseID(roleID); partyData = this.m_MarryPartyDataCache.GetParty(SpouseID); if (partyData == null) { partyData = new MarryPartyData(); } } } client.sendCmd <Dictionary <int, MarryPartyData> >(880, new Dictionary <int, MarryPartyData> { { roleID, partyData } }, false); } else { client.sendCmd(this.m_MarryPartyDataCache.GetPartyList(TCPOutPacketPool.getInstance(), 880), true); } }
public static void ProcessAllBiaoCheItems(SocketListener sl, TCPOutPacketPool pool) { List <BiaoCheItem> biaoCheItemList = new List <BiaoCheItem>(); lock (BiaoCheManager._ID2BiaoCheDict) { foreach (BiaoCheItem val in BiaoCheManager._ID2BiaoCheDict.Values) { biaoCheItemList.Add(val); } } long nowTicks = TimeUtil.NOW(); for (int i = 0; i < biaoCheItemList.Count; i++) { BiaoCheItem biaoCheItem = biaoCheItemList[i]; if (!BiaoCheManager.ProcessBiaoCheOverTime(sl, pool, nowTicks, biaoCheItem)) { if (!BiaoCheManager.ProcessBiaoCheDead(sl, pool, nowTicks, biaoCheItem)) { BiaoCheManager.ProcessBiaoCheAddLife(sl, pool, nowTicks, biaoCheItem); } } } }
public static void NotifyOthersHideBiaoChe(SocketListener sl, TCPOutPacketPool pool, BiaoCheItem biaoCheItem) { if (null != biaoCheItem) { GameManager.MapGridMgr.DictGrids[biaoCheItem.MapCode].RemoveObject(biaoCheItem); } }
public static void NotifyOthersShowBiaoChe(SocketListener sl, TCPOutPacketPool pool, BiaoCheItem biaoCheItem) { if (null != biaoCheItem) { GameManager.MapGridMgr.DictGrids[biaoCheItem.MapCode].MoveObject(-1, -1, biaoCheItem.PosX, biaoCheItem.PosY, biaoCheItem); } }
/// <summary> /// 获取领地信息字典项的发送tcp对象 /// </summary> public TCPOutPacket GetBangHuiLingDiItemsDictTCPOutPacket(TCPOutPacketPool pool, int cmdID) { Dictionary <int, BangHuiLingDiItemData> bangHuiLingDiItemDataDict = new Dictionary <int, BangHuiLingDiItemData>(); BangHuiLingDiInfoData bangHuiLingDiInfoData = null; lock (_BangHuiLingDiItemsDict) { foreach (var key in _BangHuiLingDiItemsDict.Keys) { bangHuiLingDiInfoData = _BangHuiLingDiItemsDict[key]; bangHuiLingDiItemDataDict[key] = new BangHuiLingDiItemData() { LingDiID = bangHuiLingDiInfoData.LingDiID, BHID = bangHuiLingDiInfoData.BHID, ZoneID = bangHuiLingDiInfoData.ZoneID, BHName = bangHuiLingDiInfoData.BHName, LingDiTax = bangHuiLingDiInfoData.LingDiTax, WarRequest = bangHuiLingDiInfoData.WarRequest, AwardFetchDay = bangHuiLingDiInfoData.AwardFetchDay, }; } } TCPOutPacket tcpOutPacket = DataHelper.ObjectToTCPOutPacket <Dictionary <int, BangHuiLingDiItemData> >(bangHuiLingDiItemDataDict, pool, cmdID); return(tcpOutPacket); }
public TCPOutPacket GetPartyList(TCPOutPacketPool pool, int cmdID) { lock (MarryPartyList) { return(DataHelper.ObjectToTCPOutPacket <Dictionary <int, MarryPartyData> >(MarryPartyList, pool, cmdID)); } }
public TCPOutPacket GetBangHuiLingDiInfosDictTCPOutPacket(TCPOutPacketPool pool, int bhid, int cmdID) { Dictionary <int, BangHuiLingDiInfoData> bangHuiLingDiInfoDataDict = new Dictionary <int, BangHuiLingDiInfoData>(); lock (this._BangHuiLingDiItemsDict) { foreach (int key in this._BangHuiLingDiItemsDict.Keys) { BangHuiLingDiInfoData bangHuiLingDiInfoData = this._BangHuiLingDiItemsDict[key]; if (bhid == bangHuiLingDiInfoData.BHID) { bangHuiLingDiInfoDataDict[key] = new BangHuiLingDiInfoData { LingDiID = bangHuiLingDiInfoData.LingDiID, BHID = bangHuiLingDiInfoData.BHID, ZoneID = bangHuiLingDiInfoData.ZoneID, BHName = bangHuiLingDiInfoData.BHName, LingDiTax = bangHuiLingDiInfoData.LingDiTax, TakeDayID = bangHuiLingDiInfoData.TakeDayID, TakeDayNum = bangHuiLingDiInfoData.TakeDayNum, YestodayTax = bangHuiLingDiInfoData.YestodayTax, TaxDayID = bangHuiLingDiInfoData.TaxDayID, TodayTax = bangHuiLingDiInfoData.TodayTax, TotalTax = bangHuiLingDiInfoData.TotalTax }; } } } return(DataHelper.ObjectToTCPOutPacket <Dictionary <int, BangHuiLingDiInfoData> >(bangHuiLingDiInfoDataDict, pool, cmdID)); }
public static TCPOutPacket ProcessGetWaBaoGoodsData(GameClient client, TCPOutPacketPool pool, int cmd) { TCPOutPacket result; if (null == client.ClientData.WaBaoGoodsData) { string strcmd = string.Format("{0}:{1}", -1, client.ClientData.RoleID); result = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, cmd); } else if (!Global.CanAddGoods(client, client.ClientData.WaBaoGoodsData.GoodsID, client.ClientData.WaBaoGoodsData.GCount, client.ClientData.WaBaoGoodsData.Binding, client.ClientData.WaBaoGoodsData.Endtime, true, false)) { string strcmd = string.Format("{0}:{1}", -10, client.ClientData.RoleID); result = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, cmd); } else { int dbRet = Global.AddGoodsDBCommand(pool, client, client.ClientData.WaBaoGoodsData.GoodsID, client.ClientData.WaBaoGoodsData.GCount, client.ClientData.WaBaoGoodsData.Quality, client.ClientData.WaBaoGoodsData.Props, client.ClientData.WaBaoGoodsData.Forge_level, client.ClientData.WaBaoGoodsData.Binding, client.ClientData.WaBaoGoodsData.Site, client.ClientData.WaBaoGoodsData.Jewellist, true, 1, "挖宝获取道具", "1900-01-01 12:00:00", client.ClientData.WaBaoGoodsData.AddPropIndex, client.ClientData.WaBaoGoodsData.BornIndex, client.ClientData.WaBaoGoodsData.Lucky, client.ClientData.WaBaoGoodsData.Strong, 0, 0, 0, null, null, 0, true); if (dbRet < 0) { string strcmd = string.Format("{0}:{1}", -10, client.ClientData.RoleID); result = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, cmd); } else { client.ClientData.WaBaoGoodsData = null; string strcmd = string.Format("{0}:{1}", 0, client.ClientData.RoleID); result = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, cmd); } } return(result); }
/// <summary> /// 获取副本列表数据 /// </summary> /// <returns></returns> public static TCPOutPacket GetFuBenHistListData(TCPOutPacketPool pool, int cmdID) { lock (_Mutex) { return(DataHelper.ObjectToTCPOutPacket <Dictionary <int, FuBenHistData> >(_FuBenHistDict, pool, cmdID)); } }
public static TCPCmdWrapper Get(TCPManager tcpMgr, TMSKSocket socket, TCPClientPool tcpClientPool, TCPRandKey tcpRandKey, TCPOutPacketPool pool, int nID, byte[] data, int count) { TCPCmdWrapper wrapper = null; lock (CachedWrapperList) { if (CachedWrapperList.Count > 0) { wrapper = CachedWrapperList.Dequeue(); wrapper.tcpMgr = tcpMgr; wrapper.socket = socket; wrapper.tcpClientPool = tcpClientPool; wrapper.tcpRandKey = tcpRandKey; wrapper.pool = pool; wrapper.nID = nID; wrapper.data = data; wrapper.count = count; } } if (null == wrapper) { wrapper = new TCPCmdWrapper(tcpMgr, socket, tcpClientPool, tcpRandKey, pool, nID, data, count); } return(wrapper); }
public void ExecuteDBCmd(TCPClientPool tcpClientPool, TCPOutPacketPool pool) { lock (this._DBCmdQueue) { if (this._DBCmdQueue.Count <= 0) { return; } } List <DBCommand> dbCmdList = new List <DBCommand>(); lock (this._DBCmdQueue) { while (this._DBCmdQueue.Count > 0) { dbCmdList.Add(this._DBCmdQueue.Dequeue()); } } byte[] bytesData = null; for (int i = 0; i < dbCmdList.Count; i++) { TCPProcessCmdResults result = this.DoDBCmd(tcpClientPool, pool, dbCmdList[i], out bytesData); if (result == TCPProcessCmdResults.RESULT_FAILED) { LogManager.WriteLog(LogTypes.Error, string.Format("向LogDBServer请求执行命令失败, CMD={0}", (TCPGameServerCmds)dbCmdList[i].DBCommandID), null, true); } this._DBCmdPool.Push(dbCmdList[i]); } }
/// <summary> /// 删除自己哪儿的假人 /// </summary> /// <param name="client"></param> public static void DelMySelfFakeRoleItems(SocketListener sl, TCPOutPacketPool pool, GameClient client, List <Object> objsList) { if (null == objsList) { return; } FakeRoleItem fakeRoleItem = null; for (int i = 0; i < objsList.Count; i++) { fakeRoleItem = objsList[i] as FakeRoleItem; if (null == fakeRoleItem) { continue; } if (!GameManager.TestGameShowFakeRoleForUser && fakeRoleItem.FakeRoleType != (int)FakeRoleTypes.DiaoXiang && fakeRoleItem.FakeRoleType != (int)FakeRoleTypes.DiaoXiang2 && fakeRoleItem.FakeRoleType != (int)FakeRoleTypes.DiaoXiang3) { continue; } GameManager.ClientMgr.NotifyMySelfDelFakeRole(sl, pool, client, fakeRoleItem.FakeRoleID); } }
public static TCPProcessCmdResults ProcTalentEffectClear(DBManager dbMgr, TCPOutPacketPool pool, int nID, byte[] data, int count, out TCPOutPacket tcpOutPacket) { tcpOutPacket = null; string[] fields = null; try { int length = 2; if (!CheckHelper.CheckTCPCmdFields(nID, data, count, out fields, length)) { tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, 1.ToString(), nID); return(TCPProcessCmdResults.RESULT_DATA); } int roleID = Convert.ToInt32(fields[0]); int zoneID = Convert.ToInt32(fields[1]); string strcmd = TalentManager.TalentEffectClear(dbMgr, roleID, zoneID); tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID); return(TCPProcessCmdResults.RESULT_DATA); } catch (Exception ex) { DataHelper.WriteFormatExceptionLog(ex, "", false, false); } tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, 1.ToString(), nID); return(TCPProcessCmdResults.RESULT_DATA); }
/// <summary> /// 处理已经假人的超时 /// </summary> /// <param name="client"></param> public static void ProcessAllFakeRoleItems(SocketListener sl, TCPOutPacketPool pool) { List <FakeRoleItem> FakeRoleItemList = new List <FakeRoleItem>(); lock (_ID2FakeRoleDict) { foreach (var val in _ID2FakeRoleDict.Values) { FakeRoleItemList.Add(val); } } long nowTicks = TimeUtil.NOW(); FakeRoleItem FakeRoleItem = null; for (int i = 0; i < FakeRoleItemList.Count; i++) { FakeRoleItem = FakeRoleItemList[i]; //处理假人的死亡 if (ProcessFakeRoleDead(sl, pool, nowTicks, FakeRoleItem)) { continue; } } }
/// <summary> /// 查询冲级达人信息 /// </summary> /// <param name="client"></param> /// <param name="pool"></param> /// <param name="nID"></param> /// <param name="tcpOutPacket"></param> /// <returns></returns> public static bool QueryLevelUpMadman(GameClient client, TCPOutPacketPool pool, int nID, out TCPOutPacket tcpOutPacket) { tcpOutPacket = null; try { KingActivity instActivity = (KingActivity)Global.GetActivity(ActivityTypes.NewZoneUpLevelMadman); NewZoneUpLevelData data = new NewZoneUpLevelData(); int count = instActivity.RoleLimit.Count; data.Items = new List <NewZoneUpLevelItemData>(); for (int i = 1; i < count + 1; i++) { NewZoneUpLevelItemData item = new NewZoneUpLevelItemData(); AwardItem awd = instActivity.GetAward(client, i); item.LeftNum = awd.MinAwardCondionValue2 - Global.GetChongJiLingQuShenZhuangQuota(client, i); item.GetAward = !Global.CanGetChongJiLingQuShenZhuang(client, i); data.Items.Add(item); } #region 注释掉的代码 //AwardItem awd = instActivity.GetAward(client, (int)GiftBtnIndex.BTN1); //item.LeftNum =awd.MinAwardCondionValue2 - Global.SafeConvertToInt32(GameManager.GameConfigMgr.GetGameConifgItem(GameConfigNames.ChongJiGift1)); //item.GetAward =! Global.CanGetChongJiLingQuShenZhuang(client, (int)GiftBtnIndex.BTN1); //data.Items.Add(item); //item = new NewZoneUpLevelItemData(); //awd = instActivity.GetAward(client, (int)GiftBtnIndex.BTN2); //item.LeftNum = awd.MinAwardCondionValue2 - Global.SafeConvertToInt32(GameManager.GameConfigMgr.GetGameConifgItem(GameConfigNames.ChongJiGift2)); //item.GetAward = !Global.CanGetChongJiLingQuShenZhuang(client, (int)GiftBtnIndex.BTN2); //data.Items.Add(item); //item = new NewZoneUpLevelItemData(); //awd = instActivity.GetAward(client, (int)GiftBtnIndex.BTN3); //item.LeftNum = awd.MinAwardCondionValue2 - Global.SafeConvertToInt32(GameManager.GameConfigMgr.GetGameConifgItem(GameConfigNames.ChongJiGift3)); //item.GetAward = !Global.CanGetChongJiLingQuShenZhuang(client, (int)GiftBtnIndex.BTN3); //data.Items.Add(item); //item = new NewZoneUpLevelItemData(); //awd = instActivity.GetAward(client, (int)GiftBtnIndex.BTN4); //item.LeftNum = awd.MinAwardCondionValue2 - Global.SafeConvertToInt32(GameManager.GameConfigMgr.GetGameConifgItem(GameConfigNames.ChongJiGift4)); //item.GetAward = !Global.CanGetChongJiLingQuShenZhuang(client, (int)GiftBtnIndex.BTN4); //data.Items.Add(item); //item = new NewZoneUpLevelItemData(); //awd = instActivity.GetAward(client, (int)GiftBtnIndex.BTN5); //item.LeftNum = awd.MinAwardCondionValue2 - Global.SafeConvertToInt32(GameManager.GameConfigMgr.GetGameConifgItem(GameConfigNames.ChongJiGift5)); //item.GetAward = !Global.CanGetChongJiLingQuShenZhuang(client, (int)GiftBtnIndex.BTN5); //data.Items.Add(item); #endregion tcpOutPacket = DataHelper.ObjectToTCPOutPacket <NewZoneUpLevelData>(data, pool, nID); return(true); } catch (Exception ex) { DataHelper.WriteFormatExceptionLog(ex, "LevelUpMadman", false); } return(false); }
public static void SendMySelfFakeRoleItems(SocketListener sl, TCPOutPacketPool pool, GameClient client, List <object> objsList, int totalRoleAndMonsterNum) { if (null != objsList) { for (int i = 0; i < objsList.Count; i++) { FakeRoleItem fakeRoleItem = objsList[i] as FakeRoleItem; if (null != fakeRoleItem) { if (GameManager.TestGameShowFakeRoleForUser || (fakeRoleItem.FakeRoleType != 1 && fakeRoleItem.FakeRoleType != 2)) { if (fakeRoleItem.CurrentLifeV > 0) { if (totalRoleAndMonsterNum >= 30) { if (fakeRoleItem.FakeRoleType == 2) { goto IL_A0; } } GameManager.ClientMgr.NotifyMySelfNewFakeRole(sl, pool, client, fakeRoleItem); } } } IL_A0 :; } } }
public void initialize(int capacity) { MaxConnectedClientLimit = capacity; socketListener = new SocketListener(capacity, (int)TCPCmdPacketSize.RECV_MAX_SIZE); socketListener.SocketClosed += SocketClosed; socketListener.SocketConnected += SocketConnected; socketListener.SocketReceived += SocketReceived; socketListener.SocketSended += SocketSended; _tcpClientPool = TCPClientPool.getInstance(); _tcpClientPool.initialize(100); _tcpLogClientPool = TCPClientPool.getLogInstance(); _tcpLogClientPool.initialize(100); tcpInPacketPool = new TCPInPacketPool(capacity); /*tcpOutPacketPool = new TCPOutPacketPool(capacity);*/ TCPOutPacketPool.getInstance().initialize(capacity); tcpOutPacketPool = TCPOutPacketPool.getInstance(); dictInPackets = new Dictionary <TMSKSocket, TCPInPacket>(capacity); tcpSessions = new Dictionary <TMSKSocket, TCPSession>(); TCPCmdDispatcher.getInstance().initialize(); #if UseTimer taskExecutor = new ScheduleExecutor(0); #else taskExecutor = new ScheduleExecutor(1); #endif taskExecutor.start(); }
// TODO: client should send spouse id // 发送婚宴信息 public void SendMarryPartyList(GameClient client, MarryPartyData partyData, int roleID = -1) { Dictionary <int, MarryPartyData> marryPartyList; if (partyData != null || roleID > 0) { if (partyData == null) { // 获取指定角色婚宴数据 partyData = m_MarryPartyDataCache.GetParty(roleID); if (partyData == null) { int SpouseID = MarryLogic.GetSpouseID(roleID); partyData = m_MarryPartyDataCache.GetParty(SpouseID); if (partyData == null) { // 返回空代表通知客戶端自己沒有婚宴 partyData = new MarryPartyData(); } } } marryPartyList = new Dictionary <int, MarryPartyData>(); marryPartyList.Add(roleID, partyData); client.sendCmd <Dictionary <int, MarryPartyData> >((int)TCPGameServerCmds.CMD_SPR_MARRY_PARTY_QUERY, marryPartyList); } else { // 获取全部婚宴列表 client.sendCmd(m_MarryPartyDataCache.GetPartyList(TCPOutPacketPool.getInstance(), (int)TCPGameServerCmds.CMD_SPR_MARRY_PARTY_QUERY)); } }
public static void NotifyOthersHideFakeRole(SocketListener sl, TCPOutPacketPool pool, FakeRoleItem FakeRoleItem) { if (null != FakeRoleItem) { GameManager.MapGridMgr.DictGrids[FakeRoleItem.MyRoleDataMini.MapCode].RemoveObject(FakeRoleItem); } }
/// <summary> /// 处理镖车的加血 /// </summary> /// <param name="sl"></param> /// <param name="pool"></param> /// <param name="biaoCheItem"></param> /// <returns></returns> private static void ProcessBiaoCheAddLife(SocketListener sl, TCPOutPacketPool pool, long nowTicks, BiaoCheItem biaoCheItem) { long subTicks = nowTicks - biaoCheItem.LastLifeMagicTick; //如果还没到时间,则跳过 if (subTicks < (5 * 1000)) { return; } biaoCheItem.LastLifeMagicTick = nowTicks; if (biaoCheItem.CurrentLifeV <= 0) { return; } //判断如果血量少于最大血量 if (biaoCheItem.CurrentLifeV < biaoCheItem.LifeV) { double lifeMax = biaoCheItem.CutLifeV; lifeMax += biaoCheItem.CurrentLifeV; if (biaoCheItem.CurrentLifeV > 0) { biaoCheItem.CurrentLifeV = (int)Global.GMin(biaoCheItem.LifeV, lifeMax); List <Object> objList = Global.GetAll9Clients(biaoCheItem); //镖车血变化(同一个地图才需要通知) GameManager.ClientMgr.NotifyOtherBiaoCheLifeV(sl, pool, objList, biaoCheItem.BiaoCheID, biaoCheItem.CurrentLifeV); //GameManager.SystemServerEvents.AddEvent(string.Format("镖车加血, BiaoCheID={0}({1}), Add={2}, Life={3}", biaoCheItem.BiaoCheID, biaoCheItem.BiaoCheName, biaoCheItem.CutLifeV, biaoCheItem.CurrentLifeV), EventLevels.Debug); } } }
public static bool QueryLevelUpMadman(GameClient client, TCPOutPacketPool pool, int nID, out TCPOutPacket tcpOutPacket) { tcpOutPacket = null; try { KingActivity instActivity = (KingActivity)Global.GetActivity(ActivityTypes.NewZoneUpLevelMadman); NewZoneUpLevelData data = new NewZoneUpLevelData(); int count = instActivity.RoleLimit.Count; data.Items = new List <NewZoneUpLevelItemData>(); for (int i = 1; i < count + 1; i++) { NewZoneUpLevelItemData item = new NewZoneUpLevelItemData(); AwardItem awd = instActivity.GetAward(client, i); item.LeftNum = awd.MinAwardCondionValue2 - Global.GetChongJiLingQuShenZhuangQuota(client, i); item.GetAward = !Global.CanGetChongJiLingQuShenZhuang(client, i); data.Items.Add(item); } tcpOutPacket = DataHelper.ObjectToTCPOutPacket <NewZoneUpLevelData>(data, pool, nID); return(true); } catch (Exception ex) { DataHelper.WriteFormatExceptionLog(ex, "LevelUpMadman", false, false); } return(false); }
public static void ProcessAllDecos(SocketListener sl, TCPOutPacketPool pool) { List <Decoration> decorationList = new List <Decoration>(); lock (DecorationManager.DictDecos) { foreach (Decoration val in DecorationManager.DictDecos.Values) { decorationList.Add(val); } } long nowTicks = TimeUtil.NOW(); Decoration decoration = null; for (int i = 0; i < decorationList.Count; i++) { decoration = decorationList[i]; if (decoration.MaxLiveTicks > 0) { if (nowTicks - decoration.StartTicks >= (long)decoration.MaxLiveTicks) { lock (DecorationManager.DictDecos) { DecorationManager.DictDecos.Remove(decoration.AutoID); } GameManager.MapGridMgr.DictGrids[decoration.MapCode].RemoveObject(decoration); List <object> objList = Global.GetAll9Clients(decoration); GameManager.ClientMgr.NotifyOthersDelDeco(sl, pool, objList, decoration.MapCode, decoration.AutoID); } } } }
public static TCPProcessCmdResults ProcTalentModify(DBManager dbMgr, TCPOutPacketPool pool, int nID, byte[] data, int count, out TCPOutPacket tcpOutPacket) { tcpOutPacket = null; string[] fields = null; try { int length = 6; if (!CheckHelper.CheckTCPCmdFields(nID, data, count, out fields, length)) { tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, 1.ToString(), nID); return(TCPProcessCmdResults.RESULT_DATA); } int roleID = Convert.ToInt32(fields[0]); int totalCount = Convert.ToInt32(fields[1]); long exp = Convert.ToInt64(fields[2]); long expAdd = Convert.ToInt64(fields[3]); int isUp = Convert.ToInt32(fields[4]); int zoneID = Convert.ToInt32(fields[5]); string strcmd = TalentManager.TalentInfoModify(dbMgr, roleID, totalCount, exp, expAdd, isUp, zoneID); tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID); return(TCPProcessCmdResults.RESULT_DATA); } catch (Exception ex) { DataHelper.WriteFormatExceptionLog(ex, "", false, false); } tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, 1.ToString(), nID); return(TCPProcessCmdResults.RESULT_DATA); }
/// <summary> /// 通知其他人被攻击(单攻),并且被伤害(同一个地图才需要通知) /// </summary> /// <param name="client"></param> public static void NotifyInjured(SocketListener sl, TCPOutPacketPool pool, GameClient client, int roleID, int enemy, int enemyX, int enemyY, int burst, int injure, double attackPercent, int addAttack, double baseRate = 1.0, int addVlue = 0, int nHitFlyDistance = 0) { object obj = FindFakeRoleByID(enemy); if (null != obj) { //怪物必须或者才操作 if ((obj as FakeRoleItem).CurrentLifeV > 0) { //处理BOSS克星 injure = 10000; (obj as FakeRoleItem).CurrentLifeV -= (int)injure; //是否需要锁定 (obj as FakeRoleItem).CurrentLifeV = Global.GMax((obj as FakeRoleItem).CurrentLifeV, 0); int enemyLife = (int)(obj as FakeRoleItem).CurrentLifeV; (obj as FakeRoleItem).AttackedRoleID = client.ClientData.RoleID; //判断是否将给敌人的伤害转化成自己的血量增长 GameManager.ClientMgr.SpriteInjure2Blood(sl, pool, client, injure); GameManager.SystemServerEvents.AddEvent(string.Format("假人减血, Injure={0}, Life={1}", injure, enemyLife), EventLevels.Debug); //判断怪物是否死亡 if ((int)(obj as FakeRoleItem).CurrentLifeV <= 0) { GameManager.SystemServerEvents.AddEvent(string.Format("假人死亡, roleID={0}", (obj as FakeRoleItem).FakeRoleID), EventLevels.Debug); /// 处理假人死亡 ProcessFakeRoleDead(sl, pool, client, (obj as FakeRoleItem)); } int ownerRoleID = (obj as FakeRoleItem).GetAttackerFromList(); if (ownerRoleID >= 0 && ownerRoleID != client.ClientData.RoleID) { GameClient findClient = GameManager.ClientMgr.FindClient(ownerRoleID); if (null != findClient) { //通知其他在线客户端 GameManager.ClientMgr.NotifySpriteInjured(sl, pool, findClient, findClient.ClientData.MapCode, findClient.ClientData.RoleID, (obj as FakeRoleItem).FakeRoleID, 0, 0, enemyLife, findClient.ClientData.Level, new Point(-1, -1)); //向自己发送敌人受伤的信息 ClientManager.NotifySelfEnemyInjured(sl, pool, findClient, findClient.ClientData.RoleID, (obj as FakeRoleItem).FakeRoleID, 0, 0, enemyLife, 0); } } //通知其他在线客户端 GameManager.ClientMgr.NotifySpriteInjured(sl, pool, client, client.ClientData.MapCode, client.ClientData.RoleID, (obj as FakeRoleItem).FakeRoleID, burst, injure, enemyLife, client.ClientData.Level, new Point(-1, -1)); //向自己发送敌人受伤的信息 ClientManager.NotifySelfEnemyInjured(sl, pool, client, client.ClientData.RoleID, (obj as FakeRoleItem).FakeRoleID, burst, injure, enemyLife, 0); //通知紫名信息(限制当前地图) if (!client.ClientData.DisableChangeRolePurpleName) { GameManager.ClientMgr.ForceChangeRolePurpleName2(sl, pool, client); } } } }
/// <summary> /// 为角色初始化第一阶段的翅膀 /// </summary> /// <param name="client"></param> public static void InitFirstWing(GameClient client) { if (null == client.ClientData.MyWingData) { WingData wingData = AddWingDBCommand(TCPOutPacketPool.getInstance(), client.ClientData.RoleID, 1, client.ServerId); //获取得到第一阶翅膀 client.ClientData.MyWingData = wingData; } }
public void SendCmdAfterStartPlayGame(int cmdId, byte[] cmdData) { lock (this.DelayStartPlayGameMsgQueue) { TCPOutPacket tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(TCPOutPacketPool.getInstance(), cmdData, cmdId); this.DelayStartPlayGameMsgQueue.Enqueue(tcpOutPacket); } }
/// <summary> /// 获取视频聊天室相关数据 /// </summary> /// <param name="socket"></param> /// <param name="pool"></param> /// <param name="nID"></param> /// <param name="tcpOutPacket"></param> /// <returns></returns> public static TCPProcessCmdResults ProcessOpenVideoCmd(TMSKSocket socket, TCPOutPacketPool pool, int nID, byte[] data, int count, out TCPOutPacket tcpOutPacket) { tcpOutPacket = null; string cmdData = null; try { cmdData = new UTF8Encoding().GetString(data, 0, count); } catch (Exception) //解析错误 { LogManager.WriteLog(LogTypes.Error, string.Format("解析指令字符串错误, CMD={0}", (TCPGameServerCmds)nID)); tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", (int)TCPGameServerCmds.CMD_SPR_VIDEO_OPEN); return(TCPProcessCmdResults.RESULT_DATA); } try { string[] fields = cmdData.Split(':'); if (fields.Length != 1) { LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0}, Recv={1}, CmdData={2}", (TCPGameServerCmds)nID, fields.Length, cmdData)); tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", (int)TCPGameServerCmds.CMD_SPR_VIDEO_OPEN); return(TCPProcessCmdResults.RESULT_DATA); } int roleID = Convert.ToInt32(fields[0]); GameClient client = GameManager.ClientMgr.FindClient(socket); if (null == client || client.ClientData.RoleID != roleID) { LogManager.WriteLog(LogTypes.Error, string.Format("根据RoleID定位GameClient对象失败, CMD={0}, Client={1}, RoleID={2}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket), roleID)); return(TCPProcessCmdResults.RESULT_FAILED); } VideoData roomData = GetVideoRoomData(client); if (roomData == null) { tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "", nID); return(TCPProcessCmdResults.RESULT_DATA); } var filterStatus = GetPlayerFilterStatus(client, roomData); string strcmd = string.Format("{0}:{1}:{2}", roomData.TalkID, roomData.PassWord, filterStatus); tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID); } catch (Exception ex) { DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(socket), false); } return(TCPProcessCmdResults.RESULT_DATA); }
/// <summary> /// 执行数据库命令 /// </summary> public void ExecuteDBCmd(TCPClientPool tcpClientPool, TCPOutPacketPool pool) { lock (_DBCmdQueue) { if (_DBCmdQueue.Count <= 0) { return; } } List <DBCommand> dbCmdList = new List <DBCommand>(); lock (_DBCmdQueue) { while (_DBCmdQueue.Count > 0) { dbCmdList.Add(_DBCmdQueue.Dequeue()); } } Int32 length = 0; Int16 cmd = 0; string strData = null; string[] fieldsData = null; byte[] bytesData = null; TCPProcessCmdResults result; for (int i = 0; i < dbCmdList.Count; i++) { result = DoDBCmd(tcpClientPool, pool, dbCmdList[i], out bytesData); if (result == TCPProcessCmdResults.RESULT_FAILED) { //写日志 LogManager.WriteLog(LogTypes.Error, string.Format("向DBServer请求执行命令失败, CMD={0}", (TCPGameServerCmds)dbCmdList[i].DBCommandID)); } else { //解析返回值 length = BitConverter.ToInt32(bytesData, 0); cmd = BitConverter.ToInt16(bytesData, 4); strData = new UTF8Encoding().GetString(bytesData, 6, length - 2); //解析客户端的指令 fieldsData = strData.Split(':'); } //执行事件 dbCmdList[i].DoDBCommandEvent(new DBCommandEventArgs() { Result = result, fields = fieldsData }); //还回队列 _DBCmdPool.Push(dbCmdList[i]); } }