MCPcopy Index your code
hub / github.com/NetHack/NetHack / rnd_class

Function rnd_class

src/objnam.c:5402–5419  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5400}
5401
5402int
5403rnd_class(int first, int last)
5404{
5405 int i, x, sum = 0;
5406
5407 if (last > first) {
5408 for (i = first; i <= last; i++)
5409 sum += objects[i].oc_prob;
5410 if (!sum) /* all zero, so equal probability */
5411 return rn1(last - first + 1, first);
5412
5413 x = rnd(sum);
5414 for (i = first; i <= last; i++)
5415 if ((x -= objects[i].oc_prob) <= 0)
5416 return i;
5417 }
5418 return (first == last) ? first : STRANGE_OBJECT;
5419}
5420
5421const char *
5422Japanese_item_name(int i, const char *ordinaryname)

Callers 11

mk_mplayerFunction · 0.85
readobjnam_postparse2Function · 0.85
readobjnamFunction · 0.85
give_spellFunction · 0.85
mkobjFunction · 0.85
mkbox_cntsFunction · 0.85
hornoplentyFunction · 0.85
m_initinvFunction · 0.85
poly_objFunction · 0.85
kick_nondoorFunction · 0.85
dofindgemFunction · 0.85

Calls 1

rndFunction · 0.85

Tested by

no test coverage detected