MCPcopy Create free account
hub / github.com/TheForceEngine/TheForceEngine / random

Function random

TheForceEngine/TFE_DarkForces/random.cpp:45–55  ·  view source on GitHub ↗

Generate a random value as: 1) random_next() or 2) fixed16_16(value) * fract(random_next())

Source from the content-addressed store, hash-verified

43 // 1) random_next() or
44 // 2) fixed16_16(value) * fract(random_next())
45 s32 random(s32 value)
46 {
47 s32 newValue = random_next();
48 if (newValue > value || newValue < 0)
49 {
50 // Note the value is cast to fixed16_16 but is not actually converted.
51 // This means that if the incoming value is not fixed point, the result will also not be fixed point.
52 newValue = mul16(fixed16_16(value), fract16(newValue));
53 }
54 return newValue;
55 }
56
57 void random_seed(u32 seed)
58 {

Callers 15

weaponFire_pistolFunction · 0.85
weaponFire_rifleFunction · 0.85
weaponFire_repeaterFunction · 0.85
weaponFire_fusionFunction · 0.85
weaponFire_mortarFunction · 0.85
weaponFire_concussionFunction · 0.85
weaponFire_cannonFunction · 0.85
computeAutoaimFunction · 0.85
generatorTaskFuncFunction · 0.85
generatorLogicSetupFuncFunction · 0.85
obj_createGeneratorFunction · 0.85

Calls 3

random_nextFunction · 0.85
mul16Function · 0.85
fract16Function · 0.85

Tested by

no test coverage detected