Class EoReader

A class for reading EO data from a sequence of bytes.

`EoReader` features a chunked reading mode, which is important for accurate emulation of the official game client.

See

Chunked Reading

Hierarchy

  • EoReader

Constructors

  • Creates a new EoReader instance for the specified data.

    Parameters

    • data: Uint8Array

      the byte array containing the input data

    Returns EoReader

Properties

_chunkedReadingMode: boolean = false
_position: number = 0
chunkStart: number = 0
data: Uint8Array
nextBreak: number = -1

Accessors

  • get chunkedReadingMode(): boolean
  • Gets the chunked reading mode for the reader.

    Returns

    True if the reader is in chunked reading mode

    Returns boolean

  • set chunkedReadingMode(chunkedReadingMode: boolean): void
  • Sets the chunked reading mode for the reader.

    In chunked reading mode:

    • the reader will treat `0xFF` bytes as the end of the current chunk.
    • nextChunk can be called to move to the next chunk.

    Parameters

    • chunkedReadingMode: boolean

      the new chunked reading mode

    Returns void

  • get position(): number
  • Gets the current position in the input data.

    Returns

    The current position in the input data

    Returns number

  • get remaining(): number
  • If chunked reading mode is enabled, gets the number of bytes remaining in the current chunk. Otherwise, gets the total number of bytes remaining in the input data.

    Returns

    The number of bytes remaining

    Returns number

Methods

  • Reads a raw byte from the input data.

    Returns

    A raw byte

    Returns number

  • Reads an array of raw bytes from the input data.

    Returns

    An array of raw bytes

    Parameters

    • length: number

    Returns Uint8Array

  • Reads an encoded 1-byte integer from the input data.

    Returns

    A decoded 1-byte integer

    Returns number

  • Reads an encoded string from the input data.

    Returns

    A decoded string

    Returns string

  • Reads an encoded string with a fixed length from the input data.

    Returns

    A decoded string

    Throws

    Error if the length is negative

    Parameters

    • length: number

      the length of the string

    • padded: boolean = false

      true if the string is padded with trailing 0xFF bytes

    Returns string

  • Reads a string with a fixed length from the input data.

    Returns

    A decoded string

    Throws

    Error if the length is negative

    Parameters

    • length: number

      the length of the string

    • padded: boolean = false

      true if the string is padded with trailing 0xFF bytes

    Returns string

  • Reads an encoded 4-byte integer from the input data.

    Returns

    A decoded 4-byte integer

    Returns number

  • Reads an encoded 2-byte integer from the input data.

    Returns

    A decoded 2-byte integer

    Returns number

  • Reads an encoded 3-byte integer from the input data.

    Returns

    A decoded 3-byte integer

    Returns number

  • Moves the reader position to the start of the next chunk in the input data.

    Throws

    Error if not in chunked reading mode

    Returns void

  • Creates a new EoReader whose input data is a shared subsequence of this reader's data.

    The input data of the new reader will start at position `index` in this reader and contain up to `length` bytes. The two reader's position and chunked reading mode will be independent.

    The new reader's position will be zero, and its chunked reading mode will be false.

    Throws

    Error if index or length is negative.
    This exception will not be thrown if index + length is greater than the size of the input data. Consistent with the existing over-read behaviors, the new reader will be supplied a shared subsequence of all remaining data starting from index.

    Returns

    The new reader

    Parameters

    • Optional index: number = ...

      the position in this reader at which the data of the new reader will start; must be non-negative. Defaults to the current reader position.

    • Optional length: number = ...

      the length of the shared subsequence of data to supply to the new reader; must be non-negative. Defaults to the length of the remaining data starting from index.

    Returns EoReader

  • Parameters

    • bytes: Uint8Array

    Returns Uint8Array

Generated using TypeDoc