MCPcopy Create free account
hub / github.com/NetHack/NetHack / rne

Function rne

src/rnd.c:191–210  ·  view source on GitHub ↗

1 <= rne(x) <= max(u.ulevel/3,5) */

Source from the content-addressed store, hash-verified

189
190/* 1 <= rne(x) <= max(u.ulevel/3,5) */
191int
192rne(int x)
193{
194 int tmp, utmp;
195
196 utmp = (u.ulevel < 15) ? 5 : u.ulevel / 3;
197 tmp = 1;
198 while (tmp < utmp && !rn2(x))
199 tmp++;
200 return tmp;
201
202 /* was:
203 * tmp = 1;
204 * while (!rn2(x))
205 * tmp++;
206 * return min(tmp, (u.ulevel < 15) ? 5 : u.ulevel / 3);
207 * which is clearer but less efficient and stands a vanishingly
208 * small chance of overflowing tmp
209 */
210}
211
212/* rnz: everyone's favorite! */
213int

Callers 3

rnzFunction · 0.85
mksobj_initFunction · 0.85
ini_inv_adjust_objFunction · 0.85

Calls 1

rn2Function · 0.85

Tested by

no test coverage detected