eolib - v2.0.1
    Preparing search index...

    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.

    Index

    Constructors

    • Creates a new EoReader instance for the specified data.

      Parameters

      • data: Uint8Array

        the byte array containing the input data

      Returns EoReader

    Accessors

    • get chunkedReadingMode(): boolean

      Gets the chunked reading mode for the reader.

      Returns boolean

      True if the reader is in chunked reading mode

    • 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 number

      The current position in the input data

    • 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 number

      The number of bytes remaining

    Methods

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

      Parameters

      • length: number

      Returns Uint8Array

      An array of raw bytes

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

      Returns number

      A decoded 1-byte integer

    • Reads an encoded string from the input data.

      Returns string

      A decoded string

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

      Parameters

      • length: number

        the length of the string

      • padded: boolean = false

        true if the string is padded with trailing 0xFF bytes

      Returns string

      A decoded string

      Error if the length is negative

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

      Parameters

      • length: number

        the length of the string

      • padded: boolean = false

        true if the string is padded with trailing 0xFF bytes

      Returns string

      A decoded string

      Error if the length is negative

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

      Returns number

      A decoded 4-byte integer

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

      Returns number

      A decoded 2-byte integer

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

      Returns number

      A decoded 3-byte integer

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

      Returns void

      Error if not in chunked reading mode

    • 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.

      Parameters

      • Optionalindex: 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.

      • Optionallength: 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

      The new reader

      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.