eolib 0.5.0
A core C library for writing applications related to Endless Online
Loading...
Searching...
No Matches
sequencer.h File Reference
#include <stdint.h>
#include "result.h"

Go to the source code of this file.

Data Structures

struct  EoSequencer

Typedefs

typedef struct EoSequencer EoSequencer

Functions

EoSequencer eo_sequencer_init (int32_t start)
EoResult eo_sequencer_next (EoSequencer *sequencer, int32_t *out_value)
int32_t eo_generate_sequence_start (void)
int32_t eo_sequence_start_from_init (int32_t s1, int32_t s2)
int32_t eo_sequence_start_from_ping (int32_t s1, int32_t s2)
EoResult eo_sequence_init_bytes (int32_t start, uint8_t *out_bytes)
EoResult eo_sequence_ping_bytes (int32_t start, uint8_t *out_bytes)

Typedef Documentation

◆ EoSequencer

typedef struct EoSequencer EoSequencer

Function Documentation

◆ eo_generate_sequence_start()

int32_t eo_generate_sequence_start ( void )

Generates a cryptographically random starting value for a sequencer.

Returns
A random starting value.
Remarks
The value is guaranteed to fit in the ServerInitInitPacket sequence fields.

Definition at line 29 of file sequencer.c.

◆ eo_sequence_init_bytes()

EoResult eo_sequence_init_bytes ( int32_t start,
uint8_t * out_bytes )

Initializes a sequence of bytes based on the starting value.

Parameters
startThe starting value for the sequence.
out_bytesA pointer to the buffer where the initialized byte sequence will be stored. Must have space for at least 2 bytes.
Returns
EO_SUCCESS on success, EO_NULL_PTR if out_bytes is NULL, EO_INVALID_SEQUENCE_RANGE if the derived range is empty, or EO_SEQUENCE_OUT_OF_RANGE if seq2 cannot be encoded as a single EO byte.

Definition at line 46 of file sequencer.c.

◆ eo_sequence_ping_bytes()

EoResult eo_sequence_ping_bytes ( int32_t start,
uint8_t * out_bytes )

Generates a sequence of bytes for the ping packet based on the starting value.

Parameters
startThe starting value for the sequence.
out_bytesA pointer to the buffer where the ping byte sequence will be stored. Must have space for at least 2 bytes.
Returns
EO_SUCCESS on success, EO_NULL_PTR if out_bytes is NULL, EO_INVALID_SEQUENCE_RANGE if the derived range is empty, or EO_SEQUENCE_OUT_OF_RANGE if seq2 cannot be encoded as a single EO byte.

Definition at line 87 of file sequencer.c.

◆ eo_sequence_start_from_init()

int32_t eo_sequence_start_from_init ( int32_t s1,
int32_t s2 )

Calculates the starting sequence value based on the initial server sequence values.

Parameters
s1The first sequence value from the server.
s2The second sequence value from the server.
Returns
The calculated starting sequence value.

Definition at line 34 of file sequencer.c.

◆ eo_sequence_start_from_ping()

int32_t eo_sequence_start_from_ping ( int32_t s1,
int32_t s2 )

Calculates the starting sequence value based on the ping sequence values.

Parameters
s1The first sequence value from the server ping response.
s2The second sequence value from the server ping response.
Returns
The calculated starting sequence value.

Definition at line 41 of file sequencer.c.

◆ eo_sequencer_init()

EoSequencer eo_sequencer_init ( int32_t start)

Initializes a sequencer with the given starting value.

Parameters
startThe initial value for the sequencer.
Returns
The initialized sequencer.

Definition at line 5 of file sequencer.c.

◆ eo_sequencer_next()

EoResult eo_sequencer_next ( EoSequencer * sequencer,
int32_t * out_value )

Gets the next value in the sequence, advances the counter, and writes it to out_value.

Parameters
sequencerThe sequencer to advance.
out_valueOutput for the next sequence value. May be NULL to advance without capturing the value.
Returns
EO_SUCCESS on success, or EO_NULL_PTR if sequencer is NULL.

Definition at line 13 of file sequencer.c.