예제 #1
0
        public List <IPOperaData> GetIPStatisticsResult(int serverId)
        {
            List <IPOperaData> result;

            if (!ClientAgentManager.Instance().ExistAgent(serverId))
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("GetIPStatisticsResult时ServerId错误.ServerId:{0},roleId:{1}", serverId), null, true);
                result = null;
            }
            else
            {
                List <IPOperaData> list = null;
                lock (IPStatisticsService.dictIPOperaData)
                {
                    if (IPStatisticsService.dictIPOperaData.TryGetValue(serverId, out list))
                    {
                        return(list);
                    }
                }
                result = list;
            }
            return(result);
        }
예제 #2
0
        private int ChangeRoleState(KuaFuRoleData kuaFuRoleData, KuaFuRoleStates state)
        {
            int result = -1;

            try
            {
                KuaFuRoleData roleData  = null;
                int           oldGameId = 0;
                lock (kuaFuRoleData)
                {
                    kuaFuRoleData.Age++;
                    kuaFuRoleData.State = state;
                    if (state == KuaFuRoleStates.None && kuaFuRoleData.GameId > 0)
                    {
                        oldGameId = kuaFuRoleData.GameId;
                    }
                    roleData = kuaFuRoleData;
                }
                if (oldGameId > 0)
                {
                    this.RemoveRoleFromFuBen(oldGameId, kuaFuRoleData.RoleId);
                }
                if (null != roleData)
                {
                    AsyncDataItem evItem = new AsyncDataItem(KuaFuEventTypes.RoleStateChange, new object[]
                    {
                        kuaFuRoleData
                    });
                    ClientAgentManager.Instance().PostAsyncEvent(kuaFuRoleData.ServerId, this.GameType, evItem);
                }
            }
            catch (Exception ex)
            {
                return(-1);
            }
            return(result);
        }
예제 #3
0
        private void MS_PkLoopEnd_Update(DateTime now)
        {
            ZhengBaMatchConfig matchConfig = this._Config.MatchConfigList.Find((ZhengBaMatchConfig _m) => _m.Day == this.SyncData.RealActDay);

            if (this.StateMachine.ContinueTicks(now) >= (long)matchConfig.IntervalSeconds * 10000000L)
            {
                foreach (KeyValuePair <int, ZhengBaPkLogData> kvp in this.ThisLoopPkLogs)
                {
                    kvp.Value.PkResult = 0;
                    kvp.Value.UpGrade  = false;
                    kvp.Value.EndTime  = now;
                    this.Persistence.SavePkLog(kvp.Value);
                    this.AsyncEvQ.Enqueue(new AsyncDataItem(KuaFuEventTypes.ZhengBaPkLog, new object[]
                    {
                        kvp.Value
                    }));
                }
                this.ThisLoopPkLogs.Clear();
                foreach (ZhengBaManagerK.JoinRolePkData role in this.TodayJoinRoleDatas)
                {
                    if (role.CurrGameID > 0 || role.ToServerID > 0)
                    {
                        ClientAgentManager.Instance().RemoveKfFuben(TianTiService.Instance.GameType, role.ToServerID, (long)role.CurrGameID);
                    }
                    role.ToServerID = 0;
                    role.CurrGameID = 0;
                }
                if (now.TimeOfDay.Ticks >= matchConfig.DayEndTick)
                {
                    this.StateMachine.SetCurrState(ZhengBaStateMachine.StateType.TodayPkEnd, now);
                }
                else
                {
                    this.StateMachine.SetCurrState(ZhengBaStateMachine.StateType.InitPkLoop, now);
                }
            }
        }
예제 #4
0
 private void NotifyFuBenRoleEnterGame(TianTiFuBenData fuBenData)
 {
     try
     {
         lock (fuBenData)
         {
             foreach (KuaFuFuBenRoleData role in fuBenData.RoleDict.Values)
             {
                 KuaFuRoleData kuaFuRoleData;
                 if (this.RoleIdKuaFuRoleDataDict.TryGetValue(KuaFuRoleKey.Get(role.ServerId, role.RoleId), out kuaFuRoleData) && kuaFuRoleData.State == KuaFuRoleStates.NotifyEnterGame)
                 {
                     AsyncDataItem evItem = new AsyncDataItem(KuaFuEventTypes.UpdateAndNotifyEnterGame, new object[]
                     {
                         kuaFuRoleData
                     });
                     ClientAgentManager.Instance().PostAsyncEvent(kuaFuRoleData.ServerId, this.GameType, evItem);
                 }
             }
         }
     }
     catch (Exception ex)
     {
     }
 }
예제 #5
0
 public int CanEnterKuaFuMap(int roleId, int lingDiType)
 {
     lock (this.Mutex)
     {
         if (lingDiType == 0 && this.RoleNumDiGong >= this.RoleNumMax)
         {
             return(-10);
         }
         if (lingDiType == 1 && this.RoleNumHuangMo >= this.RoleNumMax)
         {
             return(-10);
         }
         if (this.KfServerId <= 0)
         {
             int kfserverId = 0;
             if (!ClientAgentManager.Instance().SpecialKfFuben(GameTypes.LingDiCaiJi, 0L, this.RoleNumMax, out kfserverId))
             {
                 LogManager.WriteLog(LogTypes.Error, string.Format("LingDiCaiJi分配跨服地图失败,error={0}", kfserverId), null, true);
                 return(-1);
             }
             this.KfServerId = kfserverId;
         }
         if (this.KfServerId != 0)
         {
             if (lingDiType == 0)
             {
                 this.RoleNumDiGong++;
             }
             else
             {
                 this.RoleNumHuangMo++;
             }
         }
     }
     return(this.KfServerId);
 }
예제 #6
0
 public void PlatFormChat(int serverId, byte[] bytes)
 {
     try
     {
         AsyncDataItem evItem = new AsyncDataItem(KuaFuEventTypes.PlatFormChat, new object[]
         {
             bytes
         });
         HashSet <int> SpecialLineSet = new HashSet <int>();
         lock (this.Mutex)
         {
             foreach (KeyValuePair <int, List <RebornBossConfig> > item in this.RebornBossConfigDict)
             {
                 List <KuaFuLineData> lineList = KuaFuServerManager.GetKuaFuLineDataList(item.Key);
                 if (null != lineList)
                 {
                     foreach (KuaFuLineData line in lineList)
                     {
                         SpecialLineSet.Add(line.ServerId);
                     }
                 }
             }
         }
         foreach (int lineServerId in SpecialLineSet)
         {
             if (serverId != lineServerId)
             {
                 ClientAgentManager.Instance().PostAsyncEvent(lineServerId, this.EvItemGameType, evItem);
             }
         }
     }
     catch (Exception ex)
     {
         LogManager.WriteException(ex.ToString());
     }
 }
예제 #7
0
        private bool AssignGameFuben(KuaFuRoleData kuaFuRoleData, long waitSecs1, long waitSecs2, DateTime now)
        {
            int      roleCount    = 0;
            DateTime stateEndTime = now.AddSeconds((double)this.EnterGameSecs);
            HuanYingSiYuanFuBenData selectFuben        = null;
            KuaFuFuBenRoleData      kuaFuFuBenRoleData = new KuaFuFuBenRoleData
            {
                ServerId  = kuaFuRoleData.ServerId,
                RoleId    = kuaFuRoleData.RoleId,
                ZhanDouLi = kuaFuRoleData.GameData.ZhanDouLi
            };

            try
            {
                foreach (HuanYingSiYuanFuBenData tmpFuben in this.ShotOfRolesFuBenDataDict.Values)
                {
                    if (tmpFuben.CanRemove())
                    {
                        this.RemoveGameFuBen(tmpFuben);
                    }
                    else if (tmpFuben.CanEnter(kuaFuRoleData.GroupIndex, waitSecs1, waitSecs2))
                    {
                        if (ClientAgentManager.Instance().IsAgentAlive(tmpFuben.ServerId))
                        {
                            roleCount = tmpFuben.AddKuaFuFuBenRoleData(kuaFuFuBenRoleData, new GameFuBenRoleCountChanged(this.GameFuBenRoleCountChangedHandler));
                            if (roleCount > 0)
                            {
                                selectFuben = tmpFuben;
                                break;
                            }
                        }
                    }
                }
                if (null == selectFuben)
                {
                    int gameId  = this.Persistence.GetNextGameId();
                    int kfSrvId = 0;
                    if (ClientAgentManager.Instance().AssginKfFuben(this.GameType, (long)gameId, 1, out kfSrvId))
                    {
                        selectFuben            = new HuanYingSiYuanFuBenData();
                        selectFuben.ServerId   = kfSrvId;
                        selectFuben.GameId     = gameId;
                        selectFuben.GroupIndex = kuaFuRoleData.GroupIndex;
                        selectFuben.EndTime    = Global.NowTime.AddMinutes(15.0);
                        this.AddGameFuBen(selectFuben);
                        roleCount = selectFuben.AddKuaFuFuBenRoleData(kuaFuFuBenRoleData, new GameFuBenRoleCountChanged(this.GameFuBenRoleCountChangedHandler));
                        this.Persistence.LogCreateHysyFuben(gameId, kfSrvId, 0, 1);
                    }
                }
                if (selectFuben != null && roleCount > 0)
                {
                    if (roleCount == 1)
                    {
                        selectFuben.EndTime = now;
                    }
                    if (selectFuben.State == GameFuBenState.Wait)
                    {
                        if (roleCount == Consts.HuanYingSiYuanRoleCountTotal)
                        {
                            List <KuaFuFuBenRoleData> roleList = selectFuben.SortFuBenRoleList();
                            foreach (KuaFuFuBenRoleData role in roleList)
                            {
                                KuaFuRoleKey  key = KuaFuRoleKey.Get(role.ServerId, role.RoleId);
                                KuaFuRoleData kuaFuRoleDataTemp;
                                if (this.RoleIdKuaFuRoleDataDict.TryGetValue(key, out kuaFuRoleDataTemp))
                                {
                                    kuaFuRoleDataTemp.UpdateStateTime(selectFuben.GameId, KuaFuRoleStates.NotifyEnterGame, stateEndTime.Ticks);
                                }
                            }
                            selectFuben.State = GameFuBenState.Start;
                            this.NotifyFuBenRoleEnterGame(selectFuben);
                        }
                        else
                        {
                            kuaFuRoleData.UpdateStateTime(selectFuben.GameId, KuaFuRoleStates.SignUpWaiting, kuaFuRoleData.StateEndTicks);
                            this.NotifyFuBenRoleCount(selectFuben);
                        }
                    }
                    else if (selectFuben.State == GameFuBenState.Start)
                    {
                        kuaFuRoleData.UpdateStateTime(selectFuben.GameId, KuaFuRoleStates.NotifyEnterGame, stateEndTime.Ticks);
                        this.NotifyFuBenRoleEnterGame(selectFuben);
                    }
                    return(true);
                }
                return(false);
            }
            catch (Exception ex)
            {
                LogManager.WriteExceptionUseCache(ex.ToString());
            }
            return(false);
        }
예제 #8
0
        /// <summary>
        /// 创建房间
        /// </summary>
        public KFCopyTeamCreateRsp CreateTeam(KFCopyTeamCreateReq req)
        {
            KFCopyTeamCreateRsp rsp = new KFCopyTeamCreateRsp();

            try
            {
                lock (Mutex)
                {
                    // 这里有个很微妙的情况,因为创建队伍时,首先GameServer要检查是否已经加入了一个队伍
                    // 但是如果GameServer重启了,那么必然能通过检查,但是其实在中心上已经为该角色加入了一个房间,必须强制踢掉
                    ForceLeaveRoom(req.Member.RoleID);

                    if (!ClientAgentManager.Instance().IsAnyKfAgentAlive())
                    {
                        rsp.ErrorCode = CopyTeamErrorCodes.KFServerIsBusy;
                        return(rsp);
                    }

                    // 房间数量和 跨服活动服务器负载的检查
                    KFTeamCountControl control = _KFCopyService.dbMgr.TeamControl;
                    if (control == null)
                    {
                        LogManager.WriteLog(LogTypes.Error, string.Format("跨服队伍创建失败,  丢失副本上线控制的配置文件 KFTeamCountControl"));
                        rsp.ErrorCode = CopyTeamErrorCodes.ServerException;
                        return(rsp);
                    }

                    HashSet <long> teamList = null;
                    if (!CopyId2Teams.TryGetValue(req.CopyId, out teamList))
                    {
                        teamList = new HashSet <long>();
                        CopyId2Teams[req.CopyId] = teamList;
                    }

                    CopyTeamData td = new CopyTeamData();
                    td.TeamID       = req.TeamId;
                    td.LeaderRoleID = req.Member.RoleID;
                    td.FuBenId      = req.CopyId;
                    td.MinZhanLi    = req.MinCombat;
                    td.AutoStart    = req.AutoStart > 0;
                    td.TeamRoles.Add(req.Member);
                    td.TeamRoles[0].IsReady = true;
                    td.TeamName             = td.TeamRoles[0].RoleName;
                    td.MemberCount          = td.TeamRoles.Count;

                    CopyTeamDict.Add(td.TeamID, td);
                    teamList.Add(td.TeamID);
                    TimeLimitCopy.Add(td.TeamID, TimeUtil.NOW() + control.TeamMaxWaitMinutes * 60 * 1000);

                    RoleId2JoinedTeam[req.Member.RoleID] = td.TeamID;

                    CopyTeamCreateData data = new CopyTeamCreateData();
                    data.Member    = req.Member;
                    data.MinCombat = req.MinCombat;
                    data.CopyId    = req.CopyId;
                    data.TeamId    = td.TeamID;
                    data.AutoStart = req.AutoStart;

                    // 异步广播创建房间的事件
                    AsyncDataItem evItem = new AsyncDataItem();
                    evItem.EventType = KuaFuEventTypes.KFCopyTeamCreate;
                    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}, copyid={2}", req.Member.ServerId, req.Member.RoleID, req.CopyId), ex);
                rsp.ErrorCode = CopyTeamErrorCodes.CenterServerFailed;
            }

            return(rsp);
        }
예제 #9
0
        /// <summary>
        /// 开始游戏
        /// </summary>
        public KFCopyTeamStartRsp StartGame(KFCopyTeamStartReq req)
        {
            KFCopyTeamStartRsp rsp = new KFCopyTeamStartRsp();

            try
            {
                lock (Mutex)
                {
                    CopyTeamData td = null;
                    if (!CopyTeamDict.TryGetValue(req.TeamId, out td))
                    {
                        rsp.ErrorCode = CopyTeamErrorCodes.TeamIsDestoryed;
                        return(rsp);
                    }

                    if (td.StartTime > 0)
                    {
                        rsp.ErrorCode = CopyTeamErrorCodes.TeamAlreadyStart;
                        return(rsp);
                    }

                    if (td.LeaderRoleID != req.RoleId)
                    {
                        rsp.ErrorCode = CopyTeamErrorCodes.NotTeamLeader;
                        return(rsp);
                    }

                    CopyTeamMemberData leader = td.TeamRoles.Find(_role => _role.RoleID == req.RoleId);
                    if (leader == null || leader.RoleID != req.RoleId)
                    {
                        rsp.ErrorCode = CopyTeamErrorCodes.NotTeamLeader;
                        return(rsp);
                    }

                    if (td.TeamRoles.Exists(_role => _role.IsReady == false))
                    {
                        rsp.ErrorCode = CopyTeamErrorCodes.MemeberNotReady;
                        return(rsp);
                    }

                    int kfSrvId;
                    if (!ClientAgentManager.Instance().AssginKfFuben(GameTypes.KuaFuCopy, td.TeamID, td.TeamRoles.Count, out kfSrvId))
                    {
                        rsp.ErrorCode = CopyTeamErrorCodes.KFServerIsBusy;
                        return(rsp);
                    }

                    td.StartTime  = TimeUtil.NOW();
                    td.KFServerId = kfSrvId;
                    td.FuBenSeqID = 0; // not set

                    CopyTeamStartData data = new CopyTeamStartData();
                    data.TeamId     = req.TeamId;
                    data.StartMs    = td.StartTime;
                    data.ToServerId = kfSrvId;
                    data.FuBenSeqId = td.FuBenSeqID;
                    AsyncDataItem evItem = new AsyncDataItem();
                    evItem.EventType = KuaFuEventTypes.KFCopyTeamStart;
                    evItem.Args      = new object[2] {
                        leader.ServerId, data
                    };
                    AddAsyncEvent(evItem);

                    // 副本超时强制关闭的时间  副本开始(客户端点击开始) + 副本持续时间 + 3分钟额外时间
                    TimeLimitCopy[td.TeamID] = td.StartTime + req.LastMs + 3 * 60 * 1000;
                    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);
        }
예제 #10
0
 private void Broadcast2GsAgent(AsyncDataItem item)
 {
     ClientAgentManager.Instance().BroadCastAsyncEvent(this.GameType, item, 0);
 }
예제 #11
0
        public int UnionDataChange(int serverID, AllyData newData)
        {
            if (!IsAgent(serverID)) return (int)EAlly.EServer;

            lock (_Mutex)
            {
                //获取老的数据,更新状态,logtime
                KFAllyData kfData = new KFAllyData();
                kfData.Copy(newData);
                kfData.LogTime = DateTime.Now;
                kfData.ServerID = serverID;
                kfData.UpdateLogtime();

                bool result = AllyPersistence.Instance.DBUnionDataUpdate(kfData);
                if (!result) return (int)EAlly.EFail;

                KFAllyData oldData;
                if (_unionDic.TryGetValue(kfData.UnionID, out oldData))
                    _unionDic[kfData.UnionID] = kfData;
                else
                    _unionDic.TryAdd(kfData.UnionID, kfData);             

                //结盟数据
                List<int> oldAllyIDList;
                if (_allyDic.TryGetValue(kfData.UnionID, out oldAllyIDList))
                {
                    AllyData myData = new AllyData();
                    myData.Copy(kfData);
                    myData.LogState = (int)EAlly.AllyAgree;

                    foreach (int id in oldAllyIDList)
                    {
                        KFAllyData targetData = GetUnionData(id);
                        if (IsAgent(targetData.ServerID))
                            ClientAgentManager.Instance().PostAsyncEvent(targetData.ServerID, _gameType, new AsyncDataItem(KuaFuEventTypes.AllyUnionUpdate, targetData.UnionID, myData));
                    }
                }

                AllyData myData2 = new AllyData();
                myData2.Copy(kfData);
                myData2.LogState = (int)EAlly.AllyRequestSucc;
                //结盟请求
                List<KFAllyData> rList = null;
                if (_requestDic.TryGetValue(kfData.UnionID, out rList))
                {     
                    foreach (KFAllyData targetData in rList)
                    {
                        List<KFAllyData> raList = null;
                        if (IsAgent(targetData.ServerID) && _acceptDic.TryGetValue(targetData.UnionID, out raList))
                        {
                            KFAllyData oldAData = GetAcceptData(targetData.UnionID, kfData.UnionID);
                            if (oldAData != null)
                            {
                                raList.Remove(oldAData);
                                raList.Add(kfData);
                                ClientAgentManager.Instance().PostAsyncEvent(targetData.ServerID, _gameType, new AsyncDataItem(KuaFuEventTypes.AllyUnionUpdate, targetData.UnionID, myData2));
                            }
                        } 
                    }
                }

                //接受请求
                List<KFAllyData> aList = null;
                if (_acceptDic.TryGetValue(kfData.UnionID, out aList))
                {
                    foreach (KFAllyData targetData in aList)
                    {
                        List<KFAllyData> arList = null;
                        if (IsAgent(targetData.ServerID) && _requestDic.TryGetValue(targetData.UnionID, out arList))
                        {
                            KFAllyData oldRData = GetRequestData(targetData.UnionID, kfData.UnionID);
                            if (oldRData != null)
                            {
                                arList.Remove(oldRData);
                                arList.Add(kfData);
                                ClientAgentManager.Instance().PostAsyncEvent(targetData.ServerID, _gameType, new AsyncDataItem(KuaFuEventTypes.AllyUnionUpdate, targetData.UnionID, myData2));
                            }
                        }
                    }
                }

                return (int)EAlly.Succ;
            }
        }
예제 #12
0
 public void RemoveGameTeam(int kfSrvId, long teamId)
 {
     ClientAgentManager.Instance().RemoveKfFuben(this.GameType, kfSrvId, teamId);
 }
예제 #13
0
        public KFCopyTeamCreateRsp CreateTeam(KFCopyTeamCreateReq req)
        {
            KFCopyTeamCreateRsp rsp = new KFCopyTeamCreateRsp();

            try
            {
                lock (this.Mutex)
                {
                    this.ForceLeaveRoom(req.Member.RoleID);
                    if (!ClientAgentManager.Instance().IsAnyKfAgentAlive())
                    {
                        rsp.ErrorCode = CopyTeamErrorCodes.KFServerIsBusy;
                        return(rsp);
                    }
                    KFTeamCountControl control = this._KFCopyService.dbMgr.TeamControl;
                    if (control == null)
                    {
                        LogManager.WriteLog(LogTypes.Error, string.Format("跨服队伍创建失败,  丢失副本上线控制的配置文件 KFTeamCountControl", new object[0]), null, true);
                        rsp.ErrorCode = CopyTeamErrorCodes.ServerException;
                        return(rsp);
                    }
                    HashSet <long> teamList = null;
                    if (!this.CopyId2Teams.TryGetValue(req.CopyId, out teamList))
                    {
                        teamList = new HashSet <long>();
                        this.CopyId2Teams[req.CopyId] = teamList;
                    }
                    CopyTeamData td = new CopyTeamData();
                    td.TeamID       = req.TeamId;
                    td.LeaderRoleID = req.Member.RoleID;
                    td.FuBenId      = req.CopyId;
                    td.MinZhanLi    = req.MinCombat;
                    td.AutoStart    = (req.AutoStart > 0);
                    td.AutoKick     = req.AutoKick;
                    td.TeamRoles.Add(req.Member);
                    td.TeamRoles[0].IsReady = true;
                    td.TeamName             = td.TeamRoles[0].RoleName;
                    td.MemberCount          = td.TeamRoles.Count;
                    this.CopyTeamDict.Add(td.TeamID, td);
                    teamList.Add(td.TeamID);
                    this.TimeLimitCopy.Add(td.TeamID, TimeUtil.NOW() + (long)(control.TeamMaxWaitMinutes * 60 * 1000));
                    this.RoleId2JoinedTeam[req.Member.RoleID] = td.TeamID;
                    CopyTeamCreateData data = new CopyTeamCreateData();
                    data.Member    = req.Member;
                    data.MinCombat = req.MinCombat;
                    data.CopyId    = req.CopyId;
                    data.TeamId    = td.TeamID;
                    data.AutoStart = req.AutoStart;
                    data.AutoKick  = req.AutoKick;
                    this.AddAsyncEvent(new AsyncDataItem
                    {
                        EventType = KuaFuEventTypes.KFCopyTeamCreate,
                        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}, copyid={2}", req.Member.ServerId, req.Member.RoleID, req.CopyId), ex, true);
                rsp.ErrorCode = CopyTeamErrorCodes.CenterServerFailed;
            }
            return(rsp);
        }
예제 #14
0
        private bool AssignGameFuben(KuaFuRoleData kuaFuRoleData, RangeKey range, DateTime now)
        {
            int             roleCount       = 0;
            DateTime        stateEndTime    = now.AddSeconds(EnterGameSecs);
            TianTiFuBenData tianTiFuBenData = null;

            KuaFuFuBenRoleData kuaFuFuBenRoleData = new KuaFuFuBenRoleData()
            {
                ServerId = kuaFuRoleData.ServerId,
                RoleId   = kuaFuRoleData.RoleId,
            };

            List <KuaFuRoleData> updateRoleDataList = new List <KuaFuRoleData>();

            if (!ProcessTianTiFuBenDataDict.TryGetValue(range, out tianTiFuBenData))
            {
                tianTiFuBenData = new TianTiFuBenData();
                ProcessTianTiFuBenDataDict.Add(range, tianTiFuBenData);
            }
            else if (!CanAddFuBenRole(tianTiFuBenData, kuaFuRoleData))
            {
                return(true);
            }

            roleCount = tianTiFuBenData.AddKuaFuFuBenRoleData(kuaFuFuBenRoleData);
            if (roleCount < Consts.TianTiRoleCountTotal)
            {
                return(true);
            }

            try
            {
                int  kfSrvId       = 0;
                int  gameId        = Persistence.GetNextGameId();
                bool createSuccess = ClientAgentManager.Instance().AssginKfFuben(GameType, gameId, roleCount, out kfSrvId);
                if (createSuccess)
                {
                    tianTiFuBenData.ServerId = kfSrvId;
                    tianTiFuBenData.GameId   = gameId;
                    tianTiFuBenData.EndTime  = Global.NowTime.AddMinutes(Consts.TianTiGameFuBenMaxExistMinutes);
                    AddGameFuBen(tianTiFuBenData);

                    Persistence.LogCreateTianTiFuBen(tianTiFuBenData.GameId, tianTiFuBenData.ServerId, 0, roleCount);

                    foreach (var role in tianTiFuBenData.RoleDict.Values)
                    {
                        KuaFuRoleData kuaFuRoleDataTemp;
                        KuaFuRoleKey  key = KuaFuRoleKey.Get(role.ServerId, role.RoleId);
                        if (RoleIdKuaFuRoleDataDict.TryGetValue(key, out kuaFuRoleDataTemp))
                        {
                            kuaFuRoleDataTemp.UpdateStateTime(tianTiFuBenData.GameId, KuaFuRoleStates.NotifyEnterGame, stateEndTime.Ticks);
                        }
                    }

                    tianTiFuBenData.State = GameFuBenState.Start;
                    NotifyFuBenRoleEnterGame(tianTiFuBenData);

                    ProcessTianTiFuBenDataDict.Remove(range);
                }
                else
                {
                    //如果分配失败,则返回false,本轮不在尝试分配
                    return(false);
                }

                return(true);
            }
            catch (System.Exception ex)
            {
                LogManager.WriteExceptionUseCache(ex.ToString());
            }

            return(false);
        }
예제 #15
0
        public void ThreadProc(object state)
        {
            Persistence.InitConfig();
            ZhengBaManagerK.Instance().InitConfig();
            DateTime lastRunTime = TimeUtil.NowDateTime();

            Persistence.LoadTianTiRankData(lastRunTime);
            ZhengBaManagerK.Instance().ReloadSyncData(lastRunTime);
            CoupleArenaService.getInstance().StartUp();
            CoupleWishService.getInstance().StartUp();

            do
            {
                try
                {
                    DateTime now = TimeUtil.NowDateTime();
                    Global.UpdateNowTime(now);

                    //处理游戏逻辑
                    if (now > CheckRoleTimerProcTime)
                    {
                        CheckRoleTimerProcTime = now.AddSeconds(CheckRoleTimerProcInterval);
                        int signUpCnt, startCnt;
                        CheckRoleTimerProc(now, out signUpCnt, out startCnt);
                        ClientAgentManager.Instance().SetGameTypeLoad(GameType, signUpCnt, startCnt);
                    }

                    if (now > SaveServerStateProcTime)
                    {
                        SaveServerStateProcTime = now.AddSeconds(SaveServerStateProcInterval);

                        if (now.Hour >= 3 && now.Hour < 4)
                        {
                            ClearRolePairFightCount();
                            Persistence.UpdateTianTiRankData(now);
                        }
                    }

                    if (now > CheckGameFuBenTime)
                    {
                        CheckGameFuBenTime = now.AddSeconds(CheckGameFuBenInterval);
                        CheckGameFuBenTimerProc(now);
                    }

                    AsyncDataItem[] asyncEvArray = ZhengBaManagerK.Instance().Update();
                    ClientAgentManager.Instance().BroadCastAsyncEvent(GameType, asyncEvArray);

                    Persistence.WriteRoleInfoDataProc();

                    CoupleArenaService.getInstance().Update();
                    CoupleWishService.getInstance().Update();

                    int sleepMS = (int)((TimeUtil.NowDateTime() - now).TotalMilliseconds);
                    Persistence.SaveCostTime(sleepMS);
                    sleepMS = 1000 - sleepMS; //最大睡眠1000ms,最少睡眠50ms
                    if (sleepMS < 50)
                    {
                        sleepMS = 50;
                    }

                    Thread.Sleep(sleepMS);
                }
                catch (System.Exception ex)
                {
                    LogManager.WriteExceptionUseCache(ex.ToString());
                }
            } while (true);
        }
예제 #16
0
        public static bool UpdateDataFromServer()
        {
            if (Monitor.TryEnter(MutexServerList))
            {
                try
                {
                    int nextServerListAge       = DataHelper2.UnixSecondsNow();
                    int nextServerGameConfigAge = DataHelper2.UnixSecondsNow();
                    if (Math.Abs(nextServerListAge - _ServerListAge) < 3)
                    {
                        return(false);
                    }

                    if (!LoadConfigFromServer)
                    {
                        return(false);
                    }

                    //确认是否配置了获取接口地址
                    if (string.IsNullOrEmpty(KuaFuServerListUrl) || string.IsNullOrEmpty(ServerListUrl))
                    {
                        return(false);
                    }

                    //首先获取普通服务器列表
                    //1其次获取跨服活动服务器列表
                    ClientServerListData clientListData = new ClientServerListData();
                    clientListData.lTime  = TimeUtil.NOW();
                    clientListData.strMD5 = MD5Helper.get_md5_string(ConstData.HTTP_MD5_KEY + clientListData.lTime.ToString());
                    byte[] clientBytes  = DataHelper2.ObjectToBytes <ClientServerListData>(clientListData);
                    byte[] responseData = WebHelper.RequestByPost(ServerListUrl, clientBytes, 2000, 30000);
                    if (responseData == null)
                    {
                        return(false);
                    }

                    bool               serverInfoChanged = false;
                    HashSet <int>      existAllIds       = new HashSet <int>();
                    HashSet <int>      existKfIds        = new HashSet <int>();
                    BuffServerListData serverListResponseData;
                    BuffServerListData kuaFuServerListResponseData;
                    serverListResponseData = DataHelper2.BytesToObject <BuffServerListData>(responseData, 0, responseData.Length);
                    if (null == serverListResponseData || null == serverListResponseData.listServerData || serverListResponseData.listServerData.Count == 0)
                    {
                        return(false);
                    }

                    //其次获取跨服活动服务器列表
                    clientListData        = new ClientServerListData();
                    clientListData.lTime  = TimeUtil.NOW();
                    clientListData.strMD5 = MD5Helper.get_md5_string(ConstData.HTTP_MD5_KEY + clientListData.lTime.ToString());
                    clientBytes           = DataHelper2.ObjectToBytes <ClientServerListData>(clientListData);
                    responseData          = WebHelper.RequestByPost(KuaFuServerListUrl, clientBytes, 2000, 30000);
                    if (responseData == null)
                    {
                        return(false);
                    }

                    kuaFuServerListResponseData = DataHelper2.BytesToObject <BuffServerListData>(responseData, 0, responseData.Length);
                    if (null == kuaFuServerListResponseData || null == kuaFuServerListResponseData.listServerData || kuaFuServerListResponseData.listServerData.Count == 0)
                    {
                        return(false);
                    }

                    if (null != serverListResponseData && null != serverListResponseData.listServerData)
                    {
                        lock (Mutex)
                        {
                            foreach (var item in serverListResponseData.listServerData)
                            {
                                existAllIds.Add(item.nServerID);
                                KuaFuServerInfo data;
                                if (UpdateServerInfo(item, _ServerListAge, ServerFlags.NormalServer, out data, _ServerIdServerInfoDict))
                                {
                                    serverInfoChanged = true;
                                }
                            }
                        }
                    }

                    if (null != kuaFuServerListResponseData && null != kuaFuServerListResponseData.listServerData)
                    {
                        lock (Mutex)
                        {
                            foreach (var item in kuaFuServerListResponseData.listServerData)
                            {
                                existAllIds.Add(item.nServerID);
                                KuaFuServerInfo data;
                                if (UpdateServerInfo(item, _ServerListAge, ServerFlags.KuaFuServer, out data, _ServerIdServerInfoDict))
                                {
                                    serverInfoChanged = true;
                                }
                            }

                            foreach (var id in _ServerIdServerInfoDict.Keys)
                            {
                                if (!existAllIds.Contains(id))
                                {
                                    RemoveServerInfo(id, _ServerIdServerInfoDict);
                                    serverInfoChanged = true;
                                }
                            }

                            if (serverInfoChanged)
                            {
                                _ServerListAge = nextServerListAge;
                            }

                            //默认所有跨服服务器都允许分配幻影寺院活动
                            foreach (var item in _ServerIdServerInfoDict.Values)
                            {
                                if ((item.Flags & ServerFlags.KuaFuServer) > 0)
                                {
                                    existKfIds.Add(item.ServerId);
                                }

                                item.Age = _ServerListAge;
                            }
                        }
                    }

                    ClientAgentManager.Instance().SetAllKfServerId(existKfIds);
                }
                catch (System.Exception ex)
                {
                    LogManager.WriteExceptionUseCache(ex.ToString());
                    return(false);
                }
                finally
                {
                    Monitor.Exit(MutexServerList);
                }
            }

            return(true);
        }
예제 #17
0
        private static void AsyncFromDataBase()
        {
            try
            {
                //刷新服务器列表
                object ageObj = DbHelperMySQL.GetSingle("select value from t_async where id = 1");
                if (null != ageObj)
                {
                    int age = (int)ageObj;
                    if (age > _ServerListAge)
                    {
                        HashSet <int> existAllIds = new HashSet <int>();
                        HashSet <int> existKfIds  = new HashSet <int>();

                        MySqlDataReader sdr = DbHelperMySQL.ExecuteReader("select * from t_server_info");
                        while (sdr.Read())
                        {
                            try
                            {
                                KuaFuServerInfo serverInfo = new KuaFuServerInfo()
                                {
                                    ServerId  = (int)Convert.ToInt32(sdr["serverid"]),
                                    Ip        = sdr["ip"].ToString(),
                                    Port      = (int)Convert.ToInt32(sdr["port"]),
                                    DbIp      = sdr["dbip"].ToString(),
                                    DbPort    = (int)Convert.ToInt32(sdr["dbport"]),
                                    LogDbIp   = sdr["logdbip"].ToString(),
                                    LogDbPort = (int)Convert.ToInt32(sdr["logdbport"]),
                                    State     = (int)Convert.ToInt32(sdr["state"]),
                                    //Load = (int)Convert.ToInt32(sdr["load"]),
                                    Flags = (int)Convert.ToInt32(sdr["flags"]),
                                    Age   = age,
                                };


                                _ServerIdServerInfoDict[serverInfo.ServerId] = serverInfo;
                                existAllIds.Add(serverInfo.ServerId);

                                if ((serverInfo.Flags & ServerFlags.KuaFuServer) != 0)
                                {
                                    existKfIds.Add(serverInfo.ServerId);
                                }
                            }
                            catch (System.Exception ex)
                            {
                                LogManager.WriteExceptionUseCache(ex.ToString());
                            }
                        }

                        sdr.Close();

                        lock (Mutex)
                        {
                            foreach (var id in _ServerIdServerInfoDict.Keys.ToList())
                            {
                                if (!existAllIds.Contains(id))
                                {
                                    KuaFuServerInfo tmp;
                                    _ServerIdServerInfoDict.TryRemove(id, out tmp);
                                }
                            }

                            _ServerListAge = age;
                        }

                        ClientAgentManager.Instance().SetAllKfServerId(existKfIds);
                    }
                }
            }
            catch (Exception ex)
            {
                LogManager.WriteExceptionUseCache(ex.ToString());
            }
        }
예제 #18
0
        //Agree
        public int OperateAgree(int serverID, int unionID, int targetID)
        {
            lock (_Mutex)
            {
                KFAllyData targetData = GetUnionData(targetID);
                if (targetData == null) return (int)EAlly.ENoTargetUnion;

                if (!UnionIsAccept(unionID, targetID)) return (int)EAlly.EFail;
                if (!UnionIsRequest(targetID, unionID)) return (int)EAlly.EFail;

                //num
                int sum = _allyDic[unionID].Count + _requestDic[unionID].Count;
                if (sum >= Consts.AllyNumMax) return (int)EAlly.EAllyMax;

                DateTime logTime = DateTime.Now;
                int logState = (int)EAlly.AllyAgree;

                bool isDB = AllyPersistence.Instance.DBAllyRequestDel(targetID, unionID);
                if (!isDB) return (int)EAlly.EFail;

                isDB = AllyPersistence.Instance.DBAllyAdd(unionID, targetID, logTime);
                if (!isDB) return (int)EAlly.EFail;

                //my
                KFAllyData aData = GetAcceptData(unionID, targetID);
                _acceptDic[unionID].Remove(aData);
                ClientAgentManager.Instance().PostAsyncEvent(serverID, _gameType, new AsyncDataItem(KuaFuEventTypes.AllyAcceptRemove, unionID, targetID));

                _allyDic[unionID].Add(targetID);
                aData.LogTime = logTime;
                aData.LogState = logState;

                AllyData clientMy = new AllyData();
                clientMy.Copy(aData);
                ClientAgentManager.Instance().PostAsyncEvent(serverID, _gameType, new AsyncDataItem(KuaFuEventTypes.Ally, unionID, clientMy, false));

                //target
                if (_requestDic.ContainsKey(targetID))
                {
                    KFAllyData rData = GetRequestData(targetID, unionID);
                    _requestDic[targetID].Remove(rData);
                }

                if (_allyDic.ContainsKey(targetID)) _allyDic[targetID].Add(unionID);

                KFAllyData myData = GetUnionData(unionID);
                myData.LogTime = logTime;
                myData.LogState = logState;

                AllyLogData logData = new AllyLogData();
                logData.UnionID = myData.UnionID;
                logData.UnionZoneID = myData.UnionZoneID;
                logData.UnionName = myData.UnionName;
                logData.MyUnionID = targetID;
                logData.LogTime = logTime;
                logData.LogState = (int)EAlly.AllyAgreeOther;

                AllyData clientTarget = new AllyData();
                clientTarget.Copy(myData);

                if (IsAgent(targetData.ServerID))
                {                             
                    ClientAgentManager.Instance().PostAsyncEvent(targetData.ServerID, _gameType, new AsyncDataItem(KuaFuEventTypes.Ally, targetID, clientTarget, true));
                    ClientAgentManager.Instance().PostAsyncEvent(targetData.ServerID, _gameType, new AsyncDataItem(KuaFuEventTypes.AllyRequestRemove, targetID, unionID));
                    ClientAgentManager.Instance().PostAsyncEvent(targetData.ServerID, _gameType, new AsyncDataItem(KuaFuEventTypes.AllyLog, targetID, new List<AllyLogData>() { logData }));
                }
                else
                {
                    AllyPersistence.Instance.DBAllyLogAdd(logData);
                }

                ClientAgentManager.Instance().KFBroadCastAsyncEvent(_gameType, new AsyncDataItem(KuaFuEventTypes.KFAlly, clientMy, clientTarget));
                return (int)EAlly.AllyAgree;
            }
        }
예제 #19
0
        public AllyData AllyRequest(int serverID, int unionID, int zoneID, string unionName)
        {
            lock (_Mutex)
            {
                AllyData clientRequest = new AllyData();
                if (!IsAgent(serverID))
                {
                    clientRequest.LogState = (int)EAlly.EServer;
                    return clientRequest;
                }

                KFAllyData targetData = GetUnionData(zoneID, unionName);
                if (targetData == null)
                {
                    clientRequest.LogState = (int)EAlly.EName;
                    return clientRequest;
                }

                InitAllyIDList(targetData.UnionID);
                InitAllyRequestList(targetData.UnionID);
                InitAllyAcceptList(targetData.UnionID);

                if (UnionIsAlly(unionID, targetData.UnionID))
                {
                    clientRequest.LogState = (int)EAlly.EIsAlly;
                    return clientRequest;
                }

                if (UnionIsRequest(unionID, targetData.UnionID) || UnionIsAccept(targetData.UnionID, unionID))
                {
                    clientRequest.LogState = (int)EAlly.EMore;
                    return clientRequest;
                }

                int sum = _allyDic[unionID].Count + _requestDic[unionID].Count;
                if (sum >= Consts.AllyNumMax)
                {
                    clientRequest.LogState = (int)EAlly.EAllyMax;
                    return clientRequest;
                }

                DateTime logTime = DateTime.Now;
                int logState = (int)EAlly.AllyRequestSucc;
                bool isAdd = AllyPersistence.Instance.DBAllyRequestAdd(unionID, targetData.UnionID, logTime, logState);
                if (!isAdd)
                {
                    clientRequest.LogState = (int)EAlly.EAllyRequest;
                    return clientRequest;
                }
                //my
                KFAllyData myData = GetUnionData(unionID);

                AllyLogData logData = new AllyLogData();
                logData.UnionID = targetData.UnionID;
                logData.UnionZoneID = targetData.UnionZoneID;
                logData.UnionName = targetData.UnionName;
                logData.MyUnionID = unionID;
                logData.LogTime = logTime;
                logData.LogState = logState;
                ClientAgentManager.Instance().PostAsyncEvent(serverID, _gameType, new AsyncDataItem(KuaFuEventTypes.AllyLog, unionID, new List<AllyLogData>() { logData }));


                KFAllyData requestData = new KFAllyData();
                requestData.Copy(targetData);
                requestData.LogState = logState;
                requestData.LogTime = logTime;
                requestData.UpdateLogtime();

                AllyRequestAdd(unionID, requestData);

                clientRequest.Copy(requestData);
                // ClientAgentManager.Instance().PostAsyncEvent(serverID, _gameType, new AsyncDataItem(KuaFuEventTypes.AllyRequest, unionID, clientRequest));

                //target
                KFAllyData acceptData = new KFAllyData();
                acceptData.Copy(myData);
                acceptData.LogState = logState;
                acceptData.LogTime = logTime;
                AllyAcceptAdd(targetData.UnionID, acceptData);

                if (IsAgent(targetData.ServerID))
                {
                    AllyData clientAccept = new AllyData();
                    clientAccept.Copy(acceptData);
                    ClientAgentManager.Instance().PostAsyncEvent(targetData.ServerID, _gameType, new AsyncDataItem(KuaFuEventTypes.AllyAccept, targetData.UnionID, clientAccept));
                }

                return clientRequest;
            }
        }
예제 #20
0
        public KFCopyTeamStartRsp StartGame(KFCopyTeamStartReq req)
        {
            KFCopyTeamStartRsp rsp = new KFCopyTeamStartRsp();

            try
            {
                lock (this.Mutex)
                {
                    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.LeaderRoleID != req.RoleId)
                    {
                        rsp.ErrorCode = CopyTeamErrorCodes.NotTeamLeader;
                        return(rsp);
                    }
                    CopyTeamMemberData leader = td.TeamRoles.Find((CopyTeamMemberData _role) => _role.RoleID == td.LeaderRoleID);
                    if (leader == null || leader.RoleID != req.RoleId)
                    {
                        rsp.ErrorCode = CopyTeamErrorCodes.NotTeamLeader;
                        return(rsp);
                    }
                    if (td.TeamRoles.Exists((CopyTeamMemberData _role) => !_role.IsReady))
                    {
                        rsp.ErrorCode = CopyTeamErrorCodes.MemeberNotReady;
                        return(rsp);
                    }
                    int kfSrvId;
                    if (!ClientAgentManager.Instance().AssginKfFuben(GameTypes.KuaFuCopy, td.TeamID, td.TeamRoles.Count, out kfSrvId))
                    {
                        rsp.ErrorCode = CopyTeamErrorCodes.KFServerIsBusy;
                        return(rsp);
                    }
                    td.StartTime  = TimeUtil.NOW();
                    td.KFServerId = kfSrvId;
                    td.FuBenSeqID = 0;
                    CopyTeamStartData data = new CopyTeamStartData();
                    data.TeamId     = req.TeamId;
                    data.StartMs    = td.StartTime;
                    data.ToServerId = kfSrvId;
                    data.FuBenSeqId = td.FuBenSeqID;
                    this.AddAsyncEvent(new AsyncDataItem
                    {
                        EventType = KuaFuEventTypes.KFCopyTeamStart,
                        Args      = new object[]
                        {
                            leader.ServerId,
                            data
                        }
                    });
                    this.TimeLimitCopy[td.TeamID] = td.StartTime + (long)req.LastMs + 180000L;
                    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);
        }
예제 #21
0
 private void NotifySpreadData(KFSpreadData data)
 {
     ClientAgentManager.Instance().PostAsyncEvent(data.ServerID, GameType,
                                                  new AsyncDataItem(KuaFuEventTypes.SpreadCount, data.ZoneID, data.RoleID, data.CountRole, data.CountVip, data.CountLevel));
 }
예제 #22
0
 public AsyncDataItem[] GetClientCacheItems(int serverId)
 {
     return(ClientAgentManager.Instance().PickAsyncEvent(serverId, this.GameType));
 }
예제 #23
0
        /// <summary>
        /// 夫妻匹配
        /// </summary>
        /// <param name="now"></param>
        private void CheckRoleMatch(DateTime now)
        {
            lock (Mutex)
            {
                var joinDatas = JoinDataUtil.GetJoinList();
                if (joinDatas == null || joinDatas.Count <= 0)
                {
                    return;
                }

                CoupleArenaJoinMatcher joinMatcher = new CoupleArenaJoinMatcher();
                foreach (var joinData in joinDatas)
                {
                    if ((now - joinData.StartTime).TotalSeconds >= 60 || joinData.ToKfServerId > 0)
                    {
                        JoinDataUtil.DelJoinData(joinData);
                    }
                    else if ((now - joinData.StartTime).TotalSeconds >= 30)
                    {
                        joinMatcher.AddGlobalJoinData(joinData);
                    }
                    else
                    {
                        joinMatcher.AddJoinData(joinData.DuanWeiType, joinData.DuanWeiLevel, joinData);
                    }
                }

                foreach (var list in joinMatcher.GetAllMatch())
                {
                    for (int i = 0; i < list.Count - 1;)
                    {
                        var one = list[i];
                        var two = list[i + 1];
                        if (MatchTimeLimiter.GetMatchTimes(one.RoleId1, one.RoleId2, two.RoleId1, two.RoleId2)
                            >= TianTiPersistence.Instance.MaxRolePairFightCount)
                        {
                            // 次数先知 第i个元素,让第i+1个元素和第i+2个元素进行匹配
                            i += 1;
                            continue;
                        }

                        CoupleArenaFuBenData fubenData = new CoupleArenaFuBenData();
                        fubenData.GameId    = Persistence.GetNextGameId();
                        fubenData.StartTime = now;
                        fubenData.RoleList  = new List <KuaFuFuBenRoleData>();
                        fubenData.RoleList.Add(new KuaFuFuBenRoleData()
                        {
                            ServerId = one.ServerId, RoleId = one.RoleId1, Side = 1
                        });
                        fubenData.RoleList.Add(new KuaFuFuBenRoleData()
                        {
                            ServerId = one.ServerId, RoleId = one.RoleId2, Side = 1
                        });
                        fubenData.RoleList.Add(new KuaFuFuBenRoleData()
                        {
                            ServerId = two.ServerId, RoleId = two.RoleId1, Side = 2
                        });
                        fubenData.RoleList.Add(new KuaFuFuBenRoleData()
                        {
                            ServerId = two.ServerId, RoleId = two.RoleId2, Side = 2
                        });
                        if (ClientAgentManager.Instance().AssginKfFuben(GameType, fubenData.GameId, 4, out fubenData.KfServerId))
                        {
                            MatchTimeLimiter.AddMatchTimes(one.RoleId1, one.RoleId2, two.RoleId1, two.RoleId2);
                            GameFuBenDict[fubenData.GameId] = fubenData;
                            i += 2;

                            one.ToKfServerId = fubenData.KfServerId;
                            two.ToKfServerId = fubenData.KfServerId;

                            CoupleArenaCanEnterData enterData1 = new CoupleArenaCanEnterData()
                            {
                                GameId     = fubenData.GameId,
                                KfServerId = fubenData.KfServerId,
                                RoleId1    = one.RoleId1,
                                RoleId2    = one.RoleId2
                            };
                            ClientAgentManager.Instance().PostAsyncEvent(one.ServerId, EvItemGameType,
                                                                         new AsyncDataItem(KuaFuEventTypes.CoupleArenaCanEnter, enterData1));

                            CoupleArenaCanEnterData enterData2 = new CoupleArenaCanEnterData()
                            {
                                GameId     = fubenData.GameId,
                                KfServerId = fubenData.KfServerId,
                                RoleId1    = two.RoleId1,
                                RoleId2    = two.RoleId2
                            };
                            AsyncDataItem evItem2 = new AsyncDataItem(KuaFuEventTypes.CoupleArenaCanEnter, fubenData.GameId, fubenData.KfServerId, two.RoleId1, two.RoleId2);
                            ClientAgentManager.Instance().PostAsyncEvent(two.ServerId, EvItemGameType,
                                                                         new AsyncDataItem(KuaFuEventTypes.CoupleArenaCanEnter, enterData2));
                        }
                        else
                        {
                            LogManager.WriteLog(LogTypes.Error, "CoupleArena 没有跨服可以分配");
                            return;
                        }
                    }
                }
            }
        }
예제 #24
0
		public void Update(DateTime now)
		{
			if (!GameFuncControlManager.IsGameFuncDisabled(GameFuncType.System2Dot2))
			{
				bool updateData = false;
				int weekDay = TimeUtil.GetWeekStartDayIdNow();
				TimeSpan timeOfWeek = TimeUtil.GetTimeOfWeekNow();
				lock (this.Mutex)
				{
					if (this.SyncData.WeekDay != weekDay)
					{
						this.SyncData.WeekDay = weekDay;
						updateData = true;
					}
					if (timeOfWeek < this._config.FirstStartTime)
					{
						this.CurrentSceneInfo = null;
						if (this.SyncData.ZhengDuoStep != 0 || this.SyncData.State > 0)
						{
							this.SyncData.ZhengDuoStep = 0;
							this.SyncData.State = 0;
							updateData = true;
						}
					}
					else if (this.CurrentSceneInfo == null)
					{
						ZhengDuoSceneInfo sceneInfo = this.GetCurrentZhengDuoSceneInfo(timeOfWeek);
						if (null == sceneInfo)
						{
							return;
						}
						int stepOld = this._persistence.DBWeekAndStepGet(31);
						if (sceneInfo.Id == 1)
						{
							this.SyncData.ZhengDuoStep = 1;
							this.StepProcessEnd = 0;
							this.ReloadRankDatas(weekDay);
							LogManager.WriteLog(LogTypes.Info, string.Format("争夺之地,进入海选阶段", new object[0]), null, true);
						}
						else if (stepOld == sceneInfo.Id - 1 || stepOld == sceneInfo.Id)
						{
							LogManager.WriteLog(LogTypes.Info, string.Format("争夺之地,进入{0}阶段", (EZhengDuoStep)sceneInfo.Id), null, true);
							this.SyncData.ZhengDuoStep = sceneInfo.Id;
						}
						else
						{
							this.SyncData.ZhengDuoStep = 0;
							this.SyncData.State = 0;
							LogManager.WriteLog(LogTypes.Info, string.Format("争夺之地,因为前阶段的海选或淘汰赛未开启,本期活动不开启#current={0},last={1}", (EZhengDuoStep)sceneInfo.Id, (EZhengDuoStep)stepOld), null, true);
						}
						if (this.SyncData.ZhengDuoStep > 0)
						{
							while (this.StepProcessEnd < this.SyncData.ZhengDuoStep - 1)
							{
								this.StepProcessEnd++;
								this.ProcessZhengDuoRank(this.StepProcessEnd, false);
								this._persistence.DBWeekAndStepSet(32, this.StepProcessEnd);
							}
							this._persistence.DBWeekAndStepSet(31, this.SyncData.ZhengDuoStep);
							if (timeOfWeek >= sceneInfo.TimeBegin && timeOfWeek < sceneInfo.TimeEnd)
							{
								this.SyncData.State = 1;
								int rank = this.GetSuccessRank((EZhengDuoStep)(this.SyncData.ZhengDuoStep - 1));
								foreach (ZhengDuoRankData data in this.SyncData.RankDatas)
								{
									if (data != null && data.Rank2 == rank && data.Lose == 0)
									{
										data.State = 1;
									}
								}
							}
							else
							{
								this.SyncData.State = 0;
							}
						}
						updateData = true;
						this.CurrentSceneInfo = sceneInfo;
					}
					else
					{
						if (this.SyncData.ZhengDuoStep != this.CurrentSceneInfo.Id)
						{
							return;
						}
						if (timeOfWeek < this.CurrentSceneInfo.TimeEnd)
						{
							if (this.SyncData.State == 0)
							{
								this.SyncData.State = 1;
								updateData = true;
							}
						}
						else if (timeOfWeek < this.CurrentSceneInfo.TimeProcessEnd)
						{
							if (this.SyncData.State == 1)
							{
								LogManager.WriteLog(LogTypes.Info, string.Format("争夺之地,结束战斗状态#step={0}", (EZhengDuoStep)this.CurrentSceneInfo.Id), null, true);
								this.SyncData.State = 0;
								updateData = true;
							}
							if (this.StepProcessEnd < this.CurrentSceneInfo.Id)
							{
								bool end = true;
								foreach (ZhengDuoRankData item in this.SyncData.RankDatas)
								{
									if (item != null && item.State > 0)
									{
										end = false;
										break;
									}
								}
								if (end)
								{
									this.ClearZhengDuoFuBenData();
									this.StepProcessEnd++;
									this.ProcessZhengDuoRank(this.StepProcessEnd, false);
									this._persistence.DBWeekAndStepSet(32, this.StepProcessEnd);
									updateData = true;
								}
							}
						}
						else if (timeOfWeek < this.CurrentSceneInfo.NextTime)
						{
							if (this.SyncData.State == 1)
							{
								this.SyncData.State = 0;
								updateData = true;
							}
							if (this.StepProcessEnd < this.CurrentSceneInfo.Id)
							{
								this.ClearZhengDuoFuBenData();
								this.StepProcessEnd++;
								this.ProcessZhengDuoRank(this.StepProcessEnd, false);
								this._persistence.DBWeekAndStepSet(32, this.StepProcessEnd);
								updateData = true;
							}
							long age = TimeUtil.NOW();
							if (age - this.SyncData.Age > 75000L && timeOfWeek < this.CurrentSceneInfo.TimeProcessEnd)
							{
								updateData = true;
							}
						}
						else
						{
							this.CurrentSceneInfo = null;
						}
					}
					if (updateData)
					{
						this.SyncData.Age = TimeUtil.AgeByNow(this.SyncData.Age);
						ClientAgentManager.Instance().BroadCastAsyncEvent(this.EvItemGameType, new AsyncDataItem(KuaFuEventTypes.UpdateZhengDuoSyncData, new object[]
						{
							this.SyncData
						}), 0);
					}
				}
			}
		}
예제 #25
0
        private void CheckRoleTimerProc(DateTime now, out int signUpCnt, out int startCount)
        {
            signUpCnt  = 0;
            startCount = 0;
            bool assgionGameFuBen   = true;
            long maxRemoveRoleTicks = now.AddHours(-2.0).Ticks;
            long waitTicks          = now.AddSeconds((double)(-(double)this.Persistence.SignUpWaitSecs1)).Ticks;
            long waitTicks2         = now.AddSeconds((double)(-(double)this.Persistence.SignUpWaitSecs3)).Ticks;
            long waitTicksAll       = now.AddSeconds((double)(-(double)this.Persistence.SignUpWaitSecsAll)).Ticks;
            long waitTicksMax       = now.AddSeconds((double)(-(double)this.Persistence.WaitForJoinMaxSecs)).Ticks;

            this.ProcessTianTiFuBenDataDict.Clear();
            foreach (KuaFuRoleData kuaFuRoleData in this.RoleIdKuaFuRoleDataDict.Values)
            {
                int oldGameId = 0;
                lock (kuaFuRoleData)
                {
                    if (kuaFuRoleData.State == KuaFuRoleStates.None || kuaFuRoleData.State > KuaFuRoleStates.StartGame)
                    {
                        if (kuaFuRoleData.StateEndTicks < maxRemoveRoleTicks)
                        {
                            KuaFuRoleData kuaFuRoleDataTemp;
                            this.RoleIdKuaFuRoleDataDict.TryRemove(KuaFuRoleKey.Get(kuaFuRoleData.ServerId, kuaFuRoleData.RoleId), out kuaFuRoleDataTemp);
                            continue;
                        }
                    }
                    else if (kuaFuRoleData.State == KuaFuRoleStates.NotifyEnterGame || kuaFuRoleData.State == KuaFuRoleStates.EnterGame)
                    {
                        if (kuaFuRoleData.StateEndTicks < now.Ticks)
                        {
                            kuaFuRoleData.Age++;
                            kuaFuRoleData.State = KuaFuRoleStates.None;
                            oldGameId           = kuaFuRoleData.GameId;
                        }
                    }
                    else if (kuaFuRoleData.State == KuaFuRoleStates.SignUp)
                    {
                        if (kuaFuRoleData.StateEndTicks < waitTicksMax)
                        {
                            kuaFuRoleData.Age++;
                            kuaFuRoleData.State = KuaFuRoleStates.None;
                        }
                    }
                }
                if (kuaFuRoleData.State == KuaFuRoleStates.SignUp)
                {
                    signUpCnt++;
                    if (assgionGameFuBen)
                    {
                        RangeKey range = this.GetAssignRange(kuaFuRoleData.GroupIndex, kuaFuRoleData.StateEndTicks, waitTicks, waitTicks2, waitTicksAll);
                        assgionGameFuBen = this.AssignGameFuben(kuaFuRoleData, range, now);
                    }
                }
                else if (kuaFuRoleData.State == KuaFuRoleStates.SignUpWaiting)
                {
                    signUpCnt++;
                }
                else if (kuaFuRoleData.State == KuaFuRoleStates.StartGame)
                {
                    startCount++;
                }
                if (oldGameId > 0)
                {
                    this.RemoveRoleFromFuBen(oldGameId, kuaFuRoleData.RoleId);
                    AsyncDataItem evItem = new AsyncDataItem(KuaFuEventTypes.RoleStateChange, new object[]
                    {
                        kuaFuRoleData
                    });
                    ClientAgentManager.Instance().PostAsyncEvent(kuaFuRoleData.ServerId, this.GameType, evItem);
                }
            }
        }
예제 #26
0
 public AsyncDataItem[] GetClientCacheItems(int serverID)
 {
     return ClientAgentManager.Instance().PickAsyncEvent(serverID, _gameType);
 }
예제 #27
0
        private bool HandleAddEraProcess(KuaFuData <KFEraData> data, EraTaskConfig taskConfig)
        {
            bool result;

            if (taskConfig.EraStage != (int)data.V.EraStage)
            {
                result = false;
            }
            else
            {
                int oldEraStageProcess = data.V.EraStageProcess;
                int oldEraStage        = (int)data.V.EraStage;
                data.V.EraStageProcess = Math.Min(data.V.EraStageProcess + taskConfig.Reward, 100);
                if (data.V.EraStageProcess == 100 && data.V.EraStage < 4)
                {
                    data.V.EraStage        = (byte)Math.Min((int)(data.V.EraStage + 1), 4);
                    data.V.EraStageProcess = 0;
                    AsyncDataItem evItem = new AsyncDataItem(KuaFuEventTypes.JunTuanEraStage, new object[]
                    {
                        data.V.JunTuanID
                    });
                    ClientAgentManager.Instance().BroadCastAsyncEvent(GameTypes.JunTuan, evItem, 0);
                    data.V.EraTimePointList.Add(TimeUtil.NowDateTime());
                }
                if (data.V.EraStageProcess == oldEraStageProcess && (int)data.V.EraStage == oldEraStage)
                {
                    result = false;
                }
                else
                {
                    if (data.V.EraStageProcess == 100 && data.V.EraStage == 4)
                    {
                        data.V.EraTimePointList.Add(TimeUtil.NowDateTime());
                    }
                    this.HandleFastEraStage(data.V);
                    bool          needSort = false;
                    KFEraRankData rankData = this.EraRankList.V.Find((KFEraRankData x) => x.JunTuanID == data.V.JunTuanID);
                    if (null != rankData)
                    {
                        needSort                 = true;
                        rankData.JunTuanID       = data.V.JunTuanID;
                        rankData.EraStage        = data.V.EraStage;
                        rankData.EraStageProcess = data.V.EraStageProcess;
                        rankData.RankTime        = TimeUtil.NowDateTime();
                    }
                    else if (this.EraRankList.V.Count < 5)
                    {
                        needSort                 = true;
                        rankData                 = new KFEraRankData();
                        rankData.JunTuanID       = data.V.JunTuanID;
                        rankData.EraStage        = data.V.EraStage;
                        rankData.EraStageProcess = data.V.EraStageProcess;
                        rankData.RankTime        = TimeUtil.NowDateTime();
                        this.EraRankList.V.Add(rankData);
                    }
                    else
                    {
                        KFEraRankData minRankData = this.EraRankList.V[this.EraRankList.V.Count - 1];
                        if (data.V.EraStage > minRankData.EraStage || (data.V.EraStage == minRankData.EraStage && data.V.EraStageProcess > minRankData.EraStageProcess))
                        {
                            needSort = true;
                            minRankData.JunTuanID       = data.V.JunTuanID;
                            minRankData.EraStage        = data.V.EraStage;
                            minRankData.EraStageProcess = data.V.EraStageProcess;
                            minRankData.RankTime        = TimeUtil.NowDateTime();
                        }
                    }
                    if (needSort)
                    {
                        this.EraRankList.V.Sort(delegate(KFEraRankData left, KFEraRankData right)
                        {
                            int result2;
                            if (left.EraStage > right.EraStage)
                            {
                                result2 = -1;
                            }
                            else if (left.EraStage < right.EraStage)
                            {
                                result2 = 1;
                            }
                            else if (left.EraStageProcess > right.EraStageProcess)
                            {
                                result2 = -1;
                            }
                            else if (left.EraStageProcess < right.EraStageProcess)
                            {
                                result2 = 1;
                            }
                            else if (left.RankTime < right.RankTime)
                            {
                                result2 = -1;
                            }
                            else if (left.RankTime > right.RankTime)
                            {
                                result2 = 1;
                            }
                            else
                            {
                                result2 = 0;
                            }
                            return(result2);
                        });
                        for (int loop = 0; loop < this.EraRankList.V.Count; loop++)
                        {
                            this.EraRankList.V[loop].RankValue = loop + 1;
                        }
                        TimeUtil.AgeByNow(ref this.EraRankList.Age);
                    }
                    result = true;
                }
            }
            return(result);
        }
예제 #28
0
		public ZhengDuoFuBenData GetZhengDuoFuBenDataByBhid(int bhid)
		{
			ZhengDuoFuBenData fuBenData = null;
			lock (this.Mutex)
			{
				if (this.SyncData.ZhengDuoStep < 2 || this.SyncData.State == 0)
				{
					return null;
				}
				if (this.Bhid2FuBenDict.TryGetValue(bhid, out fuBenData) && fuBenData.WeekDay == this.SyncData.WeekDay && fuBenData.GroupIndex == this.SyncData.ZhengDuoStep)
				{
					return fuBenData;
				}
				fuBenData = null;
				int step = this.SyncData.ZhengDuoStep;
				int rank = this.GetSuccessRank((EZhengDuoStep)(step - 1));
				List<ZhengDuoRankData> list = new List<ZhengDuoRankData>();
				for (int i = 0; i < rank; i++)
				{
					List<ZhengDuoRankData> rankDataList = this.GetListByGroup(i, step);
					foreach (ZhengDuoRankData data in rankDataList)
					{
						if (data.Rank2 == rank)
						{
							if (data.Bhid == bhid || data.Enemy == bhid)
							{
								list.Add(data);
							}
						}
					}
					if (list.Count >= 1)
					{
						int serverId = 0;
						long gameId = this._persistence.CreateZhengDuoFuBen(17, serverId);
						if (gameId > 0L && ClientAgentManager.Instance().AssginKfFuben(GameTypes.ZhengDuo, gameId, 60, out serverId))
						{
							fuBenData = new ZhengDuoFuBenData
							{
								GameId = gameId,
								ServerId = serverId,
								GroupIndex = this.SyncData.ZhengDuoStep,
								State = GameFuBenState.Start,
								WeekDay = this.SyncData.WeekDay,
								PlayerDict = new Dictionary<int, int>()
							};
							this.FuBenDict[fuBenData.GameId] = fuBenData;
							fuBenData.PlayerDict[list[0].Bhid] = 1;
							this.Bhid2FuBenDict[list[0].Bhid] = fuBenData;
							if (list.Count >= 2)
							{
								fuBenData.PlayerDict[list[1].Bhid] = 2;
								this.Bhid2FuBenDict[list[1].Bhid] = fuBenData;
							}
							LogManager.WriteLog(LogTypes.Info, string.Format("争夺之地分配副本#gameId={0},serverId={1},{2}<==>{3}", new object[]
							{
								gameId,
								serverId,
								list[0].Bhid,
								(list.Count >= 2) ? list[1].Bhid : 0
							}), null, true);
							break;
						}
					}
				}
			}
			return fuBenData;
		}
예제 #29
0
        private bool AssignGameFuben(KuaFuRoleData kuaFuRoleData, RangeKey range, DateTime now)
        {
            DateTime           stateEndTime       = now.AddSeconds((double)this.EnterGameSecs);
            TianTiFuBenData    tianTiFuBenData    = null;
            KuaFuFuBenRoleData kuaFuFuBenRoleData = new KuaFuFuBenRoleData
            {
                ServerId = kuaFuRoleData.ServerId,
                RoleId   = kuaFuRoleData.RoleId
            };
            List <KuaFuRoleData> updateRoleDataList = new List <KuaFuRoleData>();

            if (!this.ProcessTianTiFuBenDataDict.TryGetValue(range, out tianTiFuBenData))
            {
                tianTiFuBenData = new TianTiFuBenData();
                this.ProcessTianTiFuBenDataDict.Add(range, tianTiFuBenData);
            }
            else if (!this.CanAddFuBenRole(tianTiFuBenData, kuaFuRoleData))
            {
                return(true);
            }
            int  roleCount = tianTiFuBenData.AddKuaFuFuBenRoleData(kuaFuFuBenRoleData);
            bool result;

            if (roleCount < Consts.TianTiRoleCountTotal)
            {
                result = true;
            }
            else
            {
                try
                {
                    int  kfSrvId       = 0;
                    int  gameId        = this.Persistence.GetNextGameId();
                    bool createSuccess = ClientAgentManager.Instance().AssginKfFuben(this.GameType, (long)gameId, roleCount, out kfSrvId);
                    if (createSuccess)
                    {
                        tianTiFuBenData.ServerId = kfSrvId;
                        tianTiFuBenData.GameId   = gameId;
                        tianTiFuBenData.EndTime  = Global.NowTime.AddMinutes(8.0);
                        this.AddGameFuBen(tianTiFuBenData);
                        this.Persistence.LogCreateTianTiFuBen(tianTiFuBenData.GameId, tianTiFuBenData.ServerId, 0, roleCount);
                        foreach (KuaFuFuBenRoleData role in tianTiFuBenData.RoleDict.Values)
                        {
                            KuaFuRoleKey  key = KuaFuRoleKey.Get(role.ServerId, role.RoleId);
                            KuaFuRoleData kuaFuRoleDataTemp;
                            if (this.RoleIdKuaFuRoleDataDict.TryGetValue(key, out kuaFuRoleDataTemp))
                            {
                                kuaFuRoleDataTemp.UpdateStateTime(tianTiFuBenData.GameId, KuaFuRoleStates.NotifyEnterGame, stateEndTime.Ticks);
                            }
                        }
                        tianTiFuBenData.State = GameFuBenState.Start;
                        this.NotifyFuBenRoleEnterGame(tianTiFuBenData);
                        this.ProcessTianTiFuBenDataDict.Remove(range);
                        return(true);
                    }
                    return(false);
                }
                catch (Exception ex)
                {
                    LogManager.WriteExceptionUseCache(ex.ToString());
                }
                result = false;
            }
            return(result);
        }
예제 #30
0
        /// <summary>
        /// InitPkLoop 状态机 --- enter,初始化本轮pk信息,分组,切入 NotifyEnter
        /// </summary>
        /// <param name="now"></param>
        private void MS_InitPkLoop_Enter(DateTime now)
        {
            ThisLoopPkLogs.Clear();
            CurrLoopIndex++;

            ZhengBaMatchConfig matchConfig = _Config.MatchConfigList.Find(_m => _m.Day == SyncData.RealActDay);

            if (this.HadUpGradeRoleNum >= (int)matchConfig.MaxUpGradeNum || TodayJoinRoleDatas.Count <= 1)
            {
                StateMachine.SetCurrState(ZhengBaStateMachine.StateType.TodayPkEnd, now);
                return;
            }

            if (matchConfig.Mathching == EZhengBaMatching.Random) // 随机分组
            {
                Random r = new Random((int)now.Ticks);
                for (int i = 0; TodayJoinRoleDatas.Count > 0 && i < TodayJoinRoleDatas.Count * 2; i++)
                {
                    int idx1 = r.Next(0, TodayJoinRoleDatas.Count), idx2 = r.Next(0, TodayJoinRoleDatas.Count);

                    var tmp = TodayJoinRoleDatas[idx1];
                    TodayJoinRoleDatas[idx1] = TodayJoinRoleDatas[idx2];
                    TodayJoinRoleDatas[idx2] = tmp;
                }
            }
            else if (matchConfig.Mathching == EZhengBaMatching.Group)
            {
                List <JoinRolePkData> tmpRoleDatas = new List <JoinRolePkData>();
                foreach (var range in ZhengBaUtils.GetDayPkGroupRange(SyncData.RealActDay))
                {
                    var groupRoles = TodayJoinRoleDatas.FindAll(_r => _r.Group >= range.Left && _r.Group <= range.Right);
                    if (groupRoles != null && groupRoles.Count == 2)
                    {
                        tmpRoleDatas.AddRange(groupRoles);
                    }
                }

                TodayJoinRoleDatas.Clear();
                TodayJoinRoleDatas.AddRange(tmpRoleDatas);
            }
            else
            {
                Debug.Assert(false, "unknown pk match type");
            }

            // 两两分组
            int currIdx = 0;

            for (int i = 0; i < TodayJoinRoleDatas.Count / 2; i++)
            {
                var joinRole1 = TodayJoinRoleDatas[currIdx++];
                var joinRole2 = TodayJoinRoleDatas[currIdx++];

                int toServerId = 0, gameId = 0;
                gameId = TianTiPersistence.Instance.GetNextGameId();
                if (ClientAgentManager.Instance().AssginKfFuben(TianTiService.Instance.GameType, gameId, 2, out toServerId))
                {
                    joinRole1.ToServerID     = joinRole2.ToServerID = toServerId;
                    joinRole1.CurrGameID     = joinRole2.CurrGameID = gameId;
                    joinRole1.WaitReqEnter   = joinRole2.WaitReqEnter = true;
                    joinRole1.WaitKuaFuLogin = joinRole2.WaitKuaFuLogin = false;

                    ZhengBaNtfEnterData data = new ZhengBaNtfEnterData();
                    data.RoleId1    = joinRole1.RoleID;
                    data.RoleId2    = joinRole2.RoleID;
                    data.ToServerId = toServerId;
                    data.GameId     = gameId;
                    data.Day        = SyncData.RealActDay;
                    data.Loop       = CurrLoopIndex;
                    AsyncEvQ.Enqueue(new AsyncDataItem(KuaFuEventTypes.ZhengBaNtfEnter, data));

                    ZhengBaPkLogData log = new ZhengBaPkLogData();
                    log.Month     = SyncData.Month;
                    log.Day       = SyncData.RealActDay;
                    log.RoleID1   = joinRole1.RoleID;
                    log.ZoneID1   = joinRole1.ZoneId;
                    log.RoleName1 = joinRole1.RoleName;
                    log.RoleID2   = joinRole2.RoleID;
                    log.ZoneID2   = joinRole2.ZoneId;
                    log.RoleName2 = joinRole2.RoleName;
                    log.StartTime = now;

                    ThisLoopPkLogs[gameId] = log;
                }
                else
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("众神争霸第{0}天第{1}轮分配游戏服务器失败,role1={2},role2={3}", SyncData.RealActDay, CurrLoopIndex, joinRole1.RoleID, joinRole2.RoleID));
                }
            }

            // 匹配不到对手!!!,人数为奇数了
            while (currIdx < TodayJoinRoleDatas.Count)
            {
                var joinRole = TodayJoinRoleDatas[currIdx++];
                joinRole.ToServerID     = 0;
                joinRole.CurrGameID     = 0;
                joinRole.WaitReqEnter   = false;
                joinRole.WaitKuaFuLogin = false;
            }
            StateMachine.SetCurrState(ZhengBaStateMachine.StateType.NotifyEnter, now);
        }