MCPcopy Create free account
hub / github.com/cuberite/cuberite / NextInt

Method NextInt

src/FastRandom.cpp:102–115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

100
101
102int cFastRandom::NextInt(int a_Range)
103{
104 ASSERT(a_Range <= 1000000); // The random is not sufficiently linearly distributed with bigger ranges
105 ASSERT(a_Range > 0);
106
107 // Make the m_Counter operations as minimal as possible, to emulate atomicity
108 int Counter = m_Counter++;
109
110 // Use a_Range, m_Counter and m_Seed as inputs to the pseudorandom function:
111 int n = a_Range + Counter * 57 + m_Seed * 57 * 57;
112 n = (n << 13) ^ n;
113 n = ((n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff);
114 return ((n / 11) % a_Range);
115}
116
117
118

Callers 11

UpdateMethod · 0.80
TestIntsMethod · 0.80
ChooseMobTypeMethod · 0.80
CanSpawnHereMethod · 0.80
NewMonsterFromTypeMethod · 0.80
ConvertToPickupsMethod · 0.80
OnDestroyedMethod · 0.80
ConvertToPickupsMethod · 0.80
OnUpdateMethod · 0.80
ConvertToPickupsMethod · 0.80
EatItemMethod · 0.80

Calls

no outgoing calls

Tested by 1

TestIntsMethod · 0.64