Exemplo n.º 1
0
        public static MovementAck Instantiate(int seq, Mobile m)
        {
            var noto = Notoriety.Compute(m, m);

            var p = m_Cache[noto * seq];

            if (p == null)
            {
                m_Cache[noto * seq] = p = new MovementAck(seq, noto);
                p.SetStatic();
            }

            return(p);
        }
Exemplo n.º 2
0
        public void TestMovementAck()
        {
            var m = new Mobile(0x1);

            m.DefaultMobileInit();

            const byte seq = 100;

            var expected = MovementAck.Instantiate(seq, m).Compile();

            using var ns = PacketTestUtilities.CreateTestNetState();
            ns.SendMovementAck(seq, m);

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

            AssertThat.Equal(result.Buffer[0].AsSpan(0), expected);
        }
Exemplo n.º 3
0
        public void TestMovementAck()
        {
            var m = new Mobile(0x1);

            m.DefaultMobileInit();

            const byte seq  = 100;
            var        noto = Notoriety.Compute(m, m);

            var data = MovementAck.Instantiate(seq, m).Compile();

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

            expectedData.Write(ref pos, (byte)0x22); // Packet ID
            expectedData.Write(ref pos, seq);
            expectedData.Write(ref pos, (byte)noto);

            AssertThat.Equal(data, expectedData);
        }