Class TEoReader

Unit

Declaration

type TEoReader = class(TObject)

Description

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

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

See Chunked Reading.

Hierarchy

Overview

Methods

Public constructor Create; overload;
Public constructor Create(const Data: TArray<Byte>); overload;
Public function Slice: TEoReader; overload;
Public function Slice(Index: Cardinal): TEoReader; overload;
Public function Slice(Index: Cardinal; Length: Cardinal): TEoReader; overload;
Public function GetByte: Cardinal;
Public function GetBytes(Length: Cardinal): TArray<Byte>;
Public function GetChar: Cardinal;
Public function GetShort: Cardinal;
Public function GetThree: Cardinal;
Public function GetInt: Cardinal;
Public function GetString: string;
Public function GetFixedString(Length: Cardinal; Padded: Boolean = False): string; overload;
Public function GetEncodedString: string;
Public function GetFixedEncodedString(Length: Cardinal; Padded: Boolean = False): string; overload;
Public procedure NextChunk;

Properties

Public property ChunkedReadingMode: Boolean read FChunkedReadingMode write SetChunkedReadingMode;
Public property Remaining: Cardinal read GetRemaining;
Public property Position: Cardinal read GetPosition;

Description

Methods

Public constructor Create; overload;

Creates a new TEoReader instance with no data.

Public constructor Create(const Data: TArray<Byte>); overload;

Creates a new TEoReader instance for the specified data.

Parameters
Data
The byte array containing the input data
Public function Slice: TEoReader; overload;

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

The input data of the new reader will start at this reader's current position and contain all remaining data. 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.

Returns

The new reader

Public function Slice(Index: Cardinal): TEoReader; overload;

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

The input data of the new reader will start at this reader's current position and contain all remaining data. 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
Index
The position in this reader at which the data of the new reader will start
Returns

The new reader

Public function Slice(Index: Cardinal; Length: Cardinal): TEoReader; overload;

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

The input data of the new reader will start at this reader's current position and contain all remaining data. 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
Index
The position in this reader at which the data of the new reader will start
Length
The length of the shared subsequence of data to supply to the new reader
Returns

The new reader

Public function GetByte: Cardinal;

Reads a raw byte from the input data.

Returns

A raw byte

Public function GetBytes(Length: Cardinal): TArray<Byte>;

Reads an array of raw bytes from the input data.

Returns

An array of raw bytes

Public function GetChar: Cardinal;

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

Returns

A decoded 1-byte integer

Public function GetShort: Cardinal;

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

Returns

A decoded 2-byte integer

Public function GetThree: Cardinal;

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

Returns

A decoded 3-byte integer

Public function GetInt: Cardinal;

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

Returns

A decoded 4-byte integer

Public function GetString: string;

Reads a string from the input data.

Returns

A string

Public function GetFixedString(Length: Cardinal; Padded: Boolean = False): string; overload;

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

Parameters
Length
The length of the string
Padded
True if the string is padded with trailing $FF bytes
Returns

A string

Public function GetEncodedString: string;

Reads an encoded string from the input data.

Returns

A decoded string

Public function GetFixedEncodedString(Length: Cardinal; Padded: Boolean = False): string; overload;

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

Parameters
Length
The length of the string
Padded
True if the string is padded with trailing $FF bytes
Returns

A decoded string

Public procedure NextChunk;

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

Exceptions raised
EInvalidOpException
If not in chunked reading mode

Properties

Public property ChunkedReadingMode: Boolean read FChunkedReadingMode write SetChunkedReadingMode;

Whether chunked reading mode is enabled for this reader.

In chunked reading mode:

  • The reader will treat $FF bytes as the end of the current chunk.

  • TEoReader.NextChunk can be called to move to the next chunk.

Public property Remaining: Cardinal read GetRemaining;

If chunked reading mode is enabled, the number of bytes remaining in the current chunk.
Otherwise, the total number of bytes remaining in the input data.

Public property Position: Cardinal read GetPosition;

The current position in the input data.


Generated by PasDoc 0.16.0-snapshot.