/// <summary> /// 更新准备状态 /// </summary> public KFCopyTeamSetReadyRsp TeamSetReady(KFCopyTeamSetReadyReq req) { KFCopyTeamSetReadyRsp rsp = new KFCopyTeamSetReadyRsp(); try { lock (Mutex) { CopyTeamData td = null; if (!CopyTeamDict.TryGetValue(req.TeamId, out td)) { // 房间不存在!!! GameServer要检查这个错误码,可能出现的情况是 跨服中心重启了,那么GameServer要把这个房间清掉 rsp.ErrorCode = CopyTeamErrorCodes.TeamIsDestoryed; return(rsp); } CopyTeamMemberData member = td.TeamRoles.Find(_role => _role.RoleID == req.RoleId); if (member == null) { rsp.ErrorCode = CopyTeamErrorCodes.NotInMyTeam; return(rsp); } if (td.StartTime > 0) { rsp.ErrorCode = CopyTeamErrorCodes.TeamAlreadyStart; return(rsp); } member.IsReady = req.Ready > 0; // 异步广播准备事件 CopyTeamReadyData data = new CopyTeamReadyData(); data.RoleId = req.RoleId; data.TeamId = req.TeamId; data.Ready = req.Ready; AsyncDataItem evItem = new AsyncDataItem(); evItem.EventType = KuaFuEventTypes.KFCopyTeamSetReady; evItem.Args = new object[2] { member.ServerId, data }; AddAsyncEvent(evItem); rsp.ErrorCode = CopyTeamErrorCodes.Success; rsp.Data = data; } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Error, string.Format("更新跨服副本队伍准备状态异常, role={0}, teamid={1}", req.RoleId, req.TeamId), ex); rsp.ErrorCode = CopyTeamErrorCodes.CenterServerFailed; } return(rsp); }
public KFCopyTeamSetReadyRsp TeamSetReady(KFCopyTeamSetReadyReq req) { KFCopyTeamSetReadyRsp rsp = new KFCopyTeamSetReadyRsp(); try { lock (this.Mutex) { CopyTeamData td = null; if (!this.CopyTeamDict.TryGetValue(req.TeamId, out td)) { rsp.ErrorCode = CopyTeamErrorCodes.TeamIsDestoryed; return(rsp); } if (req.Ready <= 0) { if (req.RoleId == td.LeaderRoleID) { rsp.ErrorCode = CopyTeamErrorCodes.TeamLeaderCant; return(rsp); } } CopyTeamMemberData member = td.TeamRoles.Find((CopyTeamMemberData _role) => _role.RoleID == req.RoleId); if (member == null) { rsp.ErrorCode = CopyTeamErrorCodes.NotInMyTeam; return(rsp); } if (td.StartTime > 0L) { rsp.ErrorCode = CopyTeamErrorCodes.TeamAlreadyStart; return(rsp); } member.IsReady = (req.Ready > 0); if (!member.IsReady) { member.NoReadyTicks = TimeUtil.NOW(); } CopyTeamReadyData data = new CopyTeamReadyData(); data.RoleId = req.RoleId; data.TeamId = req.TeamId; data.Ready = req.Ready; this.AddAsyncEvent(new AsyncDataItem { EventType = KuaFuEventTypes.KFCopyTeamSetReady, Args = new object[] { member.ServerId, data } }); rsp.ErrorCode = CopyTeamErrorCodes.Success; rsp.Data = data; } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Error, string.Format("更新跨服副本队伍准备状态异常, role={0}, teamid={1}", req.RoleId, req.TeamId), ex, true); rsp.ErrorCode = CopyTeamErrorCodes.CenterServerFailed; } return(rsp); }