Package com.kraken.api.core.packet
Class BufferReader
- java.lang.Object
-
- com.kraken.api.core.packet.BufferReader
-
public class BufferReader extends java.lang.ObjectReverses the obfuscated buffer encoding written byBufferUtils.The write side encodes each field by:
- Advancing a logical
offsetbyoffsetMultiplieronce per byte written. - Computing the real array index as
offset * indexMultiplier - 1. - Writing one byte derived from the full field value via the
BufferOperation:- RAW →
(byte) value - ADD(x) →
(byte)(x + value) - SUBTRACT(x) →
(byte)(x - value) - RIGHT_SHIFT(n) →
(byte)(value >> n)
- RAW →
Reading back is the mirror image:
- Replay the same offset arithmetic to find each byte in the payload.
- Invert the obfuscation to recover the byte's bit contribution.
- OR all bit contributions for the same field together to get the original value.
The
indexMultiplierandoffsetMultiplierare the same obfuscated constants used byBufferUtilsand are loaded from PacketFactory.getPacketMetadata. - Advancing a logical
-
-
Constructor Summary
Constructors Constructor Description BufferReader()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.StringdebugDecode(java.lang.String packetName, byte[] payload, java.util.List<PacketWrite> writes)Decodes the payload and returns a human-readable string, e.g.:static java.util.Map<java.lang.String,java.lang.Object>decode(byte[] payload, java.util.List<PacketWrite> writes)Decodes an encoded packet payload into a map ofparam → valueentries, in the order the writes were originally performed.
-
-
-
Method Detail
-
decode
public static java.util.Map<java.lang.String,java.lang.Object> decode(byte[] payload, java.util.List<PacketWrite> writes)Decodes an encoded packet payload into a map ofparam → valueentries, in the order the writes were originally performed.- Parameters:
payload- the raw bytes captured from the packet buffer (after Isaac cipher decoding)writes- the ordered list ofPacketWritedescriptors for this packet opcode- Returns:
- a
LinkedHashMappreserving write order, values asIntegerorString
-
debugDecode
public static java.lang.String debugDecode(java.lang.String packetName, byte[] payload, java.util.List<PacketWrite> writes)Decodes the payload and returns a human-readable string, e.g.:OPOBJ1 { objectId=41096, worldPointX=3221, worldPointY=3219, ctrlDown=0, subop=0 }- Parameters:
packetName- the display name of the packet opcode (e.g. "OPOBJ1")payload- the encoded payload byteswrites- the orderedPacketWritedescriptors for this opcode- Returns:
- a debug string
-
-