Beispiel #1
0
        public void Can_deserialize_packet_with_negative_z_coord()
        {
            var rawPacket = FakePackets.Instantiate(new byte[]
            {
                0x1B,                   // packet
                0x00, 0x00, 0x00, 0x01, // player id
                0x00, 0x00, 0x00, 0x00, // unknown
                0x01, 0x90,             // body type
                0x12, 0x97,             // xloc
                0x05, 0x46,             // yloc
                0x00,                   // unknown
                0xF0,                   // zloc
                0x03,                   // facing
                0x00, 0x00, 0x7F, 0x00, // unknown
                0x00, 0x06, 0x10, 0x00, // unknown
                0x00,                   // unknown
                0x04, 0x70,             // server boundary width - 8
                0x05, 0x00,             // server boundary height
                0x00, 0x00,             // unknown
                0x00, 0x00, 0x00, 0x00, // unknown
            });

            var packet = new CharLocaleAndBodyPacket();

            packet.Deserialize(rawPacket);

            unchecked
            {
                packet.Location.Z.Should().Be((sbyte)0xF0);
            }
        }
Beispiel #2
0
        public void Can_deserialize()
        {
            var rawPacket = FakePackets.Instantiate(new byte[]
            {
                0x1B,                   // packet
                0x00, 0x00, 0x00, 0x01, // player id
                0x00, 0x00, 0x00, 0x00, // unknown
                0x01, 0x90,             // body type
                0x12, 0x97,             // xloc
                0x05, 0x46,             // yloc
                0x00,                   // unknown
                0x0A,                   // zloc
                0x03,                   // facing
                0x00, 0x00, 0x7F, 0x00, // unknown
                0x00, 0x06, 0x10, 0x00, // unknown
                0x00,                   // unknown
                0x04, 0x70,             // server boundary width - 8
                0x05, 0x00,             // server boundary height
                0x00, 0x00,             // unknown
                0x00, 0x00, 0x00, 0x00, // unknown
            });

            var packet = new CharLocaleAndBodyPacket();

            packet.Deserialize(rawPacket);

            packet.PlayerId.Should().Be(new ObjectId(0x00000001));
            packet.BodyType.Should().Be((ModelId)0x0190);
            packet.Location.X.Should().Be(0x1297);
            packet.Location.Y.Should().Be(0x0546);
            packet.Location.Z.Should().Be(0x0A);
            packet.Direction.Should().Be(Direction.Southeast);
            packet.MovementType.Should().Be(MovementType.Walk);
        }
Beispiel #3
0
        private void HandleCharLocaleAndBodyPacket(CharLocaleAndBodyPacket packet)
        {
            player.PlayerId           = packet.PlayerId;
            player.Location           = packet.Location;
            player.PredictedLocation  = packet.Location;
            player.Direction          = packet.Direction;
            player.MovementType       = packet.MovementType;
            player.PredictedDirection = player.Direction;

            eventJournalSource.Publish(new LoginConfirmedEvent());
            LoginConfirmed?.Invoke();
        }
Beispiel #4
0
        private void EnterGamePre7000()
        {
            var loginConfirmPacket = new CharLocaleAndBodyPacket()
            {
                PlayerId     = legacyApi.Me.PlayerId,
                BodyType     = legacyApi.Me.BodyType,
                Direction    = legacyApi.Me.Direction,
                MovementType = legacyApi.Me.MovementType,
                Location     = legacyApi.Me.Location,
            };

            SendToClient(loginConfirmPacket.Serialize());
            SendToClient(new SetMapPacket(reloginInfo.MapId).RawPacket);

            var enableFeaturesPacket = packetRegistry.Instantiate <EnableLockedClientFeaturesPacket>(0xB9);

            enableFeaturesPacket.Flags = reloginInfo.EnabledFeatureFlags;
            SendToClient(enableFeaturesPacket.Serialize());

            SendToClient(new Packet(new byte[] { 0x55 }));

            var drawPlayer = new DrawGamePlayerPacket(legacyApi.Me.PlayerId, legacyApi.Me.BodyType, legacyApi.Me.Location,
                                                      legacyApi.Me.Direction, legacyApi.Me.MovementType, legacyApi.Me.Color);

            SendToClient(drawPlayer.Serialize());

            foreach (var obj in UO.Items.OnGround())
            {
                var objectInfo = new ObjectInfoPacket(obj.Id, obj.Type, obj.Location, obj.Color, obj.Amount);
                SendToClient(objectInfo.RawPacket);
            }

            SendToClient(new Packet(new byte[] { 0xBF, 0x00, 0x0D, 0x00, 0x05, 0x00, 0x00, 0x02, 0x80, 0x01, 0xFF, 0xFF, 0xA7, }));

            foreach (var mobile in UO.Mobiles)
            {
                var drawPacket = new DrawObjectPacket();
                drawPacket.Color        = mobile.Color.HasValue ? mobile.Color.Value : (Color)0;
                drawPacket.Direction    = mobile.Orientation.HasValue ? mobile.Orientation.Value : Direction.North;
                drawPacket.Flags        = mobile.Flags;
                drawPacket.Id           = mobile.Id;
                drawPacket.Location     = mobile.Location;
                drawPacket.MovementType = mobile.CurrentMovementType.HasValue ? mobile.CurrentMovementType.Value : MovementType.Walk;
                drawPacket.Notoriety    = mobile.Notoriety.HasValue ? mobile.Notoriety.Value : Notoriety.Innocent;
                drawPacket.Type         = mobile.Type;

                var items = UO.Items.InContainer(mobile.Id).Where(i => i.Layer.HasValue).ToArray();
                drawPacket.Items = items;

                SendToClient(drawPacket.Serialize());
            }
        }