Beispiel #1
0
        public void GumpWriterTest()
        {
            //TODO: More extensive testing

            TestGump g = new TestGump();

            byte[] packet = g.Compile();

            string layout = "{ page 0 }{ resizepic 0 0 5054 100 100 }{ checkertrans 10 10 80 80 }";

            PacketWriter pw = new PacketWriter();
            pw.Write( (byte) 0xB0 );
            pw.Write( (short) (23+layout.Length) );
            pw.Write( (int) -1 );
            pw.Write( (int) -1 );
            pw.Write( (int) 100 );
            pw.Write( (int) 100 );
            pw.Write( (short) layout.Length );
            pw.WriteAsciiFixed( layout, layout.Length );
            pw.Write( (short) 0 );

            byte[] packet2 = pw.ToArray();

            Assert.AreEqual( packet.Length, packet2.Length );

            for (int i = 0; i < packet.Length;i++)
            {
                Assert.AreEqual( packet[i], packet2[i], String.Format("No match at position {0}", i ) );
            }
        }
Beispiel #2
0
        public void GumpWriterTest()
        {
            //TODO: More extensive testing

            TestGump g = new TestGump();

            byte[] packet = g.Compile();

            string layout = "{ page 0 }{ resizepic 0 0 5054 100 100 }{ checkertrans 10 10 80 80 }";

            PacketWriter pw = new PacketWriter();
            pw.Write( (byte) 0xB0 );
            pw.Write( (short) (23+layout.Length) );
            pw.Write( (int) -1 );
            pw.Write( (int) -1 );
            pw.Write( (int) 100 );
            pw.Write( (int) 100 );
            pw.Write( (short) layout.Length );
            pw.WriteAsciiFixed( layout, layout.Length );
            pw.Write( (short) 0 );

            byte[] packet2 = pw.ToArray();

            Assert.AreEqual( packet.Length, packet2.Length );

            for (int i = 0; i < packet.Length;i++)
            {
                Assert.AreEqual( packet[i], packet2[i], String.Format("No match at position {0}", i ) );
            }

            List<GumpResponseFilter> grf = new List<GumpResponseFilter>();

            grf.Add( new GumpResponseFilter( 0xFFFFFFFF, 0xFFFFFFFF ) );

            bool contains = grf.Contains( new GumpResponseFilter( 0xFFFFFFFF, 0xFFFFFFFF ) );
            Assert.IsTrue( contains );

            grf.Clear();
            contains = grf.Contains( new GumpResponseFilter( 0xFFFFFFFF, 0xFFFFFFFF ) );
            Assert.IsFalse( contains );
        }
Beispiel #3
0
 public byte[] Serialize()
 {
     PacketWriter pw = new PacketWriter();
     pw.Write( (byte) m_PacketID );
     if (Conditions == null)
         pw.Write( (short) 0 );
     else
     {
         pw.Write( (short) Conditions.Length );
         for (int i = 0; i < Conditions.Length; i++)
         {
             pw.Write( (short) Conditions[i].Position );
             pw.Write( (short) Conditions[i].Bytes.Length );
             pw.Write( Conditions[i].Bytes, 0, Conditions[i].Bytes.Length );
             pw.Write( (short) Conditions[i].Length );
         }
     }
     return pw.ToArray();
 }
Beispiel #4
0
 public bool WaitForProperties(int serial, int timeout)
 {
     bool result = false;
     myWaitingForProperties = 1;
     myWaitingPropertiesSerial = serial;
     lock (myWaitForPropertiesLock) {
         PacketWriter pw = new PacketWriter();
         pw.Write( (byte) 0xD6 );
         pw.Write( (byte) 0x07 );
         pw.Write( (byte) 0x00 );
         pw.Write( (int) serial );
         Network.SendCommand( IPCServerIndex, Command.SendPacket, ServerSendCaveAddress.ToInt32(), (byte) PacketType.Server, pw.ToArray() );
         result = Monitor.Wait( myWaitForPropertiesLock, timeout );
     }
     return result;
 }
 /// <summary>
 /// Send packet directly to client's packet receive function.
 /// </summary>
 /// <param name="client">Target client.</param>
 /// <param name="packet">PacketWriter to send.</param>
 public static void SendPacketToClient(int client, PacketWriter packet)
 {
     SendPacketToClient(0, packet.ToArray());
 }