public bool processCmd(GameClient client, string[] cmdParams) { int lookWho = Convert.ToInt32(cmdParams[1]); PlayerJingJiData jingjiData = Global.sendToDB <PlayerJingJiData, byte[]>((int)TCPGameServerCmds.CMD_DB_JINGJICHANG_GET_DATA, DataHelper.ObjectToBytes <int>(lookWho), client.ServerId); if (jingjiData != null) { // 有一些字段,PlayerJingJiData未保存,理论上客户端单纯显示是不需要这些字段的,如果有需要,那么创建竞技场数据的时候再保存下来 RoleData4Selector rd = new RoleData4Selector(); rd.RoleID = jingjiData.roleId; rd.RoleName = jingjiData.roleName; rd.RoleSex = jingjiData.sex; rd.Occupation = jingjiData.occupationId; rd.Level = jingjiData.level; // rd.Faction = jingjiData暂未保存 rd.MyWingData = jingjiData.wingData; rd.GoodsDataList = JingJiChangManager.GetUsingGoodsList(jingjiData.equipDatas); // rd.OtherName = jingjiData暂未保存 rd.CombatForce = jingjiData.combatForce; rd.AdmiredCount = jingjiData.AdmiredCount; // rd.FashionWingsID = jingjiData暂未保存; rd.SettingBitFlags = jingjiData.settingFlags; client.sendCmd <RoleData4Selector>((int)TCPGameServerCmds.CMD_SPR_JINGJICHANG_GET_ROLE_LOOKS, rd); } return(true); }
private void RoleDataSelectorQuery(GameServerClient client, int nID, byte[] cmdParams, int count) { int roleId = DataHelper.BytesToObject <int>(cmdParams, 0, count); RoleData4Selector roleData4Selector = this.GetRoleData4Selector(roleId, true); client.sendCmd <RoleData4Selector>(nID, roleData4Selector); }
private static FakeRoleItem AddFakeRole(RoleData4Selector clientData, FakeRoleTypes fakeRoleType) { FakeRoleItem result; if (null == clientData) { result = null; } else { FakeRoleItem fakeRoleItem = new FakeRoleItem { FakeRoleID = (int)GameManager.FakeRoleIDMgr.GetNewID(), FakeRoleType = (int)fakeRoleType, MyRoleDataMini = RoleManager.getInstance().GetRoleDataMiniFromRoleData4Selector(clientData) }; lock (FakeRoleManager._ID2FakeRoleDict) { FakeRoleManager._ID2FakeRoleDict[fakeRoleItem.FakeRoleID] = fakeRoleItem; } string roleID_Type = string.Format("{0}_{1}", fakeRoleItem.MyRoleDataMini.RoleID, (int)fakeRoleType); lock (FakeRoleManager._RoleIDType2FakeRoleDict) { FakeRoleManager._RoleIDType2FakeRoleDict[roleID_Type] = fakeRoleItem; } result = fakeRoleItem; } return(result); }
public void GMSetRoleData(GameClient client, int duanWeiId, int duanWeiJiFen, int rongYao, int monthDuanWeiRank, int lianSheng, int successCount, int fightCount) { RoleTianTiData roleTianTiData = client.ClientData.TianTiData; roleTianTiData.DuanWeiId = duanWeiId; roleTianTiData.DuanWeiJiFen = duanWeiJiFen; roleTianTiData.RongYao = rongYao; roleTianTiData.MonthDuanWeiRank = monthDuanWeiRank; roleTianTiData.LianSheng = lianSheng; roleTianTiData.SuccessCount = successCount; roleTianTiData.FightCount = fightCount; int selfDuanWeiId; if (RuntimeData.DuanWeiJiFenRangeDuanWeiIdDict.TryGetValue(roleTianTiData.DuanWeiJiFen, out selfDuanWeiId)) { roleTianTiData.DuanWeiId = selfDuanWeiId; } Global.sendToDB <int, RoleTianTiData>((int)TCPGameServerCmds.CMD_DB_TIANTI_UPDATE_ROLE_DATA, roleTianTiData, client.ServerId); TianTiPaiHangRoleData tianTiPaiHangRoleData = new TianTiPaiHangRoleData(); tianTiPaiHangRoleData.DuanWeiId = roleTianTiData.DuanWeiId; tianTiPaiHangRoleData.RoleId = roleTianTiData.RoleId; tianTiPaiHangRoleData.RoleName = client.ClientData.RoleName; tianTiPaiHangRoleData.Occupation = client.ClientData.Occupation; tianTiPaiHangRoleData.ZhanLi = client.ClientData.CombatForce; tianTiPaiHangRoleData.ZoneId = client.ClientData.ZoneID; tianTiPaiHangRoleData.DuanWeiJiFen = roleTianTiData.DuanWeiJiFen; RoleData4Selector roleInfo = Global.sendToDB <RoleData4Selector, string>((int)TCPGameServerCmds.CMD_SPR_GETROLEUSINGGOODSDATALIST, string.Format("{0}", client.ClientData.RoleID), client.ServerId); if (null != roleInfo || roleInfo.RoleID < 0) { tianTiPaiHangRoleData.RoleData4Selector = roleInfo; } PlayerJingJiData jingJiData = JingJiChangManager.getInstance().createJingJiData(client); TianTiRoleInfoData tianTiRoleInfoData = new TianTiRoleInfoData(); tianTiRoleInfoData.RoleId = tianTiPaiHangRoleData.RoleId; tianTiRoleInfoData.ZoneId = tianTiPaiHangRoleData.ZoneId; tianTiRoleInfoData.ZhanLi = tianTiPaiHangRoleData.ZhanLi; tianTiRoleInfoData.RoleName = tianTiPaiHangRoleData.RoleName; tianTiRoleInfoData.DuanWeiId = tianTiPaiHangRoleData.DuanWeiId; tianTiRoleInfoData.DuanWeiJiFen = tianTiPaiHangRoleData.DuanWeiJiFen; tianTiRoleInfoData.DuanWeiRank = tianTiPaiHangRoleData.DuanWeiRank; tianTiRoleInfoData.TianTiPaiHangRoleData = DataHelper.ObjectToBytes(tianTiPaiHangRoleData); tianTiRoleInfoData.PlayerJingJiMirrorData = DataHelper.ObjectToBytes(jingJiData); TianTiClient.getInstance().UpdateRoleInfoData(tianTiRoleInfoData); GameManager.ClientMgr.ModifyTianTiRongYaoValue(client, rongYao, "GM添加"); }
public RoleData4Selector GetMainOccupationRoleDataForSelector(int roleId, int serverId) { RoleData4Selector roleData4Selector = Global.sendToDB <RoleData4Selector, int>(10232, roleId, serverId); RoleData4Selector result; if (roleData4Selector == null || roleData4Selector.RoleID < 0) { result = null; } else { result = roleData4Selector; } return(result); }
public void SetDiaoXiang(CoupleWishSyncStatueData newStatue) { if (newStatue.DbCoupleId > 0 && (newStatue.ManRoleDataEx == null || newStatue.WifeRoleDataEx == null)) { RoleData4Selector manRoleData4Selector = RoleManager.getInstance().GetMainOccupationRoleDataForSelector(newStatue.Man.RoleId, GameManager.ServerId); RoleData4Selector wifeRoleData4Selector = RoleManager.getInstance().GetMainOccupationRoleDataForSelector(newStatue.Wife.RoleId, GameManager.ServerId); if (manRoleData4Selector != null && wifeRoleData4Selector != null) { CoupleWishReportStatueData statueReq = new CoupleWishReportStatueData(); statueReq.DbCoupleId = newStatue.DbCoupleId; statueReq.ManStatue = DataHelper.ObjectToBytes <RoleData4Selector>(manRoleData4Selector); statueReq.WifeStatue = DataHelper.ObjectToBytes <RoleData4Selector>(wifeRoleData4Selector); TianTiClient.getInstance().CoupleWishReportCoupleStatue(statueReq); } } if (newStatue.DbCoupleId > 0 && newStatue.ManRoleDataEx != null && newStatue.WifeRoleDataEx != null) { if (newStatue.IsDivorced == 1) { this.ReshowCoupleStatue(null, null); } else if (this._Statue == null || this._Statue.ManRoleDataEx == null || this._Statue.WifeRoleDataEx == null || this._Statue.DbCoupleId != newStatue.DbCoupleId) { this.ReshowCoupleStatue(DataHelper.BytesToObject <RoleData4Selector>(newStatue.ManRoleDataEx, 0, newStatue.ManRoleDataEx.Length), DataHelper.BytesToObject <RoleData4Selector>(newStatue.WifeRoleDataEx, 0, newStatue.WifeRoleDataEx.Length)); } } else { this.ReshowCoupleStatue(null, null); } NPC npc = NPCGeneralManager.GetNPCFromConfig(this.YanHuiMapCode, this.YanHuiNpcId, this.YanHuiNpcX, this.YanHuiNpcY, this.YanHuiNpcDir); if (newStatue.DbCoupleId > 0 && npc != null && (this._Statue == null || this._Statue.DbCoupleId != newStatue.DbCoupleId) && newStatue.YanHuiJoinNum < this._Config.YanHuiCfg.TotalMaxJoinNum) { NPCGeneralManager.AddNpcToMap(npc); } if (newStatue.DbCoupleId <= 0 || newStatue.YanHuiJoinNum >= this._Config.YanHuiCfg.TotalMaxJoinNum) { NPCGeneralManager.RemoveMapNpc(this.YanHuiMapCode, this.YanHuiNpcId); } this._Statue = newStatue; }
public static int ProcessNewFakeRole(RoleData4Selector clientData, int mapCode, FakeRoleTypes fakeRoleType, int direction = -1, int toPosX = -1, int toPosY = -1, int ToExtensionID = -1) { int result; if (mapCode <= 0 || !GameManager.MapGridMgr.DictGrids.ContainsKey(mapCode)) { LogManager.WriteLog(LogTypes.Error, string.Format("生成雕像目标地图不存在, MapCode={0}, RoleID={1}", mapCode, clientData.RoleID), null, true); result = -1; } else { FakeRoleManager.RemoveFakeRoleByRoleIDType(clientData.RoleID, fakeRoleType); FakeRoleItem fakeRoleItem = FakeRoleManager.AddFakeRole(clientData, fakeRoleType); if (null == fakeRoleItem) { LogManager.WriteLog(LogTypes.Error, string.Format("为RoleID生成假人对象时失败, MapCode={0}, RoleID={1}", mapCode, clientData.RoleID), null, true); result = -1; } else { fakeRoleItem.MyRoleDataMini.MapCode = mapCode; if (toPosX >= 0 && toPosY >= 0) { fakeRoleItem.MyRoleDataMini.PosX = toPosX; fakeRoleItem.MyRoleDataMini.PosY = toPosY; } if (direction >= 0) { fakeRoleItem.MyRoleDataMini.RoleDirection = direction; } if (ToExtensionID >= 0) { fakeRoleItem.ToExtensionID = ToExtensionID; } GameManager.MapGridMgr.DictGrids[fakeRoleItem.MyRoleDataMini.MapCode].MoveObject(-1, -1, fakeRoleItem.MyRoleDataMini.PosX, fakeRoleItem.MyRoleDataMini.PosY, fakeRoleItem); result = fakeRoleItem.FakeRoleID; } } return(result); }
private void ReshowCoupleStatue(RoleData4Selector manStatue, RoleData4Selector wifeStatue) { NPC manNpc = NPCGeneralManager.FindNPC(GameManager.MainMapCode, FakeRoleNpcId.CoupleWishMan); if (null != manNpc) { if (manStatue == null) { manNpc.ShowNpc = true; GameManager.ClientMgr.NotifyMySelfNewNPCBy9Grid(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, manNpc); FakeRoleManager.ProcessDelFakeRoleByType(FakeRoleTypes.CoupleWishMan, true); } else { manNpc.ShowNpc = false; GameManager.ClientMgr.NotifyMySelfDelNPCBy9Grid(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, manNpc); FakeRoleManager.ProcessDelFakeRoleByType(FakeRoleTypes.CoupleWishMan, true); FakeRoleManager.ProcessNewFakeRole(manStatue, manNpc.MapCode, FakeRoleTypes.CoupleWishMan, (int)manNpc.CurrentDir, (int)manNpc.CurrentPos.X, (int)manNpc.CurrentPos.Y, FakeRoleNpcId.CoupleWishMan); } } NPC wifeNpc = NPCGeneralManager.FindNPC(GameManager.MainMapCode, FakeRoleNpcId.CoupleWishWife); if (null != wifeNpc) { if (wifeStatue == null) { wifeNpc.ShowNpc = true; GameManager.ClientMgr.NotifyMySelfNewNPCBy9Grid(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, wifeNpc); FakeRoleManager.ProcessDelFakeRoleByType(FakeRoleTypes.CoupleWishWife, true); } else { wifeNpc.ShowNpc = false; GameManager.ClientMgr.NotifyMySelfDelNPCBy9Grid(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, wifeNpc); FakeRoleManager.ProcessDelFakeRoleByType(FakeRoleTypes.CoupleWishWife, true); FakeRoleManager.ProcessNewFakeRole(wifeStatue, wifeNpc.MapCode, FakeRoleTypes.CoupleWishWife, (int)wifeNpc.CurrentDir, (int)wifeNpc.CurrentPos.X, (int)wifeNpc.CurrentPos.Y, FakeRoleNpcId.CoupleWishWife); } } }
public RoleDataMini GetRoleDataMiniFromRoleData4Selector(RoleData4Selector roleData4Selector) { RoleDataMini MyRoleDataMini = null; if (roleData4Selector != null && roleData4Selector.RoleID > 0) { MyRoleDataMini = new RoleDataMini(); MyRoleDataMini.RoleID = roleData4Selector.RoleID; MyRoleDataMini.RoleName = roleData4Selector.RoleName; MyRoleDataMini.RoleSex = roleData4Selector.RoleSex; MyRoleDataMini.Occupation = roleData4Selector.Occupation; MyRoleDataMini.SubOccupation = roleData4Selector.SubOccupation; MyRoleDataMini.OccupationList = roleData4Selector.OccupationList; MyRoleDataMini.Level = roleData4Selector.Level; MyRoleDataMini.Faction = roleData4Selector.Faction; MyRoleDataMini.MyWingData = roleData4Selector.MyWingData; MyRoleDataMini.GoodsDataList = roleData4Selector.GoodsDataList; MyRoleDataMini.OtherName = roleData4Selector.OtherName; MyRoleDataMini.ZoneID = roleData4Selector.ZoneId; MyRoleDataMini.SettingBitFlags = roleData4Selector.SettingBitFlags; for (int i = MyRoleDataMini.RoleCommonUseIntPamams.Count; i < 53; i++) { MyRoleDataMini.RoleCommonUseIntPamams.Add(0); } MyRoleDataMini.RoleCommonUseIntPamams[26] = roleData4Selector.FashionWingsID; MyRoleDataMini.RoleCommonUseIntPamams[40] = roleData4Selector.BuffFashionID; MyRoleDataMini.LifeV = (MyRoleDataMini.MaxLifeV = 100); MyRoleDataMini.MagicV = (MyRoleDataMini.MaxMagicV = 100); MyRoleDataMini.JunTuanId = roleData4Selector.JunTuanId; MyRoleDataMini.JunTuanName = roleData4Selector.JunTuanName; MyRoleDataMini.JunTuanZhiWu = roleData4Selector.JunTuanZhiWu; MyRoleDataMini.LingDi = roleData4Selector.LingDi; MyRoleDataMini.HuiJiData = roleData4Selector.HuiJiData; MyRoleDataMini.CompType = roleData4Selector.CompType; MyRoleDataMini.CompZhiWu = roleData4Selector.CompZhiWu; } return(MyRoleDataMini); }
public RoleData4Selector GetRoleData4Selector(int roleID, bool mainOccupation = false) { DBManager dbMgr = DBManager.getInstance(); RoleData4Selector roleData4Selector = new RoleData4Selector(); roleData4Selector.RoleID = -1; try { DBRoleInfo dbRoleInfo = dbMgr.GetDBRoleInfo(ref roleID); if (null != dbRoleInfo) { if (mainOccupation && dbRoleInfo.OccupationList[0] != dbRoleInfo.Occupation) { if (dbRoleInfo.roleCustomData == null || null == dbRoleInfo.roleCustomData.roleData4Selector) { dbRoleInfo.roleCustomData = this.QueryRoleCustomData(roleID); } if (null != dbRoleInfo.roleCustomData) { return(dbRoleInfo.roleCustomData.roleData4Selector); } } else { lock (dbRoleInfo) { Global.DBRoleInfo2RoleData4Selector(dbMgr, dbRoleInfo, roleData4Selector); } } } } catch (Exception ex) { LogManager.WriteException(ex.ToString()); } return(roleData4Selector); }
/// <summary> /// 给奖励 /// </summary> public void GiveAwards(TianTiScene tianTiScene) { try { DateTime now = TimeUtil.NowDateTime(); DateTime startTime = now.Subtract(RuntimeData.RefreshTime); //后退刷新时间,这样来保证不跨天计次 List <GameClient> objsList = tianTiScene.CopyMap.GetClientsList(); if (objsList != null && objsList.Count > 0) { int nowDayId = Global.GetOffsetDayNow(); for (int n = 0; n < objsList.Count; ++n) { GameClient client = objsList[n]; if (client != null && client == GameManager.ClientMgr.FindClient(client.ClientData.RoleID)) //确认角色仍然在线 { RoleTianTiData roleTianTiData = client.ClientData.TianTiData; bool success = client.ClientData.BattleWhichSide == tianTiScene.SuccessSide; int selfDuanWeiId = roleTianTiData.DuanWeiId; TianTiRoleMiniData enemyMiniData = GetEnemyBattleSide(tianTiScene, client); int addDuanWeiJiFen = 0; int addLianShengJiFen = 0; int addRongYao = 0; int dayId = Global.GetOffsetDay(startTime); if (dayId != roleTianTiData.LastFightDayId) { roleTianTiData.LastFightDayId = dayId; roleTianTiData.TodayFightCount = 1; } else { roleTianTiData.TodayFightCount++; } //设置每日天梯积分获得上限为60万 if (roleTianTiData.DayDuanWeiJiFen < RuntimeData.MaxTianTiJiFen) { TianTiDuanWei tianTiDuanWei; if (success) { roleTianTiData.LianSheng++; roleTianTiData.SuccessCount++; if (RuntimeData.TianTiDuanWeiDict.TryGetValue(enemyMiniData.DuanWeiId, out tianTiDuanWei)) { //连胜后积分=基础积分*(1+Min(2,((连续胜利次数-1)* 0.2))) addDuanWeiJiFen = tianTiDuanWei.WinJiFen; addLianShengJiFen = (int)(tianTiDuanWei.WinJiFen * Math.Min(2, (roleTianTiData.LianSheng - 1) * 0.2)); if (roleTianTiData.TodayFightCount <= tianTiDuanWei.RongYaoNum) { addRongYao = tianTiDuanWei.WinRongYu; } } } else { roleTianTiData.LianSheng = 0; if (RuntimeData.TianTiDuanWeiDict.TryGetValue(roleTianTiData.DuanWeiId, out tianTiDuanWei)) { addDuanWeiJiFen = tianTiDuanWei.LoseJiFen; if (roleTianTiData.TodayFightCount <= tianTiDuanWei.RongYaoNum) { addRongYao = tianTiDuanWei.LoseRongYu; } } } if (addDuanWeiJiFen != 0) { roleTianTiData.DuanWeiJiFen += addDuanWeiJiFen + addLianShengJiFen; roleTianTiData.DuanWeiJiFen = Math.Max(0, roleTianTiData.DuanWeiJiFen); roleTianTiData.DayDuanWeiJiFen += addDuanWeiJiFen + addLianShengJiFen; roleTianTiData.DayDuanWeiJiFen = Math.Max(0, roleTianTiData.DayDuanWeiJiFen); Global.SaveRoleParamsInt32ValueToDB(client, RoleParamName.TianTiDayScore, roleTianTiData.DayDuanWeiJiFen, true); } } else { GameManager.ClientMgr.NotifyHintMsg(client, Global.GetLang("今日获得段位积分已达上限!")); } if (addRongYao != 0) { GameManager.ClientMgr.ModifyTianTiRongYaoValue(client, addRongYao, "天梯系统获得荣耀", true); } roleTianTiData.FightCount++; if (RuntimeData.DuanWeiJiFenRangeDuanWeiIdDict.TryGetValue(roleTianTiData.DuanWeiJiFen, out selfDuanWeiId)) { roleTianTiData.DuanWeiId = selfDuanWeiId; } TianTiAwardsData awardsData = new TianTiAwardsData(); awardsData.DuanWeiJiFen = addDuanWeiJiFen; awardsData.LianShengJiFen = addLianShengJiFen; awardsData.RongYao = addRongYao; awardsData.DuanWeiId = roleTianTiData.DuanWeiId; if (success) { awardsData.Success = 1; GlobalNew.UpdateKuaFuRoleDayLogData(client.ServerId, client.ClientData.RoleID, TimeUtil.NowDateTime(), client.ClientData.ZoneID, 0, 0, 1, 0, (int)GameTypes.TianTi); } else { GlobalNew.UpdateKuaFuRoleDayLogData(client.ServerId, client.ClientData.RoleID, TimeUtil.NowDateTime(), client.ClientData.ZoneID, 0, 0, 0, 1, (int)GameTypes.TianTi); } client.sendCmd((int)TCPGameServerCmds.CMD_SPR_TIANTI_AWARD, awardsData); Global.sendToDB <int, RoleTianTiData>((int)TCPGameServerCmds.CMD_DB_TIANTI_UPDATE_ROLE_DATA, roleTianTiData, client.ServerId); TianTiLogItemData tianTiLogItemData = new TianTiLogItemData() { Success = awardsData.Success, ZoneId1 = client.ClientData.ZoneID, RoleName1 = client.ClientData.RoleName, ZoneId2 = enemyMiniData.ZoneId, RoleName2 = enemyMiniData.RoleName, DuanWeiJiFenAward = addDuanWeiJiFen + addLianShengJiFen, RongYaoAward = addRongYao, RoleId = client.ClientData.RoleID, EndTime = now, }; Global.sendToDB <int, TianTiLogItemData>((int)TCPGameServerCmds.CMD_DB_TIANTI_ADD_ZHANBAO_LOG, tianTiLogItemData, client.ServerId); TianTiPaiHangRoleData tianTiPaiHangRoleData = new TianTiPaiHangRoleData(); tianTiPaiHangRoleData.DuanWeiId = roleTianTiData.DuanWeiId; tianTiPaiHangRoleData.RoleId = roleTianTiData.RoleId; tianTiPaiHangRoleData.RoleName = client.ClientData.RoleName; tianTiPaiHangRoleData.Occupation = client.ClientData.Occupation; tianTiPaiHangRoleData.ZhanLi = client.ClientData.CombatForce; tianTiPaiHangRoleData.ZoneId = client.ClientData.ZoneID; tianTiPaiHangRoleData.DuanWeiJiFen = roleTianTiData.DuanWeiJiFen; RoleData4Selector roleInfo = Global.sendToDB <RoleData4Selector, string>((int)TCPGameServerCmds.CMD_SPR_GETROLEUSINGGOODSDATALIST, string.Format("{0}", client.ClientData.RoleID), client.ServerId); if (null != roleInfo || roleInfo.RoleID < 0) { tianTiPaiHangRoleData.RoleData4Selector = roleInfo; } PlayerJingJiData jingJiData = JingJiChangManager.getInstance().createJingJiData(client); TianTiRoleInfoData tianTiRoleInfoData = new TianTiRoleInfoData(); tianTiRoleInfoData.RoleId = tianTiPaiHangRoleData.RoleId; tianTiRoleInfoData.ZoneId = tianTiPaiHangRoleData.ZoneId; tianTiRoleInfoData.ZhanLi = tianTiPaiHangRoleData.ZhanLi; tianTiRoleInfoData.RoleName = tianTiPaiHangRoleData.RoleName; tianTiRoleInfoData.DuanWeiId = tianTiPaiHangRoleData.DuanWeiId; tianTiRoleInfoData.DuanWeiJiFen = tianTiPaiHangRoleData.DuanWeiJiFen; tianTiRoleInfoData.DuanWeiRank = tianTiPaiHangRoleData.DuanWeiRank; tianTiRoleInfoData.TianTiPaiHangRoleData = DataHelper.ObjectToBytes(tianTiPaiHangRoleData); tianTiRoleInfoData.PlayerJingJiMirrorData = DataHelper.ObjectToBytes(jingJiData); TianTiClient.getInstance().UpdateRoleInfoData(tianTiRoleInfoData); } } } } catch (System.Exception ex) { DataHelper.WriteExceptionLogEx(ex, "天梯系统清场调度异常"); } }
public void PushGameResultData(KarenBattleScene scene) { JunTuanRankData rankData = this.GetJunTuanRankDataBySide(scene.SuccessSide); if (null != rankData) { JunTuanBaseData baseData = JunTuanManager.getInstance().GetJunTuanBaseDataByJunTuanID(rankData.JunTuanId); if (null == baseData) { LogManager.WriteLog(LogTypes.Fatal, string.Format("无法获取军团基本信息 JunTuanId={0}", rankData.JunTuanId), null, true); } else if (baseData.BhList == null || baseData.BhList.Count == 0) { LogManager.WriteLog(LogTypes.Fatal, string.Format("军团基本信息BhList为空 JunTuanId={0}", rankData.JunTuanId), null, true); } else { int leaderBangHui = baseData.BhList[0]; int leaderServerID = 0; SceneUIClasses mapType = Global.GetMapSceneType(scene.m_nMapCode); int lingDiType = this.ConvertMapSceneTypeToCaiJiLingDiType(mapType); LingDiData oldLingDiData = null; List <LingDiData> LingDiList = JunTuanClient.getInstance().GetLingDiData(); if (null != LingDiList) { oldLingDiData = LingDiList.Find((LingDiData x) => x.LingDiType == lingDiType); } RoleData4Selector oldLeader = (oldLingDiData != null && oldLingDiData.RoleData != null) ? DataHelper.BytesToObject <RoleData4Selector>(oldLingDiData.RoleData, 0, oldLingDiData.RoleData.Length) : null; lock (this.Mutex) { if (!this.FactionIDVsServerIDDict.TryGetValue(leaderBangHui, out leaderServerID)) { JunTuanData data = JunTuanClient.getInstance().GetJunTuanData(leaderBangHui, rankData.JunTuanId, true); if (null == data) { LogManager.WriteLog(LogTypes.Fatal, string.Format("无法获取JunTuanData BangHuiID={0} JunTuanId={1}", leaderBangHui, rankData.JunTuanId), null, true); return; } LingDiCaiJiManager.getInstance().SetLingZhu(lingDiType, data.LeaderRoleId, rankData.JunTuanId, rankData.JunTuanName, null); EventLogManager.AddKarenBattleEvent(lingDiType, oldLeader, data.LeaderZoneId, rankData.JunTuanId, data.LeaderRoleId); return; } } BangHuiDetailData bhData = Global.GetBangHuiDetailData(-1, leaderBangHui, leaderServerID); if (null == bhData) { LogManager.WriteLog(LogTypes.Fatal, string.Format("无法获取帮会详细信息 BangHuiID={0} ServerID={1}", leaderBangHui, leaderServerID), null, true); } else { RoleDataEx dbRd = Global.sendToDB <RoleDataEx, string>(275, string.Format("{0}:{1}", -1, bhData.BZRoleID), leaderServerID); if (dbRd == null || dbRd.RoleID <= 0) { LogManager.WriteLog(LogTypes.Fatal, string.Format("无法获取帮主详细信息 BangHuiID={0} BZRoleID={1} ServerID={2}", leaderBangHui, bhData.BZRoleID, leaderServerID), null, true); } else { JunTuanManager.getInstance().OnInitGame(dbRd); RoleData4Selector leaderShowInfo = Global.RoleDataEx2RoleData4Selector(dbRd); LingDiCaiJiManager.getInstance().SetLingZhu(lingDiType, dbRd.RoleID, rankData.JunTuanId, rankData.JunTuanName, leaderShowInfo); EventLogManager.AddKarenBattleEvent(lingDiType, oldLeader, dbRd.ZoneID, rankData.JunTuanId, dbRd.RoleID); } } } } }
private void TimerProc(object sender, EventArgs e) { bool notifyPrepareGame = false; bool notifyEnterGame = false; bool notifyEndGame = false; DateTime now = TimeUtil.NowDateTime(); lock (this.Mutex) { KarenBattleSceneInfo sceneItem = this.SceneDataDict.Values.FirstOrDefault <KarenBattleSceneInfo>(); for (int i = 0; i < sceneItem.TimePoints.Count - 1; i += 2) { if (now.DayOfWeek == (DayOfWeek)sceneItem.TimePoints[i].Days && now.TimeOfDay.TotalSeconds >= sceneItem.SecondsOfDay[i] - 120.0 && now.TimeOfDay.TotalSeconds <= sceneItem.SecondsOfDay[i + 1] + 120.0) { double secsPrepare = sceneItem.SecondsOfDay[i] - now.TimeOfDay.TotalSeconds; double secsEnd = sceneItem.SecondsOfDay[i + 1] + 120.0 - now.TimeOfDay.TotalSeconds; if (!this.PrepareGame) { if (secsPrepare > 0.0 && secsPrepare < 120.0) { this.PrepareGame = true; notifyPrepareGame = true; break; } } else if (secsPrepare < 0.0) { notifyEnterGame = true; this.PrepareGame = false; break; } if (!this.EndGame) { if (secsEnd > 0.0 && secsEnd < 120.0) { this.EndGame = true; notifyEndGame = true; break; } } else if (secsEnd < 0.0) { this.EndGame = false; break; } } } } if (notifyPrepareGame) { LogManager.WriteLog(LogTypes.Error, "阿卡伦战场活动即将开始,准备通知军团角色进入!", null, true); lock (this.Mutex) { this.FactionIDVsServerIDDict.Clear(); } } if (notifyEnterGame) { int westcount = 0; int eastcount = 0; lock (this.Mutex) { LogManager.WriteLog(LogTypes.Error, "阿卡伦战场开启,可以通知已分配到场次的玩家进入游戏了", null, true); KarenBattleSceneInfo sceneItem = this.SceneDataDict.Values.FirstOrDefault <KarenBattleSceneInfo>(); foreach (GameClient client in GameManager.ClientMgr.GetAllClients(true)) { if (this.CheckCanEnterKarenBattle(client) && this.CheckMap(client) && this.IsGongNengOpened(client, false)) { if (null != client) { client.sendCmd(1210, string.Format("{0}:{1}:{2}:{3}", new object[] { 1, 1, westcount, eastcount }), false); } } } } } if (notifyEndGame) { lock (this.Mutex) { foreach (KarenBattleSceneInfo item in this.SceneDataDict.Values) { KarenFuBenData fubenData = JunTuanClient.getInstance().GetKarenKuaFuFuBenData(item.MapCode); if (fubenData != null && fubenData.ServerId == GameManager.ServerId) { SceneUIClasses mapType = Global.GetMapSceneType(item.MapCode); if (mapType != SceneUIClasses.KarenEast || KarenBattleManager_MapEast.getInstance().SceneDict.Count == 0) { if (mapType != SceneUIClasses.KarenWest || KarenBattleManager_MapWest.getInstance().SceneDict.Count == 0) { int lingDiType = this.ConvertMapSceneTypeToCaiJiLingDiType(mapType); LingDiData oldLingDiData = null; List <LingDiData> LingDiList = JunTuanClient.getInstance().GetLingDiData(); if (null != LingDiList) { oldLingDiData = LingDiList.Find((LingDiData x) => x.LingDiType == lingDiType); } RoleData4Selector oldLeader = (oldLingDiData != null && oldLingDiData.RoleData != null) ? DataHelper.BytesToObject <RoleData4Selector>(oldLingDiData.RoleData, 0, oldLingDiData.RoleData.Length) : null; LingDiCaiJiManager.getInstance().SetLingZhu(lingDiType, 0, 0, "", null); EventLogManager.AddKarenBattleEvent(lingDiType, oldLeader, 0, 0, 0); } } } } } } this.UpdateKuaFuMapClientCount(KarenBattleManager_MapWest.getInstance().SceneDict.Values.FirstOrDefault <KarenBattleScene>()); this.UpdateKuaFuMapClientCount(KarenBattleManager_MapEast.getInstance().SceneDict.Values.FirstOrDefault <KarenBattleScene>()); }
/// <summary> /// 副本结算 /// </summary> /// <param name="scene"></param> /// <param name="now"></param> /// <param name="nowTicks"></param> private void ProcessEnd(CoupleArenaCopyScene scene, DateTime now, long nowTicks) { GameManager.CopyMapMgr.KillAllMonster(scene.CopyMap); //结算奖励 scene.m_eStatus = GameSceneStatuses.STATUS_AWARD; scene.m_lEndTime = nowTicks; scene.m_lLeaveTime = scene.m_lEndTime + WarCfg.ClearSec * TimeUtil.SECOND; scene.StateTimeData.GameType = (int)GameTypes.CoupleArena; scene.StateTimeData.State = (int)GameSceneStatuses.STATUS_END; scene.StateTimeData.EndTicks = scene.m_lLeaveTime; GameManager.ClientMgr.BroadSpecialCopyMapMessage((int)TCPGameServerCmds.CMD_SPR_NOTIFY_TIME_STATE, scene.StateTimeData, scene.CopyMap); CoupleArenaFuBenData fubenData = null; if (!GameId2FuBenData.TryGetValue(scene.GameId, out fubenData)) { return; } List <RoleData4Selector> selectorList = new List <RoleData4Selector>(); foreach (var roledata in fubenData.RoleList) { RoleData4Selector _roleInfo = Global.sendToDB <RoleData4Selector, string>((int)TCPGameServerCmds.CMD_SPR_GETROLEUSINGGOODSDATALIST, string.Format("{0}", roledata.RoleId), roledata.ServerId); if (_roleInfo == null) { LogManager.WriteLog(LogTypes.Error, string.Format("加载RoleData4Selector失败, serverid={0}, roleid={1}", roledata.ServerId, roledata.RoleId)); return; } selectorList.Add(_roleInfo); } if (selectorList[0].RoleSex == (int)ERoleSex.Girl) { var tmp = selectorList[0]; selectorList[0] = selectorList[1]; selectorList[1] = tmp; } if (selectorList[2].RoleSex == (int)ERoleSex.Girl) { var tmp = selectorList[2]; selectorList[2] = selectorList[3]; selectorList[3] = tmp; } // selectorList 存储的分别为男1,女1,男2,女2 CoupleArenaPkResultReq req = new CoupleArenaPkResultReq(); req.GameId = scene.GameId; req.winSide = scene.WinSide; req.ManRole1 = selectorList[0].RoleID; req.ManZoneId1 = selectorList[0].ZoneId; req.ManSelector1 = DataHelper.ObjectToBytes <RoleData4Selector>(selectorList[0]); req.WifeRole1 = selectorList[1].RoleID; req.WifeZoneId1 = selectorList[1].ZoneId; req.WifeSelector1 = DataHelper.ObjectToBytes <RoleData4Selector>(selectorList[1]); req.ManRole2 = selectorList[2].RoleID; req.ManZoneId2 = selectorList[2].ZoneId; req.ManSelector2 = DataHelper.ObjectToBytes <RoleData4Selector>(selectorList[2]); req.WifeRole2 = selectorList[3].RoleID; req.WifeZoneId2 = selectorList[3].ZoneId; req.WifeSelector2 = DataHelper.ObjectToBytes <RoleData4Selector>(selectorList[3]); CoupleArenaPkResultRsp rsp = TianTiClient.getInstance().CoupleArenaPkResult(req); if (rsp == null) { return; } if (rsp.Couple1RetData != null) { if (rsp.Couple1RetData.Result != (int)ECoupleArenaPkResult.Invalid) { CoupleArenaZhanBaoSaveDbData saveData = new CoupleArenaZhanBaoSaveDbData(); saveData.FromMan = req.ManRole1; saveData.FromWife = req.WifeRole1; saveData.FirstWeekday = TimeUtil.MakeFirstWeekday(now); saveData.ZhanBao = new CoupleArenaZhanBaoItemData() { TargetManZoneId = req.ManZoneId2, TargetManRoleName = selectorList[2].RoleName, TargetWifeZoneId = req.WifeZoneId2, TargetWifeRoleName = selectorList[3].RoleName, IsWin = rsp.Couple1RetData.Result == (int)ECoupleArenaPkResult.Win, GetJiFen = rsp.Couple1RetData.GetJiFen }; Global.sendToDB <bool, CoupleArenaZhanBaoSaveDbData>((int)TCPGameServerCmds.CMD_COUPLE_ARENA_DB_SAVE_ZHAN_BAO, saveData, fubenData.RoleList[0].ServerId); } NtfAwardData(req.ManRole1, rsp.Couple1RetData); NtfAwardData(req.WifeRole1, rsp.Couple1RetData); } if (rsp.Couple2RetData != null) { if (rsp.Couple2RetData.Result != (int)ECoupleArenaPkResult.Invalid) { CoupleArenaZhanBaoSaveDbData saveData = new CoupleArenaZhanBaoSaveDbData(); saveData.FirstWeekday = TimeUtil.MakeFirstWeekday(now); saveData.FromMan = req.ManRole2; saveData.FromWife = req.WifeRole2; saveData.ZhanBao = new CoupleArenaZhanBaoItemData() { TargetManZoneId = req.ManZoneId1, TargetManRoleName = selectorList[0].RoleName, TargetWifeZoneId = req.WifeZoneId1, TargetWifeRoleName = selectorList[1].RoleName, IsWin = rsp.Couple2RetData.Result == (int)ECoupleArenaPkResult.Win, GetJiFen = rsp.Couple2RetData.GetJiFen }; Global.sendToDB <bool, CoupleArenaZhanBaoSaveDbData>((int)TCPGameServerCmds.CMD_COUPLE_ARENA_DB_SAVE_ZHAN_BAO, saveData, fubenData.RoleList[2].ServerId); } NtfAwardData(req.ManRole2, rsp.Couple2RetData); NtfAwardData(req.WifeRole2, rsp.Couple2RetData); } }
/// <summary> /// 玩家请求祝福他人 /// </summary> /// <param name="client"></param> /// <param name="nID"></param> /// <param name="bytes"></param> /// <param name="cmdParams"></param> private void HandleWishOtherRoleCommand(GameClient client, int nID, byte[] bytes, string[] cmdParams) { var cliReq = DataHelper.BytesToObject <CoupleWishWishReqData>(bytes, 0, bytes.Length); DateTime now = TimeUtil.NowDateTime(); if (client.ClientSocket.IsKuaFuLogin) { client.sendCmd(nID, StdErrorCode.Error_Operation_Denied.ToString()); return; } if (cliReq.CostType != (int)CoupleWishWishReqData.ECostType.Goods && cliReq.CostType != (int)CoupleWishWishReqData.ECostType.ZuanShi) { client.sendCmd(nID, StdErrorCode.Error_Invalid_Params.ToString()); return; } // 是否是活动时间 int wishWeek; if (!_Config.IsInWishTime(now, out wishWeek)) { client.sendCmd(nID, StdErrorCode.Error_Wish_In_Balance_Time.ToString()); return; } // 祝福类型检查 CoupleWishTypeConfig wishCfg = _Config.WishTypeCfgList.Find(_w => _w.WishType == cliReq.WishType); if (wishCfg == null) { client.sendCmd(nID, StdErrorCode.Error_Config_Fault.ToString()); return; } // 道具检查 if (cliReq.CostType == (int)CoupleWishWishReqData.ECostType.Goods && wishCfg.CostGoodsId > 0 && wishCfg.CostGoodsNum > 0 && Global.GetTotalGoodsCountByID(client, wishCfg.CostGoodsId) < wishCfg.CostGoodsNum) { client.sendCmd(nID, StdErrorCode.Error_Goods_Not_Enough.ToString()); return; } // 钻石检查 if (cliReq.CostType == (int)CoupleWishWishReqData.ECostType.ZuanShi && wishCfg.CostZuanShi > 0 && client.ClientData.UserMoney < wishCfg.CostZuanShi) { client.sendCmd(nID, StdErrorCode.Error_ZuanShi_Not_Enough.ToString()); return; } // 祝福寄语检查 if (!string.IsNullOrEmpty(cliReq.WishTxt)) { if (wishCfg.CanHaveWishTxt != 1) { client.sendCmd(nID, StdErrorCode.Error_Cannot_Have_Wish_Txt.ToString()); return; } else if (cliReq.WishTxt.Length > CoupleWishConsts.MaxWishTxtLen) { client.sendCmd(nID, StdErrorCode.Error_Wish_Txt_Length_Limit.ToString()); return; } } CoupleWishWishRoleReq centerReq = new CoupleWishWishRoleReq(); centerReq.From.RoleId = client.ClientData.RoleID; centerReq.From.ZoneId = client.ClientData.ZoneID; centerReq.From.RoleName = client.ClientData.RoleName; centerReq.WishType = cliReq.WishType; centerReq.WishTxt = cliReq.WishTxt; RoleData4Selector toManSelector = null; RoleData4Selector toWifeSelector = null; CoupleWishCoupleDataK rankCoupleData = null; if (cliReq.IsWishRankRole) { centerReq.IsWishRank = true; // 跨服排行榜祝福 lock (Mutex) { int coupleIdx; if (!this.SyncData.ThisWeek.CoupleIdex.TryGetValue(cliReq.ToRankCoupleId, out coupleIdx)) { client.sendCmd(nID, StdErrorCode.Error_Operation_Denied.ToString()); return; } rankCoupleData = this.SyncData.ThisWeek.RankList[coupleIdx]; if (rankCoupleData == null || rankCoupleData.DbCoupleId != cliReq.ToRankCoupleId || rankCoupleData.Rank > CoupleWishConsts.MaxRankNum * 2) { // 因为客户端看到的不是实时的数据,客户端看到的时候某对情侣可能处于前20名,但是当祝福的时候,可能已经不是前20名了,优化下体验,如果是前40名就允许 client.sendCmd(nID, StdErrorCode.Error_Operation_Denied.ToString()); return; } centerReq.ToCoupleId = cliReq.ToRankCoupleId; // 赠送排行榜情侣,检测是否是本服的情侣,尝试更新角色形象 toManSelector = Global.sendToDB <RoleData4Selector, string>((int)TCPGameServerCmds.CMD_SPR_GETROLEUSINGGOODSDATALIST, string.Format("{0}", rankCoupleData.Man.RoleId), client.ServerId); toWifeSelector = Global.sendToDB <RoleData4Selector, string>((int)TCPGameServerCmds.CMD_SPR_GETROLEUSINGGOODSDATALIST, string.Format("{0}", rankCoupleData.Wife.RoleId), client.ServerId); if (toManSelector == null || toWifeSelector == null || toManSelector.RoleID <= 0 || toWifeSelector.RoleID <= 0) { toManSelector = toWifeSelector = null; } } } else { // 本服祝福 int toRoleId = -1; if (!string.IsNullOrEmpty(cliReq.ToLocalRoleName)) { toRoleId = RoleName2IDs.FindRoleIDByName(cliReq.ToLocalRoleName, true); } if (toRoleId <= 0) { client.sendCmd(nID, StdErrorCode.Error_Wish_Player_Not_Exist.ToString()); return; } if (toRoleId == client.ClientData.RoleID) { client.sendCmd(nID, StdErrorCode.Error_Cannot_Wish_Self.ToString()); return; } int nSpouseId = MarryLogic.GetSpouseID(toRoleId); if (nSpouseId <= 0) { client.sendCmd(nID, StdErrorCode.Error_Wish_Player_Not_Marry.ToString()); return; } toManSelector = Global.sendToDB <RoleData4Selector, string>((int)TCPGameServerCmds.CMD_SPR_GETROLEUSINGGOODSDATALIST, string.Format("{0}", toRoleId), client.ServerId); toWifeSelector = Global.sendToDB <RoleData4Selector, string>((int)TCPGameServerCmds.CMD_SPR_GETROLEUSINGGOODSDATALIST, string.Format("{0}", nSpouseId), client.ServerId); if (toManSelector == null || toWifeSelector == null || toManSelector.RoleSex == toWifeSelector.RoleSex) { client.sendCmd(nID, StdErrorCode.Error_DB_Faild.ToString()); return; } if (toManSelector.RoleSex == (int)ERoleSex.Girl) { DataHelper2.Swap(ref toManSelector, ref toWifeSelector); } } if (toManSelector != null && toWifeSelector != null) { // 不管是排行榜赠送还是选中好友赠送,都尝试更新被赠送者形象数据 // 排行榜赠送时,toManSelector和toWifeSelector可能都为null,或者都不为null // 选中好友赠送,toManSelector和toWifeSelector一定都不为null centerReq.ToMan.RoleId = toManSelector.RoleID; centerReq.ToMan.ZoneId = toManSelector.ZoneId; centerReq.ToMan.RoleName = toManSelector.RoleName; centerReq.ToManSelector = DataHelper.ObjectToBytes <RoleData4Selector>(toManSelector); centerReq.ToWife.RoleId = toWifeSelector.RoleID; centerReq.ToWife.ZoneId = toWifeSelector.ZoneId; centerReq.ToWife.RoleName = toWifeSelector.RoleName; centerReq.ToWifeSelector = DataHelper.ObjectToBytes <RoleData4Selector>(toWifeSelector); } int ec = TianTiClient.getInstance().CoupleWishWishRole(centerReq); if (ec < 0) { client.sendCmd(nID, ec.ToString()); return; } // 扣除物品 if (cliReq.CostType == (int)CoupleWishWishReqData.ECostType.Goods && wishCfg.CostGoodsId > 0 && wishCfg.CostGoodsNum > 0) { bool oneUseBind = false; bool oneUseTimeLimit = false; Global.UseGoodsBindOrNot(client, wishCfg.CostGoodsId, wishCfg.CostGoodsNum, true, out oneUseBind, out oneUseTimeLimit); } // 扣除钻石 if (cliReq.CostType == (int)CoupleWishWishReqData.ECostType.ZuanShi && wishCfg.CostZuanShi > 0) { GameManager.ClientMgr.SubUserMoney(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, wishCfg.CostZuanShi, "情侣祝福"); } // 增加本服祝福特效 if (wishCfg.IsHaveEffect == 1) { CoupleWishNtfWishEffectData effectData = new CoupleWishNtfWishEffectData(); effectData.From = centerReq.From; effectData.WishType = cliReq.WishType; effectData.WishTxt = cliReq.WishTxt; effectData.To = new List <KuaFuRoleMiniData>(); if (cliReq.IsWishRankRole) { effectData.To.Add(rankCoupleData.Man); effectData.To.Add(rankCoupleData.Wife); } else { if (centerReq.ToMan.RoleName == cliReq.ToLocalRoleName) { effectData.To.Add(centerReq.ToMan); } else { effectData.To.Add(centerReq.ToWife); } } lock (Mutex) { // 这里必须锁住,不然多个人同时祝福,都有可能修改所有在线玩家的奖励数据 HandleWishEffect(effectData); } } client.sendCmd(nID, StdErrorCode.Error_Success.ToString()); }
private void HandleWishOtherRoleCommand(GameClient client, int nID, byte[] bytes, string[] cmdParams) { CoupleWishWishReqData cliReq = DataHelper.BytesToObject <CoupleWishWishReqData>(bytes, 0, bytes.Length); DateTime now = TimeUtil.NowDateTime(); int wishWeek; if (client.ClientSocket.IsKuaFuLogin) { client.sendCmd(nID, -12); } else if (cliReq.CostType != 1 && cliReq.CostType != 2) { client.sendCmd(nID, -18); } else if (!this._Config.IsInWishTime(now, out wishWeek)) { client.sendCmd(nID, -31); } else { CoupleWishTypeConfig wishCfg = this._Config.WishTypeCfgList.Find((CoupleWishTypeConfig _w) => _w.WishType == cliReq.WishType); if (wishCfg == null) { client.sendCmd(nID, -3); } else if (cliReq.CostType == 1 && wishCfg.CostGoodsId > 0 && wishCfg.CostGoodsNum > 0 && Global.GetTotalGoodsCountByID(client, wishCfg.CostGoodsId) < wishCfg.CostGoodsNum) { client.sendCmd(nID, -6, false); } else if (cliReq.CostType == 2 && wishCfg.CostZuanShi > 0 && client.ClientData.UserMoney < wishCfg.CostZuanShi) { client.sendCmd(nID, -10, false); } else { if (!string.IsNullOrEmpty(cliReq.WishTxt)) { if (wishCfg.CanHaveWishTxt != 1) { client.sendCmd(nID, -25, false); return; } if (cliReq.WishTxt.Length > CoupleWishConsts.MaxWishTxtLen) { client.sendCmd(nID, -26, false); return; } } CoupleWishWishRoleReq centerReq = new CoupleWishWishRoleReq(); centerReq.From.RoleId = client.ClientData.RoleID; centerReq.From.ZoneId = client.ClientData.ZoneID; centerReq.From.RoleName = client.ClientData.RoleName; centerReq.WishType = cliReq.WishType; centerReq.WishTxt = cliReq.WishTxt; RoleData4Selector toManSelector = null; RoleData4Selector toWifeSelector = null; CoupleWishCoupleDataK rankCoupleData = null; if (cliReq.IsWishRankRole) { centerReq.IsWishRank = true; lock (this.Mutex) { int coupleIdx; if (!this.SyncData.ThisWeek.CoupleIdex.TryGetValue(cliReq.ToRankCoupleId, out coupleIdx)) { client.sendCmd(nID, -12, false); return; } rankCoupleData = this.SyncData.ThisWeek.RankList[coupleIdx]; if (rankCoupleData == null || rankCoupleData.DbCoupleId != cliReq.ToRankCoupleId || rankCoupleData.Rank > CoupleWishConsts.MaxRankNum * 2) { client.sendCmd(nID, -12, false); return; } centerReq.ToCoupleId = cliReq.ToRankCoupleId; toManSelector = Global.sendToDB <RoleData4Selector, int>(10232, rankCoupleData.Man.RoleId, client.ServerId); toWifeSelector = Global.sendToDB <RoleData4Selector, int>(10232, rankCoupleData.Wife.RoleId, client.ServerId); if (toManSelector == null || toWifeSelector == null || toManSelector.RoleID <= 0 || toWifeSelector.RoleID <= 0) { toWifeSelector = (toManSelector = null); } } } else { int toRoleId = -1; if (!string.IsNullOrEmpty(cliReq.ToLocalRoleName)) { toRoleId = RoleName2IDs.FindRoleIDByName(cliReq.ToLocalRoleName, true); } if (toRoleId <= 0) { client.sendCmd(nID, -28, false); return; } if (toRoleId == client.ClientData.RoleID) { client.sendCmd(nID, -27, false); return; } int nSpouseId = MarryLogic.GetSpouseID(toRoleId); if (nSpouseId <= 0) { client.sendCmd(nID, -29, false); return; } toManSelector = Global.sendToDB <RoleData4Selector, int>(10232, toRoleId, client.ServerId); toWifeSelector = Global.sendToDB <RoleData4Selector, int>(10232, nSpouseId, client.ServerId); if (toManSelector == null || toWifeSelector == null) { client.sendCmd(nID, -15, false); return; } if (!MarryLogic.SameSexMarry(false)) { if (toManSelector.RoleSex == toWifeSelector.RoleSex) { client.sendCmd(nID, -15, false); return; } if (toManSelector.RoleSex == 1) { DataHelper2.Swap <RoleData4Selector>(ref toManSelector, ref toWifeSelector); } } } if (toManSelector != null && toWifeSelector != null) { centerReq.ToMan.RoleId = toManSelector.RoleID; centerReq.ToMan.ZoneId = toManSelector.ZoneId; centerReq.ToMan.RoleName = toManSelector.RoleName; centerReq.ToManSelector = DataHelper.ObjectToBytes <RoleData4Selector>(toManSelector); centerReq.ToWife.RoleId = toWifeSelector.RoleID; centerReq.ToWife.ZoneId = toWifeSelector.ZoneId; centerReq.ToWife.RoleName = toWifeSelector.RoleName; centerReq.ToWifeSelector = DataHelper.ObjectToBytes <RoleData4Selector>(toWifeSelector); } int ec = TianTiClient.getInstance().CoupleWishWishRole(centerReq); if (ec < 0) { client.sendCmd(nID, ec); } else { if (cliReq.CostType == 1 && wishCfg.CostGoodsId > 0 && wishCfg.CostGoodsNum > 0) { bool oneUseBind = false; bool oneUseTimeLimit = false; Global.UseGoodsBindOrNot(client, wishCfg.CostGoodsId, wishCfg.CostGoodsNum, true, out oneUseBind, out oneUseTimeLimit); } if (cliReq.CostType == 2 && wishCfg.CostZuanShi > 0) { GameManager.ClientMgr.SubUserMoney(Global._TCPManager.MySocketListener, Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, client, wishCfg.CostZuanShi, "情侣祝福", true, true, false, DaiBiSySType.None); } if (wishCfg.IsHaveEffect == 1) { CoupleWishNtfWishEffectData effectData = new CoupleWishNtfWishEffectData(); effectData.From = centerReq.From; effectData.WishType = cliReq.WishType; effectData.WishTxt = cliReq.WishTxt; effectData.To = new List <KuaFuRoleMiniData>(); if (cliReq.IsWishRankRole) { effectData.To.Add(rankCoupleData.Man); effectData.To.Add(rankCoupleData.Wife); } else if (centerReq.ToMan.RoleName == cliReq.ToLocalRoleName) { effectData.To.Add(centerReq.ToMan); } else { effectData.To.Add(centerReq.ToWife); } lock (this.Mutex) { this.HandleWishEffect(effectData); } } client.sendCmd(nID, 1); } } } }