Esempio n. 1
0
 public void SendCmdAfterStartPlayGame(int cmdId, byte[] cmdData)
 {
     lock (this.DelayStartPlayGameMsgQueue)
     {
         TCPOutPacket tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(TCPOutPacketPool.getInstance(), cmdData, cmdId);
         this.DelayStartPlayGameMsgQueue.Enqueue(tcpOutPacket);
     }
 }
Esempio n. 2
0
 /// <summary>
 /// 为角色初始化第一阶段的翅膀
 /// </summary>
 /// <param name="client"></param>
 public static void InitFirstWing(GameClient client)
 {
     if (null == client.ClientData.MyWingData)
     {
         WingData wingData = AddWingDBCommand(TCPOutPacketPool.getInstance(), client.ClientData.RoleID, 1); //获取得到第一阶翅膀
         client.ClientData.MyWingData = wingData;
     }
 }
Esempio n. 3
0
 public static void InitFirstWing(GameClient client)
 {
     if (null == client.ClientData.MyWingData)
     {
         WingData wingData = MUWingsManager.AddWingDBCommand(TCPOutPacketPool.getInstance(), client.ClientData.RoleID, 1, client.ServerId);
         client.ClientData.MyWingData = wingData;
     }
 }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        /// <summary>
        /// 处理客户端查询七日活动
        /// </summary>
        private bool HandleClientQuery(GameClient client, int nID, byte[] bytes, string[] cmdParams)
        {
            // 如果1.8的功能没开放
            if (GameFuncControlManager.IsGameFuncDisabled(GameFuncType.System1Dot8))
            {
                return(false);
            }

            int act = Convert.ToInt32(cmdParams[1]);

            SevenDayActQueryData resultData = new SevenDayActQueryData();

            resultData.ActivityType = act;
            resultData.ItemDict     = null;

            TCPOutPacket packet = null;
            Dictionary <int, SevenDayItemData> itemData = GetActivityData(client, (ESevenDayActType)act);

            if (itemData == null)
            {
                packet = DataHelper.ObjectToTCPOutPacket(resultData, TCPOutPacketPool.getInstance(), nID);
            }
            else
            {
                // 外部会修改,锁住,保证原子性
                lock (itemData)
                {
                    resultData.ItemDict = itemData;
                    if (act == (int)ESevenDayActType.Charge)
                    {
                        //为兼容老数据,七日充值数据,数据库保存的是人民币值,给客户端时,转换为钻石数
                        resultData.ItemDict = new Dictionary <int, SevenDayItemData>();
                        foreach (var kv in itemData)
                        {
                            resultData.ItemDict.Add(kv.Key, new SevenDayItemData()
                            {
                                AwardFlag = kv.Value.AwardFlag, Params1 = Global.TransMoneyToYuanBao(kv.Value.Params1), Params2 = kv.Value.Params2,
                            });
                        }
                    }

                    packet = DataHelper.ObjectToTCPOutPacket(resultData, TCPOutPacketPool.getInstance(), nID);
                }
            }

            if (packet != null)
            {
                client.sendCmd(packet);
            }

            return(true);
        }
Esempio n. 6
0
 public void initialize(int capacity)
 {
     this.socketListener = new SocketListener(capacity, 32768);
     this.socketListener.SocketClosed    += this.SocketClosed;
     this.socketListener.SocketConnected += this.SocketConnected;
     this.socketListener.SocketReceived  += this.SocketReceived;
     this.socketListener.SocketSended    += this.SocketSended;
     this.tcpInPacketPool  = new TCPInPacketPool(capacity);
     this.tcpOutPacketPool = TCPOutPacketPool.getInstance();
     this.tcpOutPacketPool.initialize(capacity * 5);
     TCPCmdDispatcher.getInstance().initialize();
     this.dictInPackets     = new Dictionary <Socket, TCPInPacket>(capacity);
     this.gameServerClients = new Dictionary <Socket, GameServerClient>();
 }
Esempio n. 7
0
        /// <summary>
        /// 透传到DBServer处理
        /// </summary>
        /// <param name="socket"></param>
        /// <param name="nID"></param>
        /// <param name="data"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        public TCPProcessCmdResults transmission(TMSKSocket socket, int nID, byte[] data, int count)
        {
            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);
            }

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

            try
            {
                byte[] bytesData = Global.SendAndRecvData(nID, data, socket.ServerId);
                if (null == bytesData)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("与DBServer通讯失败, CMD={0}", (TCPGameServerCmds)nID));
                    return(TCPProcessCmdResults.RESULT_FAILED);
                }

                Int32  length = BitConverter.ToInt32(bytesData, 0);
                UInt16 cmd    = BitConverter.ToUInt16(bytesData, 4);

                TCPOutPacket tcpOutPacket = TCPOutPacketPool.getInstance().Pop();
                tcpOutPacket.PacketCmdID = cmd;
                tcpOutPacket.FinalWriteData(bytesData, 6, length - 2);

                //client.sendCmd(tcpOutPacket);
                TCPManager.getInstance().MySocketListener.SendData(socket, tcpOutPacket);
                return(TCPProcessCmdResults.RESULT_OK);
            }
            catch (Exception ex)
            {
                // 格式化异常错误信息
                DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(socket), false);
            }


            return(TCPProcessCmdResults.RESULT_FAILED);
        }
Esempio n. 8
0
 public void initialize(int capacity)
 {
     capacity              = Math.Max(capacity, 10);
     this.socketListener   = new SocketListener(capacity, 32768);
     this.inputServers     = new Dictionary <Socket, int>();
     this.dictInPackets    = new Dictionary <Socket, TCPInPacket>();
     this.tcpInPacketPool  = new TCPInPacketPool(capacity);
     this.tcpOutPacketPool = TCPOutPacketPool.getInstance();
     this.tcpOutPacketPool.initialize(capacity * 5);
     this.socketListener.SocketClosed    += this.SocketClosed;
     this.socketListener.SocketConnected += this.SocketConnected;
     this.socketListener.SocketReceived  += this.SocketReceived;
     this.socketListener.SocketSended    += this.SocketSended;
     this.InitCmds();
 }
Esempio n. 9
0
        public void initialize(int capacity)
        {
            socketListener = new SocketListener(capacity, (int)TCPCmdPacketSize.MAX_SIZE / 4);
            socketListener.SocketClosed    += SocketClosed;
            socketListener.SocketConnected += SocketConnected;
            socketListener.SocketReceived  += SocketReceived;
            socketListener.SocketSended    += SocketSended;

            tcpInPacketPool = new TCPInPacketPool(capacity);
/*            tcpOutPacketPool = new TCPOutPacketPool(capacity * 5);*/
            tcpOutPacketPool = TCPOutPacketPool.getInstance();
            tcpOutPacketPool.initialize(capacity * 5);
            TCPCmdDispatcher.getInstance().initialize();
            dictInPackets     = new Dictionary <Socket, TCPInPacket>(capacity);
            gameServerClients = new Dictionary <Socket, GameServerClient>();
        }
Esempio n. 10
0
 public void initialize(int capacity)
 {
     this.MaxConnectedClientLimit         = capacity;
     this.socketListener                  = new SocketListener(capacity, 6144);
     this.socketListener.SocketClosed    += this.SocketClosed;
     this.socketListener.SocketConnected += this.SocketConnected;
     this.socketListener.SocketReceived  += this.SocketReceived;
     this.socketListener.SocketSended    += this.SocketSended;
     this._tcpClientPool                  = TCPClientPool.getInstance();
     this._tcpClientPool.initialize(100);
     this._tcpLogClientPool = TCPClientPool.getLogInstance();
     this._tcpLogClientPool.initialize(100);
     this.tcpInPacketPool = new TCPInPacketPool(capacity);
     TCPOutPacketPool.getInstance().initialize(capacity);
     this.tcpOutPacketPool = TCPOutPacketPool.getInstance();
     this.dictInPackets    = new Dictionary <TMSKSocket, TCPInPacket>(capacity);
     this.tcpSessions      = new Dictionary <TMSKSocket, TCPSession>();
     TCPCmdDispatcher.getInstance().initialize();
     this.taskExecutor = new ScheduleExecutor(0);
     this.taskExecutor.start();
 }
Esempio n. 11
0
        /// <summary>
        /// 重置世界等级
        /// </summary>
        public void ResetWorldLevel()
        {
            int dayID = TimeUtil.NowDateTime().DayOfYear;

            if (m_nResetWorldLevelDayID == dayID)
            {
                return;
            }

            TCPOutPacket         tcpOutPacket    = null;
            string               strcmd          = string.Format("{0}:{1}", 0, (int)PaiHangTypes.RoleLevel);
            TCPProcessCmdResults dbRequestResult = Global.RequestToDBServer2(Global._TCPManager.tcpClientPool, TCPOutPacketPool.getInstance(), (int)TCPGameServerCmds.CMD_SPR_GETPAIHANGLIST, strcmd, out tcpOutPacket, GameManager.LocalServerId);

            if (dbRequestResult == TCPProcessCmdResults.RESULT_FAILED)
            {
                LogManager.WriteLog(LogTypes.Error, "世界等级装入异常");
                return;
            }

            int nBakResetWorldLevelDayID = m_nResetWorldLevelDayID;

            m_nResetWorldLevelDayID = dayID;

            // 处理本地精简的好友列表数据
            PaiHangData paiHangData = DataHelper.BytesToObject <PaiHangData>(tcpOutPacket.GetPacketBytes(), 6, tcpOutPacket.PacketDataSize - 6);

            if (null != paiHangData)
            {
                int nLevelCount = 0;
                if (null != paiHangData.PaiHangList)
                {
                    for (int i = 0; i < 10 && i < paiHangData.PaiHangList.Count; i++)
                    {
                        nLevelCount += paiHangData.PaiHangList[i].Val2 * 100 + paiHangData.PaiHangList[i].Val1;
                    }
                }
                m_nWorldLevel = nLevelCount / 10;
            }
            else
            {
                LogManager.WriteLog(LogTypes.Error, "世界等级装入时,获取等级排行榜失败");
                return;
            }


            if (0 != nBakResetWorldLevelDayID)
            {
                int count = GameManager.ClientMgr.GetMaxClientCount();
                for (int i = 0; i < count; i++)
                {
                    GameClient client = GameManager.ClientMgr.FindClientByNid(i);
                    if (null != client)
                    {
                        UpddateWorldLevelBuff(client);
                    }
                }
            }
        }
Esempio n. 12
0
 /// <summary>
 /// Send instructions to GameServer
 /// </summary>
 public void sendCmd <T>(int cmdId, T cmdData)
 {
     TCPManager.getInstance().MySocketListener.SendData(currentSocket, DataHelper.ObjectToTCPOutPacket <T>(cmdData, TCPOutPacketPool.getInstance(), cmdId));
 }
Esempio n. 13
0
 /// <summary>
 /// Send instructions to GameServer
 /// </summary>
 public void sendCmd(int cmdId, string cmdData)
 {
     TCPManager.getInstance().MySocketListener.SendData(currentSocket, TCPOutPacket.MakeTCPOutPacket(TCPOutPacketPool.getInstance(), cmdData, cmdId));
 }
Esempio n. 14
0
        /// <summary>
        /// 兼容老版本的宠物
        /// </summary>
        /// <param name="goodsData"></param>
        public static void AddOldDamonGoodsData(GameClient client)
        {
            if (null == client.ClientData.GoodsDataList)
            {
                return;
            }

            List <GoodsData> listDamon = new List <GoodsData>();

            // 把在装备栏也在背包中的精灵添加到精灵栏
            for (int i = 0; i < client.ClientData.GoodsDataList.Count; i++)
            {
                int nCategories = Global.GetGoodsCatetoriy(client.ClientData.GoodsDataList[i].GoodsID);
                if (nCategories >= (int)ItemCategories.ShouHuChong && nCategories <= (int)ItemCategories.ChongWu)
                {
                    if (client.ClientData.GoodsDataList[i].Using > 0 && client.ClientData.GoodsDataList[i].Site == 0)
                    {
                        int                  nBagIndex       = Global.GetIdleSlotOfDamonGoods(client);
                        string[]             dbFields        = null;
                        String               strcmd          = Global.FormatUpdateDBGoodsStr(client.ClientData.RoleID, client.ClientData.GoodsDataList[i].Id, client.ClientData.GoodsDataList[i].Using, "*", "*", "*", (int)SaleGoodsConsts.UsingDemonGoodsID, "*", "*", client.ClientData.GoodsDataList[i].GCount, "*", nBagIndex, "*", "*", "*", "*", "*", "*", "*", "*", "*", "*", "*"); // 卓越信息 [12/13/2013 LiaoWei] 装备转生
                        TCPProcessCmdResults dbRequestResult = Global.RequestToDBServer(TCPClientPool.getInstance(), TCPOutPacketPool.getInstance(), (int)TCPGameServerCmds.CMD_DB_UPDATEGOODS_CMD, strcmd, out dbFields, client.ServerId);
                        if (dbRequestResult == TCPProcessCmdResults.RESULT_FAILED)
                        {
                            continue;
                        }

                        if (dbFields.Length <= 0 || Convert.ToInt32(dbFields[1]) < 0)
                        {
                            continue;
                        }

                        AddDamonGoodsData(client, client.ClientData.GoodsDataList[i], false);
                        client.ClientData.GoodsDataList[i].Site     = (int)SaleGoodsConsts.UsingDemonGoodsID;
                        client.ClientData.GoodsDataList[i].BagIndex = nBagIndex;
                        listDamon.Add(client.ClientData.GoodsDataList[i]);
                    }
                }
            }

            // 添加到精灵栏的精灵从背包中移除
            for (int i = 0; i < listDamon.Count; i++)
            {
                Global.RemoveGoodsData(client, listDamon[i]);
            }

            JingLingQiYuanManager.getInstance().RefreshProps(client);
        }
Esempio n. 15
0
 public void sendCmd <T>(int cmdId, T cmdData, bool waitEnterScene = false)
 {
     if (waitEnterScene && this.ClientData.FirstPlayStart)
     {
         this.SendCmdAfterStartPlayGame <T>(cmdId, cmdData);
     }
     else
     {
         TCPManager.getInstance().MySocketListener.SendData(this.ClientSocket, DataHelper.ObjectToTCPOutPacket <T>(cmdData, TCPOutPacketPool.getInstance(), cmdId), true);
     }
 }
Esempio n. 16
0
 public void sendCmd(int cmdId, byte[] cmdData, bool waitEnterScene = false)
 {
     if (waitEnterScene && this.ClientData.FirstPlayStart)
     {
         this.SendCmdAfterStartPlayGame(cmdId, cmdData);
     }
     else
     {
         TCPManager.getInstance().MySocketListener.SendData(this.ClientSocket, TCPOutPacket.MakeTCPOutPacket(TCPOutPacketPool.getInstance(), cmdData, cmdId), true);
     }
 }
Esempio n. 17
0
 private void Tracking(GameClient tClient, GameClient beTClient)
 {
     try
     {
         lock (this.Mutex)
         {
             this.CancleTracking(tClient, true);
             if (tClient.ClientData.MapCode != beTClient.ClientData.MapCode)
             {
                 GameManager.ClientMgr.ChangeMap(TCPManager.getInstance().MySocketListener, TCPOutPacketPool.getInstance(), tClient, -1, beTClient.ClientData.MapCode, beTClient.ClientData.PosX, beTClient.ClientData.PosY, beTClient.ClientData.RoleDirection, 123);
             }
             else
             {
                 GameManager.ClientMgr.NotifyOthersGoBack(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, tClient, beTClient.ClientData.PosX, beTClient.ClientData.PosY, -1);
             }
             tClient.ClientData.BeTrackingRoleID = beTClient.ClientData.RoleID;
             if (!beTClient.ClientData.TrackingRoleIDList.Exists((int x) => x == tClient.ClientData.RoleID))
             {
                 beTClient.ClientData.TrackingRoleIDList.Add(tClient.ClientData.RoleID);
             }
             int result = 0;
             tClient.sendCmd(1403, string.Format("{0}:{1}", result, beTClient.ClientData.RoleID), false);
         }
     }
     catch (Exception ex)
     {
         DataHelper.WriteFormatExceptionLog(ex, "", false, false);
     }
 }
Esempio n. 18
0
 private void HandleStartPlayGame(GameClient client)
 {
     try
     {
         lock (this.Mutex)
         {
             if (client.ClientData.BeTrackingRoleID != 0 || client.ClientData.TrackingRoleIDList.Count != 0)
             {
                 bool toGuanZhanMap = true;
                 int  posX          = 0;
                 int  posY          = 0;
                 if (!this.GetGuanZhanPos(client.ClientData.MapCode, ref posX, ref posY))
                 {
                     toGuanZhanMap = false;
                 }
                 if (0 != client.ClientData.BeTrackingRoleID)
                 {
                     if (!toGuanZhanMap)
                     {
                         this.CancleTracking(client, true);
                     }
                     else
                     {
                         ClientManager.DoSpriteMapGridMove(client, 0);
                         GameClient beTClient = GameManager.ClientMgr.FindClient(client.ClientData.BeTrackingRoleID);
                         if (null != beTClient)
                         {
                             int result = 0;
                             client.sendCmd(1403, string.Format("{0}:{1}", result, beTClient.ClientData.RoleID), false);
                         }
                     }
                 }
                 List <int> tempTrackingRoleIDList = new List <int>(client.ClientData.TrackingRoleIDList);
                 foreach (int rid in tempTrackingRoleIDList)
                 {
                     GameClient tClient = GameManager.ClientMgr.FindClient(rid);
                     if (null != tClient)
                     {
                         if (!toGuanZhanMap)
                         {
                             this.CancleTracking(tClient, true);
                         }
                         else if (tClient.ClientData.MapCode != client.ClientData.MapCode)
                         {
                             GameManager.ClientMgr.ChangeMap(TCPManager.getInstance().MySocketListener, TCPOutPacketPool.getInstance(), tClient, -1, client.ClientData.MapCode, client.ClientData.PosX, client.ClientData.PosY, client.ClientData.RoleDirection, 123);
                         }
                         else
                         {
                             GameManager.ClientMgr.NotifyOthersGoBack(Global._TCPManager.MySocketListener, Global._TCPManager.TcpOutPacketPool, tClient, client.ClientData.PosX, client.ClientData.PosY, -1);
                         }
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         DataHelper.WriteFormatExceptionLog(ex, "", false, false);
     }
 }
Esempio n. 19
0
        //玩家使用传送门
        public static TCPProcessCmdResults OnTeleport(GameClient client, int teleportID, TCPOutPacketPool pool, out TCPOutPacket tcpOutPacket)
        {
            tcpOutPacket = null;

            if (client.ClientData.FuBenID != LuoLanFaZhenFubenID || client.ClientData.FuBenSeqID <= 0)
            {
                return(TCPProcessCmdResults.RESULT_FAILED);
            }

            SingleLuoLanFaZhenFubenData fubenData = GetFubenData(client.ClientData.FuBenSeqID);

            if (null == fubenData)
            {
                return(TCPProcessCmdResults.RESULT_FAILED);
            }

            FazhenMapData            mapdata  = null;
            SingleFazhenTelegateData teledata = null;

            lock (fubenData.MapDatas)
            {
                if (!fubenData.MapDatas.TryGetValue(client.ClientData.CopyMapID, out mapdata) || null == mapdata)
                {
                    return(TCPProcessCmdResults.RESULT_FAILED);
                }
            }

            if (mapdata.MapCode != client.ClientData.MapCode || mapdata.CopyMapID != client.ClientData.CopyMapID)
            {
                return(TCPProcessCmdResults.RESULT_FAILED);
            }

            lock (mapdata.Telegates)
            {
                //如果找不到这个传送门,说明这是个普通的传送点
                if (!mapdata.Telegates.TryGetValue(teleportID, out teledata) || null == teledata)
                {
                    return(TCPProcessCmdResults.RESULT_FAILED);
                }
            }

            if (teledata.destMapCode <= 0)
            {
                return(TCPProcessCmdResults.RESULT_FAILED);
            }

            //判断是否随机传到特殊地图
            bool TeleToSpecial = false;

            if (teledata.SpecialDestMapCode > 0)
            {
                //[bing] 有些人进入特殊地图时 该地图怪物已经被杀了 导致进入地图后又要返回 所以预先判断有无怪物 没怪物则不传送特殊地
                if (0 != fubenData.SpecailBossLeftNum)
                {
                    int rand = Global.GetRandomNumber(0, 100);
                    //是否随机传送到特殊地图
                    if (rand < SpecialTeleRate)
                    {
                        //传送到特殊地图
                        TeleToSpecial = true;
                    }
                }
            }

            if (TeleToSpecial)
            {
                //传送到特殊地图teledata.SpecialDestMapCode
                GameManager.ClientMgr.ChangeMap(TCPManager.getInstance().MySocketListener, TCPOutPacketPool.getInstance(), client, teleportID,
                                                teledata.SpecialDestMapCode, teledata.SpecialDestX, teledata.SpecialDestY, client.ClientData.RoleDirection,
                                                (int)TCPGameServerCmds.CMD_SPR_MAPCHANGE);
            }
            else   //传送到普通地图
            {
                //是否已经用过?
                bool NeedSend = false;
                lock (teledata)
                {
                    if (!teledata.usedAlready)
                    {
                        //没用过
                        teledata.usedAlready = true;
                        NeedSend             = true;
                    }
                }

                if (NeedSend)
                {
                    //通知副本内所有玩家传送门被用过后的数据
                    FazhenMapProtoData senddata = new FazhenMapProtoData();
                    senddata.listTelegate = new List <FazhenTelegateProtoData>();
                    senddata.SrcMapCode   = mapdata.MapCode;

                    FazhenTelegateProtoData gatedata_s = new FazhenTelegateProtoData();
                    gatedata_s.gateId      = teledata.gateId;
                    gatedata_s.DestMapCode = teledata.destMapCode;
                    senddata.listTelegate.Add(gatedata_s);

                    //发送此传送门数据给地图内所有玩家
                    BroadMapData <FazhenMapProtoData>((int)TCPGameServerCmds.CMD_MAP_TELEPORT, senddata, mapdata.MapCode, client.ClientData.FuBenSeqID);
                }

                //传送到普通地图
                GameManager.ClientMgr.ChangeMap(TCPManager.getInstance().MySocketListener, TCPOutPacketPool.getInstance(), client, teleportID,
                                                teledata.destMapCode, teledata.destX, teledata.destY, client.ClientData.RoleDirection,
                                                (int)TCPGameServerCmds.CMD_SPR_MAPCHANGE);
            }

            return(TCPProcessCmdResults.RESULT_OK);
        }
Esempio n. 20
0
        public void ResetWorldLevel()
        {
            int dayID = TimeUtil.NowDateTime().DayOfYear;

            if (this.m_nResetWorldLevelDayID != dayID)
            {
                int           offsetDay     = TimeUtil.GetOffsetDayNow();
                string        cDate         = TimeUtil.GetRealDate(offsetDay).Date.ToString("yyyy-MM-dd");
                ServerDayData serverDayData = Global.sendToDB <ServerDayData, int>(11004, offsetDay, GameManager.ServerId);
                if (serverDayData != null && serverDayData.Dayid == offsetDay)
                {
                    LogManager.WriteLog(LogTypes.Info, string.Format("从数据加载世界等级:day={0},worldlevel={1}", serverDayData.CDate, serverDayData.WorldLevel), null, true);
                    this.m_nWorldLevel           = serverDayData.WorldLevel;
                    this.m_nResetWorldLevelDayID = dayID;
                }
                else
                {
                    TCPOutPacket         tcpOutPacket    = null;
                    string               strcmd          = string.Format("{0}:{1}", 0, 5);
                    TCPProcessCmdResults dbRequestResult = Global.RequestToDBServer2(Global._TCPManager.tcpClientPool, TCPOutPacketPool.getInstance(), 269, strcmd, out tcpOutPacket, 0);
                    if (dbRequestResult == TCPProcessCmdResults.RESULT_FAILED)
                    {
                        LogManager.WriteLog(LogTypes.Error, "世界等级装入异常", null, true);
                    }
                    else
                    {
                        int nBakResetWorldLevelDayID = this.m_nResetWorldLevelDayID;
                        this.m_nResetWorldLevelDayID = dayID;
                        PaiHangData paiHangData = DataHelper.BytesToObject <PaiHangData>(tcpOutPacket.GetPacketBytes(), 6, tcpOutPacket.PacketDataSize - 6);
                        if (null != paiHangData)
                        {
                            int nLevelCount = 0;
                            int roleCount   = 0;
                            if (null != paiHangData.PaiHangList)
                            {
                                int i = 0;
                                while (i < 100 && i < paiHangData.PaiHangList.Count)
                                {
                                    roleCount++;
                                    nLevelCount += paiHangData.PaiHangList[i].Val2 * 100 + paiHangData.PaiHangList[i].Val1;
                                    i++;
                                }
                            }
                            this.m_nWorldLevel = ((roleCount > 0) ? (nLevelCount / roleCount) : 1);
                            serverDayData      = new ServerDayData
                            {
                                Dayid      = offsetDay,
                                CDate      = cDate,
                                WorldLevel = this.m_nWorldLevel
                            };
                            for (;;)
                            {
                                int dbRet = Global.sendToDB <int, ServerDayData>(11003, serverDayData, GameManager.ServerId);
                                if (dbRet >= 0)
                                {
                                    break;
                                }
                                Thread.Sleep(1000);
                            }
                            if (0 != nBakResetWorldLevelDayID)
                            {
                                int count = GameManager.ClientMgr.GetMaxClientCount();
                                for (int i = 0; i < count; i++)
                                {
                                    GameClient client = GameManager.ClientMgr.FindClientByNid(i);
                                    if (null != client)
                                    {
                                        this.UpddateWorldLevelBuff(client);
                                    }
                                }
                            }
                        }
                        else
                        {
                            LogManager.WriteLog(LogTypes.Error, "世界等级装入时,获取等级排行榜失败", null, true);
                        }
                    }
                }
            }
        }
Esempio n. 21
0
        public static TCPProcessCmdResults OnTeleport(GameClient client, int teleportID, TCPOutPacketPool pool, out TCPOutPacket tcpOutPacket)
        {
            tcpOutPacket = null;
            TCPProcessCmdResults result;

            if (client.ClientData.FuBenID != LuoLanFaZhenCopySceneManager.LuoLanFaZhenFubenID || client.ClientData.FuBenSeqID <= 0)
            {
                result = TCPProcessCmdResults.RESULT_FAILED;
            }
            else
            {
                SingleLuoLanFaZhenFubenData fubenData = LuoLanFaZhenCopySceneManager.GetFubenData(client.ClientData.FuBenSeqID);
                if (null == fubenData)
                {
                    result = TCPProcessCmdResults.RESULT_FAILED;
                }
                else
                {
                    FazhenMapData            mapdata  = null;
                    SingleFazhenTelegateData teledata = null;
                    lock (fubenData.MapDatas)
                    {
                        if (!fubenData.MapDatas.TryGetValue(client.ClientData.CopyMapID, out mapdata) || null == mapdata)
                        {
                            return(TCPProcessCmdResults.RESULT_FAILED);
                        }
                    }
                    if (mapdata.MapCode != client.ClientData.MapCode || mapdata.CopyMapID != client.ClientData.CopyMapID)
                    {
                        result = TCPProcessCmdResults.RESULT_FAILED;
                    }
                    else
                    {
                        lock (mapdata.Telegates)
                        {
                            if (!mapdata.Telegates.TryGetValue(teleportID, out teledata) || null == teledata)
                            {
                                return(TCPProcessCmdResults.RESULT_FAILED);
                            }
                        }
                        if (teledata.destMapCode <= 0)
                        {
                            result = TCPProcessCmdResults.RESULT_FAILED;
                        }
                        else
                        {
                            bool TeleToSpecial = false;
                            if (teledata.SpecialDestMapCode > 0)
                            {
                                if (0 != fubenData.SpecailBossLeftNum)
                                {
                                    int rand = Global.GetRandomNumber(0, 100);
                                    if (rand < LuoLanFaZhenCopySceneManager.SpecialTeleRate)
                                    {
                                        TeleToSpecial = true;
                                    }
                                }
                            }
                            if (TeleToSpecial)
                            {
                                GameManager.ClientMgr.ChangeMap(TCPManager.getInstance().MySocketListener, TCPOutPacketPool.getInstance(), client, teleportID, teledata.SpecialDestMapCode, teledata.SpecialDestX, teledata.SpecialDestY, client.ClientData.RoleDirection, 123);
                            }
                            else
                            {
                                bool NeedSend = false;
                                lock (teledata)
                                {
                                    if (!teledata.usedAlready)
                                    {
                                        teledata.usedAlready = true;
                                        NeedSend             = true;
                                    }
                                }
                                if (NeedSend)
                                {
                                    FazhenMapProtoData senddata = new FazhenMapProtoData();
                                    senddata.listTelegate = new List <FazhenTelegateProtoData>();
                                    senddata.SrcMapCode   = mapdata.MapCode;
                                    FazhenTelegateProtoData gatedata_s = new FazhenTelegateProtoData();
                                    gatedata_s.gateId      = teledata.gateId;
                                    gatedata_s.DestMapCode = teledata.destMapCode;
                                    senddata.listTelegate.Add(gatedata_s);
                                    LuoLanFaZhenCopySceneManager.BroadMapData <FazhenMapProtoData>(685, senddata, mapdata.MapCode, client.ClientData.FuBenSeqID);
                                }
                                GameManager.ClientMgr.ChangeMap(TCPManager.getInstance().MySocketListener, TCPOutPacketPool.getInstance(), client, teleportID, teledata.destMapCode, teledata.destX, teledata.destY, client.ClientData.RoleDirection, 123);
                            }
                            result = TCPProcessCmdResults.RESULT_OK;
                        }
                    }
                }
            }
            return(result);
        }
Esempio n. 22
0
        private bool HandleClientQuery(GameClient client, int nID, byte[] bytes, string[] cmdParams)
        {
            bool result;

            if (GameFuncControlManager.IsGameFuncDisabled(GameFuncType.System1Dot8))
            {
                result = false;
            }
            else
            {
                int act = Convert.ToInt32(cmdParams[1]);
                SevenDayActQueryData resultData = new SevenDayActQueryData();
                resultData.ActivityType = act;
                resultData.ItemDict     = null;
                TCPOutPacket packet = null;
                Dictionary <int, SevenDayItemData> itemData = this.GetActivityData(client, (ESevenDayActType)act);
                if (itemData == null)
                {
                    packet = DataHelper.ObjectToTCPOutPacket <SevenDayActQueryData>(resultData, TCPOutPacketPool.getInstance(), nID);
                }
                else
                {
                    lock (itemData)
                    {
                        resultData.ItemDict = itemData;
                        if (act == 2)
                        {
                            resultData.ItemDict = new Dictionary <int, SevenDayItemData>();
                            foreach (KeyValuePair <int, SevenDayItemData> kv in itemData)
                            {
                                resultData.ItemDict.Add(kv.Key, new SevenDayItemData
                                {
                                    AwardFlag = kv.Value.AwardFlag,
                                    Params1   = Global.TransMoneyToYuanBao(kv.Value.Params1),
                                    Params2   = kv.Value.Params2
                                });
                            }
                        }
                        packet = DataHelper.ObjectToTCPOutPacket <SevenDayActQueryData>(resultData, TCPOutPacketPool.getInstance(), nID);
                    }
                }
                if (packet != null)
                {
                    client.sendCmd(packet, true);
                }
                result = true;
            }
            return(result);
        }
Esempio n. 23
0
 public void SendCmdAfterStartPlayGame <T>(int cmdId, T cmdData)
 {
     lock (this.DelayStartPlayGameMsgQueue)
     {
         TCPOutPacket tcpOutPacket = DataHelper.ObjectToTCPOutPacket <T>(cmdData, TCPOutPacketPool.getInstance(), cmdId);
         this.DelayStartPlayGameMsgQueue.Enqueue(tcpOutPacket);
     }
 }
Esempio n. 24
0
        public static void AddOldPaiZhuDamonGoodsData(GameClient client)
        {
            if (null != client.ClientData.GoodsDataList)
            {
                List <GoodsData> listDamon = new List <GoodsData>();
                int i = 0;
                while (i < client.ClientData.GoodsDataList.Count)
                {
                    int nCategories = Global.GetGoodsCatetoriy(client.ClientData.GoodsDataList[i].GoodsID);
                    if (nCategories >= 9 && nCategories <= 10)
                    {
                        if (client.ClientData.GoodsDataList[i].Using > 0 && client.ClientData.GoodsDataList[i].Site == 0)
                        {
                            int      nBagIndex = JingLingYaoSaiManager.GetIdleSlotOfPaiZhuDamonGoods(client);
                            string[] dbFields  = null;
                            string   strcmd    = Global.FormatUpdateDBGoodsStr(new object[]
                            {
                                client.ClientData.RoleID,
                                client.ClientData.GoodsDataList[i].Id,
                                client.ClientData.GoodsDataList[i].Using,
                                "*",
                                "*",
                                "*",
                                10000,
                                "*",
                                "*",
                                client.ClientData.GoodsDataList[i].GCount,
                                "*",
                                nBagIndex,
                                "*",
                                "*",
                                "*",
                                "*",
                                "*",
                                "*",
                                "*",
                                "*",
                                "*",
                                "*",
                                "*"
                            });
                            TCPProcessCmdResults dbRequestResult = Global.RequestToDBServer(TCPClientPool.getInstance(), TCPOutPacketPool.getInstance(), 10006, strcmd, out dbFields, client.ServerId);
                            if (dbRequestResult != TCPProcessCmdResults.RESULT_FAILED)
                            {
                                if (dbFields.Length > 0 && Convert.ToInt32(dbFields[1]) >= 0)
                                {
                                    JingLingYaoSaiManager.AddPaiZhuDamonGoodsData(client, client.ClientData.GoodsDataList[i], false);
                                    client.ClientData.GoodsDataList[i].Site     = 10000;
                                    client.ClientData.GoodsDataList[i].BagIndex = nBagIndex;
                                    listDamon.Add(client.ClientData.GoodsDataList[i]);
                                }
                            }
                        }
                    }
IL_2AC:
                    i++;
                    continue;
                    goto IL_2AC;
                }
                for (i = 0; i < listDamon.Count; i++)
                {
                    Global.RemoveGoodsData(client, listDamon[i]);
                }
            }
        }
Esempio n. 25
0
 public void sendProtocolCmd <T>(int cmdId, T cmdData)
 {
     TCPManager.getInstance().MySocketListener.SendData(ClientSocket, DataHelper.ProtocolToTCPOutPacket <T>(cmdData, TCPOutPacketPool.getInstance(), cmdId));
 }