Пример #1
0
 public static SGameNodeItem InitGameNodeItem(tagGameNode data)
 {
     return(new SGameNodeItem()
     {
         KindID = data.KindID,
         JoinID = data.JoinID,
         SortID = data.SortID,
         NodeID = data.NodeID,
         Name = data.NodeName
     });
 }
Пример #2
0
        public void OnServerListResp(Packet packet)
        {
            switch (packet.SubCmd)
            {
            case SubCommand.SUB_GP_LIST_TYPE:
            {
                int dataStruct = Marshal.SizeOf(typeof(tagGameType));
                if (packet.DataSize < dataStruct)
                {
                    com.QH.QPGame.GameUtils.Logger.Net.LogError(" tagGameType Game List data error!");
                    return;
                }

                int dataSzie  = Marshal.SizeOf(typeof(tagGameType));
                int dataCount = packet.DataSize / dataSzie;

                ByteBuffer listDataBuff = ByteBufferPool.PopPacket(packet.Data);
                for (int i = 0; i < dataCount; i++)
                {
                    byte[]      tempDataBB = listDataBuff.PopByteArray(dataSzie);
                    tagGameType kindDataE  = GameConvert.ByteToStruct <tagGameType>(tempDataBB);
                    GameApp.GameListMgr.AppendTypeItem(ProtoHelper.InitGameTypeItem(kindDataE));

                    //Logger.Sys.Log("Append Game Type===========" + kindDataE.TypeID + " Name:" + kindDataE.TypeName);
                }
                ByteBufferPool.DropPacket(listDataBuff);

                return;
            }

            case SubCommand.SUB_GP_LIST_KIND:
            {
                int dataStruct = Marshal.SizeOf(typeof(tagGameKind));
                if (packet.DataSize < dataStruct)
                {
                    com.QH.QPGame.GameUtils.Logger.Net.LogError(" tagGameKind Game name list data error!");
                    return;
                }

                int dataSzie  = Marshal.SizeOf(typeof(tagGameKind));
                int dataCount = packet.DataSize / dataSzie;

                ByteBuffer listDataBuff = ByteBufferPool.PopPacket(packet.Data);
                for (int i = 0; i < dataCount; i++)
                {
                    byte[]      tempDataBB = listDataBuff.PopByteArray(dataSzie);
                    tagGameKind tempNameS  = GameConvert.ByteToStruct <tagGameKind>(tempDataBB);
                    GameApp.GameListMgr.AppendKindItem(ProtoHelper.InitGameKindItem(tempNameS));
                    //Logger.Sys.Log("Append Game Kind==========="+ tempNameS.KindID +"  Name:"+tempNameS.KindName + " Process:"+tempNameS.ProcessName);
                }
                ByteBufferPool.DropPacket(listDataBuff);

                //GameApp.Account.CallGameListFinishEvent();
                return;
            }

            case SubCommand.SUB_GP_LIST_NODE:
            {
                int dataStruct = Marshal.SizeOf(typeof(tagGameNode));
                if (packet.DataSize < dataStruct)
                {
                    com.QH.QPGame.GameUtils.Logger.Net.LogError(" tagGameNode Game List data error!");
                    return;
                }

                int dataSzie  = Marshal.SizeOf(typeof(tagGameNode));
                int dataCount = packet.DataSize / dataSzie;

                ByteBuffer listDataBuff = ByteBufferPool.PopPacket(packet.Data);
                for (int i = 0; i < dataCount; i++)
                {
                    byte[]      tempDataBB = listDataBuff.PopByteArray(dataSzie);
                    tagGameNode nodeDataE  = GameConvert.ByteToStruct <tagGameNode>(tempDataBB);
                    GameApp.GameListMgr.AppendNodeItem(ProtoHelper.InitGameNodeItem(nodeDataE));
                }
                ByteBufferPool.DropPacket(listDataBuff);

                GameApp.Account.CallGameListFinishEvent();
                return;
            }

            case SubCommand.SUB_GP_LIST_SERVER:
            {
                int dataStruct = Marshal.SizeOf(typeof(tagGameServer));
                if (packet.DataSize < dataStruct)
                {
                    com.QH.QPGame.GameUtils.Logger.Net.LogError(" tagGameServer Room list data error!");
                    return;
                }

                uint       kindID       = 0;
                int        dataSzie     = Marshal.SizeOf(typeof(tagGameServer));
                int        dataCount    = packet.DataSize / dataSzie;
                ByteBuffer listDataBuff = ByteBufferPool.PopPacket(packet.Data);

                for (int i = 0; i < dataCount; i++)
                {
                    byte[]        tempData  = listDataBuff.PopByteArray(dataSzie);
                    tagGameServer roomInfoS = GameConvert.ByteToStruct <tagGameServer>(tempData);

                    //Logger.Net.Log("--------------ROOM:" + roomInfoS.KindID + " " + roomInfoS.ServerID + " " + roomInfoS.ServerName+" "+roomInfoS.ServerAddr);

                    kindID = roomInfoS.KindID;

                    GameApp.GameListMgr.AppendRoomItem(ProtoHelper.InitGameRoomItem(roomInfoS));

                    /* if (GameApp.GameData.ReEnter &&
                     *   GameApp.GameData.ReEnterRoomID == roomInfoS.ServerID)
                     * {
                     *   GameApp.GameData.ReEnterNameID = roomInfoS.KindID;
                     *   if (ReconnectGameEvent != null)
                     *   {
                     *       ReconnectGameEvent(roomInfoS.ServerID, false);
                     *   }
                     * }*/
                }

                ByteBufferPool.DropPacket(listDataBuff);

                GameApp.Account.CallRoomListFinishEvent(kindID);
                return;
            }

            case SubCommand.SUB_CS_S_SERVER_ONLINE:
            {
                int dataSzie = Marshal.SizeOf(typeof(tagOnLineInfoServer));
                if (packet.DataSize < dataSzie)
                {
                    com.QH.QPGame.GameUtils.Logger.Net.LogError(" tagGameServer Room list data error! size:" + packet.DataSize);
                    return;
                }

                int dataCount = packet.DataSize / dataSzie;

                ByteBuffer listDataBuff = ByteBufferPool.PopPacket(packet.Data);
                for (int i = 0; i < dataCount; i++)
                {
                    byte[] tempDataBB = listDataBuff.PopByteArray(dataSzie);
                    tagOnLineInfoServer OnlineDataE = GameConvert.ByteToStruct <tagOnLineInfoServer>(tempDataBB);

                    SGameRoomItem temRoomItem = GameApp.GameListMgr.FindRoomItem((uint)OnlineDataE.wServerID);
                    if (temRoomItem != null)
                    {
                        temRoomItem.UpdateOnlineCnt((uint)OnlineDataE.dwOnLineCount);
                    }
                }
                ByteBufferPool.DropPacket(listDataBuff);

                GameApp.Account.CallOnlineCountEvent();

                return;
            }
            }
        }