Exemplo n.º 1
0
        public void TestWorldItemSAPacket()
        {
            Serial serial = 0x1000;
            ushort itemId = 1;

            // Move to fixture
            TileData.ItemTable[itemId] = new ItemData(
                "Test Item Data",
                TileFlag.Generic,
                1,
                1,
                1,
                1,
                1
                );

            var item = new Item(serial)
            {
                ItemID   = itemId,
                Hue      = 0x1024,
                Amount   = 10,
                Location = new Point3D(1000, 100, -10)
            };

            var expected = new WorldItemSA(item).Compile();

            var ns = PacketTestUtilities.CreateTestNetState();

            ns.ProtocolChanges = ProtocolChanges.StygianAbyss;
            ns.SendWorldItem(item);

            var result = ns.SendPipe.Reader.TryRead();

            AssertThat.Equal(result.Buffer[0].AsSpan(0), expected);
        }
Exemplo n.º 2
0
        public void TestWorldItemSAPacket()
        {
            Serial serial = 0x1000;
            ushort itemId = 1;

            // Move to fixture
            TileData.ItemTable[itemId] = new ItemData(
                "Test Item Data",
                TileFlag.Generic,
                1,
                1,
                1,
                1,
                1
                );

            var item = new Item(serial)
            {
                ItemID   = itemId,
                Hue      = 0x1024,
                Amount   = 10,
                Location = new Point3D(1000, 100, -10)
            };

            var loc     = item.Location;
            var isMulti = item is BaseMulti;

            var data = new WorldItemSA(item).Compile();

            Span <byte> expectedData = stackalloc byte[24];
            var         pos          = 0;

            expectedData.Write(ref pos, (byte)0xF3);                   // Packet ID
            expectedData.Write(ref pos, (ushort)0x1);
            expectedData.Write(ref pos, (byte)(isMulti ? 0x2 : 0x00)); // Item Type (Regular, or Multi)
            expectedData.Write(ref pos, item.Serial);
            expectedData.Write(ref pos, (ushort)(item.ItemID & (isMulti ? 0x3FFF : 0xFFFF)));

#if NO_LOCAL_INIT
            expectedData.Write(ref pos, (byte)0)
#else
            pos++;
#endif

            expectedData.Write(ref pos, (ushort)item.Amount);         // Amount (min?)
            expectedData.Write(ref pos, (ushort)item.Amount);         // Amount (max?)
            expectedData.Write(ref pos, loc);                         // X, Y, Z
            expectedData.Write(ref pos, (byte)item.Light);            // Light
            expectedData.Write(ref pos, (ushort)item.Hue);            // Hue
            expectedData.Write(ref pos, (byte)item.GetPacketFlags()); // Flags

            AssertThat.Equal(data, expectedData);
        }
Exemplo n.º 3
0
 public void SwitchID(NetState state, bool multi, WorldItemSA p)
 {
     RewriteID(state, multi, p, 8);
 }
Exemplo n.º 4
0
 public static bool RewriteItemID(this WorldItemSA p, int itemID, bool reset = true)
 {
     return(Rewrite(p, 8, (short)itemID, reset));
 }
Exemplo n.º 5
0
 public bool SwitchID(bool multi, WorldItemSA p)
 {
     return(RewriteID(multi, p, 8));
 }