コード例 #1
0
        public static ProjectileSpawn Read(NetPacketReader message)
        {
            var p = new ProjectileSpawn();

            p.Owner     = message.GetVariableInt32();
            p.Gun       = message.GetUInt();
            p.Hardpoint = message.GetUInt();
            p.Start     = message.GetVector3();
            p.Heading   = message.GetNormal();
            return(p);
        }
コード例 #2
0
        public static NetShipLoadout Read(NetPacketReader message)
        {
            var s = new NetShipLoadout();

            s.ShipCRC = message.GetUInt();
            var equipCount = (int)message.GetVariableUInt32();

            s.Equipment = new List <NetShipEquip>(equipCount);
            for (int i = 0; i < equipCount; i++)
            {
                s.Equipment.Add(new NetShipEquip(message.GetUInt(), message.GetUInt(), message.GetByte()));
            }
            return(s);
        }
コード例 #3
0
ファイル: Packets.cs プロジェクト: Regenhardt/Librelancer
        public static NetShipLoadout Read(NetPacketReader message)
        {
            var s = new NetShipLoadout();

            s.ShipCRC = message.GetUInt();
            s.Health  = message.GetFloat();
            var cargoCount = (int)message.GetVariableUInt32();

            s.Items = new List <NetShipCargo>(cargoCount);
            for (int i = 0; i < cargoCount; i++)
            {
                s.Items.Add(new NetShipCargo(message.GetInt(), message.GetUInt(), message.GetUInt(), message.GetByte(), message.GetInt()));
            }
            return(s);
        }
コード例 #4
0
ファイル: RPCFunction.cs プロジェクト: randomcrab/SE
        /// <inheritdoc/>
        public override void Read(NetPacketReader message)
        {
            base.Read(message);
            try {
                NetworkID = message.GetUInt();
                MethodID  = message.GetUShort();

                RPCInfo = Network.InstanceType == NetInstanceType.Server
                    ? (RPCInfo)Network.ServerRPCLookupTable.GetRPCInfo(MethodID)
                    : Network.ClientRPCLookupTable.GetRPCInfo(MethodID);
                ParametersNum = RPCInfo.ParameterTypes.Length;

                if (Parameters.Length < ParametersNum)
                {
                    Parameters = new object[ParametersNum];
                }

                for (int i = 0; i < ParametersNum; i++)
                {
                    Parameters[i] = NetData.Read(RPCInfo.ParameterTypes[i], message);
                }
            } catch (Exception e) {
                throw new MalformedPacketException("Failed to read packet.", e);
            }
        }
コード例 #5
0
 public static object Read(NetPacketReader message)
 {
     return(new LineSpokenPacket()
     {
         Hash = message.GetUInt()
     });
 }
コード例 #6
0
        private void ServerOutgoingHandler(MessageType messageType, NetPeer peer, NetPacketReader reader)
        {
            var writer = new NetDataWriter();

            switch (messageType)
            {
            case MessageType.GetConcurrentUsers:
                GetConcurrentUsers(writer);
                break;

            case MessageType.LeaderboardsResponse:
                break;

            case MessageType.PlayerStatsResponse:
                writer.Put((byte)MessageType.PlayerStatsResponse);
                var data = reader.GetUInt();
                Console.WriteLine($"{data} id received");
                try
                {
                    Console.WriteLine(_connectionProvider.PlayerPool.List
                                      .FirstOrDefault(x => x.AccountInfo.Id == data)
                                      ?.Statistics.Username);
                    writer.Put(_connectionProvider.PlayerPool.List
                               .FirstOrDefault(x => x.AccountInfo.Id == data)
                               ?.Statistics);
                }
                catch
                {
                    // ignored
                }

                break;

            case MessageType.GetConcurrentUsersResponse:
                GetConcurrentUsers(writer);
                break;

            case MessageType.UpdateProfileSettingsResponse:
                break;

            case MessageType.GetAvatarResponse:
                break;

            default:
                Console.WriteLine();
                throw new ArgumentOutOfRangeException();
            }
            ConnectionProvider.SendMessage(peer, writer);
        }
コード例 #7
0
        public static object Read(NetPacketReader message)
        {
            var p = new ObjectUpdatePacket();

            p.Tick = message.GetUInt();
            var pack        = new BitReader(message.GetRemainingBytes(), 0);
            var updateCount = pack.GetUInt(8);

            p.Updates = new PackedShipUpdate[updateCount];
            for (int i = 0; i < p.Updates.Length; i++)
            {
                p.Updates[i] = PackedShipUpdate.ReadFrom(ref pack);
            }
            return(p);
        }
コード例 #8
0
        public static object Read(NetPacketReader message)
        {
            var pk = new MsnDialogPacket()
            {
                Lines = new NetDlgLine[(int)message.GetVariableUInt32()]
            };

            for (int i = 0; i < pk.Lines.Length; i++)
            {
                pk.Lines[i] = new NetDlgLine()
                {
                    Voice = message.GetString(),
                    Hash  = message.GetUInt()
                };
            }

            return(pk);
        }
コード例 #9
0
        protected override void OnNetworkReceiveUnconnected(IPEndPoint remoteEndPoint, NetPacketReader reader, UnconnectedMessageType messageType)
        {
            switch (messageType)
            {
            // 处理房间发现请求或主机信息更新请求
            case UnconnectedMessageType.Broadcast:
            case UnconnectedMessageType.BasicMessage:
                if (RoomValid && reader.GetInt() == (int)PacketType.discoveryRequest)
                {
                    logger?.Log($"主机房间收到了局域网发现请求或主机信息更新请求");
                    NetDataWriter writer = room.Write(PacketType.discoveryResponse, reader.GetUInt());
                    net.SendUnconnectedMessage(writer, remoteEndPoint);
                }
                break;

            default:
                break;
            }
        }
コード例 #10
0
ファイル: Packets.cs プロジェクト: Regenhardt/Librelancer
 public static NetDlgLine Read(NetPacketReader message) => new NetDlgLine()
 {
     Voice = message.GetString(), Hash = message.GetUInt()
 };