public void WontThrowExceptionDuplicateKey() { byte[] packet = { 0xb1, 0x00, 0x83, 0x00, 0x1d, 0x78, 0xb9, 0x04, 0x5d, 0xd3, 0xaa, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x05, 0xb3, 0xd9, 0xd5, 0x89, 0x00, 0x20, 0xc2, 0xb9, 0xb0, 0x99, 0x00, 0x00, 0x00, 0x18, 0x00, 0x46, 0x00, 0x69, 0x00, 0x73, 0x00, 0x68, 0x00, 0x61, 0x00, 0x6e, 0x00, 0x64, 0x00, 0x43, 0x00, 0x68, 0x00, 0x69, 0x00, 0x70, 0x00, 0x73, 0x00, 0x20, 0xc7, 0x74, 0x00, 0x20, 0xb2, 0xf9, 0xc2, 0xe0, 0xc7, 0x44, 0x00, 0x20, 0xcd, 0x08, 0xb3, 0x00, 0xd5, 0x69, 0xb2, 0xc8, 0xb2, 0xe4, 0x00, 0x00, 0x00, 0x0b, 0xc2, 0x18, 0xb7, 0x7d, 0xc5, 0xec, 0xbd, 0x80, 0xb9, 0x7c, 0x00, 0x20, 0xd0, 0x74, 0xb9, 0xad, 0xd5, 0x58, 0xc1, 0x38, 0xc6, 0x94, 0x00, 0x00, 0x00, 0x02, 0xc2, 0x18, 0xb7, 0x7d, 0x00, 0x00, 0x00, 0x02, 0xac, 0x70, 0xc8, 0x08 }; PacketHandler handler = OutgoingPacketHandlers.GetHandler(packet[0]); try { handler.OnReceive(new PacketReader(packet, packet.Length, false)); } catch (Exception) { Assert.Fail(); throw; } }
private static void ServerInstance_OutgoingPacketEvent(int clientID, byte[] data) { int clientIndex = GetClient(clientID); PacketHandler handler = OutgoingPacketHandlers.GetHandler(data[0]); if (handler != null) { handler.OnReceive(clientIndex, new PacketReader(data, data.Length, handler.Length != 0)); } LowLevel.OnOutgoingPacket(clientIndex, data); }
public void WillSetHolding() { byte[] packet = { 0x07, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF }; PacketHandler handler = OutgoingPacketHandlers.GetHandler(0x07); handler.OnReceive(new PacketReader(packet, packet.Length, true)); Assert.AreEqual(unchecked ((int)0xAABBCCDD), Engine.Player.Holding); Assert.AreEqual(0xEEFF, Engine.Player.HoldingAmount); }
private static void ProcessOutgoingQueue(Packet packet) { PacketSentEvent?.Invoke(packet.GetPacket(), packet.GetLength()); PacketHandler handler = OutgoingPacketHandlers.GetHandler(packet.GetPacketID()); int length = _getPacketLength(packet.GetPacketID()); handler?.OnReceive?.Invoke(new PacketReader(packet.GetPacket(), packet.GetLength(), length > 0)); PacketWaitEntries.CheckWait(packet.GetPacket(), PacketDirection.Outgoing); }
public void WontThrowExceptionVersionAlpha() { // 5.0.1j byte[] packet = { 0xbd, 0x00, 0x0a, 0x35, 0x2e, 0x30, 0x2e, 0x31, 0x6a, 0x00 }; OutgoingPacketHandlers.Initialize(); PacketHandler handler = OutgoingPacketHandlers.GetHandler(0xBD); handler?.OnReceive(new PacketReader(packet, packet.Length, false)); Engine.ClientVersion = null; }
public void WillChangeLastAliasOnTargetSent() { _player.LastTargetSerial = 0x02; AliasCommands.SetDefaultAliases(); Assert.AreEqual(0x02, AliasCommands.GetAlias("last")); OutgoingPacketHandlers.Initialize(); PacketHandler handler = OutgoingPacketHandlers.GetHandler(0x6C); byte[] packet = { 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAA, 0xBB, 0xCC, 0xDD, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; handler?.OnReceive(new PacketReader(packet, packet.Length, true)); Assert.AreEqual(0xAABBCCDD, (uint)AliasCommands.GetAlias("last")); }
private static void ProcessOutgoingQueue(Packet packet) { try { PacketSentEvent?.Invoke(packet.GetPacket(), packet.GetLength()); PacketHandler handler = OutgoingPacketHandlers.GetHandler(packet.GetPacketID()); int length = _getPacketLength(packet.GetPacketID()); handler?.OnReceive?.Invoke(new PacketReader(packet.GetPacket(), packet.GetLength(), length > 0)); PacketWaitEntries.CheckWait(packet.GetPacket(), PacketDirection.Outgoing); } catch (Exception e) { e.ToExceptionless().SetProperty("Packet", packet.GetPacket()) .SetProperty("Player", Player.ToString()).SetProperty("WorldItemCount", Items.Count()) .SetProperty("WorldMobileCount", Mobiles.Count()).Submit(); } }
private void OnInternalPacketSentEvent(byte[] data, int length) { PacketHandler handler = OutgoingPacketHandlers.GetHandler(data[0]); handler?.OnReceive(new PacketReader(data, data.Length, _packetLengths[data[0]] != 0)); if (data[0] == 0x08) { int serial = (data[1] << 24) | (data[2] << 16) | (data[3] << 8) | data[4]; int containerSerial = (data[11] << 24) | (data[12] << 16) | (data[13] << 8) | data[14]; //container cont update PacketWriter pw = new PacketWriter(21); pw.Write((byte)0x25); pw.Write(serial); pw.Seek(10, SeekOrigin.Current); pw.Write(containerSerial); pw.Write((short)0); byte[] packet = pw.ToArray(); handler = IncomingPacketHandlers.GetHandler(packet[0]); handler?.OnReceive(new PacketReader(packet, packet.Length, true)); } if (data[0] == 0x13) { int serial = (data[1] << 24) | (data[2] << 16) | (data[3] << 8) | data[4]; Layer layer = (Layer)data[5]; int containerSerial = (data[6] << 24) | (data[7] << 16) | (data[8] << 8) | data[9]; Mobile mobile = Engine.Mobiles.GetMobile(containerSerial); int itemInLayer = mobile?.GetLayer(layer) ?? 0; if (itemInLayer != 0) { // item already in layer / liftrej return; } // equip update PacketWriter pw = new PacketWriter(15); pw.Write((byte)0x2E); pw.Write(serial); pw.Write((short)0); pw.Write((byte)0); pw.Write((byte)layer); pw.Write(containerSerial); pw.Write((short)0); byte[] packet = pw.ToArray(); handler = IncomingPacketHandlers.GetHandler(packet[0]); handler?.OnReceive(new PacketReader(packet, packet.Length, true)); } }