Exemplo n.º 1
0
 public void ThreadProc(object state)
 {
     do
     {
         Thread.Sleep(1000);
     }while (!this.Persistence.Initialized);
     for (;;)
     {
         try
         {
             DateTime now = TimeUtil.NowDateTime();
             Global.UpdateNowTime(now);
             if (now > this.CheckRoleTimerProcTime)
             {
                 this.CheckRoleTimerProcTime = now.AddSeconds(1.428);
                 int signUpCnt;
                 int startCnt;
                 this.CheckRoleTimerProc(now, out signUpCnt, out startCnt);
                 ClientAgentManager.Instance().SetGameTypeLoad(this.GameType, signUpCnt, startCnt);
             }
             if (now > this.SaveServerStateProcTime)
             {
                 this.SaveServerStateProcTime = now.AddSeconds(30.0);
                 if (now.Hour >= 3 && now.Hour < 4)
                 {
                     this.ClearRolePairFightCount();
                     this.Persistence.UpdateTianTiRankData(now, false, false);
                 }
             }
             if (now > this.CheckGameFuBenTime)
             {
                 this.CheckGameFuBenTime = now.AddSeconds(1000.0);
                 this.CheckGameFuBenTimerProc(now);
             }
             AsyncDataItem[] asyncEvArray = ZhengBaManagerK.Instance().Update();
             ClientAgentManager.Instance().BroadCastAsyncEvent(this.GameType, asyncEvArray);
             this.Persistence.WriteRoleInfoDataProc();
             CoupleArenaService.getInstance().Update();
             CoupleWishService.getInstance().Update();
             zhengDuoService.Instance().Update(now);
             BangHuiMatchService.Instance().Update(now);
             CompService.Instance().Update(now);
             TianTi5v5Service.ThreadProc(null);
             Zork5v5Service.Instance().Update(now);
             int sleepMS = (int)(TimeUtil.NowDateTime() - now).TotalMilliseconds;
             this.Persistence.SaveCostTime(sleepMS);
             sleepMS = 1000 - sleepMS;
             if (sleepMS < 50)
             {
                 sleepMS = 50;
             }
             Thread.Sleep(sleepMS);
         }
         catch (Exception ex)
         {
             LogManager.WriteExceptionUseCache(ex.ToString());
         }
     }
 }
Exemplo n.º 2
0
 public List <ZhengBaNtfPkResultData> ZhengBaPkResult(int gameId, int winner, int FirstLeaveRoleId)
 {
     return(ZhengBaManagerK.Instance().ZhengBaPkResult(gameId, winner, FirstLeaveRoleId));
 }
Exemplo n.º 3
0
 public int ZhengBaKuaFuLogin(int roleid, int gameId)
 {
     return(ZhengBaManagerK.Instance().ZhengBaKuaFuLogin(roleid, gameId));
 }
Exemplo n.º 4
0
 public int ZhengBaRequestEnter(int roleId, int gameId, EZhengBaEnterType enter)
 {
     return(ZhengBaManagerK.Instance().ZhengBaRequestEnter(roleId, gameId, enter));
 }
Exemplo n.º 5
0
 public int ZhengBaSupport(ZhengBaSupportLogData data)
 {
     return(ZhengBaManagerK.Instance().ZhengBaSupport(data));
 }
Exemplo n.º 6
0
 public ZhengBaSyncData SyncZhengBaData(ZhengBaSyncData lastSyncData)
 {
     return(ZhengBaManagerK.Instance().SyncZhengBaData(lastSyncData));
 }
Exemplo n.º 7
0
        public void UpdateTianTiRankData(DateTime now, bool monthRank = false, bool force = false)
        {
            if (Monitor.TryEnter(MutexPaiHang))
            {
                try
                {
                    if (!force)
                    {
                        lock (Mutex)
                        {
                            if (RankData.ModifyTime.DayOfYear == now.DayOfYear)
                            {
                                return;
                            }
                        }
                    }

                    if (!monthRank)
                    {
                        if (now.Day == 1)
                        {
                            monthRank = true;
                        }
                    }

                    List <TianTiRoleInfoData> tianTiRoleInfoDataList = new List <TianTiRoleInfoData>();
                    string          strSql = "";
                    MySqlDataReader sdr    = null;

                    try
                    {
                        ReloadTianTiRankDayList(tianTiRoleInfoDataList);
                    }
                    catch (System.Exception ex)
                    {
                        LogManager.WriteExceptionUseCache(ex.ToString());
                        return;
                    }
                    finally
                    {
                        if (null != sdr)
                        {
                            sdr.Close();
                        }
                    }

                    int ret = 0;
                    try
                    {
                        if (tianTiRoleInfoDataList.Count > 0)
                        {
                            ret = DbHelperMySQL.ExecuteSql(string.Format("UPDATE t_tianti_roles SET `duanweirank`={0}", RankData.MaxPaiMingRank + 1));
                            if (ret >= 0)
                            {
                                ret = DbHelperMySQL.ExecuteSql("DELETE FROM t_tianti_day_paihang;");
                            }
                            if (ret >= 0)
                            {
                                int c          = tianTiRoleInfoDataList.Count;
                                int numPerExec = 50;
                                for (int i = 0; i < c; i++)
                                {
                                    if (i % numPerExec == 0)
                                    {
                                        strSql = "INSERT INTO t_tianti_day_paihang(rid,rank) VALUES";
                                    }

                                    strSql += string.Format("({0},{1})", tianTiRoleInfoDataList[i].RoleId, tianTiRoleInfoDataList[i].DuanWeiRank);
                                    if ((i % numPerExec) == (numPerExec - 1) || i == (c - 1))
                                    {
                                        DbHelperMySQL.ExecuteSql(strSql);
                                    }
                                    else
                                    {
                                        strSql += ',';
                                    }
                                }

                                DbHelperMySQL.ExecuteSql("UPDATE t_tianti_roles r, t_tianti_day_paihang d SET r.`duanweirank` = d.`rank` WHERE r.`rid` = d.`rid`;");

                                if (monthRank)
                                {
                                    DbHelperMySQL.ExecuteSql("DELETE FROM t_tianti_month_paihang;");
                                    strSql = "INSERT INTO t_tianti_month_paihang SELECT * FROM t_tianti_roles WHERE rid IN (SELECT rid FROM t_tianti_day_paihang) ORDER BY `duanweirank` ASC;";
                                    DbHelperMySQL.ExecuteSql(strSql);

                                    DbHelperMySQL.ExecuteSql("DELETE FROM t_tianti_day_paihang;");
                                    DbHelperMySQL.ExecuteSql("UPDATE t_tianti_roles SET `duanweirank`=0,`duanweijifen`=0,`duanweiid`=0;");
                                }
                            }

                            if (ret >= 0)
                            {
                                strSql = string.Format("UPDATE t_async SET `value`={1} WHERE `id`={0};", AsyncTypes.TianTiPaiHangModifyOffsetDay, DataHelper2.GetOffsetDay(now));
                                ExecuteSqlNoQuery(strSql);
                            }
                        }

                        lock (Mutex)
                        {
                            RankData.ModifyTime = now;
                            if (monthRank)
                            {
                                RankData.TianTiRoleInfoDataList      = new List <TianTiRoleInfoData>();
                                RankData.TianTiMonthRoleInfoDataList = tianTiRoleInfoDataList;
                            }
                            else
                            {
                                RankData.TianTiRoleInfoDataList = tianTiRoleInfoDataList;
                            }
                        }

                        if (monthRank)
                        {
                            try
                            {
                                // 这里是为了保证跨服中心月初跨天的时候,更新
                                ZhengBaManagerK.Instance().ReloadSyncData(now);
                            }
                            catch (Exception ex)
                            {
                                LogManager.WriteLog(LogTypes.Error, "UpdateTianTiRankData -> zhengba reload execption", ex);
                            }
                        }
                    }
                    catch (System.Exception ex)
                    {
                        ret = -1;
                        LogManager.WriteException(ex.ToString());
                    }
                }
                finally
                {
                    Monitor.Exit(MutexPaiHang);
                }
            }
        }
Exemplo n.º 8
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);
        }