public void TestWorldItemHSPacket()
        {
            Serial serial = 0x1000;
            var    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 WorldItemHS(item).Compile();

            var ns = PacketTestUtilities.CreateTestNetState();

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

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

            AssertThat.Equal(result.Buffer[0].AsSpan(0), expected);
        }
Exemple #2
0
        public override void OnLocationChange(Point3D oldLoc)
        {
            WorldItemHS packet = new WorldItemHS(this);

            packet.SetStatic();

            IPooledEnumerable eable = GetClientsInRange(GetMaxUpdateRange());

            foreach (NetState state in eable)
            {
                Mobile mob = state.Mobile;
                if (mob.CanSee(this) && mob.InRange(Location, GetUpdateRange(mob)))
                {
                    state.Send(packet);
                }
            }
            eable.Free();
            packet.Release();

            int rx = X - oldLoc.X;
            int ry = Y - oldLoc.Y;
            int rz = Z - oldLoc.Z;

            m_ContainedObjects.ForEachObject(
                item => item.Location = new Point3D(item.X + rx, item.Y + ry, item.Z + rz),
                mob => mob.Location   = new Point3D(mob.X + rx, mob.Y + ry, mob.Z + rz));
        }
Exemple #3
0
        public void TestWorldItemHSPacket()
        {
            Serial serial = 0x1000;
            var    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 WorldItemHS(item).Compile();

            Span <byte> expectedData = stackalloc byte[26];
            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

#if NO_LOCAL_INIT
            expectedData.Write(ref pos, (ushort)0); // ??
#endif

            AssertThat.Equal(data, expectedData);
        }
Exemple #4
0
 public void SwitchID(NetState state, bool multi, WorldItemHS p)
 {
     RewriteID(state, multi, p, 8);
 }
Exemple #5
0
 public static bool RewriteItemID(this WorldItemHS p, int itemID, bool reset = true)
 {
     return(Rewrite(p, 8, (ushort)itemID, reset));
 }
 public bool SwitchID(bool multi, WorldItemHS p)
 {
     return(RewriteID(multi, p, 8));
 }