helapordo 1.4.20
Loading...
Searching...
No Matches
game_rng.c File Reference
#include "game_rng.h"
Include dependency graph for game_rng.c:

Functions

int hlpd_rand_docount (bool count)
 Wraps over rand() to update G_RNG_ADVANCEMENTS if passed flag is true.
int hlpd_rand (void)
 Wraps over hlpd_rand_docount() to update G_RNG_ADVANCEMENTS.
unsigned long hlpd_hash (unsigned char *str)
 djb2 by Dan Bernstein.
void gen_random_seed (char buffer[PATH_SEED_BUFSIZE+1])
 Sets the passed buffer up to be a random seed.
bool check_seed (char buffer[PATH_SEED_BUFSIZE])
 Checks the passed buffer as a seed.

Variables

int64_t G_RNG_ADVANCEMENTS = 0
 Global variable used to count advancements of the rng.

Function Documentation

◆ check_seed()

bool check_seed ( char buffer[PATH_SEED_BUFSIZE])

Checks the passed buffer as a seed.

Only chars >= 0, <= Z; not including the symbols between digits and letters. Notably, the passed buffer is checked by applying toupper() to each char.

Parameters
bufferThe buffer to check.
Returns
True for a valid seed.

◆ gen_random_seed()

void gen_random_seed ( char buffer[PATH_SEED_BUFSIZE+1])

Sets the passed buffer up to be a random seed.

Only chars >= 0, <= Z; not including the symbols between digits and letters.

Parameters
bufferThe buffer to set.

◆ hlpd_hash()

unsigned long hlpd_hash ( unsigned char * str)

djb2 by Dan Bernstein.

See: http://www.cse.yorku.ca/~oz/hash.html https://stackoverflow.com/questions/7666509/hash-function-for-string

Parameters
strThe string to hash.
Returns
The resulting hash.

◆ hlpd_rand()

int hlpd_rand ( void )

Wraps over hlpd_rand_docount() to update G_RNG_ADVANCEMENTS.

See also
G_RNG_ADVANCEMENTS
hlpd_rand_docount()
Returns
A random integer from hlpd_rand_docount().

◆ hlpd_rand_docount()

int hlpd_rand_docount ( bool count)

Wraps over rand() to update G_RNG_ADVANCEMENTS if passed flag is true.

See also
G_RNG_ADVANCEMENTS
rand()
Parameters
countWhen true, advance G_RNG_ADVANCEMENTS.
Returns
A random integer from rand().

Variable Documentation

◆ G_RNG_ADVANCEMENTS

int64_t G_RNG_ADVANCEMENTS = 0

Global variable used to count advancements of the rng.