コード例 #1
0
 private void HandleGetZhanBao(GameServerClient client, int nID, byte[] cmdParams, int count)
 {
     try
     {
         string   cmdData = new UTF8Encoding().GetString(cmdParams, 0, count);
         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);
             client.sendCmd(30767, "0");
         }
         else
         {
             int  role        = Convert.ToInt32(fields[0]);
             int  role2       = Convert.ToInt32(fields[1]);
             long unionCouple = this.GetUnionCouple(role, role2);
             List <CoupleArenaZhanBaoItemData> result = this.GetZhanBao(unionCouple).ToList <CoupleArenaZhanBaoItemData>();
             result.Reverse();
             client.sendCmd <List <CoupleArenaZhanBaoItemData> >(nID, result);
         }
     }
     catch (Exception ex)
     {
         LogManager.WriteLog(LogTypes.Error, "HandleGetZhanBao failed, " + ex.Message, null, true);
         client.sendCmd(30767, "0");
     }
 }
コード例 #2
0
        public void processCmd(GameServerClient client, int nID, byte[] cmdParams, int count)
        {
            string cmdData = null;

            try
            {
                cmdData = new UTF8Encoding().GetString(cmdParams, 0, count);
            }
            catch (Exception)
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("解析指令字符串错误, CMD={0}", (TCPGameServerCmds)nID), null, true);
                client.sendCmd(30767, "0");
                return;
            }
            List <BaiTanLogItemData> list = new List <BaiTanLogItemData>();

            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);
                client.sendCmd <List <BaiTanLogItemData> >(30767, list);
            }
            else
            {
                int rid       = Convert.ToInt32(fields[0]);
                int pageIndex = Convert.ToInt32(fields[1]);
                client.sendCmd <List <BaiTanLogItemData> >(603, BaiTanManager.getInstance().getDetailByPageIndex(rid, pageIndex));
            }
        }
コード例 #3
0
        public void processCmd(GameServerClient client, byte[] cmdParams, int count)
        {
            string cmdData = null;
            int    nID     = 20002;

            try
            {
                cmdData = new UTF8Encoding().GetString(cmdParams, 0, count);
            }
            catch (Exception)
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("解析指令字符串错误, CMD={0}", (TCPGameServerCmds)nID));
                client.sendCmd(32767, "0");
                return;
            }
            string[] fields = cmdData.Split(new char[]
            {
                ':'
            });
            if (fields.Length != 24)
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0}, Recv={1}, CmdData={2}", (TCPGameServerCmds)nID, fields.Length, cmdData));
                client.sendCmd(32767, "0");
            }
            else
            {
                DBItemLogWriter.getInstance().insertTradeNumLog(DBManager.getInstance(), fields);
                string strcmd = string.Format("{0}", 1);
                client.sendCmd(nID, strcmd);
            }
        }
コード例 #4
0
        public static TCPProcessCmdResults ProcessDBUpdateUserLimitGoodsUsedNumCmd(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 != 5)
                {
                    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        goodsID    = Convert.ToInt32(fields[1]);
                int        dayID      = Convert.ToInt32(fields[2]);
                int        usedNum    = Convert.ToInt32(fields[3]);
                string     stage      = fields[4];
                DBRoleInfo dbRoleInfo = dbMgr.GetDBRoleInfo(ref roleID);
                if (null == dbRoleInfo)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("发起请求的角色不存在,CMD={0}, RoleID={1}", (TCPGameServerCmds)nID, roleID), null, true);
                    tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", 30767);
                    return(TCPProcessCmdResults.RESULT_DATA);
                }
                int    ret = DBWriter.AddUserLimitGoodsBuyItem(dbMgr, dbRoleInfo.UserID, goodsID, dayID, usedNum, stage);
                string strcmd;
                if (ret < 0)
                {
                    strcmd = string.Format("{0}:{1}", roleID, -1);
                    LogManager.WriteLog(LogTypes.Error, string.Format("添加限购物品的历史记录失败,CMD={0}, RoleID={1}", (TCPGameServerCmds)nID, roleID), null, true);
                }
                else
                {
                    strcmd = string.Format("{0}:{1}", roleID, 0);
                }
                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);
        }
コード例 #5
0
        public void processCmdUpdateBuildLog(GameServerClient client, int nID, byte[] cmdParams, int count)
        {
            string cmdData = null;

            try
            {
                cmdData = new UTF8Encoding().GetString(cmdParams, 0, count);
            }
            catch (Exception)
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("解析指令字符串错误, CMD={0}", (TCPGameServerCmds)nID), null, true);
                client.sendCmd(30767, "0");
                return;
            }
            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);
                client.sendCmd(30767, "0");
            }
            else
            {
                string          TimeLog = fields[0];
                BuildingLogType LogType = (BuildingLogType)Convert.ToInt32(fields[1]);
                DBManager       dbMgr   = DBManager.getInstance();
                DBWriter.UpdateBuildingLog(dbMgr, TimeLog, LogType);
                string strcmd = string.Format("{0}", 0);
                client.sendCmd(nID, strcmd);
            }
        }
コード例 #6
0
        public void processCmd(GameServerClient client, byte[] cmdParams, int count)
        {
            string cmdData = null;
            int    nID     = (int)TCPGameServerCmds.CMD_SPR_GETBAITANLOG;

            try
            {
                cmdData = new UTF8Encoding().GetString(cmdParams, 0, count);
            }
            catch (Exception) //解析错误
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("解析指令字符串错误, CMD={0}", (TCPGameServerCmds)nID));
                client.sendCmd((int)TCPGameServerCmds.CMD_DB_ERR_RETURN, "0");
                return;
            }

            List <BaiTanLogItemData> list = new List <BaiTanLogItemData>();

            string[] fields = cmdData.Split(':');
            if (fields.Length != 2)
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0}, Recv={1}, CmdData={2}",
                                                                  (TCPGameServerCmds)nID, fields.Length, cmdData));

                client.sendCmd((int)TCPGameServerCmds.CMD_DB_ERR_RETURN, list);
                return;
            }

            int rid       = Convert.ToInt32(fields[0]);
            int pageIndex = Convert.ToInt32(fields[1]);

            client.sendCmd <List <BaiTanLogItemData> >((int)TCPGameServerCmds.CMD_SPR_GETBAITANLOG, BaiTanManager.getInstance().getDetailByPageIndex(rid, pageIndex));
        }
コード例 #7
0
        public void processCmd(GameServerClient client, byte[] cmdParams, int count)
        {
            string cmd = new UTF8Encoding().GetString(cmdParams, 0, count);

            string[] param = cmd.Split(':');

            ZhanMengShiJianData data = new ZhanMengShiJianData();

            data.BHID        = Convert.ToInt32(param[0]);
            data.RoleName    = Convert.ToString(param[1]);
            data.ShiJianType = Convert.ToInt32(param[2]);
            data.SubValue1   = Convert.ToInt32(param[3]);
            data.SubValue2   = Convert.ToInt32(param[4]);
            data.SubValue3   = Convert.ToInt32(param[5]);
            data.CreateTime  = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

            //需要特殊处理的战盟事件类型: 职务改变
            if (data.ShiJianType == ZhanMengShiJianConstants.ChangeZhiWu)
            {
                string otherRoleName;
                string otherUserID;
                Global.GetRoleNameAndUserID(DBManager.getInstance(), data.SubValue3, out otherRoleName, out otherUserID);
                data.RoleName = otherRoleName;
            }

            ZhanMengShiJianManager.getInstance().onAddZhanMengShiJian(data);

            byte[] arrSendData = DataHelper.ObjectToBytes <string>(string.Format("{0}", 1));
            client.sendCmd((int)TCPGameServerCmds.CMD_DB_ADD_ZHANMENGSHIJIAN, arrSendData);
        }
コード例 #8
0
 public TCPProcessCmdResults dispathProcessor(TMSKSocket socket, int nID, byte[] data, int count)
 {
     try
     {
         CmdHandler tcpCmdHandler;
         if ((tcpCmdHandler = this.GetCmdHandler(nID)) == null)
         {
             return(TCPProcessCmdResults.RESULT_UNREGISTERED);
         }
         GameClient client = GameManager.ClientMgr.FindClient(socket);
         if (null == client)
         {
             LogManager.WriteLog(LogTypes.Error, string.Format("根据RoleID定位GameClient对象失败, CMD={0}, Client={1}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket, false)), null, true);
             return(TCPProcessCmdResults.RESULT_FAILED);
         }
         ICmdProcessorEx cmdProcessorEx = tcpCmdHandler.CmdProcessor as ICmdProcessorEx;
         if ((tcpCmdHandler.CmdFlags & 2U) > 0U)
         {
             string   cmdData   = new UTF8Encoding().GetString(data, 0, count);
             string[] cmdParams = cmdData.Split(new char[]
             {
                 ':'
             });
             if (cmdParams.Length < (int)tcpCmdHandler.MinParamCount || cmdParams.Length > (int)tcpCmdHandler.MaxParamCount)
             {
                 LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0}, Client={1}, Recv={2}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket, false), cmdParams.Length), null, true);
                 return(TCPProcessCmdResults.RESULT_FAILED);
             }
             if (null == cmdProcessorEx)
             {
                 if (!tcpCmdHandler.CmdProcessor.processCmd(client, cmdParams))
                 {
                     return(TCPProcessCmdResults.RESULT_FAILED);
                 }
             }
             else if (!cmdProcessorEx.processCmdEx(client, nID, data, cmdParams))
             {
                 return(TCPProcessCmdResults.RESULT_FAILED);
             }
             return(TCPProcessCmdResults.RESULT_OK);
         }
         else
         {
             if (null == cmdProcessorEx)
             {
                 return(TCPProcessCmdResults.RESULT_FAILED);
             }
             if (!cmdProcessorEx.processCmdEx(client, nID, data, null))
             {
                 return(TCPProcessCmdResults.RESULT_FAILED);
             }
             return(TCPProcessCmdResults.RESULT_OK);
         }
     }
     catch (Exception ex)
     {
         DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(socket), false, false);
     }
     return(TCPProcessCmdResults.RESULT_FAILED);
 }
コード例 #9
0
ファイル: CheckHelper.cs プロジェクト: songxiaopeng/mu_server
        public static bool CheckTCPCmdFields(int nID, byte[] data, int count, out string[] fields, int length)
        {
            string cmdData = null;

            fields = null;
            try
            {
                cmdData = new UTF8Encoding().GetString(data, 0, count);
            }
            catch (Exception)
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("解析指令字符串错误, CMD={0}", (TCPGameServerCmds)nID), null, true);
                return(false);
            }
            fields = cmdData.Split(new char[]
            {
                ':'
            });
            bool result;

            if (fields.Length != length)
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0},  Recv={1}, CmdData={2}", (TCPGameServerCmds)nID, fields.Length, cmdData), null, true);
                result = false;
            }
            else
            {
                result = true;
            }
            return(result);
        }
コード例 #10
0
ファイル: MapEditor.cs プロジェクト: nCore/sanguozhi
    void Load()
    {
        mMapDatas = MapManager.GetInstance().GetMapDatas();
        if (!mEditorModel)
        {
            return;
        }
        Debug.Log("Load");
        FileStream fs = new FileStream(Application.dataPath + "/mapdata.txt", FileMode.Open);

        byte[] bytes = new byte[fs.Length];
        fs.Read(bytes, 0, bytes.Length);
        fs.Close();
        string s = new UTF8Encoding().GetString(bytes);

        string[] itemIds = s.Split(';');
        // 初始化地图
        for (int i = 0; i < 200; i++)
        {
            for (int j = 0; j < 200; j++)
            {
                mMapDatas[i, j] = uint.Parse(itemIds[i * 200 + j]);
            }
        }
        Save();
    }
コード例 #11
0
ファイル: MarryPartyLogic.cs プロジェクト: chenchungit/ky
        public TCPProcessCmdResults ProcessMarryPartyQuery(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}", (TCPGameServerCmds)nID));

                tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", (int)TCPGameServerCmds.CMD_DB_ERR_RETURN);
                return(TCPProcessCmdResults.RESULT_DATA);
            }

            try
            {
                string[] fields = cmdData.Split(':');
                if (fields.Length != 1)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0}, Recv={1}, CmdData={2}",
                                                                      (TCPGameServerCmds)nID, fields.Length, cmdData));

                    tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", (int)TCPGameServerCmds.CMD_DB_ERR_RETURN);
                    return(TCPProcessCmdResults.RESULT_DATA);
                }

                int roleID = Convert.ToInt32(fields[0]);

                GameClient client = GameManager.ClientMgr.FindClient(socket);
                if (null == client)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("根据RoleID定位GameClient对象失败, CMD={0}, Client={1}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket)));
                    return(TCPProcessCmdResults.RESULT_FAILED);
                }

                if (client.ClientSocket.IsKuaFuLogin)
                {
                    client.sendCmd((int)TCPGameServerCmds.CMD_SPR_MARRY_PARTY_QUERY, new Dictionary <int, MarryPartyData>());
                }
                else
                {
                    //return Global.RequestToDBServer2(tcpClientPool, pool, (int)TCPGameServerCmds.CMD_DB_MARRY_PARTY_QUERY, string.Format("{0}", GameManager.ServerLineID), out tcpOutPacket);
                    SendMarryPartyList(client, null, roleID);
                }

                return(TCPProcessCmdResults.RESULT_OK);
            }
            catch (Exception ex)
            {
                // 格式化异常错误信息
                DataHelper.WriteFormatExceptionLog(ex, "", false);
            }

            tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", (int)TCPGameServerCmds.CMD_DB_ERR_RETURN);
            return(TCPProcessCmdResults.RESULT_DATA);
        }
コード例 #12
0
        public void processCmd(GameServerClient client, byte[] cmdParams, int count)
        {
            string cmdData = null;
            int    nID     = (int)TCPGameServerCmds.CMD_DB_ADD_BAITANLOG;

            try
            {
                cmdData = new UTF8Encoding().GetString(cmdParams, 0, count);
            }
            catch (Exception) //解析错误
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("解析指令字符串错误, CMD={0}", (TCPGameServerCmds)nID));
                client.sendCmd((int)TCPGameServerCmds.CMD_DB_ERR_RETURN, "0");
                return;
            }

            string[] fields = cmdData.Split(':');
            if (fields.Length != 12)
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0}, Recv={1}, CmdData={2}",
                                                                  (TCPGameServerCmds)nID, fields.Length, cmdData));

                client.sendCmd((int)TCPGameServerCmds.CMD_DB_ERR_RETURN, "0");
                return;
            }

            int    roleID         = Convert.ToInt32(fields[0]);
            int    otherroleid    = Convert.ToInt32(fields[1]);
            string otherrname     = fields[2];
            int    goodsid        = Convert.ToInt32(fields[3]);
            int    goodsnum       = Convert.ToInt32(fields[4]);
            int    forgelevel     = Convert.ToInt32(fields[5]);
            int    totalprice     = Convert.ToInt32(fields[6]);
            int    leftyuanbao    = Convert.ToInt32(fields[7]);
            int    YinLiang       = Convert.ToInt32(fields[8]);
            int    LeftYinLiang   = Convert.ToInt32(fields[9]);
            int    tax            = Convert.ToInt32(fields[10]);
            int    excellenceinfo = Convert.ToInt32(fields[11]);

            BaiTanLogItemData data = new BaiTanLogItemData();

            data.rid            = roleID;
            data.OtherRoleID    = otherroleid;
            data.OtherRName     = otherrname;
            data.GoodsID        = goodsid;
            data.GoodsNum       = goodsnum;
            data.ForgeLevel     = forgelevel;
            data.TotalPrice     = totalprice;
            data.LeftYuanBao    = leftyuanbao;
            data.YinLiang       = YinLiang;
            data.LeftYinLiang   = LeftYinLiang;
            data.BuyTime        = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            data.Tax            = tax;
            data.Excellenceinfo = excellenceinfo;

            BaiTanManager.getInstance().onAddBaiTanLog(data);

            client.sendCmd <string>((int)TCPGameServerCmds.CMD_DB_ADD_BAITANLOG, string.Format("{0}", 0));
        }
コード例 #13
0
        public void processCmdUpdateBuildData(GameServerClient client, int nID, byte[] cmdParams, int count)
        {
            string cmdData = null;

            try
            {
                cmdData = new UTF8Encoding().GetString(cmdParams, 0, count);
            }
            catch (Exception)
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("解析指令字符串错误, CMD={0}", (TCPGameServerCmds)nID), null, true);
                client.sendCmd(30767, "0");
                return;
            }
            string[] fields = cmdData.Split(new char[]
            {
                ':'
            });
            if (fields.Length != 9)
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0}, Recv={1}, CmdData={2}", (TCPGameServerCmds)nID, fields.Length, cmdData), null, true);
                client.sendCmd(30767, "0");
            }
            else
            {
                BuildingData myBuildData = new BuildingData();
                int          roleID      = Convert.ToInt32(fields[0]);
                myBuildData.BuildId   = Convert.ToInt32(fields[1]);
                myBuildData.BuildLev  = Convert.ToInt32(fields[2]);
                myBuildData.BuildExp  = Convert.ToInt32(fields[3]);
                myBuildData.TaskID_1  = Convert.ToInt32(fields[5]);
                myBuildData.TaskID_2  = Convert.ToInt32(fields[6]);
                myBuildData.TaskID_3  = Convert.ToInt32(fields[7]);
                myBuildData.TaskID_4  = Convert.ToInt32(fields[8]);
                myBuildData.BuildTime = fields[4].Replace('$', ':');
                DBManager  dbMgr      = DBManager.getInstance();
                DBRoleInfo dbRoleInfo = dbMgr.GetDBRoleInfo(ref roleID);
                if (null == dbRoleInfo)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("发起请求的角色不存在,CMD={0}, RoleID={1}", (TCPGameServerCmds)nID, roleID), null, true);
                    client.sendCmd(30767, "0");
                }
                else
                {
                    lock (dbRoleInfo)
                    {
                        if (null == dbRoleInfo.BuildingDataList)
                        {
                            dbRoleInfo.BuildingDataList = new List <BuildingData>();
                        }
                        this.UpdateBuildData(dbRoleInfo.BuildingDataList, myBuildData);
                    }
                    DBWriter.UpdateBuildingData(dbMgr, roleID, myBuildData);
                    string strcmd = string.Format("{0}", 0);
                    client.sendCmd(nID, strcmd);
                }
            }
        }
コード例 #14
0
        public static TCPProcessCmdResults ProcessFazhenBossCMD(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 (fields.Length != 1)
                {
                    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);
                }
                if (client.ClientData.FuBenID != LuoLanFaZhenCopySceneManager.LuoLanFaZhenFubenID)
                {
                    return(TCPProcessCmdResults.RESULT_OK);
                }
                SingleLuoLanFaZhenFubenData fubenData = LuoLanFaZhenCopySceneManager.GetFubenData(client.ClientData.FuBenSeqID);
                if (null == fubenData)
                {
                    return(TCPProcessCmdResults.RESULT_OK);
                }
                string strcmd = string.Format("{0}:{1}:{2}:{3}:{4}", new object[]
                {
                    LuoLanFaZhenCopySceneManager.LuoLanFaZhenFubenID,
                    LuoLanFaZhenCopySceneManager.FinalBossID,
                    fubenData.FinalBossLeftNum,
                    LuoLanFaZhenCopySceneManager.SpecialBossID,
                    fubenData.SpecailBossLeftNum
                });
                tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, 760);
                return(TCPProcessCmdResults.RESULT_DATA);
            }
            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, "ProcessFazhenBossCMD", false, false);
            }
            return(TCPProcessCmdResults.RESULT_FAILED);
        }
コード例 #15
0
ファイル: NameManager.cs プロジェクト: qiuhoude/mu_server
        public TCPProcessCmdResults ProcessChangeName(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 != 3)
                {
                    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    zoneId  = Convert.ToInt32(fields[1]);
                string newName = fields[2];
                string uid     = GameManager.OnlineUserSession.FindUserID(socket);
                if (string.IsNullOrEmpty(uid))
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("角色改名时,找不到socket对应的uid,其中roleid={0},zoneid={1},newname={2}", roleId, zoneId, newName), null, true);
                    return(TCPProcessCmdResults.RESULT_FAILED);
                }
                ChangeNameResult result = new ChangeNameResult();
                if (socket.IsKuaFuLogin || GameManager.ClientMgr.FindClient(socket) != null)
                {
                    result.ErrCode = 11;
                }
                else
                {
                    result.ErrCode = (int)this.HandleChangeName(uid, zoneId, roleId, newName);
                }
                result.ZoneId   = zoneId;
                result.NewName  = newName;
                result.NameInfo = this.GetChangeNameInfo(uid, zoneId, socket.ServerId);
                tcpOutPacket    = DataHelper.ObjectToTCPOutPacket <ChangeNameResult>(result, pool, nID);
                return(TCPProcessCmdResults.RESULT_DATA);
            }
            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, "", false, false);
            }
            tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", 30767);
            return(TCPProcessCmdResults.RESULT_DATA);
        }
コード例 #16
0
ファイル: QingGongYanManager.cs プロジェクト: chenchungit/ky
        /// <summary>
        /// 申请举办
        /// </summary>
        public TCPProcessCmdResults ProcessHoldQingGongYanCMD(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)));
                return(TCPProcessCmdResults.RESULT_FAILED);
            }

            try
            {
                string[] fields = cmdData.Split(':');
                if (fields.Length != 3)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0}, Client={1}, Recv={2}",
                                                                      (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket), fields.Length));
                    return(TCPProcessCmdResults.RESULT_FAILED);
                }

                int        roleID    = Convert.ToInt32(fields[0]);
                int        Index     = Convert.ToInt32(fields[1]);
                int        OnlyCheck = Convert.ToInt32(fields[2]);
                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);
                }

                QingGongYanResult result = HoldQingGongYan(client, Index, OnlyCheck);
                string            strcmd = "";

                if (result != QingGongYanResult.Success)
                {
                    strcmd       = string.Format("{0}:{1}:{2}", (int)result, roleID, OnlyCheck);
                    tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID);
                    return(TCPProcessCmdResults.RESULT_DATA);
                }

                strcmd       = string.Format("{0}:{1}:{2}", (int)QingGongYanResult.Success, roleID, OnlyCheck);
                tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID);
                return(TCPProcessCmdResults.RESULT_DATA);
            }

            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, "ProcessHoldQingGongYanCMD", false);
            }


            return(TCPProcessCmdResults.RESULT_FAILED);
        }
コード例 #17
0
ファイル: DBCmdManager.cs プロジェクト: neyma2379294/MuOrigin
        /// <summary>
        /// 执行数据库命令
        /// </summary>
        public void ExecuteDBCmd(TCPClientPool tcpClientPool, TCPOutPacketPool pool)
        {
            lock (_DBCmdQueue)
            {
                if (_DBCmdQueue.Count <= 0)
                {
                    return;
                }
            }

            List <DBCommand> dbCmdList = new List <DBCommand>();

            lock (_DBCmdQueue)
            {
                while (_DBCmdQueue.Count > 0)
                {
                    dbCmdList.Add(_DBCmdQueue.Dequeue());
                }
            }

            Int32  length  = 0;
            Int16  cmd     = 0;
            string strData = null;

            string[]             fieldsData = null;
            byte[]               bytesData  = null;
            TCPProcessCmdResults result;

            for (int i = 0; i < dbCmdList.Count; i++)
            {
                result = DoDBCmd(tcpClientPool, pool, dbCmdList[i], out bytesData);
                if (result == TCPProcessCmdResults.RESULT_FAILED)
                {
                    //写日志
                    LogManager.WriteLog(LogTypes.Error, string.Format("向DBServer请求执行命令失败, CMD={0}", (TCPGameServerCmds)dbCmdList[i].DBCommandID));
                }
                else
                {
                    //解析返回值
                    length  = BitConverter.ToInt32(bytesData, 0);
                    cmd     = BitConverter.ToInt16(bytesData, 4);
                    strData = new UTF8Encoding().GetString(bytesData, 6, length - 2);

                    //解析客户端的指令
                    fieldsData = strData.Split(':');
                }

                //执行事件
                dbCmdList[i].DoDBCommandEvent(new DBCommandEventArgs()
                {
                    Result = result, fields = fieldsData
                });

                //还回队列
                _DBCmdPool.Push(dbCmdList[i]);
            }
        }
コード例 #18
0
ファイル: VideoLogic.cs プロジェクト: chenchungit/ky
        /// <summary>
        /// 获取视频聊天室相关数据
        /// </summary>
        /// <param name="socket"></param>
        /// <param name="pool"></param>
        /// <param name="nID"></param>
        /// <param name="tcpOutPacket"></param>
        /// <returns></returns>
        public static TCPProcessCmdResults ProcessOpenVideoCmd(TMSKSocket socket, 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));

                tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", (int)TCPGameServerCmds.CMD_SPR_VIDEO_OPEN);
                return(TCPProcessCmdResults.RESULT_DATA);
            }

            try
            {
                string[] fields = cmdData.Split(':');
                if (fields.Length != 1)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0}, Recv={1}, CmdData={2}",
                                                                      (TCPGameServerCmds)nID, fields.Length, cmdData));

                    tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", (int)TCPGameServerCmds.CMD_SPR_VIDEO_OPEN);
                    return(TCPProcessCmdResults.RESULT_DATA);
                }

                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);
                }

                VideoData roomData = GetVideoRoomData(client);
                if (roomData == null)
                {
                    tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "", nID);
                    return(TCPProcessCmdResults.RESULT_DATA);
                }
                var filterStatus = GetPlayerFilterStatus(client, roomData);

                string strcmd = string.Format("{0}:{1}:{2}", roomData.TalkID, roomData.PassWord, filterStatus);
                tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID);
            }
            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(socket), false);
            }

            return(TCPProcessCmdResults.RESULT_DATA);
        }
コード例 #19
0
        /// <summary>
        /// 整理精灵背包
        /// </summary>
        public static TCPProcessCmdResults ProcessResetPetBagCMD(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)));
                return(TCPProcessCmdResults.RESULT_FAILED);
            }

            try
            {
                string[] fields = cmdData.Split(':');
                if (fields.Length != 1)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0}, Client={1}, Recv={2}",
                                                                      (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket), fields.Length));
                    return(TCPProcessCmdResults.RESULT_FAILED);
                }

                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);
                }

                ResetPetBagAllGoods(client);
                return(TCPProcessCmdResults.RESULT_OK);

                /*CallSpriteResult result = ResetPetBagAllGoods(client);
                 * string strcmd = "";
                 *
                 * if (result != CallSpriteResult.Success)
                 * {
                 *  strcmd = string.Format("{0}:{1}:{2}", (int)result, roleID, dbid);
                 *  tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID);
                 *  return TCPProcessCmdResults.RESULT_DATA;
                 * }*/

                //strcmd = string.Format("{0}:{1}:{2}", (int)CallSpriteResult.Success, roleID, dbid);
                //tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID);
                //return TCPProcessCmdResults.RESULT_DATA;
            }
            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, "ProcessResetPetBagCMD", false);
            }

            return(TCPProcessCmdResults.RESULT_FAILED);
        }
コード例 #20
0
        public TCPProcessCmdResults ProcGetJieriGiveKingAward(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 != 3)
                {
                    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     fromDate = fields[1].Replace('$', ':');
                string     toDate   = fields[2].Replace('$', ':');
                DBRoleInfo roleInfo = dbMgr.GetDBRoleInfo(ref roleID);
                if (null == roleInfo)
                {
                    tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, string.Format("{0}", -1001), nID);
                    return(TCPProcessCmdResults.RESULT_DATA);
                }
                string huoDongKeyStr = Global.GetHuoDongKeyString(fromDate, toDate);
                lock (roleInfo)
                {
                    int ret = DBWriter.AddHongDongAwardRecordForRole(dbMgr, roleInfo.RoleID, roleInfo.ZoneID, 51, huoDongKeyStr, 1, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                    if (ret < 0)
                    {
                        tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, string.Format("{0}", -1008), nID);
                        return(TCPProcessCmdResults.RESULT_DATA);
                    }
                }
                tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, string.Format("{0}", 1), nID);
                return(TCPProcessCmdResults.RESULT_DATA);
            }
            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, "", false, false);
            }
            tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", 30767);
            return(TCPProcessCmdResults.RESULT_DATA);
        }
コード例 #21
0
        /// <summary>
        /// 客户端请求user的二级密码状态
        /// </summary>
        public static TCPProcessCmdResults ProcessUsrCheckState(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)));
                return(TCPProcessCmdResults.RESULT_FAILED);
            }

            try
            {
                // usrid:zoneid
                string[] fields = cmdData.Split(':');
                if (2 != fields.Length)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0}, Client={1}, Recv={2}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket), fields.Length));
                    return(TCPProcessCmdResults.RESULT_FAILED);
                }

                string userid = fields[0];

                /*
                 * 在CMD_LOGIN_ON的时候,会初始化usrid对应的二级密码状态
                 * 所以客户端请求二级密码状态时,已经被正确初始化
                 * 服务器返回has:need
                 * has:是否有二级密码
                 * need:是否需要验证二级密码
                 */
                SecPwdState pwdState = GetSecPwdState(userid);
                string      cmdRsp   = null;
                if (pwdState != null)
                {
                    cmdRsp = string.Format("{0}:{1}", 1, pwdState.NeedVerify ? 1 : 0);
                }
                else
                {
                    cmdRsp = string.Format("{0}:{1}", 0, 0);
                }

                tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, cmdRsp, nID);
                return(TCPProcessCmdResults.RESULT_DATA);
            }
            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(socket), false);
            }

            return(TCPProcessCmdResults.RESULT_FAILED);
        }
コード例 #22
0
ファイル: MarryPartyLogic.cs プロジェクト: chenchungit/ky
        public TCPProcessCmdResults ProcessMarryPartyCreate(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)));
                return(TCPProcessCmdResults.RESULT_FAILED);
            }

            try
            {
                string[] fields = cmdData.Split(':');
                if (fields.Length != 3)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0}, Client={1}, Recv={2}",
                                                                      (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket), fields.Length));
                    return(TCPProcessCmdResults.RESULT_FAILED);
                }

                int  roleID    = Convert.ToInt32(fields[0]);
                int  partyType = Convert.ToInt32(fields[1]);
                long startTime = Convert.ToInt64(fields[2]);

                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);
                }

                if (client.ClientSocket.IsKuaFuLogin)
                {
                    client.sendCmd(nID, string.Format("{0}:{1}", (int)StdErrorCode.Error_Operation_Denied, roleID));
                    return(TCPProcessCmdResults.RESULT_OK);
                }

                MarryPartyResult result = MarryPartyCreate(client, partyType, startTime);

                string strcmd = string.Format("{0}:{1}", (int)result, roleID);
                tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID);
                return(TCPProcessCmdResults.RESULT_DATA);
            }

            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, "ProcessMarryPartyCreate", false);
            }

            return(TCPProcessCmdResults.RESULT_FAILED);
        }
コード例 #23
0
 public TCPProcessCmdResults ProcAddBangHuiChangeNameTimes(DBManager dbMgr, TCPOutPacketPool pool, int nID, byte[] data, int count, out TCPOutPacket tcpOutPacket)
 {
     tcpOutPacket = null;
     try
     {
         string   cmdData = new UTF8Encoding().GetString(data, 0, count);
         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        addValue = Convert.ToInt32(fields[1]);
         DBRoleInfo roleInfo = dbMgr.GetDBRoleInfo(ref roleId);
         int        ne;
         if (null == roleInfo)
         {
             ne = -1;
         }
         else
         {
             int    factionId = roleInfo.Faction;
             string sql       = string.Format("UPDATE t_banghui SET can_mod_name_times=can_mod_name_times+{0} WHERE bhid={1}", addValue, factionId);
             if (!this._Util_ExecNonQuery(dbMgr, sql))
             {
                 ne = -3;
             }
             else
             {
                 BangHuiDetailData detail = DBQuery.QueryBangHuiInfoByID(dbMgr, factionId);
                 if (detail == null)
                 {
                     ne = -2;
                 }
                 else
                 {
                     ne = detail.CanModNameTimes;
                 }
             }
         }
         byte[] bytesData = DataHelper.ObjectToBytes <int>(ne);
         tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, bytesData, 0, bytesData.Length, nID);
         return(TCPProcessCmdResults.RESULT_DATA);
     }
     catch (Exception ex)
     {
         DataHelper.WriteFormatExceptionLog(ex, "", false, false);
     }
     tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", 30767);
     return(TCPProcessCmdResults.RESULT_DATA);
 }
コード例 #24
0
        private void HandleLoad(GameServerClient client, int nID, byte[] cmdParams, int count)
        {
            List <TradeBlackHourItem> items = null;
            MySQLConnection           conn  = null;

            try
            {
                string   reqCmd = new UTF8Encoding().GetString(cmdParams, 0, count);
                string[] fields = reqCmd.Split(new char[]
                {
                    ':'
                });
                int        roleid   = Convert.ToInt32(fields[0]);
                string     currDay  = fields[1].Trim();
                int        currHour = Convert.ToInt32(fields[2]);
                DBRoleInfo dbRole   = DBManager.getInstance().GetDBRoleInfo(ref roleid);
                if (dbRole == null)
                {
                    throw new Exception("TradeBlackManager.HandleLoad not Find DBRoleInfo, roleid=" + roleid);
                }
                conn = DBManager.getInstance().DBConns.PopDBConnection();
                string sql = string.Format("SELECT day,hour,distinct_roles,market_times,market_in_price,market_out_price,trade_times,trade_in_price,trade_out_price FROM t_ban_trade WHERE rid={0} AND ((TO_DAYS('{1}') - TO_DAYS(day) = 0 AND hour <= {2}) or (TO_DAYS('{1}') - TO_DAYS(day) = 1 AND hour > {2}))", roleid, currDay, currHour);
                GameDBManager.SystemServerSQLEvents.AddEvent(string.Format("+SQL: {0}", sql), EventLevels.Important);
                MySQLCommand    cmd    = new MySQLCommand(sql, conn);
                MySQLDataReader reader = cmd.ExecuteReaderEx();
                items = new List <TradeBlackHourItem>();
                while (reader.Read())
                {
                    items.Add(new TradeBlackHourItem
                    {
                        RoleId = roleid,
                        Day    = reader["day"].ToString().Trim(),
                        Hour   = Convert.ToInt32(reader["hour"].ToString()),
                        TradeDistinctRoleCount = Convert.ToInt32(reader["distinct_roles"].ToString()),
                        MarketInPrice          = Convert.ToInt64(reader["market_in_price"]),
                        MarketTimes            = Convert.ToInt32(reader["market_times"]),
                        MarketOutPrice         = Convert.ToInt64(reader["market_out_price"]),
                        TradeInPrice           = Convert.ToInt64(reader["Trade_in_price"]),
                        TradeTimes             = Convert.ToInt32(reader["Trade_times"]),
                        TradeOutPrice          = Convert.ToInt64(reader["Trade_out_price"])
                    });
                }
            }
            catch (Exception ex)
            {
                LogManager.WriteException("TradeBlackManager.HandleLoad " + ex.Message);
            }
            finally
            {
                if (null != conn)
                {
                    DBManager.getInstance().DBConns.PushDBConnection(conn);
                }
            }
            client.sendCmd <List <TradeBlackHourItem> >(nID, items);
        }
コード例 #25
0
        public static TCPProcessCmdResults ProcessGetActiveAwards(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}", (TCPGameServerCmds)nID), null, true);
                tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", 30767);
                return(TCPProcessCmdResults.RESULT_DATA);
            }
            try
            {
                string[] fields = cmdData.Split(new char[]
                {
                    ':'
                });
                if (fields.Length != 3)
                {
                    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        activityType = Global.SafeConvertToInt32(fields[1]);
                int        extTag       = Global.SafeConvertToInt32(fields[2]);
                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);
                }
                switch (activityType)
                {
                case 33:
                    return(NewZoneActiveManager.GetNewLevelUpMadmanAward(client, pool, nID, roleID, activityType, extTag, out tcpOutPacket));

                case 34:
                case 35:
                case 36:
                case 37:
                    return(NewZoneActiveManager.GetActiveAwards(client, tcpClientPool, pool, nID, roleID, activityType, out tcpOutPacket));
                }
            }
            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, "", false, false);
            }
            tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", 30767);
            return(TCPProcessCmdResults.RESULT_DATA);
        }
コード例 #26
0
        public TCPProcessCmdResults ProcQueryJieriGiveInfo(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 != 5)
                {
                    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        actType             = Convert.ToInt32(fields[1]);
                string     fromDate            = fields[2].Replace('$', ':');
                string     toDate              = fields[3].Replace('$', ':');
                int        todayIdxInActPeriod = Convert.ToInt32(fields[4]);
                DBRoleInfo roleInfo            = dbMgr.GetDBRoleInfo(ref roleID);
                if (null == roleInfo)
                {
                    tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "-1", nID);
                    return(TCPProcessCmdResults.RESULT_DATA);
                }
                int    awardBitFlag = 0;
                int    totalGive    = 0;
                int    totalRecv    = 0;
                string lastgettime_just_placeholder = string.Empty;
                JieriGiveActHandler.GetTotalGiveAndRecv(dbMgr, roleID, fromDate, toDate, out totalGive, out totalRecv);
                DBQuery.GetAwardHistoryForRole(dbMgr, roleID, roleInfo.ZoneID, actType, this._GetAwardKey_Ext_DayIdxInPeriod(fromDate, toDate, todayIdxInActPeriod), out awardBitFlag, out lastgettime_just_placeholder);
                string strcmd = string.Format("{0}:{1}:{2}", totalGive, totalRecv, awardBitFlag);
                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);
        }
コード例 #27
0
ファイル: NameManager.cs プロジェクト: qiuhoude/mu_server
        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);
        }
コード例 #28
0
        //客户端请求法阵boss信息
        public static TCPProcessCmdResults ProcessFazhenBossCMD(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)));
                return(TCPProcessCmdResults.RESULT_FAILED);
            }

            try
            {
                string[] fields = cmdData.Split(':');
                if (fields.Length != 1)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0}, Client={1}, Recv={2}",
                                                                      (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket), fields.Length));
                    return(TCPProcessCmdResults.RESULT_FAILED);
                }

                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);
                }
                if (client.ClientData.FuBenID != LuoLanFaZhenFubenID)
                {
                    return(TCPProcessCmdResults.RESULT_OK);
                }

                SingleLuoLanFaZhenFubenData fubenData = GetFubenData(client.ClientData.FuBenSeqID);
                if (null == fubenData)
                {
                    return(TCPProcessCmdResults.RESULT_OK);
                }

                string strcmd = string.Format("{0}:{1}:{2}:{3}:{4}", LuoLanFaZhenFubenID, FinalBossID, fubenData.FinalBossLeftNum, SpecialBossID, fubenData.SpecailBossLeftNum);
                tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, (int)TCPGameServerCmds.CMD_SPR_FAZHEN_BOSS);
                return(TCPProcessCmdResults.RESULT_DATA);
            }
            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, "ProcessFazhenBossCMD", false);
            }

            return(TCPProcessCmdResults.RESULT_FAILED);
        }
コード例 #29
0
        public TCPProcessCmdResults HandleClientQueryPlatChargeKing(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));

                tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", (int)TCPGameServerCmds.CMD_DB_ERR_RETURN);
                return(TCPProcessCmdResults.RESULT_DATA);
            }

            try
            {
                string[] fields = cmdData.Split(':');
                if (fields.Length != 1)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0}, Recv={1}, CmdData={2}",
                                                                      (TCPGameServerCmds)nID, fields.Length, cmdData));

                    tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", (int)TCPGameServerCmds.CMD_DB_ERR_RETURN);
                    return(TCPProcessCmdResults.RESULT_DATA);
                }

                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);
                }

                JieriPlatChargeKing act = HuodongCachingMgr.GetJieriPlatChargeKingActivity();
                if (act != null)
                {
                    tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, DataHelper.ObjectToBytes <List <InputKingPaiHangData> >(act.RealRankList), nID);
                }

                return(TCPProcessCmdResults.RESULT_DATA);
            }
            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, "", false);
            }

            tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", (int)TCPGameServerCmds.CMD_DB_ERR_RETURN);
            return(TCPProcessCmdResults.RESULT_DATA);
        }
コード例 #30
0
        private void HandleLoadPkLog(GameServerClient client, int nID, byte[] cmdParams, int count)
        {
            string cmdData = null;

            try
            {
                cmdData = new UTF8Encoding().GetString(cmdParams, 0, count);
            }
            catch (Exception)
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("解析指令字符串错误, CMD={0}", (TCPGameServerCmds)nID), null, true);
                client.sendCmd(30767, "0");
                return;
            }
            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);
                client.sendCmd(30767, "0");
            }
            else
            {
                int                     month   = Convert.ToInt32(fields[0]);
                int                     maxNum  = Convert.ToInt32(fields[1]);
                string                  sql     = string.Format("SELECT month,day,rid1,zoneid1,rname1,ismirror1,rid2,zoneid2,rname2,ismirror2,result,upgrade,starttime,endtime FROM t_zhengba_pk_log WHERE month={0} ORDER BY endtime DESC LIMIT {1};", month, maxNum);
                MySQLDataReader         reader  = this.ExecSelect(sql);
                List <ZhengBaPkLogData> logList = new List <ZhengBaPkLogData>();
                while (reader != null && reader.Read())
                {
                    logList.Add(new ZhengBaPkLogData
                    {
                        Day       = Convert.ToInt32(reader["day"].ToString()),
                        Month     = Convert.ToInt32(reader["month"].ToString()),
                        RoleID1   = Convert.ToInt32(reader["rid1"].ToString()),
                        ZoneID1   = Convert.ToInt32(reader["zoneid1"].ToString()),
                        RoleName1 = reader["rname1"].ToString(),
                        IsMirror1 = (Convert.ToInt32(reader["ismirror1"].ToString()) == 1),
                        RoleID2   = Convert.ToInt32(reader["rid2"].ToString()),
                        ZoneID2   = Convert.ToInt32(reader["zoneid2"].ToString()),
                        RoleName2 = reader["rname2"].ToString(),
                        IsMirror2 = (Convert.ToInt32(reader["ismirror2"].ToString()) == 1),
                        PkResult  = Convert.ToInt32(reader["result"].ToString()),
                        UpGrade   = (Convert.ToInt32(reader["upgrade"].ToString()) == 1),
                        StartTime = DateTime.Parse(reader["starttime"].ToString()),
                        EndTime   = DateTime.Parse(reader["endtime"].ToString())
                    });
                }
                logList.Reverse();
                client.sendCmd <List <ZhengBaPkLogData> >(nID, logList);
            }
        }