示例#1
0
        public bool LoadConfig()
        {
            bool bResult = true;

            try
            {
            }
            catch (Exception ex)
            {
                bResult = false;
                LogManager.WriteLog(LogTypes.Error, "load " + GoodsPriceCfgFile + " exception!", ex);
            }

            try
            {
                List <TradeConfigItem> tmpTradeCfgItems = new List <TradeConfigItem>();
                XElement xml = XElement.Load(Global.GameResPath(TradeBlackCfgFile));
                foreach (var xmlItem in xml.Elements())
                {
                    TradeConfigItem item = new TradeConfigItem();
                    item.Id       = (int)Global.GetSafeAttributeLong(xmlItem, "ID");
                    item.MinVip   = (int)Global.GetSafeAttributeLong(xmlItem, "MinVip");
                    item.MaxVip   = (int)Global.GetSafeAttributeLong(xmlItem, "MaxVip");
                    item.MaxPrice = (int)Global.GetSafeAttributeLong(xmlItem, "MaxPrice");
                    item.MaxTimes = (int)Global.GetSafeAttributeLong(xmlItem, "MaxNum");
                    int cl, lvl;
                    cl  = (int)Global.GetSafeAttributeLong(xmlItem, "MinZhuanSheng");
                    lvl = (int)Global.GetSafeAttributeLong(xmlItem, "MinLevel");
                    item.UnionMinLevel = Global.GetUnionLevel(cl, lvl);
                    cl  = (int)Global.GetSafeAttributeLong(xmlItem, "MaxZhuanSheng");
                    lvl = (int)Global.GetSafeAttributeLong(xmlItem, "MaxLevel");
                    item.UnionMaxLevel = Global.GetUnionLevel(cl, lvl);

                    tmpTradeCfgItems.Add(item);
                }

                this.TradeCfgItems = tmpTradeCfgItems;
            }
            catch (Exception ex)
            {
                bResult = false;
                LogManager.WriteLog(LogTypes.Error, "load " + TradeBlackCfgFile + " exception!", ex);
            }

            string        szPlatFlag = string.Empty;
            PlatformTypes pt         = GameCoreInterface.getinstance().GetPlatformType();

            if (pt == PlatformTypes.Android)
            {
                szPlatFlag = "Android";
            }
            else if (pt == PlatformTypes.YueYu)
            {
                szPlatFlag = "YueYu";
            }
            else if (pt == PlatformTypes.APP)
            {
                szPlatFlag = "APP";
            }
            else if (pt == PlatformTypes.YYB)
            {
                szPlatFlag = "YYB";
            }

            this.BanTradeSec   = (int)GameManager.systemParamsList.GetParamValueIntByName("NoTrade_" + szPlatFlag);
            this.BanTradeLog   = (int)GameManager.systemParamsList.GetParamValueIntByName("TradeLog_" + szPlatFlag);
            this.BanTradeLogin = (int)GameManager.systemParamsList.GetParamValueIntByName("TradeKill_" + szPlatFlag);

            return(bResult);
        }
示例#2
0
        /// <summary>
        /// 检查封禁交易
        /// </summary>
        /// <param name="roleId"></param>
        private void CheckBanTrade(int roleId)
        {
            TradeBlackObject obj = LoadTradeBlackObject(roleId);

            if (obj == null)
            {
                return;
            }

            int kick_out_minutes = -1;

            lock (obj)
            {
                if (obj.BanTradeToTicks <= 0)
                {
                    List <TradeConfigItem> items = this.TradeCfgItems;
                    TradeConfigItem        item  = items != null?items.Find(_i => {
                        return(_i.MinVip <= obj.VipLevel && _i.MaxVip >= obj.VipLevel &&
                               _i.UnionMinLevel <= Global.GetUnionLevel(obj.ChangeLife, obj.Level) &&
                               _i.UnionMaxLevel >= Global.GetUnionLevel(obj.ChangeLife, obj.Level));
                    }) : null;

                    if (item != null)
                    {
                        long totalInPrice = 0, totalOutPrice = 0, totalTimes = 0;
                        foreach (var hourItem in obj.HourItems)
                        {
                            if (hourItem == null)
                            {
                                continue;
                            }

                            totalInPrice  += hourItem.MarketInPrice + hourItem.TradeInPrice;
                            totalOutPrice += hourItem.MarketOutPrice + hourItem.TradeOutPrice;
                            totalTimes    += hourItem.MarketTimes + hourItem.TradeTimes;
                        }

                        if (totalInPrice >= item.MaxPrice || totalOutPrice >= item.MaxPrice || totalTimes >= item.MaxTimes)
                        {
                            int _banTradeSec = Math.Max(this.BanTradeSec, 0);
                            if (_banTradeSec > 0)
                            {
                                long toTicks = TimeUtil.NowDateTime().AddSeconds(_banTradeSec).Ticks;
                                SetBanTradeToTicks(roleId, toTicks);
                            }

                            if (this.BanTradeLog == 1)
                            {
                                LogManager.WriteLog(LogTypes.Analysis, string.Format("tradeblack player={0} inprice={1} outprice={2} times={3} bansec={4}", roleId, totalInPrice, totalOutPrice, totalTimes, _banTradeSec));
                            }

                            kick_out_minutes = Math.Max(this.BanTradeLogin, 0) / 60;
                            if (kick_out_minutes > 0)
                            {
                                BanManager.BanRoleName(Global.FormatRoleName3(obj.ZoneId, obj.RoleName), kick_out_minutes, (int)BanManager.BanReason.TradeException);
                            }
                        }
                    }
                }
            }

            if (kick_out_minutes > 0)
            {
                GameClient client = GameManager.ClientMgr.FindClient(roleId);
                if (client != null)
                {
                    GameManager.ClientMgr.NotifyImportantMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client,
                                                             StringUtil.substitute(Global.GetLang("系统检测到您交易异常,您的帐号将被禁止登录{0}分钟!"), kick_out_minutes), GameInfoTypeIndexes.Error, ShowGameInfoTypes.HintAndBox);

                    Global.ForceCloseClient(client, "交易封禁");

                    /*
                     * string gmCmdData = string.Format("-kick {0}", obj.RoleName);
                     * //转发GM消息到DBServer
                     * GameManager.DBCmdMgr.AddDBCmd((int)TCPGameServerCmds.CMD_SPR_CHAT,
                     *  string.Format("{0}:{1}:{2}:{3}:{4}:{5}:{6}:{7}:{8}", obj.RoleId, "", 0, "", 0, gmCmdData, 0, 0, GameManager.ServerLineID),
                     *  null, GameManager.LocalServerId);
                     */
                }
            }
        }
        private void CheckBanTrade(int roleId)
        {
            TradeBlackObject obj = this.LoadTradeBlackObject(roleId, true);

            if (obj != null)
            {
                int kick_out_minutes = -1;
                lock (obj)
                {
                    if (obj.BanTradeToTicks <= 0L)
                    {
                        List <TradeConfigItem> items = this.TradeCfgItems;
                        TradeConfigItem        tradeConfigItem;
                        if (items == null)
                        {
                            tradeConfigItem = null;
                        }
                        else
                        {
                            tradeConfigItem = items.Find((TradeConfigItem _i) => _i.MinVip <= obj.VipLevel && _i.MaxVip >= obj.VipLevel && _i.UnionMinLevel <= Global.GetUnionLevel(obj.ChangeLife, obj.Level, false) && _i.UnionMaxLevel >= Global.GetUnionLevel(obj.ChangeLife, obj.Level, false));
                        }
                        TradeConfigItem item = tradeConfigItem;
                        if (item != null)
                        {
                            long totalInPrice  = 0L;
                            long totalOutPrice = 0L;
                            long totalTimes    = 0L;
                            foreach (TradeBlackHourItem hourItem in obj.HourItems)
                            {
                                if (hourItem != null)
                                {
                                    totalInPrice  += hourItem.MarketInPrice + hourItem.TradeInPrice;
                                    totalOutPrice += hourItem.MarketOutPrice + hourItem.TradeOutPrice;
                                    totalTimes    += (long)(hourItem.MarketTimes + hourItem.TradeTimes);
                                }
                            }
                            if (totalInPrice >= (long)item.MaxPrice || totalOutPrice >= (long)item.MaxPrice || totalTimes >= (long)item.MaxTimes)
                            {
                                int _banTradeSec = Math.Max(this.BanTradeSec, 0);
                                if (_banTradeSec > 0)
                                {
                                    long toTicks = TimeUtil.NowDateTime().AddSeconds((double)_banTradeSec).Ticks;
                                    this.SetBanTradeToTicks(roleId, toTicks);
                                }
                                if (this.BanTradeLog == 1)
                                {
                                    LogManager.WriteLog(LogTypes.Analysis, string.Format("tradeblack player={0} inprice={1} outprice={2} times={3} bansec={4}", new object[]
                                    {
                                        roleId,
                                        totalInPrice,
                                        totalOutPrice,
                                        totalTimes,
                                        _banTradeSec
                                    }), null, true);
                                }
                                kick_out_minutes = Math.Max(this.BanTradeLogin, 0) / 60;
                                if (kick_out_minutes > 0)
                                {
                                    BanManager.BanRoleName(Global.FormatRoleName3(obj.ZoneId, obj.RoleName), kick_out_minutes, 3);
                                }
                            }
                        }
                    }
                }
                if (kick_out_minutes > 0)
                {
                    GameClient client = GameManager.ClientMgr.FindClient(roleId);
                    if (client != null)
                    {
                        GameManager.ClientMgr.NotifyImportantMsg(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, client, StringUtil.substitute(GLang.GetLang(36, new object[0]), new object[]
                        {
                            kick_out_minutes
                        }), GameInfoTypeIndexes.Error, ShowGameInfoTypes.HintAndBox, 0);
                        Global.ForceCloseClient(client, "交易封禁", true);
                    }
                }
            }
        }