Example #1
0
        public static TCPProcessCmdResults RequestNewGroupMailList(DBManager dbMgr, 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 beginID = Convert.ToInt32(fields[0]);
                List <GroupMailData> GroupMailList = GroupMailManager.GetGroupMailList(beginID);
                byte[] retBytes = DataHelper.ObjectToBytes <List <GroupMailData> >(GroupMailList);
                tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, retBytes, 0, retBytes.Length, nID);
            }
            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, "", false, false);
            }
            return(TCPProcessCmdResults.RESULT_DATA);
        }
Example #2
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);
                }
            }
        }
Example #3
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);
     }
 }