Пример #1
0
        public static void Tick()
        {
            LoadBanFile();

            if (null == m_BanList)
            {
                return;
            }

            // 如果需要清除 就清除掉
            if (m_IsNeedClear > 0)
            {
                m_BanList.Clear();
                m_IsNeedClear = 0;
            }

            bool bCrashForce = GameManager.VersionSystemOpenMgr.IsVersionSystemOpen(VersionSystemOpenKey.CrashUnityForce);

            int i = 20;

            while (i > 0 && m_BanList.Count > 0)
            {
                i--;

                string userID = m_BanList[m_BanList.Count - 1];
                m_BanList.RemoveAt(m_BanList.Count - 1);

                BanManager.BanUserID2Memory(userID);

                TMSKSocket clientSocket = GameManager.OnlineUserSession.FindSocketByUserID(userID);

                if (null == clientSocket)
                {
                    continue;
                }

                GameClient gameClient = GameManager.ClientMgr.FindClient(clientSocket);

                // 封号删除
                if (null != gameClient)
                {
                    RoleData roleData = new RoleData()
                    {
                        RoleID = StdErrorCode.Error_70
                    };
                    gameClient.sendCmd((int)TCPGameServerCmds.CMD_INIT_GAME, roleData);

                    //string gmCmdData = string.Format("-ban4 {0} 1", gameClient.ClientData.RoleID);

                    //转发GM消息到DBServer
                    //GameManager.DBCmdMgr.AddDBCmd((int)TCPGameServerCmds.CMD_SPR_CHAT,
                    //    string.Format("{0}:{1}:{2}:{3}:{4}:{5}:{6}:{7}:{8}", 0, "", 0, "", 0, gmCmdData, 0, 0, 0, 0, GameManager.ServerLineID),
                    //    null, GameManager.LocalServerId);

                    if (bCrashForce)
                    {
                        SendMagicCrashMsg(gameClient, MagicCrashUnityType.CrashTimeOut);
                    }

                    // log it!
                    LogManager.WriteLog(LogTypes.FileBan, string.Format("FileBanLogic ban2 userID={0} roleID={1}", userID, gameClient.ClientData.RoleID));
                }
                else
                {
                    // log it!
                    //关闭连接
                    Global.ForceCloseSocket(clientSocket, "被禁止登陆");
                    LogManager.WriteLog(LogTypes.FileBan, string.Format("FileBanLogic ForceCloseSocket userID={0}", userID));
                }
            }
        }
Пример #2
0
        private static int GetLeftCountByType(GameClient client, int type, int copyId)
        {
            int leftnum = 0;

            switch (type)
            {
            case 1:
            {
                DailyTaskData dailyTaskData = Global.FindDailyTaskDataByTaskClass(client, 8);
                if (null == dailyTaskData)
                {
                    return(10);
                }
                int maxnum = Global.GetMaxDailyTaskNum(client, 8, dailyTaskData);
                leftnum = maxnum - dailyTaskData.RecNum;
                goto IL_4AC;
            }

            case 5:
            {
                int nMapID = Global.GetDaimonSquareCopySceneIDForRole(client);
                DaimonSquareDataInfo bcDataTmp = null;
                Data.DaimonSquareDataInfoList.TryGetValue(nMapID, out bcDataTmp);
                int nDate  = TimeUtil.NowDateTime().DayOfYear;
                int nCount = Global.QueryDayActivityEnterCountToDB(client, client.ClientData.RoleID, nDate, 2);
                if (nCount < 0)
                {
                    nCount = 0;
                }
                int   nVipLev = client.ClientData.VipLevel;
                int   nNum    = 0;
                int[] nArry   = GameManager.systemParamsList.GetParamValueIntArrayByName("VIPEnterDaimonSquareCountAddValue", ',');
                if (nVipLev > 0 && nArry != null && nArry[nVipLev] > 0)
                {
                    nNum = nArry[nVipLev];
                }
                leftnum = bcDataTmp.MaxEnterNum + nNum - nCount;
                goto IL_4AC;
            }

            case 6:
            {
                int nMapID = Global.GetBloodCastleCopySceneIDForRole(client);
                BloodCastleDataInfo bcDataTmp2 = null;
                if (!Data.BloodCastleDataInfoList.TryGetValue(nMapID, out bcDataTmp2))
                {
                    goto IL_4AC;
                }
                int nDate  = TimeUtil.NowDateTime().DayOfYear;
                int nType  = 1;
                int nCount = Global.QueryDayActivityEnterCountToDB(client, client.ClientData.RoleID, nDate, nType);
                if (nCount < 0)
                {
                    nCount = 0;
                }
                int   nVipLev = client.ClientData.VipLevel;
                int   nNum    = 0;
                int[] nArry   = GameManager.systemParamsList.GetParamValueIntArrayByName("VIPEnterBloodCastleCountAddValue", ',');
                if (nVipLev > 0 && nArry != null && nArry[nVipLev] > 0)
                {
                    nNum = nArry[nVipLev];
                }
                leftnum = bcDataTmp2.MaxEnterNum + nNum - nCount;
                goto IL_4AC;
            }

            case 7:
            {
                DateTime      now            = TimeUtil.NowDateTime();
                string        nowTime        = TimeUtil.NowDateTime().ToString("HH:mm");
                List <string> timePointsList = GameManager.AngelTempleMgr.m_AngelTempleData.BeginTime;
                leftnum = 0;
                for (int i = 0; i < timePointsList.Count; i++)
                {
                    DateTime perpareTime = DateTime.Parse(timePointsList[i]).AddMinutes((double)(GameManager.AngelTempleMgr.m_AngelTempleData.PrepareTime / 60));
                    if (now <= perpareTime)
                    {
                        leftnum++;
                    }
                }
                goto IL_4AC;
            }

            case 8:
                leftnum = 1;
                if (SweepWanMotaManager.GetSweepCount(client) >= SweepWanMotaManager.nWanMoTaMaxSweepNum)
                {
                    leftnum = 0;
                }
                goto IL_4AC;

            case 9:
            {
                BufferData bufferData = Global.GetBufferDataByID(client, 34);
                leftnum = (int)(bufferData.BufferVal - (long)bufferData.BufferSecs);
                goto IL_4AC;
            }

            case 10:
                leftnum = GameManager.BattleMgr.LeftEnterCount();
                goto IL_4AC;

            case 11:
                leftnum = GameManager.ArenaBattleMgr.LeftEnterCount();
                goto IL_4AC;

            case 13:
                leftnum = JingJiChangManager.getInstance().GetLeftEnterCount(client);
                goto IL_4AC;

            case 15:
            {
                DailyTaskData dailyTaskData = Global.FindDailyTaskDataByTaskClass(client, 9);
                if (null == dailyTaskData)
                {
                    return(Global.MaxTaofaTaskNumForMU);
                }
                int maxnum = Global.GetMaxDailyTaskNum(client, 9, dailyTaskData);
                leftnum = maxnum - dailyTaskData.RecNum;
                goto IL_4AC;
            }

            case 16:
            {
                int temp = 0;
                CaiJiLogic.ReqCaiJiLastNum(client, 0, out temp);
                leftnum = temp;
                goto IL_4AC;
            }

            case 19:
                leftnum = HuanYingSiYuanManager.getInstance().GetLeftCount(client);
                goto IL_4AC;
            }
            if (copyId > 0)
            {
                SystemXmlItem systemFuBenItem = null;
                if (!GameManager.systemFuBenMgr.SystemXmlItemDict.TryGetValue(copyId, out systemFuBenItem))
                {
                    return(-1);
                }
                int enternum  = systemFuBenItem.GetIntValue("EnterNumber", -1);
                int finishnum = systemFuBenItem.GetIntValue("FinishNumber", -1);
                int total     = (enternum < finishnum) ? finishnum : enternum;
                if (type == 4 || type == 3)
                {
                    int[] nAddNum = GameManager.systemParamsList.GetParamValueIntArrayByName("VIPJinBiFuBenNum", ',');
                    if (type == 3)
                    {
                        nAddNum = GameManager.systemParamsList.GetParamValueIntArrayByName("VIPJinYanFuBenNum", ',');
                    }
                    if (client.ClientData.VipLevel > 0 && client.ClientData.VipLevel <= VIPEumValue.VIPENUMVALUE_MAXLEVEL && nAddNum != null && nAddNum.Length > VIPEumValue.VIPENUMVALUE_MAXLEVEL)
                    {
                        total += nAddNum[client.ClientData.VipLevel];
                    }
                }
                FuBenData tmpfubdata = Global.GetFuBenData(client, copyId);
                if (null == tmpfubdata)
                {
                    return(total);
                }
                leftnum = total - tmpfubdata.EnterNum;
            }
IL_4AC:
            return(leftnum);
        }
Пример #3
0
 private static bool TaskHasDone(GameClient client, int taskID)
 {
     return(client.ClientData.MainTaskID >= taskID);
 }
Пример #4
0
        private static List <TodayCandoData> GetRoleCandoData(int typeId, GameClient client)
        {
            List <TodayCandoData> candolist = new List <TodayCandoData>();
            List <TodayCandoData> result;

            if (TodayCandoManager.xmlData == null)
            {
                result = null;
            }
            else
            {
                IEnumerable <XElement> xmlItems = TodayCandoManager.xmlData.Elements();
                int iMaxlevel      = -1;
                int iMaxchangelife = -1;
                int ifirst         = 0;
                int lastSectype    = -1;
                Dictionary <int, List <TodayCandoData> > temp = new Dictionary <int, List <TodayCandoData> >();
                foreach (XElement item in xmlItems)
                {
                    if (null != item)
                    {
                        int      type      = (int)Global.GetSafeAttributeLong(item, "Type");
                        string[] minilevel = Global.GetSafeAttributeStr(item, "MinLevel").Split(new char[]
                        {
                            ','
                        });
                        string[] maxlevel = Global.GetSafeAttributeStr(item, "MaxLevel").Split(new char[]
                        {
                            ','
                        });
                        int    curmaxchangelife = Global.SafeConvertToInt32(minilevel[0]);
                        int    curmaxlevel      = Global.SafeConvertToInt32(minilevel[1]);
                        string NeedRenWu        = Global.GetSafeAttributeStr(item, "NeedRenWu");
                        bool   condition        = false;
                        if (Global.SafeConvertToInt32(minilevel[0]) < client.ClientData.ChangeLifeCount && client.ClientData.ChangeLifeCount < Global.SafeConvertToInt32(maxlevel[0]))
                        {
                            condition = true;
                        }
                        if (Global.SafeConvertToInt32(minilevel[0]) == client.ClientData.ChangeLifeCount)
                        {
                            if (Global.SafeConvertToInt32(minilevel[1]) <= client.ClientData.Level)
                            {
                                condition = true;
                            }
                        }
                        if (Global.SafeConvertToInt32(maxlevel[0]) == client.ClientData.ChangeLifeCount)
                        {
                            if (Global.SafeConvertToInt32(maxlevel[1]) >= client.ClientData.Level)
                            {
                                condition = true;
                            }
                        }
                        bool condition2;
                        if (string.IsNullOrEmpty(NeedRenWu))
                        {
                            condition2 = true;
                        }
                        else
                        {
                            int taskid = Global.SafeConvertToInt32(NeedRenWu);
                            condition2 = TodayCandoManager.TaskHasDone(client, taskid);
                        }
                        if (type == typeId && condition && condition2)
                        {
                            TodayCandoData data = new TodayCandoData();
                            data.ID = (int)Global.GetSafeAttributeLong(item, "ID");
                            int secondtype = (int)Global.GetSafeAttributeLong(item, "SecondType");
                            if (ifirst == 0)
                            {
                                lastSectype = secondtype;
                            }
                            else if (ifirst != 0 && lastSectype != secondtype)
                            {
                                iMaxchangelife = curmaxchangelife;
                                iMaxlevel      = curmaxlevel;
                            }
                            ifirst++;
                            if (iMaxchangelife < curmaxchangelife && lastSectype == secondtype)
                            {
                                if (temp.ContainsKey(secondtype))
                                {
                                    foreach (TodayCandoData tempitem in temp[secondtype])
                                    {
                                        candolist.Remove(tempitem);
                                    }
                                    temp[secondtype] = new List <TodayCandoData>();
                                }
                                iMaxchangelife = curmaxchangelife;
                                iMaxlevel      = curmaxlevel;
                            }
                            if (iMaxchangelife == curmaxchangelife && iMaxlevel < curmaxlevel && lastSectype == secondtype)
                            {
                                if (temp.ContainsKey(secondtype))
                                {
                                    foreach (TodayCandoData tempitem in temp[secondtype])
                                    {
                                        candolist.Remove(tempitem);
                                    }
                                    temp[secondtype] = new List <TodayCandoData>();
                                }
                                iMaxchangelife = curmaxchangelife;
                                iMaxlevel      = curmaxlevel;
                            }
                            int copyId    = (int)Global.GetSafeAttributeLong(item, "CodeID");
                            int leftcount = TodayCandoManager.GetLeftCountByType(client, secondtype, copyId);
                            if (leftcount > 0)
                            {
                                data.LeftCount = leftcount;
                                candolist.Add(data);
                                if (temp.ContainsKey(secondtype))
                                {
                                    temp[secondtype].Add(data);
                                }
                                else
                                {
                                    temp[secondtype] = new List <TodayCandoData>();
                                    temp[secondtype].Add(data);
                                }
                                lastSectype = secondtype;
                            }
                        }
                    }
                }
                result = candolist;
            }
            return(result);
        }
Пример #5
0
        /// <summary>
        /// 处理分享相关命令
        /// </summary>
        /// <param name="tcpMgr"></param>
        /// <param name="socket"></param>
        /// <param name="tcpClientPool"></param>
        /// <param name="pool"></param>
        /// <param name="nID"></param>
        /// <param name="data"></param>
        /// <param name="count"></param>
        /// <param name="tcpOutPacket"></param>
        /// <returns></returns>
        public static TCPProcessCmdResults ProcessShareCMD(TCPManager tcpMgr, TMSKSocket socket, TCPClientPool tcpClientPool, TCPOutPacketPool pool, int nID, byte[] data, int count, out TCPOutPacket tcpOutPacket)
        {
            tcpOutPacket = null;
            string cmdData = null;

            string[] fields = 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)));
                return(TCPProcessCmdResults.RESULT_FAILED);
            }

            try
            {
                fields = cmdData.Split(':');
                int        roleID = Convert.ToInt32(fields[0]);
                GameClient client = GameManager.ClientMgr.FindClient(socket);
                if (null == client || client.ClientData.RoleID != roleID)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("根据RoleID定位GameClient对象失败, CMD={0}, Client={1}, RoleID={2}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket), roleID));
                    return(TCPProcessCmdResults.RESULT_FAILED);
                }
                int resoult = 0;
                int extdata = 0;
                switch ((TCPGameServerCmds)nID)
                {
                case TCPGameServerCmds.CMD_SPR_GETSHARESTATE:
                    if (HasDoneShare(client))
                    {
                        if (CanGetShareAward(client))
                        {
                            extdata = 1;    //表示可领取,按钮状态激活
                        }
                        else
                        {
                            extdata = 2;    //表示已经领取
                        }
                    }
                    else
                    {
                        extdata = 0;
                    }
                    break;

                case TCPGameServerCmds.CMD_SPR_UPDATESHARESTATE:
                    UpdateRoleShareState(client);
                    if (HasDoneShare(client))
                    {
                        if (CanGetShareAward(client))
                        {
                            extdata = 1;    //表示可领取,按钮状态激活
                        }
                        else
                        {
                            extdata = 2;    //表示已经领取
                        }
                    }
                    else
                    {
                        extdata = 0;
                    }
                    break;

                case TCPGameServerCmds.CMD_SPR_GETSHAREAWARD:
                    resoult = GiveRoleShareAward(client);
                    if (resoult == 0 || resoult == -2)
                    {
                        extdata = 2;    //修改状态已经领取
                    }
                    else if (resoult == -1)
                    {
                        extdata = 0;    //按钮状态是未激活,灰色
                    }
                    else
                    {
                        extdata = 1;    //领取按钮激活,可领取
                    }
                    break;
                }
                string strcmd = string.Format("{0}:{1}", resoult, extdata);
                tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID);
            }
            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, "ProcessShareCMD", false);
            }
            return(TCPProcessCmdResults.RESULT_DATA);
        }