Esempio n. 1
0
 public static void ProcessPaiHang(DBManager dbMgr, bool force = false)
 {
     if (force)
     {
         PaiHangManager.LoadPaiHangLists(dbMgr);
     }
     else
     {
         DateTime dateTime = DateTime.Now;
         long     nowTicks = dateTime.Ticks / 10000L;
         if (nowTicks - PaiHangManager.LastUpdatePaiHangTickTimer >= 1800000L)
         {
             PaiHangManager.LastUpdatePaiHangTickTimer = nowTicks;
             PaiHangManager.LoadPaiHangLists(dbMgr);
         }
         else
         {
             int dayID = dateTime.DayOfYear;
             if (dayID != PaiHangManager.LastCheckPaiHangDayID)
             {
                 PaiHangManager.LastCheckPaiHangDayID = dayID;
                 string gmCmdData = string.Format("-updatepaihangbang", new object[0]);
                 ChatMsgManager.AddGMCmdChatMsg(-1, gmCmdData);
             }
         }
     }
 }
        public static void DoDestroyBangHui(DBManager dbMgr, int bhid)
        {
            lock (Global.BangHuiMutex)
            {
                DBWriter.DeleteBangHui(dbMgr, bhid);
                GameDBManager.BangHuiJunQiMgr.RemoveBangHuiJunQi(bhid);
                DBWriter.ClearAllRoleBangHuiInfo(dbMgr, bhid);
                List <DBRoleInfo> dbRoleInfoList = dbMgr.DBRoleMgr.GetCachingDBRoleInfoListByFaction(bhid);
                if (null != dbRoleInfoList)
                {
                    for (int i = 0; i < dbRoleInfoList.Count; i++)
                    {
                        dbRoleInfoList[i].Faction = 0;
                        dbRoleInfoList[i].BHName  = "";
                        dbRoleInfoList[i].BHZhiWu = 0;
                    }
                }
            }
            DBWriter.ClearBHLingDiByID(dbMgr, bhid);
            GameDBManager.BangHuiLingDiMgr.ClearBangHuiLingDi(bhid);
            ZhanMengShiJianManager.getInstance().onZhanMengJieSan(bhid);
            string gmCmdData = string.Format("-synclingdi", new object[0]);

            ChatMsgManager.AddGMCmdChatMsg(-1, gmCmdData);
        }
Esempio n. 3
0
        public static void AddGMCmdChatMsgToOneClient(string gmCmd)
        {
            string chatMsg = string.Format("{0}:{1}:{2}:{3}:{4}:{5}:{6}:{7}:{8}", new object[]
            {
                0,
                "",
                0,
                "",
                0,
                gmCmd,
                0,
                0,
                -1
            });
            List <LineItem> itemList = LineManager.GetLineItemList();

            if (null != itemList)
            {
                for (int i = 0; i < itemList.Count; i++)
                {
                    if (itemList[i].LineID < 9000 || itemList[i].LineID == GameDBManager.ZoneID)
                    {
                        ChatMsgManager.AddChatMsg(itemList[i].LineID, chatMsg);
                        break;
                    }
                }
            }
        }
Esempio n. 4
0
        private static void _ProcessBuyYueKa(DBManager dbMgr, DBUserInfo dbUserInfo)
        {
            int    rid       = DBQuery.LastLoginRole(dbMgr, dbUserInfo.UserID);
            string gmCmdData = string.Format("-buyyueka {0} {1}", dbUserInfo.UserID, rid);

            LogManager.WriteLog(LogTypes.Error, string.Format("处理玩家购买月卡,userid={0}, roleid={1}", dbUserInfo.UserID, rid), null, true);
            ChatMsgManager.AddGMCmdChatMsg(-1, gmCmdData);
        }
        public static void ClearBangHuiLingDi(DBManager dbMgr, int bhid)
        {
            lock (Global.BangHuiMutex)
            {
                GameDBManager.BangHuiJunQiMgr.RemoveBangHuiJunQi(bhid);
            }
            DBWriter.ClearBHLingDiByID(dbMgr, bhid);
            GameDBManager.BangHuiLingDiMgr.ClearBangHuiLingDi(bhid);
            string gmCmdData = string.Format("-synclingdi", new object[0]);

            ChatMsgManager.AddGMCmdChatMsg(-1, gmCmdData);
        }
Esempio n. 6
0
        public static TCPOutPacket GetWaitingChatMsg(TCPOutPacketPool pool, int cmdID, int serverLineID)
        {
            List <string>  msgList  = new List <string>();
            Queue <string> msgQueue = ChatMsgManager.GetChatMsgQueue(serverLineID);

            lock (msgQueue)
            {
                while (msgQueue.Count > 0 && msgList.Count < 250)
                {
                    msgList.Add(msgQueue.Dequeue());
                }
            }
            return(DataHelper.ObjectToTCPOutPacket <List <string> >(msgList, pool, cmdID));
        }
Esempio n. 7
0
        public static void ScanLastMails(DBManager dbMgr)
        {
            long nowTicks = DateTime.Now.Ticks / 10000L;

            if (nowTicks - UserMailManager.LastScanMailTicks >= 30000L)
            {
                UserMailManager.LastScanMailTicks = nowTicks;
                Dictionary <int, int> lastMailDict = DBQuery.ScanLastMailIDListFromTable(dbMgr);
                if (lastMailDict != null && lastMailDict.Count > 0)
                {
                    string gmCmd        = "";
                    string mailIDsToDel = "";
                    foreach (KeyValuePair <int, int> item in lastMailDict)
                    {
                        int        roleID     = item.Key;
                        DBRoleInfo dbRoleInfo = dbMgr.GetDBRoleInfo(ref roleID);
                        if (null != dbRoleInfo)
                        {
                            if (gmCmd.Length > 0)
                            {
                                gmCmd += "_";
                            }
                            dbRoleInfo.LastMailID = item.Value;
                            gmCmd += string.Format("{0}|{1}", dbRoleInfo.RoleID, item.Value);
                        }
                        else
                        {
                            DBWriter.UpdateRoleLastMail(dbMgr, item.Key, item.Value);
                        }
                        if (mailIDsToDel.Length > 0)
                        {
                            mailIDsToDel += ",";
                        }
                        mailIDsToDel += item.Value;
                    }
                    if (gmCmd.Length > 0)
                    {
                        string gmCmdData = string.Format("-notifymail {0}", gmCmd);
                        ChatMsgManager.AddGMCmdChatMsg(-1, gmCmdData);
                    }
                    if (mailIDsToDel.Length >= 0)
                    {
                        DBWriter.DeleteLastScanMailIDs(dbMgr, lastMailDict);
                    }
                }
            }
        }
Esempio n. 8
0
        /// <summary>
        /// 发送给gameserver 增加角色绑钻
        /// </summary>
        /// <param name="dbMgr"></param>
        /// <param name="uid"></param>
        /// <param name="rid"></param>
        /// <param name="addMoney"></param>
        public static void SendToRolebindgold(DBManager dbMgr, string uid, int rid, int addMoney)
        {
            string data = GetFirstChargeInfo(dbMgr, uid);

            if (_FirstChargeConfig == null)
            {
                LogManager.WriteException("送绑钻失败,配置表信息为空 uid=" + uid + " money=" + addMoney);
                return;
            }
            if (!_FirstChargeConfig.ContainsKey(addMoney))
            {
                return;
            }
            if (!string.IsNullOrEmpty(data))
            {
                string[] datalist = data.Split(',');

                foreach (string item in datalist)
                {
                    //已经充过了
                    if (item == addMoney.ToString())
                    {
                        return;
                    }
                }
                data += "," + addMoney;
            }
            else
            {
                data = "" + addMoney;
            }
            int bindMoney = _FirstChargeConfig[addMoney];
            //更新数据库首次记录
            bool svResoult = UpdateFirstCharge(dbMgr, uid, data);

            if (!svResoult)
            {
                LogManager.WriteException("送绑钻失败,保存数据库失败 uid=" + uid + " money=" + addMoney);
                return;
            }

            //添加GM命令消息
            string gmCmdData = string.Format("-updateBindgold {0} {1} {2} {3}", uid, rid, bindMoney, data);

            ChatMsgManager.AddGMCmdChatMsg(-1, gmCmdData);
        }
Esempio n. 9
0
        /// <summary>
        /// 添加GM命令消息
        /// </summary>
        /// <param name="serverLineID"></param>
        /// <param name="gmCmd"></param>
        public static void AddGMCmdChatMsg(int serverLineID, string gmCmd)
        {
            string          chatMsg  = string.Format("{0}:{1}:{2}:{3}:{4}:{5}:{6}:{7}:{8}", 0, "", 0, "", 0, gmCmd, 0, 0, serverLineID);
            List <LineItem> itemList = LineManager.GetLineItemList();

            if (null != itemList)
            {
                for (int i = 0; i < itemList.Count; i++)
                {
                    if (itemList[i].LineID == serverLineID)
                    {
                        continue;
                    }

                    ChatMsgManager.AddChatMsg(itemList[i].LineID, chatMsg);
                }
            }
        }
Esempio n. 10
0
 public void UpdatePreDeleteRole()
 {
     lock (this._PreDeleteRoleDict)
     {
         DBManager dbMgr = DBManager.getInstance();
         List <PreDeleteRoleInfo> DeleteRoleInfoList = new List <PreDeleteRoleInfo>();
         foreach (KeyValuePair <int, DateTime> kvp in this._PreDeleteRoleDict)
         {
             if ((TimeUtil.NowDateTime() - kvp.Value).TotalSeconds >= (double)GameDBManager.PreDeleteRoleDelaySeconds)
             {
                 int roleID = kvp.Key;
                 PreDeleteRoleInfo DelInfo = new PreDeleteRoleInfo();
                 DelInfo.RoleID = roleID;
                 DBRoleInfo dbRoleInfo = dbMgr.GetDBRoleInfo(ref roleID);
                 if (null != dbRoleInfo)
                 {
                     DelInfo.UserID = dbRoleInfo.UserID;
                     DelInfo.ZoneID = dbRoleInfo.ZoneID;
                     bool ret     = false;
                     bool hasrole = DBQuery.GetUserRole(dbMgr, dbRoleInfo.UserID, roleID);
                     if (hasrole)
                     {
                         ret = DBWriter.RemoveRole(dbMgr, roleID);
                     }
                     DBUserInfo dbUserInfo = dbMgr.GetDBUserInfo(dbRoleInfo.UserID);
                     if (ret && null != dbUserInfo)
                     {
                         DeleteRoleInfoList.Add(DelInfo);
                         this.HandleDeleteRole(dbUserInfo, dbRoleInfo);
                     }
                 }
             }
         }
         foreach (PreDeleteRoleInfo data in DeleteRoleInfoList)
         {
             string gmCmdData = string.Format("-deleterole {0} {1} {2}", data.UserID, data.RoleID, data.ZoneID);
             ChatMsgManager.AddGMCmdChatMsg(-1, gmCmdData);
             this._PreDeleteRoleDict.Remove(data.RoleID);
         }
     }
 }
Esempio n. 11
0
        /// <summary>
        /// 扫描GM命令流水发送到客户端
        /// </summary>
        public static void ScanGMMsgToGameServer(DBManager dbMgr)
        {
            try
            {
                long nowTicks = DateTime.Now.Ticks / 10000;
                if (nowTicks - LastScanInputGMMsgTicks < (10 * 1000))
                {
                    return;
                }

                LastScanInputGMMsgTicks = nowTicks;

                List <string> msgList = new List <string>();

                /// 查询GM命令的,并且写入日志中
                DBQuery.ScanGMMsgFromTable(dbMgr, msgList);

                // 如果是-config -- 更新缓存  [9/22/2013 LiaoWei]
                bool reloadConfig = false;
                for (int i = 0; i < msgList.Count; i++)
                {
                    string msg = msgList[i].Replace(":", ":");
                    ChatMsgManager.AddGMCmdChatMsg(-1, msg);

                    if (msg.IndexOf("-config ") >= 0)
                    {
                        reloadConfig = true;
                    }
                }

                if (reloadConfig)
                {
                    // 注意!! [9/22/2013 LiaoWei]
                    GameDBManager.GameConfigMgr.LoadGameConfigFromDB(dbMgr);
                }
            }
            catch (Exception)
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("扫描GM命令表时发生了错误"));
            }
        }
Esempio n. 12
0
        private static void HandleDestroyBangHuis(DBManager dbMgr)
        {
            int moneyPerLevel = GameDBManager.GameConfigMgr.GetGameConfigItemInt("money-per-qilevel", 10000);

            if (moneyPerLevel > 0)
            {
                DBWriter.SubBangHuiTongQianByQiLevel(dbMgr, moneyPerLevel);
                int        maxLevel           = GameDBManager.GameConfigMgr.GetGameConfigItemInt("juntuanbanghuimax", 8);
                string     goldjoin           = GameDBManager.GameConfigMgr.GetGameConfigItemStr("bhmatch_goldjoin", "");
                List <int> goldjoinList       = ConfigHelper.String2IntList(goldjoin, '|');
                List <int> noMoneyBangHuiList = DBQuery.GetNoMoneyBangHuiList(dbMgr, maxLevel);
                for (int i = 0; i < noMoneyBangHuiList.Count; i++)
                {
                    int bhid = noMoneyBangHuiList[i];
                    if (!goldjoinList.Exists((int x) => x == bhid))
                    {
                        BangHuiDestroyMgr.DoDestroyBangHui(dbMgr, bhid);
                        string gmCmdData = string.Format("-autodestroybh {0}", bhid);
                        ChatMsgManager.AddGMCmdChatMsg(-1, gmCmdData);
                    }
                }
            }
        }
Esempio n. 13
0
        /// <summary>
        /// 处理解散帮会
        /// </summary>
        /// <param name="dbMgr"></param>
        private static void HandleDestroyBangHuis(DBManager dbMgr)
        {
            // 临时注释掉战盟解散代码 [5/11/2014 LiaoWei]
            int moneyPerLevel = GameDBManager.GameConfigMgr.GetGameConfigItemInt("money-per-qilevel", 10000);

            //执行扣除战盟维护资金
            DBWriter.SubBangHuiTongQianByQiLevel(dbMgr, moneyPerLevel);

            //获取帮会列表数据
            List <int> noMoneyBangHuiList = DBQuery.GetNoMoneyBangHuiList(dbMgr);

            for (int i = 0; i < noMoneyBangHuiList.Count; i++)
            {
                int bhid = noMoneyBangHuiList[i];

                //执行删除帮会的操作
                BangHuiDestroyMgr.DoDestroyBangHui(dbMgr, bhid);

                //添加GM命令消息
                string gmCmdData = string.Format("-autodestroybh {0}", bhid);
                ChatMsgManager.AddGMCmdChatMsg(-1, gmCmdData);
            }
        }
Esempio n. 14
0
        public static void ScanLastGroupMails(DBManager dbMgr)
        {
            long nowTicks = DateTime.Now.Ticks / 10000L;

            if (nowTicks - GroupMailManager.LastScanGroupMailTicks >= 30000L)
            {
                GroupMailManager.LastScanGroupMailTicks = nowTicks;
                List <GroupMailData> GroupMailList = DBQuery.ScanNewGroupMailFromTable(dbMgr, GroupMailManager.LastMaxGroupMailID);
                if (GroupMailList != null && GroupMailList.Count > 0)
                {
                    foreach (GroupMailData item in GroupMailList)
                    {
                        GroupMailManager.AddGroupMailData(item);
                        if (item.GMailID > GroupMailManager.LastMaxGroupMailID)
                        {
                            GroupMailManager.LastMaxGroupMailID = item.GMailID;
                        }
                    }
                    string gmCmdData = string.Format("-notifygmail ", new object[0]);
                    ChatMsgManager.AddGMCmdChatMsg(-1, gmCmdData);
                }
            }
        }
Esempio n. 15
0
        public static void AddChatMsg(int serverLineID, string chatMsg)
        {
            LogManager.WriteLog(LogTypes.SQL, string.Format("AddChatMsg:LineID={0},Msg={1}", serverLineID, chatMsg), null, true);
            Queue <string> msgQueue = ChatMsgManager.GetChatMsgQueue(serverLineID);

            lock (msgQueue)
            {
                if (msgQueue.Count > 30000)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("线路{0}的转发消息太多,被丢弃,一共丢弃{1}条,请检查GameServer是否正常", serverLineID, msgQueue.Count), null, true);
                    List <string> cmdList = msgQueue.ToList <string>();
                    msgQueue.Clear();
                    Dictionary <string, int> cmdAnalysis = new Dictionary <string, int>();
                    foreach (string cmd in cmdList)
                    {
                        string szKey = string.Empty;
                        try
                        {
                            szKey = cmd.Split(new char[]
                            {
                                ':'
                            })[5].Split(new char[]
                            {
                                ' '
                            })[0];
                        }
                        catch
                        {
                        }
                        if (!string.IsNullOrEmpty(szKey))
                        {
                            if (cmdAnalysis.ContainsKey(szKey))
                            {
                                Dictionary <string, int> dictionary;
                                string key;
                                (dictionary = cmdAnalysis)[key = szKey] = dictionary[key] + 1;
                            }
                            else
                            {
                                cmdAnalysis[szKey] = 1;
                            }
                            if (szKey.StartsWith("-buyyueka") || szKey.StartsWith("-updateyb") || szKey.StartsWith("-updateBindgold") || szKey.StartsWith("-config"))
                            {
                                msgQueue.Enqueue(cmd);
                            }
                        }
                    }
                    if (msgQueue.Count <string>() >= 15000)
                    {
                        LogManager.WriteLog(LogTypes.Error, string.Format("线路{0}丢失重要命令{1}条", serverLineID, msgQueue.Count <string>()), null, true);
                        msgQueue.Clear();
                    }
                    List <KeyValuePair <string, int> > cmdAnaList = cmdAnalysis.ToList <KeyValuePair <string, int> >();
                    cmdAnaList.Sort((KeyValuePair <string, int> _left, KeyValuePair <string, int> _right) => _right.Value - _left.Value);
                    StringBuilder sb = new StringBuilder();
                    sb.Append("转发消息统计,").AppendFormat("共有{0}类消息:    ", cmdAnaList.Count <KeyValuePair <string, int> >()).AppendLine();
                    for (int i = 0; i < cmdAnaList.Count <KeyValuePair <string, int> >(); i++)
                    {
                        string _cmd = cmdAnaList[i].Key;
                        int    _cnt = cmdAnaList[i].Value;
                        if (_cnt <= 10)
                        {
                            break;
                        }
                        sb.AppendFormat("   cmd={0}, cnt={1}", _cmd, _cnt).AppendLine();
                    }
                    LogManager.WriteLog(LogTypes.Error, string.Format("线路{0}的转发消息太多,丢弃日志分析如下{1}", serverLineID, sb.ToString()), null, true);
                }
                msgQueue.Enqueue(chatMsg);
            }
        }
Esempio n. 16
0
        public void HandleDeleteRole(DBUserInfo dbUserInfo, DBRoleInfo dbRoleInfo)
        {
            DBManager dbMgr  = DBManager.getInstance();
            string    userID = dbUserInfo.UserID;
            int       roleID = dbRoleInfo.RoleID;

            lock (dbUserInfo)
            {
                if (dbRoleInfo.Faction > 0 && dbRoleInfo.BHZhiWu == 1)
                {
                    int  nRoleID = -1;
                    bool bGoOn   = false;
                    List <BangHuiMemberData>  bangHuiMemberDataList  = DBQuery.GetBangHuiMemberDataList(dbMgr, dbRoleInfo.Faction);
                    List <BangHuiMgrItemData> bangHuiMgrItemDataList = DBQuery.GetBangHuiMgrItemItemDataList(dbMgr, dbRoleInfo.Faction);
                    if (bangHuiMemberDataList != null && bangHuiMemberDataList.Count > 0)
                    {
                        if (bangHuiMgrItemDataList != null)
                        {
                            nRoleID = Global.GetDBRoleInfoByZhiWu(bangHuiMgrItemDataList, 2);
                            if (nRoleID <= 0)
                            {
                                nRoleID = Global.GetDBRoleInfoByZhiWu(bangHuiMgrItemDataList, 3);
                                if (nRoleID <= 0)
                                {
                                    nRoleID = Global.GetDBRoleInfoByZhiWu(bangHuiMgrItemDataList, 4);
                                    if (nRoleID <= 0)
                                    {
                                        bGoOn = true;
                                    }
                                }
                            }
                        }
                        if (bGoOn)
                        {
                            for (int i = 0; i < bangHuiMemberDataList.Count; i++)
                            {
                                if (bangHuiMemberDataList[i].RoleID != roleID)
                                {
                                    nRoleID = bangHuiMemberDataList[i].RoleID;
                                    break;
                                }
                            }
                        }
                        if (nRoleID > 0)
                        {
                            lock (Global.BangHuiMutex)
                            {
                                DBRoleInfo dbRole = dbMgr.GetDBRoleInfo(ref nRoleID);
                                if (dbRole != null)
                                {
                                    if (dbRole.Faction == dbRoleInfo.Faction)
                                    {
                                        dbRole.BHZhiWu = 1;
                                        DBWriter.UpdateBangHuiMemberZhiWu(dbMgr, dbRole.Faction, nRoleID, 1);
                                        DBWriter.UpdateBangHuiRoleID(dbMgr, nRoleID, dbRole.Faction);
                                        int    serverLineID = dbRoleInfo.ServerLineID;
                                        string strCmdData   = string.Format("0::0::0:-chbhzhiwu {0} {1} {2} {3}:0:0:-1", new object[]
                                        {
                                            dbRoleInfo.Faction,
                                            nRoleID,
                                            1,
                                            dbRoleInfo.RoleID
                                        });
                                        List <LineItem> itemList = LineManager.GetLineItemList();
                                        if (null != itemList)
                                        {
                                            for (int i = 0; i < itemList.Count; i++)
                                            {
                                                if (itemList[i].LineID != serverLineID)
                                                {
                                                    ChatMsgManager.AddChatMsg(itemList[i].LineID, strCmdData);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        BangHuiDestroyMgr.ClearBangHuiLingDi(dbMgr, dbRoleInfo.Faction);
                    }
                    else
                    {
                        BangHuiDestroyMgr.DoDestroyBangHui(dbMgr, dbRoleInfo.Faction);
                    }
                }
                dbRoleInfo.Faction  = 0;
                dbRoleInfo.BHName   = "";
                dbRoleInfo.BHZhiWu  = 0;
                dbRoleInfo.BangGong = 0;
                DBWriter.UpdateRoleBangHuiInfo(dbMgr, dbRoleInfo.RoleID, dbRoleInfo.Faction, dbRoleInfo.BHName, 0);
                int index = dbUserInfo.ListRoleIDs.IndexOf(roleID);
                if (index >= 0 && index < dbUserInfo.ListRoleIDs.Count)
                {
                    dbUserInfo.ListRoleIDs.RemoveAt(index);
                    dbUserInfo.ListRoleSexes.RemoveAt(index);
                    dbUserInfo.ListRoleOccups.RemoveAt(index);
                    dbUserInfo.ListRoleNames.RemoveAt(index);
                    dbUserInfo.ListRoleLevels.RemoveAt(index);
                    dbUserInfo.ListRoleZoneIDs.RemoveAt(index);
                    dbUserInfo.ListRoleChangeLifeCount.RemoveAt(index);
                    dbUserInfo.ListRolePreRemoveTime.RemoveAt(index);
                }
            }
        }
Esempio n. 17
0
        /// <summary>
        /// 更新用户充值的元宝数据
        /// </summary>
        public static void UpdateUsersMoney(DBManager dbMgr)
        {
            long nowTicks = DateTime.Now.Ticks / 10000;

            if (nowTicks - LastUpdateUserMoneyTicks < (3 * 1000))
            {
                return;
            }

            LastUpdateUserMoneyTicks = nowTicks;

            List <string> userIDList       = new List <string>();
            List <int>    addUserMoneyList = new List <int>();

            DBQuery.QueryTempMoney(dbMgr, userIDList, addUserMoneyList);
            if (userIDList.Count <= 0)
            {
                return;
            }

            int currentGiftID  = GameDBManager.GameConfigMgr.GetGameConfigItemInt("big_award_id", 0);
            int moneyToYuanBao = GameDBManager.GameConfigMgr.GetGameConfigItemInt("money-to-yuanbao", 10);
            int moneyToJiFen   = GameDBManager.GameConfigMgr.GetGameConfigItemInt("money-to-jifen", 1);

            for (int i = 0; i < userIDList.Count; i++)
            {
                string userID       = userIDList[i];
                int    addUserMoney = addUserMoneyList[i];

                DBUserInfo dbUserInfo = dbMgr.GetDBUserInfo(userID);
                if (null != dbUserInfo)
                {
                    int userMoney = 0;
                    int realMoney = 0;
                    int giftID    = 0;
                    int giftJiFen = 0;

                    lock (dbUserInfo)
                    {
                        dbUserInfo.Money += (addUserMoney * moneyToYuanBao); //一分钱??元宝
                        userMoney         = dbUserInfo.Money;

                        dbUserInfo.RealMoney += addUserMoney;
                        realMoney             = dbUserInfo.RealMoney;

                        if (currentGiftID != dbUserInfo.GiftID)
                        {
                            dbUserInfo.GiftJiFen = 0;
                            dbUserInfo.GiftID    = currentGiftID;
                        }

                        giftID = dbUserInfo.GiftID;

                        if (dbUserInfo.GiftID > 0)
                        {
                            dbUserInfo.GiftJiFen += (addUserMoney * moneyToJiFen); //一分钱??积分
                        }

                        giftJiFen = dbUserInfo.GiftJiFen;
                    }

                    //更新用户元宝表
                    DBWriter.UpdateUserMoney2(dbMgr, dbUserInfo.UserID, userMoney, realMoney, giftID, giftJiFen);
                    string resoult = "1";
                    int    rid     = DBQuery.LastLoginRole(dbMgr, dbUserInfo.UserID);
                    //送绑钻
                    CFirstChargeMgr.SendToRolebindgold(dbMgr, dbUserInfo.UserID, rid, addUserMoney);
                    //添加GM命令消息
                    string gmCmdData = string.Format("-updateyb {0} {1} {2} {3}", dbUserInfo.UserID, rid, addUserMoney, resoult);
                    ChatMsgManager.AddGMCmdChatMsg(-1, gmCmdData);
                }
            }
        }
Esempio n. 18
0
 public static void SendToRolebindgold(DBManager dbMgr, string uid, int rid, int addMoney, SingleChargeData chargeData)
 {
     if (chargeData == null)
     {
         LogManager.WriteException(string.Concat(new object[]
         {
             "送绑钻失败,配置表信息为空 uid=",
             uid,
             " money=",
             addMoney
         }));
     }
     else
     {
         string data        = CFirstChargeMgr.GetFirstChargeInfo(dbMgr, uid);
         string strPlat     = (uid.Length >= 4) ? uid.Substring(0, 4) : "";
         int    nPlatformID = 1;
         if (strPlat == "APPS")
         {
             nPlatformID = 2;
         }
         CFirstChargeMgr.ChargeType type = CFirstChargeMgr.ChargeType.Normal;
         string strYYB = (uid.Length >= 3) ? uid.Substring(0, 3) : "";
         if (strYYB == "YYB")
         {
             type = CFirstChargeMgr.ChargeType.YingYongBao;
         }
         else if (strYYB == "GAT" || strYYB == "430")
         {
             type = CFirstChargeMgr.ChargeType.GangAoTai;
         }
         string[] datalist = null;
         if (!string.IsNullOrEmpty(data))
         {
             datalist = data.Split(new char[]
             {
                 ','
             });
         }
         List <int> listAddMoney = CFirstChargeMgr.MuiltchargeGetBindmoney(addMoney, nPlatformID, datalist, type, chargeData);
         if (listAddMoney != null)
         {
             for (int i = 0; i < listAddMoney.Count; i++)
             {
                 if (!string.IsNullOrEmpty(data))
                 {
                     data = data + "," + listAddMoney[i];
                 }
                 else
                 {
                     data = string.Concat(listAddMoney[i]);
                 }
             }
             if (!CFirstChargeMgr.UpdateFirstCharge(dbMgr, uid, data, 0))
             {
                 LogManager.WriteException(string.Concat(new object[]
                 {
                     "送绑钻失败,保存数据库失败 uid=",
                     uid,
                     " money=",
                     addMoney
                 }));
             }
             else
             {
                 for (int i = 0; i < listAddMoney.Count; i++)
                 {
                     int    bindMoney = chargeData.singleData[listAddMoney[i]];
                     string gmCmdData = string.Format("-updateBindgold {0} {1} {2} {3}", new object[]
                     {
                         uid,
                         rid,
                         bindMoney,
                         data
                     });
                     ChatMsgManager.AddGMCmdChatMsg(-1, gmCmdData);
                 }
             }
         }
     }
 }
Esempio n. 19
0
        public static int SendAward(DBManager dbMgr, int roleID, int awardID)
        {
            FacebookAwardData awardData = FacebookManager.getFacebookAward(awardID);
            int result;

            if (awardData == null)
            {
                result = -6;
            }
            else
            {
                if (awardData.OnlyNum > 0)
                {
                    int totalNum = DBQuery.FacebookOnlyNum(dbMgr, roleID, awardID);
                    if (totalNum > 0)
                    {
                        return(-5);
                    }
                }
                if (awardData.DayMaxNum > 0)
                {
                    int totalNum = DBQuery.FacebookDayNum(dbMgr, roleID, awardID);
                    if (totalNum >= awardData.DayMaxNum)
                    {
                        return(-5);
                    }
                }
                string mailGoodsString = "";
                if (null != awardData.AwardGoods)
                {
                    foreach (GoodsData goods in awardData.AwardGoods)
                    {
                        int useCount = goods.GCount;
                        mailGoodsString += string.Format("{0}_{1}_{2}_{3}_{4}_{5}_{6}_{7}_{8}_{9}_{10}_{11}_{12}_{13}_{14}_{15}", new object[]
                        {
                            goods.GoodsID,
                            goods.Forge_level,
                            goods.Quality,
                            goods.Props,
                            useCount,
                            0,
                            0,
                            goods.Jewellist,
                            goods.AddPropIndex,
                            goods.Binding,
                            goods.BornIndex,
                            goods.Lucky,
                            goods.Strong,
                            goods.ExcellenceInfo,
                            goods.AppendPropLev,
                            goods.ChangeLifeLevForEquip
                        });
                        if (mailGoodsString.Length > 0)
                        {
                            mailGoodsString += "|";
                        }
                    }
                }
                string[] fields = new string[]
                {
                    "-1",
                    awardData.MailUser,
                    roleID.ToString(),
                    "",
                    awardData.MailTitle.ToString(),
                    awardData.MailContent.ToString(),
                    "0",
                    "0",
                    "0",
                    mailGoodsString
                };
                int addGoodsCount = 0;
                int mailID        = Global.AddMail(dbMgr, fields, out addGoodsCount);
                if (mailID > 0)
                {
                    string gmCmd     = string.Format("{0}|{1}", roleID.ToString(), mailID);
                    string gmCmdData = string.Format("-notifymail {0}", gmCmd);
                    ChatMsgManager.AddGMCmdChatMsg(-1, gmCmdData);
                    result = mailID;
                }
                else
                {
                    result = -8;
                }
            }
            return(result);
        }
Esempio n. 20
0
        public static void ScanLastGroup(DBManager dbMgr)
        {
            long nowTicks = DateTime.Now.Ticks / 10000L;

            if (nowTicks - GiftCodeNewManager.LastScanTicks >= 10000L)
            {
                GiftCodeNewManager.LastScanTicks = nowTicks;
                List <LineItem> itemList = LineManager.GetLineItemList();
                if (itemList != null && itemList.Count != 0)
                {
                    bool bExistLocalServer = false;
                    for (int i = 0; i < itemList.Count; i++)
                    {
                        if (itemList[i].LineID > 0 && (itemList[i].LineID < 9000 || itemList[i].LineID == GameDBManager.ZoneID))
                        {
                            bExistLocalServer = true;
                            break;
                        }
                    }
                    if (bExistLocalServer)
                    {
                        List <GiftCodeAwardData> groupList = DBQuery.ScanNewGiftCodeFromTable(dbMgr);
                        if (groupList != null && groupList.Count != 0)
                        {
                            string        nowtime  = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                            List <string> GiftData = new List <string>();
                            foreach (GiftCodeAwardData item in groupList)
                            {
                                if (item.RoleID > 0 && !string.IsNullOrEmpty(item.UserId) && !string.IsNullOrEmpty(item.GiftId) && !string.IsNullOrEmpty(item.CodeNo))
                                {
                                    bool isSucc = DBWriter.UpdateGiftCodeState(dbMgr, item.Dbid, 1, nowtime);
                                    if (isSucc)
                                    {
                                        string szCmd = string.Format("{0},{1},{2},{3}", new object[]
                                        {
                                            item.UserId,
                                            item.RoleID,
                                            item.GiftId,
                                            item.CodeNo
                                        });
                                        GiftData.Add(szCmd);
                                    }
                                }
                                else
                                {
                                    LogManager.WriteLog(LogTypes.Error, string.Format("[GiftCodeNew]数据表t_giftcode相关配置DBID:{0},RoleId:{1},UserId:{2}错误!", item.Dbid, item.RoleID, item.UserId), null, true);
                                }
                            }
                            if (GiftData.Count > 0)
                            {
                                string szCmds    = string.Join("#", GiftData);
                                string gmCmdData = string.Format("-giftcodecmd {0}", szCmds);
                                ChatMsgManager.AddGMCmdChatMsgToOneClient(gmCmdData);
                            }
                            groupList.Clear();
                            GiftData.Clear();
                        }
                    }
                }
            }
        }
Esempio n. 21
0
        private static void _ProcessCharge(DBManager dbMgr, DBUserInfo dbUserInfo, int chargeRoleID, int addUserMoney, int zhigouID, string chargeTm, SingleChargeData chargeData, bool bZhiGouFail = false)
        {
            int currentGiftID  = GameDBManager.GameConfigMgr.GetGameConfigItemInt("big_award_id", 0);
            int moneyToYuanBao = GameDBManager.GameConfigMgr.GetGameConfigItemInt("money-to-yuanbao", 10);
            int moneyToJiFen   = GameDBManager.GameConfigMgr.GetGameConfigItemInt("money-to-jifen", 1);
            int ChargeID       = 0;

            chargeData.MoneyVsChargeIDDict.TryGetValue(addUserMoney, out ChargeID);
            bool bWillGiveZuanShi     = zhigouID == 0 && (chargeData.ChargePlatType == 1 || addUserMoney != chargeData.YueKaMoney);
            bool bSystemProcessCharge = chargeRoleID == -1;
            bool bProcessBuyItem      = zhigouID != 0 && chargeRoleID > 0;

            lock (dbUserInfo)
            {
                if (bWillGiveZuanShi)
                {
                    dbUserInfo.Money += addUserMoney * moneyToYuanBao;
                    if (dbUserInfo.Money < 0)
                    {
                        LogManager.WriteLog(LogTypes.Error, string.Format("充值后玩家元宝变负数修正为0, UserID={0}, Money={1}, AddMoney={2}", dbUserInfo.UserID, dbUserInfo.Money, addUserMoney), null, true);
                        dbUserInfo.Money = 0;
                    }
                }
                if (!bSystemProcessCharge && !bZhiGouFail)
                {
                    dbUserInfo.RealMoney += addUserMoney;
                    if (dbUserInfo.RealMoney < 0)
                    {
                        LogManager.WriteLog(LogTypes.Error, string.Format("充值后玩家realmoney变负数修正为0, UserID={0}, Money={1}, AddMoney={2}", dbUserInfo.UserID, dbUserInfo.RealMoney, addUserMoney), null, true);
                        dbUserInfo.RealMoney = 0;
                    }
                    if (currentGiftID != dbUserInfo.GiftID)
                    {
                        dbUserInfo.GiftJiFen = 0;
                        dbUserInfo.GiftID    = currentGiftID;
                    }
                    if (dbUserInfo.GiftID > 0)
                    {
                        dbUserInfo.GiftJiFen += addUserMoney * moneyToJiFen;
                    }
                }
                int userMoney = dbUserInfo.Money;
                int realMoney = dbUserInfo.RealMoney;
                int giftID    = dbUserInfo.GiftID;
                int giftJiFen = dbUserInfo.GiftJiFen;
                DBWriter.UpdateUserInfo(dbMgr, dbUserInfo);
            }
            DBRoleInfo dbRoleInfo = Global.FindOnlineRoleInfoByUserInfo(dbMgr, dbUserInfo);

            if (dbRoleInfo != null && !bZhiGouFail)
            {
                DBWriter.UpdateCityInfoItem(dbMgr, dbRoleInfo.LastIP, dbRoleInfo.UserID, "inputmoney", addUserMoney * moneyToYuanBao);
            }
            int rid = chargeRoleID;

            if (!bSystemProcessCharge && !bProcessBuyItem)
            {
                rid = DBQuery.LastLoginRole(dbMgr, dbUserInfo.UserID);
            }
            int addUserYuanBao = Global.TransMoneyToYuanBao(addUserMoney);

            if (bProcessBuyItem)
            {
                UserMoneyMgr._ProcessBuyItem(dbMgr, dbUserInfo, chargeRoleID, addUserMoney, zhigouID, chargeTm);
            }
            int superInputFanLi = 0;

            if (!bProcessBuyItem && addUserMoney != chargeData.YueKaMoney && !bZhiGouFail)
            {
                superInputFanLi = UserMoneyMgr._ProcessSuperInputFanLi(dbMgr, dbUserInfo, chargeData, addUserMoney, ChargeID, chargeTm);
            }
            if (!bSystemProcessCharge && bWillGiveZuanShi)
            {
                CFirstChargeMgr.SendToRolebindgold(dbMgr, dbUserInfo.UserID, rid, addUserMoney, chargeData);
            }
            if (!bSystemProcessCharge && !bZhiGouFail)
            {
                SingletonTemplate <FundManager> .Instance().FundAddMoney(dbUserInfo.UserID, addUserYuanBao, rid, 0);

                GameDBManager.RankCacheMgr.OnUserDoSomething(rid, RankType.Charge, addUserYuanBao);
            }
            string gmCmdData = string.Format("-updateyb {0} {1} {2} {3} {4}", new object[]
            {
                dbUserInfo.UserID,
                rid,
                addUserMoney,
                superInputFanLi,
                zhigouID
            });

            ChatMsgManager.AddGMCmdChatMsg(-1, gmCmdData);
            LogManager.WriteLog(LogTypes.Error, string.Format("处理充值成功 UID={0},money={1},itemid={2}", dbUserInfo.UserID, addUserMoney, zhigouID), null, true);
        }
Esempio n. 22
0
        /// <summary>
        /// 扫描新邮件
        /// </summary>
        public static void ScanLastMails(DBManager dbMgr)
        {
            long nowTicks = DateTime.Now.Ticks / 10000;

            if (nowTicks - LastScanMailTicks < (30 * 1000))
            {
                return;
            }

            LastScanMailTicks = nowTicks;

            //扫描新邮件
            Dictionary <int, int> lastMailDict = DBQuery.ScanLastMailIDListFromTable(dbMgr);

            if (null != lastMailDict && lastMailDict.Count > 0)
            {
                String gmCmd = "", mailIDsToDel = "";

                foreach (var item in lastMailDict)
                {
                    DBRoleInfo dbRoleInfo = dbMgr.GetDBRoleInfo(item.Key);
                    if (null != dbRoleInfo)
                    {
                        //理论上新扫描到的肯定是最新的,如果同一个客户端同时有多封新邮件,lastMailDict中只有mailID值最大的那一封
                        if (gmCmd.Length > 0)
                        {
                            gmCmd += "_";
                        }

                        //如果本次提示用户没有打开邮件列表,下次还能继续提示
                        dbRoleInfo.LastMailID = item.Value;
                        gmCmd += String.Format("{0}|{1}", dbRoleInfo.RoleID, item.Value);
                    }
                    else
                    {
                        //缓存中没有的用户更新其数据库字段
                        DBWriter.UpdateRoleLastMail(dbMgr, item.Key, item.Value);
                    }

                    if (mailIDsToDel.Length > 0)
                    {
                        mailIDsToDel += ",";
                    }

                    mailIDsToDel += item.Value;
                }

                //通知客户端
                if (gmCmd.Length > 0)
                {
                    //添加GM命令消息
                    string gmCmdData = string.Format("-notifymail {0}", gmCmd);
                    ChatMsgManager.AddGMCmdChatMsg(-1, gmCmdData);
                }

                //清空邮件临时表中本次扫描到的信息,不能全部删除,因为处理过程中可能又有新邮件信息
                if (mailIDsToDel.Length >= 0)
                {
                    DBWriter.DeleteLastScanMailIDs(dbMgr, lastMailDict);
                }
            }
        }
Esempio n. 23
0
 public static void ScanGMMsgToGameServer(DBManager dbMgr)
 {
     try
     {
         long nowTicks = DateTime.Now.Ticks / 10000L;
         if (nowTicks - ChatMsgManager.LastScanInputGMMsgTicks >= 10000L)
         {
             ChatMsgManager.LastScanInputGMMsgTicks = nowTicks;
             List <string> msgList = new List <string>();
             DBQuery.ScanGMMsgFromTable(dbMgr, msgList);
             bool reloadConfig             = false;
             bool reloadGameserverLineList = false;
             bool reloadGMail = false;
             for (int i = 0; i < msgList.Count; i++)
             {
                 string msg = msgList[i].Replace(":", ":");
                 if (msg.IndexOf("-config ") >= 0)
                 {
                     reloadConfig = true;
                     string[] fields = msg.Trim().Split(new char[]
                     {
                         ' '
                     });
                     if (fields.Count <string>() == 3)
                     {
                         string paramName  = fields[1];
                         string paramValue = fields[2];
                         DBWriter.UpdateGameConfig(dbMgr, paramName, paramValue);
                     }
                 }
                 else if (msg == "-reload kuafu")
                 {
                     reloadGameserverLineList = true;
                 }
                 else if (msg == "-reloadall")
                 {
                     try
                     {
                         AssemblyPatchManager.getInstance().InitConfig();
                     }
                     catch (Exception ex)
                     {
                         LogManager.WriteException(ex.ToString());
                     }
                 }
                 if (msg.IndexOf("-resetgmail") >= 0)
                 {
                     reloadGMail = true;
                 }
                 if (msg.IndexOf("-outrank") >= 0)
                 {
                     GameDBManager.RankCacheMgr.PrintfRankData();
                 }
                 ChatMsgManager.AddGMCmdChatMsg(-1, msg);
             }
             if (reloadConfig)
             {
                 GameDBManager.GameConfigMgr.LoadGameConfigFromDB(dbMgr);
             }
             if (reloadGameserverLineList)
             {
                 LineManager.LoadConfig();
             }
             if (reloadGMail)
             {
                 GroupMailManager.ResetData();
             }
         }
     }
     catch (Exception)
     {
         LogManager.WriteLog(LogTypes.Error, string.Format("扫描GM命令表时发生了错误", new object[0]), null, true);
     }
 }