Table of Contents

Class EoReader

Namespace
Moffat.EndlessOnline.SDK.Data
Assembly
Moffat.EndlessOnline.SDK.dll

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

public sealed class EoReader
Inheritance
EoReader
Inherited Members

Constructors

EoReader(byte[])

Creates a new EoReader instance for the specified data.

public EoReader(byte[] data)

Parameters

data byte[]

The byte array containing the input data

Properties

ChunkedReadingMode

Gets or sets chunked reading mode for the reader.

public bool ChunkedReadingMode { get; set; }

Property Value

bool

Remarks

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.

Position

Gets the current Position in the input data.

public int Position { get; }

Property Value

int

Remaining

Gets the number of bytes remaining.

public int Remaining { get; }

Property Value

int

Remarks

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.

Methods

GetByte()

Reads a raw byte from the input data.

public int GetByte()

Returns

int

GetBytes(int)

Reads an array of raw bytes from the input data.

public byte[] GetBytes(int length)

Parameters

length int

Returns

byte[]

GetChar()

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

public int GetChar()

Returns

int

GetEncodedString()

Reads an encoded string from the input data.

public string GetEncodedString()

Returns

string

GetFixedEncodedString(int)

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

public string GetFixedEncodedString(int length)

Parameters

length int

The length of the string

Returns

string

A decoded string

Exceptions

ArgumentException

If the length is negative

GetFixedEncodedString(int, bool)

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

public string GetFixedEncodedString(int length, bool padded)

Parameters

length int

The length of the string

padded bool

True if the string is padded with trailing 0xFF bytes

Returns

string

A decoded string

Exceptions

ArgumentException

If the length is negative

GetFixedString(int)

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

public string GetFixedString(int length)

Parameters

length int

The length of the string

Returns

string

A decoded string

Exceptions

ArgumentException

If the length is negative

GetFixedString(int, bool)

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

public string GetFixedString(int length, bool padded)

Parameters

length int

The length of the string

padded bool

True if the string is padded with trailing 0xFF bytes

Returns

string

A decoded string

Exceptions

ArgumentException

If the length is negative

GetInt()

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

public int GetInt()

Returns

int

GetShort()

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

public int GetShort()

Returns

int

GetString()

Reads a string from the input data.

public string GetString()

Returns

string

GetThree()

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

public int GetThree()

Returns

int

NextChunk()

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

public void NextChunk()

Exceptions

InvalidOperationException

If not in chunked reading mode

Slice()

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

public EoReader Slice()

Returns

EoReader

The new reader.

Remarks

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.

Slice(int)

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

public EoReader Slice(int index)

Parameters

index int

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

Returns

EoReader

The new reader.

Remarks

The input data of the new reader will start at position index in this reader 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.

Exceptions

ArgumentException

Thrown if index is negative.
This exception will not be thrown if index is greater than the size of the input data. Consistent with the existing over-read behaviors, an empty reader will be returned.

Slice(int, int)

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

public EoReader Slice(int index, int length)

Parameters

index int

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

length int

The length of the shared subsequence of data to supply to the new reader; must be non-negative.

Returns

EoReader

The new reader.

Remarks

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.

Exceptions

ArgumentException

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