Esempio n. 1
0
 public void TimerProc(object sender, EventArgs e)
 {
     try
     {
         DateTime now           = TimeUtil.NowDateTime();
         string   KuaFuWorldUri = this.CoreInterface.GetRuntimeVariable("KuaFuWorldUri", null);
         if (this.RemoteServiceUri != KuaFuWorldUri)
         {
             this.RemoteServiceUri = KuaFuWorldUri;
         }
         IKuaFuWorld kuaFuService = this.GetKuaFuService(false);
         if (null != kuaFuService)
         {
             if (this.ClientInfo.ClientId > 0)
             {
                 if (KuaFuManager.KuaFuWorldKuaFuGameServer)
                 {
                     List <KuaFuServerInfo> dict = kuaFuService.GetKuaFuServerInfoData(KuaFuManager.getInstance().GetServerInfoAsyncAge());
                     KuaFuManager.getInstance().UpdateServerInfoList(dict);
                 }
                 AsyncDataItem[] items = kuaFuService.GetClientCacheItems(this.ClientInfo.ServerId);
                 if (items != null && items.Length > 0)
                 {
                     this.ExecuteEventCallBackAsync(items);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         this.ResetKuaFuService();
     }
 }
Esempio n. 2
0
        public void OnLogOut(GameClient client)
        {
            // MoRiJudgeClient.getInstance().GameFuBenRoleChangeState(client.ClientData.RoleID, (int)KuaFuRoleStates.None);

            MoRiJudgeCopy judgeCopy = null;

            lock (copyDict)
            {
                if (!copyDict.TryGetValue(client.ClientData.FuBenSeqID, out judgeCopy))
                {
                    return;
                }
            }

            lock (judgeCopy)
            {
                judgeCopy.RoleCount--;
                if (judgeCopy.m_eStatus != GameSceneStatuses.STATUS_END &&
                    judgeCopy.m_eStatus != GameSceneStatuses.STATUS_AWARD &&
                    judgeCopy.m_eStatus != GameSceneStatuses.STATUS_CLEAR)
                {
                    KuaFuManager.getInstance().SetCannotJoinKuaFu_UseAutoEndTicks(client);
                }
            }
        }
Esempio n. 3
0
        public int EnterKuaFuMap(int roleId, int mapCode, int kuaFuLine, int roleSourceServerId, KuaFuServerLoginData kuaFuServerLoginData)
        {
            IYongZheZhanChangService kuaFuService = this.GetKuaFuService(false);

            if (null != kuaFuService)
            {
                try
                {
                    int kuaFuServerId = kuaFuService.EnterKuaFuMap(this.ClientInfo.ServerId, roleId, mapCode, kuaFuLine);
                    if (kuaFuServerId > 0)
                    {
                        kuaFuServerLoginData.RoleId   = roleId;
                        kuaFuServerLoginData.ServerId = roleSourceServerId;
                        kuaFuServerLoginData.GameType = 7;
                        kuaFuServerLoginData.GameId   = (long)mapCode;
                        KuaFuServerInfo kuaFuServerInfo;
                        if (KuaFuManager.getInstance().TryGetValue(kuaFuServerId, out kuaFuServerInfo))
                        {
                            kuaFuServerLoginData.ServerIp   = kuaFuServerInfo.Ip;
                            kuaFuServerLoginData.ServerPort = kuaFuServerInfo.Port;
                            return(kuaFuServerId);
                        }
                    }
                }
                catch (Exception ex)
                {
                    this.ResetKuaFuService();
                }
            }
            return(-11003);
        }
Esempio n. 4
0
 public bool ProcessCmdPrestigeMedalInfo(GameClient client, int nID, byte[] bytes, string[] cmdParams)
 {
     try
     {
         if (cmdParams.Length != 1)
         {
             LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0}, Client={1}, Recv={2}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(client.ClientSocket, false), cmdParams.Length), null, true);
             return(false);
         }
         int roleID = Convert.ToInt32(cmdParams[0]);
         if (KuaFuManager.getInstance().ClientCmdCheckFaild(nID, client, ref roleID))
         {
             LogManager.WriteLog(LogTypes.Error, string.Format("根据RoleID定位GameClient对象失败, CMD={0}, Client={1}, RoleID={2}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(client.ClientSocket, false), roleID), null, true);
             return(false);
         }
         PrestigeMedalData runeData = PrestigeMedalManager.GetPrestigeMedalData(client);
         client.sendCmd <PrestigeMedalData>(782, runeData, false);
         return(true);
     }
     catch (Exception ex)
     {
         DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false, false);
     }
     return(false);
 }
Esempio n. 5
0
        public TCPProcessCmdResults ProcessChangeBangHuiName(TCPManager tcpMgr, TMSKSocket socket, TCPClientPool tcpClientPool, TCPRandKey tcpRandKey, TCPOutPacketPool pool, int nID, byte[] data, int count, out TCPOutPacket tcpOutPacket)
        {
            tcpOutPacket = null;
            string cmdData = null;

            try
            {
                cmdData = new UTF8Encoding().GetString(data, 0, count);
            }
            catch (Exception)
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("解析指令字符串错误, CMD={0}", (TCPGameServerCmds)nID), null, true);
                tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", 30767);
                return(TCPProcessCmdResults.RESULT_DATA);
            }
            try
            {
                string[] fields = cmdData.Split(new char[]
                {
                    ':'
                });
                if (fields.Length != 2)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0}, Recv={1}, CmdData={2}", (TCPGameServerCmds)nID, fields.Length, cmdData), null, true);
                    tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", 30767);
                    return(TCPProcessCmdResults.RESULT_DATA);
                }
                int        roleId  = Convert.ToInt32(fields[0]);
                string     newName = fields[1];
                GameClient client  = GameManager.ClientMgr.FindClient(socket);
                if (KuaFuManager.getInstance().ClientCmdCheckFaild(nID, client, ref roleId))
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("根据RoleID定位GameClient对象失败, CMD={0}, Client={1}, RoleID={2}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket, false), roleId), null, true);
                    return(TCPProcessCmdResults.RESULT_FAILED);
                }
                if (client.ClientSocket.IsKuaFuLogin)
                {
                    return(TCPProcessCmdResults.RESULT_OK);
                }
                if (client.ClientData.Faction <= 0)
                {
                    return(TCPProcessCmdResults.RESULT_OK);
                }
                EChangeGuildNameError ne = this.HandleChangeBangHuiName(client, newName);
                string rsp = string.Format("{0}:{1}:{2}", (int)ne, client.ClientData.Faction, newName);
                tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(TCPOutPacketPool.getInstance(), rsp, nID);
                return(TCPProcessCmdResults.RESULT_DATA);
            }
            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, "", false, false);
            }
            tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", 30767);
            return(TCPProcessCmdResults.RESULT_DATA);
        }
        public TCPProcessCmdResults ProcessQueryJieRiMeiRiPlatChargeKingCmd(TCPManager tcpMgr, TMSKSocket socket, TCPClientPool tcpClientPool, TCPRandKey tcpRandKey, TCPOutPacketPool pool, int nID, byte[] data, int count, out TCPOutPacket tcpOutPacket)
        {
            tcpOutPacket = null;
            string cmdData = null;

            try
            {
                cmdData = new UTF8Encoding().GetString(data, 0, count);
            }
            catch (Exception)
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("解析指令字符串错误, CMD={0}", (TCPGameServerCmds)nID), null, true);
                tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", 30767);
                return(TCPProcessCmdResults.RESULT_DATA);
            }
            try
            {
                string[] fields = cmdData.Split(new char[]
                {
                    ':'
                });
                if (fields.Length != 1)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0}, Recv={1}, CmdData={2}", (TCPGameServerCmds)nID, fields.Length, cmdData), null, true);
                    tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", 30767);
                    return(TCPProcessCmdResults.RESULT_DATA);
                }
                int        roleID = Convert.ToInt32(fields[0]);
                GameClient client = GameManager.ClientMgr.FindClient(socket);
                if (KuaFuManager.getInstance().ClientCmdCheckFaild(nID, client, ref roleID))
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("根据RoleID定位GameClient对象失败, CMD={0}, Client={1}, RoleID={2}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket, false), roleID), null, true);
                    return(TCPProcessCmdResults.RESULT_FAILED);
                }
                JieriPlatChargeKingEverydayData myData = null;
                JieriPlatChargeKingEveryDay     act    = HuodongCachingMgr.GetJieriPCKingEveryDayActivity();
                if (act != null)
                {
                    myData = act.BuildQueryDataForClient(client);
                }
                tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, DataHelper.ObjectToBytes <JieriPlatChargeKingEverydayData>(myData), nID);
                return(TCPProcessCmdResults.RESULT_DATA);
            }
            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, "", false, false);
            }
            tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", 30767);
            return(TCPProcessCmdResults.RESULT_DATA);
        }
Esempio n. 7
0
 public bool LangHunLingYuKuaFuLoginData(int roleId, int cityId, int gameId, KuaFuServerLoginData kuaFuServerLoginData)
 {
     try
     {
         IYongZheZhanChangService kuaFuService = this.GetKuaFuService(false);
         if (null != kuaFuService)
         {
             try
             {
                 LangHunLingYuFuBenData fuBenData;
                 lock (this.Mutex)
                 {
                     if (!this.LangHunLingYuFuBenDataDict.TryGetValue(gameId, out fuBenData))
                     {
                         fuBenData = null;
                     }
                 }
                 if (null == fuBenData)
                 {
                     fuBenData = kuaFuService.GetLangHunLingYuGameFuBenDataByCityId(cityId);
                 }
                 if (null != fuBenData)
                 {
                     kuaFuServerLoginData.RoleId   = roleId;
                     kuaFuServerLoginData.GameId   = (long)fuBenData.GameId;
                     kuaFuServerLoginData.GameType = 10;
                     kuaFuServerLoginData.EndTicks = fuBenData.EndTime.Ticks;
                     kuaFuServerLoginData.ServerId = this.ClientInfo.ServerId;
                     KuaFuServerInfo kuaFuServerInfo;
                     if (KuaFuManager.getInstance().TryGetValue(fuBenData.ServerId, out kuaFuServerInfo))
                     {
                         kuaFuServerLoginData.ServerIp   = kuaFuServerInfo.Ip;
                         kuaFuServerLoginData.ServerPort = kuaFuServerInfo.Port;
                         return(true);
                     }
                 }
             }
             catch (Exception ex)
             {
                 this.ResetKuaFuService();
             }
         }
     }
     catch (Exception ex)
     {
         LogManager.WriteExceptionUseCache(ex.ToString());
     }
     return(false);
 }
Esempio n. 8
0
        public static bool CheckCmdRole(GameClient client, int nID, string[] cmdParams)
        {
            int  roleID = int.Parse(cmdParams[0]);
            bool result;

            if (KuaFuManager.getInstance().ClientCmdCheckFaild(nID, client, ref roleID))
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("根据RoleID定位GameClient对象失败, CMD={0}, Client={1}, RoleID={2}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(client.ClientSocket, false), roleID), null, true);
                result = false;
            }
            else
            {
                result = true;
            }
            return(result);
        }
Esempio n. 9
0
        public TCPProcessCmdResults ProcessGetFirstChargeInfoCMD(TCPManager tcpMgr, TMSKSocket socket, TCPClientPool tcpClientPool, TCPOutPacketPool pool, int nID, byte[] data, int count, out TCPOutPacket tcpOutPacket)
        {
            tcpOutPacket = null;
            string cmdData = null;

            try
            {
                cmdData = new UTF8Encoding().GetString(data, 0, count);
            }
            catch (Exception)
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("解析指令字符串错误, CMD={0}, Client={1}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket, false)), null, true);
                return(TCPProcessCmdResults.RESULT_FAILED);
            }
            try
            {
                string[] fields = cmdData.Split(new char[]
                {
                    ':'
                });
                int        roleID = Convert.ToInt32(fields[0]);
                GameClient client = GameManager.ClientMgr.FindClient(socket);
                if (KuaFuManager.getInstance().ClientCmdCheckFaild(nID, client, ref roleID))
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("根据RoleID定位GameClient对象失败, CMD={0}, Client={1}, RoleID={2}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket, false), roleID), null, true);
                    return(TCPProcessCmdResults.RESULT_FAILED);
                }
                string[] dbFields = null;
                Global.RequestToDBServer(Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, 671, client.strUserID, out dbFields, client.ServerId);
                if (null == dbFields)
                {
                    return(TCPProcessCmdResults.RESULT_FAILED);
                }
                string returndata = dbFields[0];
                if (returndata == "-1")
                {
                    returndata = "";
                }
                string strcmd = string.Format("{0}", returndata);
                tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID);
            }
            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, "ProcessGetFirstChargeInfoCMD", false, false);
            }
            return(TCPProcessCmdResults.RESULT_DATA);
        }
Esempio n. 10
0
        public static TCPProcessCmdResults ProcessGetYueKaData(TCPManager tcpMgr, TMSKSocket socket, TCPClientPool tcpClientPool, TCPRandKey tcpRandKey, TCPOutPacketPool pool, int nID, byte[] data, int count, out TCPOutPacket tcpOutPacket)
        {
            tcpOutPacket = null;
            string cmdData = null;

            try
            {
                cmdData = new UTF8Encoding().GetString(data, 0, count);
            }
            catch (Exception)
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("解析指令字符串错误, CMD={0}, Client={1}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket, false)), null, true);
                return(TCPProcessCmdResults.RESULT_FAILED);
            }
            try
            {
                string[] fields = cmdData.Split(new char[]
                {
                    ':'
                });
                if (1 != fields.Length)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0}, Client={1}, Recv={2}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket, false), fields.Length), null, true);
                    return(TCPProcessCmdResults.RESULT_FAILED);
                }
                int        roleID = Convert.ToInt32(fields[0]);
                GameClient client = GameManager.ClientMgr.FindClient(socket);
                if (KuaFuManager.getInstance().ClientCmdCheckFaild(nID, client, ref roleID))
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("根据RoleID定位GameClient对象失败, CMD={0}, Client={1}, RoleID={2}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket, false), roleID), null, true);
                    return(TCPProcessCmdResults.RESULT_FAILED);
                }
                YueKaData ykData = null;
                lock (client.ClientData.YKDetail)
                {
                    ykData = client.ClientData.YKDetail.ToYueKaData();
                }
                GameManager.ClientMgr.SendToClient(client, DataHelper.ObjectToBytes <YueKaData>(ykData), nID);
                return(TCPProcessCmdResults.RESULT_OK);
            }
            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, "ProcessGetYueKaData", false, false);
            }
            return(TCPProcessCmdResults.RESULT_DATA);
        }
Esempio n. 11
0
        // 客户端发来是否确定进入
        private bool ProcessMoRiJudgeEnter(GameClient client, int nID, byte[] bytes, string[] cmdParams)
        {
            try
            {
                if (!IsGongNengOpened(client))
                {
                    client.sendCmd(nID, StdErrorCode.Error_Not_In_valid_Time.ToString() + ":0");
                    return(true);
                }

                int result = StdErrorCode.Error_Success;
                int flag   = Global.SafeConvertToInt32(cmdParams[1]);
                if (flag > 0)
                {
                    //  result = MoRiJudgeClient.getInstance().ChangeRoleState(client.ClientData.RoleID, KuaFuRoleStates.EnterGame);
                    if (result < 0)
                    {
                        flag = 0;
                    }
                }
                else
                {
                    result = 0;// MoRiJudgeClient.getInstance().ChangeRoleState(client.ClientData.RoleID, KuaFuRoleStates.None);
                    client.ClientData.SignUpGameType = (int)GameTypes.None;
                    // 增加惩罚时间
                    KuaFuManager.getInstance().SetCannotJoinKuaFu_UseAutoEndTicks(client);
                }

                if (flag <= 0)
                {
                    Global.GetClientKuaFuServerLoginData(client).RoleId = 0;
                    client.sendCmd((int)TCPGameServerCmds.CMD_SPR_MORI_QUIT, StdErrorCode.Error_Success_No_Info);
                }

                // 进入就不发送消息了
                //client.sendCmd(nID, result.ToString() + ":0");
                return(true);
            }
            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false);
            }

            return(false);
        }
Esempio n. 12
0
        public int EnterPTKuaFuMap(int roleSourceServerId, int roleId, int ptid, int mapCode, int kuaFuLine, KuaFuServerLoginData kuaFuServerLoginData, out string signToken, out string signKey)
        {
            signToken = null;
            signKey   = null;
            int         tempRoleID    = -11000;
            int         kuaFuServerID = 0;
            IKuaFuWorld kuaFuService  = this.GetKuaFuService(false);

            if (null != kuaFuService)
            {
                try
                {
                    string[] ips;
                    int[]    ports;
                    tempRoleID = kuaFuService.EnterPTKuaFuMap(roleSourceServerId, roleId, ptid, mapCode, kuaFuLine, out signToken, out signKey, out kuaFuServerID, out ips, out ports);
                    if (tempRoleID <= 0)
                    {
                        return(tempRoleID);
                    }
                    kuaFuServerLoginData.RoleId         = roleId;
                    kuaFuServerLoginData.ServerId       = (KuaFuManager.KuaFuWorldKuaFuGameServer ? roleSourceServerId : GameManager.KuaFuServerId);
                    kuaFuServerLoginData.GameType       = 32;
                    kuaFuServerLoginData.GameId         = (long)mapCode;
                    kuaFuServerLoginData.EndTicks       = TimeUtil.UTCTicks();
                    kuaFuServerLoginData.TargetServerID = kuaFuServerID;
                    KuaFuServerInfo kuaFuServerInfo;
                    if (ips != null && ports != null)
                    {
                        kuaFuServerLoginData.ServerIp   = ips[0];
                        kuaFuServerLoginData.ServerPort = ports[0];
                    }
                    else if (KuaFuManager.getInstance().TryGetValue(kuaFuServerID, out kuaFuServerInfo))
                    {
                        kuaFuServerLoginData.ServerIp   = kuaFuServerInfo.Ip;
                        kuaFuServerLoginData.ServerPort = kuaFuServerInfo.Port;
                    }
                }
                catch (Exception ex)
                {
                    this.ResetKuaFuService();
                }
            }
            return(tempRoleID);
        }
Esempio n. 13
0
        public bool GetKuaFuGSInfo(int serverId, out string gsIp, out int gsPort)
        {
            gsIp   = string.Empty;
            gsPort = 0;
            KuaFuServerInfo info = null;
            bool            result;

            if (!KuaFuManager.getInstance().TryGetValue(serverId, out info))
            {
                result = false;
            }
            else
            {
                gsIp   = info.Ip;
                gsPort = info.Port;
                result = true;
            }
            return(result);
        }
        public static TCPProcessCmdResults ProcessReqZhuHun(TCPManager tcpMgr, TMSKSocket socket, TCPClientPool tcpClientPool, TCPOutPacketPool pool, int nID, byte[] data, int count, out TCPOutPacket tcpOutPacket)
        {
            tcpOutPacket = null;
            string cmdData = null;

            try
            {
                cmdData = new UTF8Encoding().GetString(data, 0, count);
            }
            catch (Exception)
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("解析指令字符串错误, CMD={0}, Client={1}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket, false)), null, true);
                return(TCPProcessCmdResults.RESULT_FAILED);
            }
            try
            {
                string[] fields = cmdData.Split(new char[]
                {
                    ':'
                });
                if (1 != fields.Length)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0}, Client={1}, Recv={2}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket, false), fields.Length), null, true);
                    return(TCPProcessCmdResults.RESULT_FAILED);
                }
                int        roleID = Convert.ToInt32(fields[0]);
                GameClient client = GameManager.ClientMgr.FindClient(socket);
                if (KuaFuManager.getInstance().ClientCmdCheckFaild(nID, client, ref roleID))
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("根据RoleID定位GameClient对象失败, CMD={0}, Client={1}, RoleID={2}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket, false), roleID), null, true);
                    return(TCPProcessCmdResults.RESULT_FAILED);
                }
                ZhuLingZhuHunError e      = ZhuLingZhuHunManager.ReqZhuHun(client);
                string             strcmd = string.Format("{0}:{1}:{2}", roleID, (int)e, client.ClientData.MyWingData.ZhuHunNum);
                tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID);
            }
            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, "ProcessReqZhuHun", false, false);
            }
            return(TCPProcessCmdResults.RESULT_DATA);
        }
Esempio n. 15
0
 public void TimerProc(object sender, EventArgs e)
 {
     try
     {
         string huanYingSiYuanUri = this.CoreInterface.GetRuntimeVariable("HuanYingSiYuanUri", null);
         if (this.RemoteServiceUri != huanYingSiYuanUri)
         {
             this.RemoteServiceUri = huanYingSiYuanUri;
         }
         IKuaFuService kuaFuService = this.GetKuaFuService(false);
         if (null != kuaFuService)
         {
             if (this.ClientInfo.ClientId > 0)
             {
                 List <KuaFuServerInfo> dict = kuaFuService.GetKuaFuServerInfoData(KuaFuManager.getInstance().GetServerInfoAsyncAge());
                 KuaFuManager.getInstance().UpdateServerInfoList(dict);
                 AsyncData asyncData = kuaFuService.GetClientCacheItems2(this.ClientInfo.ServerId, TimeUtil.NOW());
                 long      nowTicks  = TimeUtil.NOW();
                 long      subTicks  = nowTicks - asyncData.RequestTicks;
                 if (subTicks < 200L)
                 {
                     if (TimeUtil.AsyncNetTicks(asyncData.RequestTicks, asyncData.ServerTicks))
                     {
                         LogManager.WriteLog(LogTypes.Ignore, string.Format("时间漂移#local={0},server={1}", asyncData.RequestTicks, asyncData.ServerTicks), null, true);
                     }
                 }
                 AsyncDataItem[] items = asyncData.ItemList;
                 if (items != null && items.Length > 0)
                 {
                     this.ExecuteEventCallBackAsync(items);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         this.ResetKuaFuService();
     }
 }
Esempio n. 16
0
 private bool ProcessMoRiJudgeEnter(GameClient client, int nID, byte[] bytes, string[] cmdParams)
 {
     try
     {
         if (!this.IsGongNengOpened(client, true))
         {
             client.sendCmd(nID, -2001 + ":0", false);
             return(true);
         }
         int result = 1;
         int flag   = Global.SafeConvertToInt32(cmdParams[1]);
         if (flag > 0)
         {
             if (result < 0)
             {
                 flag = 0;
             }
         }
         else
         {
             client.ClientData.SignUpGameType = 0;
             KuaFuManager.getInstance().SetCannotJoinKuaFu_UseAutoEndTicks(client);
         }
         if (flag <= 0)
         {
             Global.GetClientKuaFuServerLoginData(client).RoleId = 0;
             client.sendCmd <int>(1302, 0, false);
         }
         return(true);
     }
     catch (Exception ex)
     {
         DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false, false);
     }
     return(false);
 }
Esempio n. 17
0
        public void TimerProc()
        {
            long nowMs = TimeUtil.NOW();

            if (nowMs >= this.NextHeartBeatMs)
            {
                this.NextHeartBeatMs = nowMs + 1020L;
                List <MoRiJudgeCopy> copyList = null;
                lock (this.copyDict)
                {
                    copyList = this.copyDict.Values.ToList <MoRiJudgeCopy>();
                }
                if (copyList != null && copyList.Count > 0)
                {
                    foreach (MoRiJudgeCopy judgeCopy in copyList)
                    {
                        lock (judgeCopy)
                        {
                            if (judgeCopy.m_eStatus == GameSceneStatuses.STATUS_NULL)
                            {
                                judgeCopy.m_eStatus              = GameSceneStatuses.STATUS_PREPARE;
                                judgeCopy.CurrStateBeginMs       = nowMs;
                                judgeCopy.DeadlineMs             = nowMs + (long)(this.CopyMaxAliveMinutes * 60 * 1000);
                                judgeCopy.StateTimeData.State    = 2;
                                judgeCopy.StateTimeData.EndTicks = judgeCopy.DeadlineMs;
                                GameManager.ClientMgr.BroadSpecialCopyMapMessage <GameSceneStateTimeData>(827, judgeCopy.StateTimeData, judgeCopy.MyCopyMap);
                            }
                            else if (judgeCopy.m_eStatus == GameSceneStatuses.STATUS_PREPARE)
                            {
                                if (nowMs >= judgeCopy.CurrStateBeginMs + 1500L)
                                {
                                    judgeCopy.m_eStatus        = GameSceneStatuses.STATUS_BEGIN;
                                    judgeCopy.CurrStateBeginMs = nowMs;
                                }
                            }
                            else if (judgeCopy.m_eStatus == GameSceneStatuses.STATUS_BEGIN)
                            {
                                if (nowMs >= judgeCopy.DeadlineMs || (nowMs >= judgeCopy.CurrStateBeginMs + 90000L && judgeCopy.RoleCount <= 0))
                                {
                                    judgeCopy.m_eStatus        = GameSceneStatuses.STATUS_END;
                                    judgeCopy.CurrStateBeginMs = nowMs;
                                    break;
                                }
                                int nextMonsterIdx = -1;
                                if (judgeCopy.CurrMonsterIdx == -1)
                                {
                                    nextMonsterIdx = 0;
                                }
                                else if (judgeCopy.MonsterList[judgeCopy.CurrMonsterIdx].DeathMs > 0L && nowMs >= judgeCopy.MonsterList[judgeCopy.CurrMonsterIdx].DeathMs + 1300L)
                                {
                                    nextMonsterIdx = judgeCopy.CurrMonsterIdx + 1;
                                }
                                if (nextMonsterIdx != -1)
                                {
                                    if (nextMonsterIdx >= this.BossConfigList.Count)
                                    {
                                        judgeCopy.m_eStatus        = GameSceneStatuses.STATUS_END;
                                        judgeCopy.CurrStateBeginMs = nowMs;
                                    }
                                    else
                                    {
                                        this.FlushMonster(judgeCopy, nextMonsterIdx);
                                    }
                                }
                            }
                            else if (judgeCopy.m_eStatus == GameSceneStatuses.STATUS_END)
                            {
                                GameManager.CopyMapMgr.KillAllMonster(judgeCopy.MyCopyMap);
                                judgeCopy.EndTime = TimeUtil.NowDateTime();
                                int roleCount = 0;
                                List <GameClient> clientList = judgeCopy.MyCopyMap.GetClientsList();
                                if (clientList != null && clientList.Count > 0)
                                {
                                    int combatSum = 0;
                                    foreach (GameClient client in clientList)
                                    {
                                        roleCount++;
                                        combatSum += client.ClientData.CombatForce;
                                        if (judgeCopy.Passed)
                                        {
                                            GlobalNew.UpdateKuaFuRoleDayLogData(client.ServerId, client.ClientData.RoleID, TimeUtil.NowDateTime(), client.ClientData.ZoneID, 0, 0, 1, 0, 3);
                                        }
                                        else
                                        {
                                            GlobalNew.UpdateKuaFuRoleDayLogData(client.ServerId, client.ClientData.RoleID, TimeUtil.NowDateTime(), client.ClientData.ZoneID, 0, 0, 0, 1, 3);
                                        }
                                    }
                                    if (roleCount > 0)
                                    {
                                        int combatAvg = combatSum / roleCount;
                                    }
                                    if (judgeCopy.Passed)
                                    {
                                        GameManager.CopyMapMgr.CopyMapPassAwardForAll(clientList[0], judgeCopy.MyCopyMap, false);
                                    }
                                }
                                judgeCopy.m_eStatus              = GameSceneStatuses.STATUS_AWARD;
                                judgeCopy.CurrStateBeginMs       = nowMs;
                                judgeCopy.StateTimeData.State    = 3;
                                judgeCopy.StateTimeData.EndTicks = nowMs + 30000L;
                                GameManager.ClientMgr.BroadSpecialCopyMapMessage <GameSceneStateTimeData>(827, judgeCopy.StateTimeData, judgeCopy.MyCopyMap);
                            }
                            else if (judgeCopy.m_eStatus == GameSceneStatuses.STATUS_AWARD)
                            {
                                if (nowMs >= judgeCopy.CurrStateBeginMs + 30000L)
                                {
                                    lock (this.copyDict)
                                    {
                                        this.copyDict.Remove(judgeCopy.MyCopyMap.FuBenSeqID);
                                    }
                                    try
                                    {
                                        List <GameClient> clientList = judgeCopy.MyCopyMap.GetClientsList();
                                        if (clientList != null)
                                        {
                                            foreach (GameClient client in clientList)
                                            {
                                                KuaFuManager.getInstance().GotoLastMap(client);
                                            }
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        DataHelper.WriteExceptionLogEx(ex, "末日审判清场调度异常");
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 18
0
 private bool ProcessMoRiJudgeJoin(GameClient client, int nID, byte[] bytes, string[] cmdParams)
 {
     try
     {
         SceneUIClasses sceneType = Global.GetMapSceneType(client.ClientData.MapCode);
         if (sceneType != SceneUIClasses.Normal)
         {
             client.sendCmd(nID, -21, false);
             return(true);
         }
         if (!this.IsGongNengOpened(client, true))
         {
             client.sendCmd(nID, -2001, false);
             return(true);
         }
         if (client.ClientData.SignUpGameType != 0)
         {
             client.sendCmd(nID, -2002, false);
             return(true);
         }
         if (KuaFuManager.getInstance().IsInCannotJoinKuaFuCopyTime(client))
         {
             client.sendCmd(nID, -2004, false);
             return(true);
         }
         SystemXmlItem systemFuBenItem = null;
         if (!GameManager.systemFuBenMgr.SystemXmlItemDict.TryGetValue(70000, out systemFuBenItem))
         {
             client.sendCmd(nID, -3, false);
             return(true);
         }
         int minLevel       = systemFuBenItem.GetIntValue("MinLevel", -1);
         int maxLevel       = systemFuBenItem.GetIntValue("MaxLevel", -1);
         int nMinZhuanSheng = systemFuBenItem.GetIntValue("MinZhuanSheng", -1);
         int nMaxZhuanSheng = systemFuBenItem.GetIntValue("MaxZhuanSheng", -1);
         if (client.ClientData.ChangeLifeCount < nMinZhuanSheng || (client.ClientData.ChangeLifeCount == nMinZhuanSheng && client.ClientData.Level < minLevel))
         {
             client.sendCmd(nID, "-19".ToString(), false);
             return(true);
         }
         if (client.ClientData.ChangeLifeCount > nMaxZhuanSheng || (client.ClientData.ChangeLifeCount == nMaxZhuanSheng && client.ClientData.Level > maxLevel))
         {
             client.sendCmd(nID, "-19".ToString(), false);
             return(true);
         }
         FuBenData fuBenData = Global.GetFuBenData(client, 70000);
         if (fuBenData != null && fuBenData.FinishNum >= systemFuBenItem.GetIntValue("FinishNumber", -1))
         {
             client.sendCmd(nID, "-16".ToString(), false);
             return(true);
         }
         int result = 0;
         if (result == 1)
         {
             client.ClientData.SignUpGameType = 3;
             GlobalNew.UpdateKuaFuRoleDayLogData(client.ServerId, client.ClientData.RoleID, TimeUtil.NowDateTime(), client.ClientData.ZoneID, 1, 0, 0, 0, 3);
         }
         client.sendCmd(nID, result.ToString(), false);
         return(true);
     }
     catch (Exception ex)
     {
         DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false, false);
     }
     return(false);
 }
Esempio n. 19
0
        public void EventCallBackHandler(AsyncDataItem item)
        {
            try
            {
                int      eventType = (int)item.EventType;
                object[] args      = item.Args;
                int      num       = eventType;
                switch (num)
                {
                case 0:
                case 1:
                    if (args.Length == 1)
                    {
                        KuaFuRoleData kuaFuRoleData = args[0] as KuaFuRoleData;
                        if (null != kuaFuRoleData)
                        {
                            this.UpdateRoleData(kuaFuRoleData, kuaFuRoleData.RoleId);
                        }
                    }
                    break;

                case 2:
                case 4:
                case 5:
                    break;

                case 3:
                    if (args.Length == 1)
                    {
                        KuaFuRoleData kuaFuRoleData = args[0] as KuaFuRoleData;
                        if (null != kuaFuRoleData)
                        {
                            this.UpdateRoleData(kuaFuRoleData, kuaFuRoleData.RoleId);
                            YongZheZhanChangFuBenData fuBenData = this.GetKuaFuFuBenData(kuaFuRoleData.GameId);
                            if (fuBenData != null && fuBenData.State == GameFuBenState.Start)
                            {
                                KuaFuServerLoginData kuaFuServerLoginData = new KuaFuServerLoginData
                                {
                                    RoleId   = kuaFuRoleData.RoleId,
                                    GameType = kuaFuRoleData.GameType,
                                    GameId   = (long)kuaFuRoleData.GameId,
                                    EndTicks = kuaFuRoleData.StateEndTicks
                                };
                                kuaFuServerLoginData.ServerId = this.ClientInfo.ServerId;
                                KuaFuServerInfo kuaFuServerInfo;
                                if (KuaFuManager.getInstance().TryGetValue(fuBenData.ServerId, out kuaFuServerInfo))
                                {
                                    kuaFuServerLoginData.ServerIp   = kuaFuServerInfo.Ip;
                                    kuaFuServerLoginData.ServerPort = kuaFuServerInfo.Port;
                                }
                                GameTypes gameType = (GameTypes)kuaFuRoleData.GameType;
                                switch (gameType)
                                {
                                case GameTypes.YongZheZhanChang:
                                    this.CoreInterface.GetEventSourceInterface().fireEvent(new KuaFuNotifyEnterGameEvent(kuaFuServerLoginData), 27);
                                    break;

                                case GameTypes.KuaFuBoss:
                                    this.CoreInterface.GetEventSourceInterface().fireEvent(new KuaFuNotifyEnterGameEvent(kuaFuServerLoginData), 31);
                                    break;

                                default:
                                    if (gameType == GameTypes.KingOfBattle)
                                    {
                                        this.CoreInterface.GetEventSourceInterface().fireEvent(new KuaFuNotifyEnterGameEvent(kuaFuServerLoginData), 39);
                                    }
                                    break;
                                }
                            }
                        }
                    }
                    break;

                case 6:
                    if (args.Length == 1)
                    {
                        LangHunLingYuBangHuiDataEx data = args[0] as LangHunLingYuBangHuiDataEx;
                        this.CoreInterface.GetEventSourceInterface().fireEvent(new NotifyLhlyBangHuiDataGameEvent(data), 35);
                    }
                    break;

                case 7:
                    if (args.Length == 1)
                    {
                        LangHunLingYuCityDataEx data2 = args[0] as LangHunLingYuCityDataEx;
                        this.CoreInterface.GetEventSourceInterface().fireEvent(new NotifyLhlyCityDataGameEvent(data2), 35);
                    }
                    break;

                case 8:
                    if (args.Length == 1)
                    {
                        Dictionary <int, List <int> > data3 = args[0] as Dictionary <int, List <int> >;
                        this.CoreInterface.GetEventSourceInterface().fireEvent(new NotifyLhlyOtherCityListGameEvent(data3), 35);
                    }
                    break;

                case 9:
                    if (args.Length == 1)
                    {
                        List <LangHunLingYuKingHist> data4 = args[0] as List <LangHunLingYuKingHist>;
                        this.CoreInterface.GetEventSourceInterface().fireEvent(new NotifyLhlyCityOwnerHistGameEvent(data4), 35);
                    }
                    break;

                case 10:
                    if (args.Length == 2)
                    {
                        int rid         = (int)args[0];
                        int admirecount = (int)args[1];
                        this.CoreInterface.GetEventSourceInterface().fireEvent(new NotifyLhlyCityOwnerAdmireGameEvent(rid, admirecount), 35);
                    }
                    break;

                default:
                    if (num == 9997)
                    {
                        if (GMCommands.EnableGMSetAllServerTime && item.Args.Length == 4)
                        {
                            string[] a = new string[item.Args.Length];
                            for (int i = 0; i < a.Length; i++)
                            {
                                a[i] = (item.Args[i] as string);
                                if (string.IsNullOrEmpty(a[i]))
                                {
                                    return;
                                }
                            }
                            if (a[0] == "-settime")
                            {
                                GMCommands.GMSetTime(null, a, false);
                            }
                        }
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                LogManager.WriteExceptionUseCache(ex.ToString());
            }
        }
Esempio n. 20
0
        public TCPProcessCmdResults ProcessExecuteJieRiMeiRiPlatChargeKingCmd(TCPManager tcpMgr, TMSKSocket socket, TCPClientPool tcpClientPool, TCPRandKey tcpRandKey, TCPOutPacketPool pool, int nID, byte[] data, int count, out TCPOutPacket tcpOutPacket)
        {
            tcpOutPacket = null;
            string cmdData = null;

            try
            {
                cmdData = new UTF8Encoding().GetString(data, 0, count);
            }
            catch (Exception)
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("解析指令字符串错误, CMD={0}", (TCPGameServerCmds)nID), null, true);
                tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", 30767);
                return(TCPProcessCmdResults.RESULT_DATA);
            }
            try
            {
                string[] fields = cmdData.Split(new char[]
                {
                    ':'
                });
                if (fields.Length != 2)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0}, Recv={1}, CmdData={2}", (TCPGameServerCmds)nID, fields.Length, cmdData), null, true);
                    tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", 30767);
                    return(TCPProcessCmdResults.RESULT_DATA);
                }
                int        roleID = Convert.ToInt32(fields[0]);
                int        extTag = Global.SafeConvertToInt32(fields[1]);
                GameClient client = GameManager.ClientMgr.FindClient(socket);
                if (KuaFuManager.getInstance().ClientCmdCheckFaild(nID, client, ref roleID))
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("根据RoleID定位GameClient对象失败, CMD={0}, Client={1}, RoleID={2}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket, false), roleID), null, true);
                    return(TCPProcessCmdResults.RESULT_FAILED);
                }
                Activity instActivity = Global.GetActivity(ActivityTypes.JieriPCKingEveryDay);
                string   strcmd;
                if (null == instActivity)
                {
                    strcmd       = string.Format("{0}:{1}:{2}", -1, roleID, extTag);
                    tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID);
                    return(TCPProcessCmdResults.RESULT_DATA);
                }
                if (!instActivity.CanGiveAward())
                {
                    strcmd       = string.Format("{0}:{1}:{2}", -2, roleID, extTag);
                    tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID);
                    return(TCPProcessCmdResults.RESULT_DATA);
                }
                if (!instActivity.CheckCondition(client, extTag))
                {
                    strcmd       = string.Format("{0}:{1}:{2}", -10007, roleID, extTag);
                    tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID);
                    return(TCPProcessCmdResults.RESULT_DATA);
                }
                if (!instActivity.HasEnoughBagSpaceForAwardGoods(client, extTag))
                {
                    strcmd       = string.Format("{0}:{1}:{2}", -3, roleID, extTag);
                    tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID);
                    return(TCPProcessCmdResults.RESULT_DATA);
                }
                if (!instActivity.GiveAward(client, extTag))
                {
                    strcmd       = string.Format("{0}:{1}:{2}", -7, roleID, extTag);
                    tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID);
                    return(TCPProcessCmdResults.RESULT_DATA);
                }
                strcmd       = string.Format("{0}:{1}:{2}", 1, roleID, extTag);
                tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID);
                return(TCPProcessCmdResults.RESULT_DATA);
            }
            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, "", false, false);
            }
            tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", 30767);
            return(TCPProcessCmdResults.RESULT_DATA);
        }
Esempio n. 21
0
        // 定时处理副本逻辑
        public void TimerProc()
        {
            long nowMs = TimeUtil.NOW();

            if (nowMs < NextHeartBeatMs)
            {
                return;
            }

            NextHeartBeatMs = nowMs + 1020; //1020毫秒执行一次

            List <MoRiJudgeCopy> copyList = null;

            lock (copyDict)
            {
                copyList = copyDict.Values.ToList();
            }
            if (copyList == null || copyList.Count <= 0)
            {
                return;
            }

            foreach (var judgeCopy in copyList)
            {
                lock (judgeCopy)
                {
                    if (judgeCopy.m_eStatus == GameSceneStatuses.STATUS_NULL)
                    {
                        judgeCopy.m_eStatus        = GameSceneStatuses.STATUS_PREPARE;
                        judgeCopy.CurrStateBeginMs = nowMs;
                        judgeCopy.DeadlineMs       = nowMs + this.CopyMaxAliveMinutes * 60 * 1000;

                        // 末日审判副本进入之后就是等待结束
                        judgeCopy.StateTimeData.State    = (int)GameSceneStatuses.STATUS_BEGIN;
                        judgeCopy.StateTimeData.EndTicks = judgeCopy.DeadlineMs;
                        GameManager.ClientMgr.BroadSpecialCopyMapMessage((int)TCPGameServerCmds.CMD_SPR_NOTIFY_TIME_STATE, judgeCopy.StateTimeData, judgeCopy.MyCopyMap);
                    }
                    else if (judgeCopy.m_eStatus == GameSceneStatuses.STATUS_PREPARE)
                    {
                        if (nowMs >= judgeCopy.CurrStateBeginMs + 1500)
                        {
                            judgeCopy.m_eStatus        = GameSceneStatuses.STATUS_BEGIN;
                            judgeCopy.CurrStateBeginMs = nowMs;
                        }
                    }
                    else if (judgeCopy.m_eStatus == GameSceneStatuses.STATUS_BEGIN)
                    {
                        // 如果超时了
                        if (nowMs >= judgeCopy.DeadlineMs ||
                            (nowMs >= judgeCopy.CurrStateBeginMs + 90 * 1000 && judgeCopy.RoleCount <= 0)
                            )
                        {
                            judgeCopy.m_eStatus        = GameSceneStatuses.STATUS_END;
                            judgeCopy.CurrStateBeginMs = nowMs;
                            return;
                        }

                        int nextMonsterIdx = -1;
                        if (judgeCopy.CurrMonsterIdx == -1)
                        {
                            nextMonsterIdx = 0;
                        }
                        else// if (judgeCopy.CurrMonsterIndex < )
                        {
                            if (judgeCopy.MonsterList[judgeCopy.CurrMonsterIdx].DeathMs > 0 &&
                                nowMs >= judgeCopy.MonsterList[judgeCopy.CurrMonsterIdx].DeathMs + MoRiJudgeConsts.MonsterFlushIntervalMs)
                            {
                                nextMonsterIdx = judgeCopy.CurrMonsterIdx + 1;
                            }
                        }

                        if (nextMonsterIdx != -1)
                        {
                            if (nextMonsterIdx >= BossConfigList.Count)
                            {
                                judgeCopy.m_eStatus        = GameSceneStatuses.STATUS_END;
                                judgeCopy.CurrStateBeginMs = nowMs;
                            }
                            else
                            {
                                FlushMonster(judgeCopy, nextMonsterIdx);
                            }
                        }
                    }
                    else if (judgeCopy.m_eStatus == GameSceneStatuses.STATUS_END)
                    {
                        // 把所有怪杀死,主要是副本到时间的情况
                        GameManager.CopyMapMgr.KillAllMonster(judgeCopy.MyCopyMap);

                        //  MoRiJudgeClient.getInstance().GameFuBenChangeState(judgeCopy.GameId, GameFuBenState.End, DateTime.Now);
                        // 记录副本通关信息
                        judgeCopy.EndTime = TimeUtil.NowDateTime();
                        int combatAvg = 0;
                        int roleCount = 0;

                        List <GameClient> clientList = judgeCopy.MyCopyMap.GetClientsList();
                        if (clientList != null && clientList.Count > 0)
                        {
                            int combatSum = 0;

                            foreach (var client in clientList)
                            {
                                ++roleCount;
                                combatSum += client.ClientData.CombatForce;

                                if (judgeCopy.Passed)
                                {
                                    // 成功统计
                                    GlobalNew.UpdateKuaFuRoleDayLogData(client.ServerId, client.ClientData.RoleID, TimeUtil.NowDateTime(), client.ClientData.ZoneID, 0, 0, 1, 0, (int)GameTypes.MoRiJudge);
                                }
                                else
                                {
                                    // 失败统计
                                    GlobalNew.UpdateKuaFuRoleDayLogData(client.ServerId, client.ClientData.RoleID, TimeUtil.NowDateTime(), client.ClientData.ZoneID, 0, 0, 0, 1, (int)GameTypes.MoRiJudge);
                                }
                            }
                            if (roleCount > 0)
                            {
                                combatAvg = combatSum / roleCount;
                            }

                            if (judgeCopy.Passed)
                            {
                                GameManager.CopyMapMgr.CopyMapPassAwardForAll(clientList[0], judgeCopy.MyCopyMap, false);
                            }
                        }

                        //  MoRiJudgeClient.getInstance().UpdateCopyPassEvent(judgeCopy.GameId, judgeCopy.Passed, judgeCopy.StartTime, judgeCopy.EndTime, judgeCopy.LimitKillCount, roleCount, combatAvg);

                        judgeCopy.m_eStatus        = GameSceneStatuses.STATUS_AWARD;
                        judgeCopy.CurrStateBeginMs = nowMs;

                        judgeCopy.StateTimeData.State    = (int)GameSceneStatuses.STATUS_END;
                        judgeCopy.StateTimeData.EndTicks = nowMs + 30 * 1000;
                        GameManager.ClientMgr.BroadSpecialCopyMapMessage((int)TCPGameServerCmds.CMD_SPR_NOTIFY_TIME_STATE, judgeCopy.StateTimeData, judgeCopy.MyCopyMap);
                    }
                    else if (judgeCopy.m_eStatus == GameSceneStatuses.STATUS_AWARD)
                    {
                        // 暂时设置为30S的清理时间
                        // 副本到时间的话,客户端会主动关闭
                        if (nowMs >= judgeCopy.CurrStateBeginMs + 30 * 1000)
                        {
                            lock (copyDict)
                            {
                                copyDict.Remove(judgeCopy.MyCopyMap.FuBenSeqID);
                            }

                            try
                            {
                                List <GameClient> clientList = judgeCopy.MyCopyMap.GetClientsList();
                                if (clientList != null)
                                {
                                    foreach (var client in clientList)
                                    {
                                        KuaFuManager.getInstance().GotoLastMap(client);
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                DataHelper.WriteExceptionLogEx(ex, "末日审判清场调度异常");
                            }
                        }
                    }
                }
            }
        }
Esempio n. 22
0
        /// <summary>
        /// timer 更新副本
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void UpdateCopyScene()
        {
            DateTime now      = TimeUtil.NowDateTime();
            long     nowTicks = now.Ticks / TimeSpan.TicksPerMillisecond;

            if (nowTicks < NextHeartBeatTicks)
            {
                return;
            }

            NextHeartBeatTicks = nowTicks + 1020; //1020毫秒执行一次

            lock (Mutex)
            {
                foreach (var scene in this.FuBenSeq2CopyScenes.Values.ToList())
                {
                    scene.m_lPrevUpdateTime = scene.m_lCurrUpdateTime;
                    scene.m_lCurrUpdateTime = nowTicks;

                    if (scene.m_eStatus == GameSceneStatuses.STATUS_NULL)             // 如果处于空状态 -- 是否要切换到准备状态
                    {
                        NtfBuffHoldData(scene);
                        scene.m_lPrepareTime = nowTicks;
                        scene.m_lBeginTime   = nowTicks + WarCfg.WaitSec * TimeUtil.SECOND;
                        scene.m_eStatus      = GameSceneStatuses.STATUS_PREPARE;

                        scene.StateTimeData.GameType = (int)GameTypes.CoupleArena;
                        scene.StateTimeData.State    = (int)scene.m_eStatus;
                        scene.StateTimeData.EndTicks = scene.m_lBeginTime;
                        GameManager.ClientMgr.BroadSpecialCopyMapMessage((int)TCPGameServerCmds.CMD_SPR_NOTIFY_TIME_STATE, scene.StateTimeData, scene.CopyMap);
                    }
                    else if (scene.m_eStatus == GameSceneStatuses.STATUS_PREPARE)     // 场景战斗状态切换
                    {
                        if (nowTicks >= scene.m_lBeginTime)
                        {
                            // 至少有一方无人进入
                            if (scene.EnterRoleSide.Values.ToList().Distinct().Count() <= 1)
                            {
                                scene.WinSide   = 0;
                                scene.m_eStatus = GameSceneStatuses.STATUS_END;
                            }
                            else
                            {
                                NtfBuffHoldData(scene);
                                scene.m_eStatus  = GameSceneStatuses.STATUS_BEGIN;
                                scene.m_lEndTime = nowTicks + WarCfg.FightSec * TimeUtil.SECOND;

                                scene.StateTimeData.GameType = (int)GameTypes.CoupleArena;
                                scene.StateTimeData.State    = (int)scene.m_eStatus;
                                scene.StateTimeData.EndTicks = scene.m_lEndTime;

                                GameManager.ClientMgr.BroadSpecialCopyMapMessage((int)TCPGameServerCmds.CMD_SPR_NOTIFY_TIME_STATE, scene.StateTimeData, scene.CopyMap);
                                //放开光幕
                                scene.CopyMap.AddGuangMuEvent(1, 0);
                                GameManager.ClientMgr.BroadSpecialMapAIEvent(scene.CopyMap.MapCode, scene.CopyMap.CopyMapID, 1, 0);
                                scene.CopyMap.AddGuangMuEvent(2, 0);
                                GameManager.ClientMgr.BroadSpecialMapAIEvent(scene.CopyMap.MapCode, scene.CopyMap.CopyMapID, 2, 0);
                            }
                        }
                    }
                    else if (scene.m_eStatus == GameSceneStatuses.STATUS_BEGIN)       // 战斗开始
                    {
                        if (nowTicks >= scene.m_lEndTime)
                        {
                            // 超时结束,拥有真爱buff的一方胜利
                            scene.m_eStatus = GameSceneStatuses.STATUS_END;

                            if (!scene.EnterRoleSide.TryGetValue(scene.ZhenAiBuff_Role, out scene.WinSide))
                            {
                                scene.WinSide = 0;
                            }
                        }
                        else if (scene.EnterRoleSide.ContainsKey(scene.ZhenAiBuff_Role) &&
                                 (nowTicks - scene.ZhenAiBuff_StartMs) >= ZhenAiBuffHoldWinSec * 1000)
                        {
                            // 拥有真爱buff超过一段时间的一方胜利
                            scene.m_eStatus = GameSceneStatuses.STATUS_END;
                            scene.WinSide   = scene.EnterRoleSide[scene.ZhenAiBuff_Role];
                        }
                        else
                        {
                            CheckFlushZhenAiMonster(scene);
                            CheckFlushYongQiMonster(scene);
                        }
                    }
                    else if (scene.m_eStatus == GameSceneStatuses.STATUS_END)         // 战斗结束
                    {
                        ProcessEnd(scene, now, nowTicks);
                    }
                    else if (scene.m_eStatus == GameSceneStatuses.STATUS_AWARD)
                    {
                        if (nowTicks >= scene.m_lLeaveTime)
                        {
                            scene.m_eStatus = GameSceneStatuses.STATUS_CLEAR;
                            scene.CopyMap.SetRemoveTicks(scene.m_lLeaveTime);
                            try
                            {
                                List <GameClient> objsList = scene.CopyMap.GetClientsList();
                                if (objsList != null && objsList.Count > 0)
                                {
                                    for (int n = 0; n < objsList.Count; ++n)
                                    {
                                        GameClient c = objsList[n];
                                        if (c != null)
                                        {
                                            KuaFuManager.getInstance().GotoLastMap(c);
                                        }
                                    }
                                }
                            }
                            catch (System.Exception ex)
                            {
                                DataHelper.WriteExceptionLogEx(ex, "情侣竞技系统清场调度异常");
                            }
                        }
                    }
                }
            }
        }
Esempio n. 23
0
        public void EventCallBackHandler(AsyncDataItem item)
        {
            try
            {
                int      eventType = (int)item.EventType;
                object[] args      = item.Args;
                int      num       = eventType;
                if (num <= 9996)
                {
                    switch (num)
                    {
                    case 0:
                    case 1:
                        if (args.Length == 1)
                        {
                            KuaFuRoleData kuaFuRoleData = args[0] as KuaFuRoleData;
                            if (null != kuaFuRoleData)
                            {
                                this.UpdateRoleData(kuaFuRoleData, kuaFuRoleData.RoleId);
                            }
                        }
                        break;

                    case 2:
                        if (args.Length == 2)
                        {
                            int rid   = (int)args[0];
                            int count = (int)args[1];
                            this.CoreInterface.GetEventSourceInterface().fireEvent(new KuaFuFuBenRoleCountEvent(rid, count), this.SceneType);
                        }
                        break;

                    case 3:
                        if (args.Length == 1)
                        {
                            KuaFuRoleData kuaFuRoleData = args[0] as KuaFuRoleData;
                            if (null != kuaFuRoleData)
                            {
                                this.UpdateRoleData(kuaFuRoleData, kuaFuRoleData.RoleId);
                                HuanYingSiYuanFuBenData huanYingSiYuanFuBenData = this.GetKuaFuFuBenData(kuaFuRoleData.GameId);
                                if (huanYingSiYuanFuBenData != null && huanYingSiYuanFuBenData.State == GameFuBenState.Start)
                                {
                                    KuaFuServerLoginData kuaFuServerLoginData = new KuaFuServerLoginData
                                    {
                                        RoleId   = kuaFuRoleData.RoleId,
                                        GameType = kuaFuRoleData.GameType,
                                        GameId   = (long)kuaFuRoleData.GameId,
                                        EndTicks = kuaFuRoleData.StateEndTicks
                                    };
                                    kuaFuServerLoginData.ServerId = this.ClientInfo.ServerId;
                                    KuaFuServerInfo kuaFuServerInfo;
                                    if (KuaFuManager.getInstance().TryGetValue(huanYingSiYuanFuBenData.ServerId, out kuaFuServerInfo))
                                    {
                                        kuaFuServerLoginData.ServerIp   = kuaFuServerInfo.Ip;
                                        kuaFuServerLoginData.ServerPort = kuaFuServerInfo.Port;
                                    }
                                    else
                                    {
                                        LogManager.WriteLog(LogTypes.Error, string.Format("服务器列表中无法找到serverid={0}的IP和端口信息", huanYingSiYuanFuBenData.ServerId), null, true);
                                    }
                                    this.CoreInterface.GetEventSourceInterface().fireEvent(new KuaFuNotifyEnterGameEvent(kuaFuServerLoginData), this.SceneType);
                                }
                            }
                        }
                        break;

                    default:
                        if (num == 9996)
                        {
                            if (args.Length == 1)
                            {
                                GMCmdData data = args[0] as GMCmdData;
                                GVoiceManager.getInstance().UpdateGVoicePriority(data, true);
                            }
                        }
                        break;
                    }
                }
                else if (num != 10015)
                {
                    if (num == 10029)
                    {
                        KuaFuLueDuoNtfEnterData data2 = args[0] as KuaFuLueDuoNtfEnterData;
                        KuaFuLueDuoManager.getInstance().HandleNtfEnterEvent(data2);
                    }
                }
                else if (args != null && args.Length == 2)
                {
                    KuaFuManager.getInstance().UpdateServerInfoList(args[1] as List <KuaFuServerInfo>);
                }
            }
            catch (Exception ex)
            {
                LogManager.WriteExceptionUseCache(ex.ToString());
            }
        }
Esempio n. 24
0
        // 报名末日审判
        private bool ProcessMoRiJudgeJoin(GameClient client, int nID, byte[] bytes, string[] cmdParams)
        {
            try
            {
                SceneUIClasses sceneType = Global.GetMapSceneType(client.ClientData.MapCode);
                if (sceneType != SceneUIClasses.Normal)
                {
                    client.sendCmd(nID, StdErrorCode.Error_Denied_In_Current_Map.ToString());
                    return(true);
                }

                if (!IsGongNengOpened(client, true))
                {
                    client.sendCmd(nID, StdErrorCode.Error_Not_In_valid_Time.ToString());
                    return(true);
                }

                if (client.ClientData.SignUpGameType != (int)GameTypes.None)
                {
                    client.sendCmd(nID, StdErrorCode.Error_Denied_In_Activity_Time.ToString());
                    return(true);
                }

                if (KuaFuManager.getInstance().IsInCannotJoinKuaFuCopyTime(client))
                {
                    client.sendCmd(nID, StdErrorCode.Error_Time_Punish.ToString());
                    return(true);
                }

                SystemXmlItem systemFuBenItem = null;
                if (!GameManager.systemFuBenMgr.SystemXmlItemDict.TryGetValue(MoRiJudgeConsts.CopyId, out systemFuBenItem))
                {
                    client.sendCmd(nID, StdErrorCode.Error_Config_Fault.ToString());
                    return(true);
                }

                int minLevel       = systemFuBenItem.GetIntValue("MinLevel");
                int maxLevel       = systemFuBenItem.GetIntValue("MaxLevel");
                int nMinZhuanSheng = systemFuBenItem.GetIntValue("MinZhuanSheng");
                int nMaxZhuanSheng = systemFuBenItem.GetIntValue("MaxZhuanSheng");

                // 先判断等级
                if (client.ClientData.ChangeLifeCount < nMinZhuanSheng ||
                    (client.ClientData.ChangeLifeCount == nMinZhuanSheng && client.ClientData.Level < minLevel))
                {
                    client.sendCmd(nID, StdErrorCode.Error_Level_Limit.ToString());
                    return(true);
                }

                if (client.ClientData.ChangeLifeCount > nMaxZhuanSheng ||
                    (client.ClientData.ChangeLifeCount == nMaxZhuanSheng && client.ClientData.Level > maxLevel))
                {
                    client.sendCmd(nID, StdErrorCode.Error_Level_Limit.ToString());
                    return(true);
                }

                // 判断剩余次数
                FuBenData fuBenData = Global.GetFuBenData(client, MoRiJudgeConsts.CopyId);
                if (fuBenData != null && fuBenData.FinishNum >= systemFuBenItem.GetIntValue("FinishNumber"))
                {
                    client.sendCmd(nID, StdErrorCode.Error_No_Residue_Degree.ToString());
                    return(true);
                }

                int result = 0;// MoRiJudgeClient.getInstance().MoRiJudgeSignUp(client.strUserID, client.ClientData.RoleID, client.ClientData.ZoneID, client.ClientData.CombatForce);
                if (result == (int)KuaFuRoleStates.SignUp)
                {
                    // 报名成功
                    client.ClientData.SignUpGameType = (int)GameTypes.MoRiJudge;

                    // 报名统计
                    GlobalNew.UpdateKuaFuRoleDayLogData(client.ServerId, client.ClientData.RoleID, TimeUtil.NowDateTime(), client.ClientData.ZoneID, 1, 0, 0, 0, (int)GameTypes.MoRiJudge);
                }

                //发送结果给客户端
                client.sendCmd(nID, result.ToString());
                return(true);
            }

            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false);
            }

            return(false);
        }