NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
cM_rand_c Class Reference

#include <dol/cLib/c_random.hpp>

Description

Random number generation helper class.

Note
Unofficial name.

Definition at line 7 of file c_random.hpp.

Public Member Functions

 cM_rand_c (u32 seed)
 Initializes the class with the given seed.
 
u32 ranqd1 (u32 max)
 Generates an integer between 0 and the given max.
 
float ranqd2 ()
 Generates a floating point number between 0 and 1.
 
float ranqd3 ()
 Generates a floating point number between -0.5 and 0.5.
 

Public Attributes

u32 mSeed
 The current seed.
 

Private Member Functions

u32 ranqdStep ()
 Implementation of the ranqd1 algorithm.
 

Static Private Attributes

static u32 mConst1 = 0x19660D
 Constant a from the ranqd1 algorithm.
 
static u32 mConst2 = 0x3C6EF35F
 Constant c from the ranqd1 algorithm.
 

Constructor & Destructor Documentation

◆ cM_rand_c()

cM_rand_c::cM_rand_c ( u32  seed)
inline

Initializes the class with the given seed.

Definition at line 11 of file c_random.hpp.

Member Function Documentation

◆ ranqd1()

u32 cM_rand_c::ranqd1 ( u32  max)

Generates an integer between 0 and the given max.

Definition at line 28 of file c_random.cpp.

◆ ranqd2()

float cM_rand_c::ranqd2 ( )

Generates a floating point number between 0 and 1.

Definition at line 33 of file c_random.cpp.

◆ ranqd3()

float cM_rand_c::ranqd3 ( )

Generates a floating point number between -0.5 and 0.5.

Definition at line 39 of file c_random.cpp.

◆ ranqdStep()

u32 cM_rand_c::ranqdStep ( )
inlineprivate

Implementation of the ranqd1 algorithm.

Bug:
The implementation is flawed. This post explains why.

Definition at line 9 of file c_random.cpp.

Member Data Documentation

◆ mSeed

u32 cM_rand_c::mSeed

The current seed.

Definition at line 17 of file c_random.hpp.

◆ mConst1

u32 cM_rand_c::mConst1 = 0x19660D
staticprivate

Constant a from the ranqd1 algorithm.

Definition at line 25 of file c_random.hpp.

◆ mConst2

u32 cM_rand_c::mConst2 = 0x3C6EF35F
staticprivate

Constant c from the ranqd1 algorithm.

Definition at line 26 of file c_random.hpp.