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
databyte[]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
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
Remaining
Gets the number of bytes remaining.
public int Remaining { get; }
Property Value
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
GetBytes(int)
Reads an array of raw bytes from the input data.
public byte[] GetBytes(int length)
Parameters
lengthint
Returns
- byte[]
GetChar()
Reads an encoded 1-byte integer from the input data.
public int GetChar()
Returns
GetEncodedString()
Reads an encoded string from the input data.
public string GetEncodedString()
Returns
GetFixedEncodedString(int)
Reads an encoded string with a fixed length from the input data.
public string GetFixedEncodedString(int length)
Parameters
lengthintThe 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
lengthintThe length of the string
paddedboolTrue if the string is padded with trailing
0xFFbytes
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
lengthintThe 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
lengthintThe length of the string
paddedboolTrue if the string is padded with trailing
0xFFbytes
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
GetShort()
Reads an encoded 2-byte integer from the input data.
public int GetShort()
Returns
GetString()
Reads a string from the input data.
public string GetString()
Returns
GetThree()
Reads an encoded 3-byte integer from the input data.
public int GetThree()
Returns
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
indexintThe 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
indexis negative.
This exception will not be thrown ifindexis 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
indexintThe position in this reader at which the data of the new reader will start; must be non-negative.
lengthintThe 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
indexorlengthis negative.This exception will not be thrown if
index+lengthis 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 fromindex.