public KFCopyTeamJoinRsp JoinTeam(KFCopyTeamJoinReq req) { KFCopyTeamJoinRsp rsp = new KFCopyTeamJoinRsp(); try { lock (this.Mutex) { this.ForceLeaveRoom(req.Member.RoleID); CopyTeamData td = null; if (!this.CopyTeamDict.TryGetValue(req.TeamId, out td)) { rsp.ErrorCode = CopyTeamErrorCodes.TeamIsDestoryed; return(rsp); } if (td.StartTime > 0L) { rsp.ErrorCode = CopyTeamErrorCodes.TeamAlreadyStart; return(rsp); } if (td.MemberCount >= ConstData.CopyRoleMax(req.CopyId)) { rsp.ErrorCode = CopyTeamErrorCodes.TeamIsFull; return(rsp); } req.Member.IsReady = false; td.TeamRoles.Add(req.Member); td.MemberCount = td.TeamRoles.Count; if (!req.Member.IsReady) { req.Member.NoReadyTicks = TimeUtil.NOW(); } this.RoleId2JoinedTeam[req.Member.RoleID] = td.TeamID; CopyTeamJoinData data = new CopyTeamJoinData(); data.Member = req.Member; data.TeamId = req.TeamId; this.AddAsyncEvent(new AsyncDataItem { EventType = KuaFuEventTypes.KFCopyTeamJoin, Args = new object[] { req.Member.ServerId, data } }); rsp.ErrorCode = CopyTeamErrorCodes.Success; rsp.Data = data; } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Error, string.Format("加入跨服副本队伍异常, serverid={0}, role={1}, teamid={2}", req.Member.ServerId, req.Member.RoleID, req.TeamId), ex, true); rsp.ErrorCode = CopyTeamErrorCodes.CenterServerFailed; } return(rsp); }
public KFCopyTeamJoinRsp JoinTeam(KFCopyTeamJoinReq req) { IKuaFuCopyService service = GetKuaFuService(true); if (service == null) { return(null); } return(service.JoinTeam(req)); }
public KFCopyTeamJoinRsp JoinTeam(KFCopyTeamJoinReq req) { IKuaFuCopyService service = this.GetKuaFuService(true); KFCopyTeamJoinRsp result; if (service == null) { result = null; } else { result = service.JoinTeam(req); } return(result); }
public KFCopyTeamJoinRsp JoinTeam(KFCopyTeamJoinReq req) { return(this.teamMgr.JoinTeam(req)); }
/// <summary> /// 加入房间 /// </summary> public KFCopyTeamJoinRsp JoinTeam(KFCopyTeamJoinReq req) { KFCopyTeamJoinRsp rsp = new KFCopyTeamJoinRsp(); try { lock (Mutex) { // 这里有个很微妙的情况,因为加入队伍时,首先GameServer要检查 // 但是如果GameServer重启了,那么必然能通过检查,但是其实在中心上已经为该角色加入了一个队伍,必须强制踢掉 ForceLeaveRoom(req.Member.RoleID); CopyTeamData td = null; if (!CopyTeamDict.TryGetValue(req.TeamId, out td)) { // 房间不存在!!! GameServer要检查这个错误码,可能出现的情况是 跨服中心重启了,那么GameServer要把这个房间清掉 rsp.ErrorCode = CopyTeamErrorCodes.TeamIsDestoryed; return(rsp); } if (td.StartTime > 0) { // 房间已经开始了 rsp.ErrorCode = CopyTeamErrorCodes.TeamAlreadyStart; return(rsp); } // 擦,写死了5个人 if (td.MemberCount >= ConstData.CopyRoleMax(req.CopyId)) { rsp.ErrorCode = CopyTeamErrorCodes.TeamIsFull; return(rsp); } req.Member.IsReady = false; td.TeamRoles.Add(req.Member); td.MemberCount = td.TeamRoles.Count; RoleId2JoinedTeam[req.Member.RoleID] = td.TeamID; // 异步广播加入队伍的事件 CopyTeamJoinData data = new CopyTeamJoinData(); data.Member = req.Member; data.TeamId = req.TeamId; AsyncDataItem evItem = new AsyncDataItem(); evItem.EventType = KuaFuEventTypes.KFCopyTeamJoin; evItem.Args = new object[2] { req.Member.ServerId, data }; AddAsyncEvent(evItem); rsp.ErrorCode = CopyTeamErrorCodes.Success; rsp.Data = data; } } catch (Exception ex) { LogManager.WriteLog(LogTypes.Error, string.Format("加入跨服副本队伍异常, serverid={0}, role={1}, teamid={2}", req.Member.ServerId, req.Member.RoleID, req.TeamId), ex); rsp.ErrorCode = CopyTeamErrorCodes.CenterServerFailed; } return(rsp); }