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

Function setgemprobs

src/o_init.c:53–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51#endif /* TILES_IN_GLYPHMAP */
52
53staticfn void
54setgemprobs(d_level *dlev)
55{
56 int j, first, lev, sum = 0;
57
58 if (dlev)
59 lev = (ledger_no(dlev) > maxledgerno()) ? maxledgerno()
60 : ledger_no(dlev);
61 else
62 lev = 0;
63 first = svb.bases[GEM_CLASS];
64
65 for (j = 0; j < 9 - lev / 3; j++)
66 objects[first + j].oc_prob = 0;
67 first += j;
68 if (first > LAST_REAL_GEM || objects[first].oc_class != GEM_CLASS
69 || OBJ_NAME(objects[first]) == (char *) 0) {
70 raw_printf("Not enough gems? - first=%d j=%d LAST_GEM=%d", first, j,
71 LAST_REAL_GEM);
72 wait_synch();
73 }
74 for (j = first; j <= LAST_REAL_GEM; j++)
75 objects[j].oc_prob = (171 + j - first) / (LAST_REAL_GEM + 1 - first);
76
77 /* recompute GEM_CLASS total oc_prob - including rocks/stones */
78 for (j = svb.bases[GEM_CLASS]; j < svb.bases[GEM_CLASS + 1]; j++)
79 sum += objects[j].oc_prob;
80 go.oclass_prob_totals[GEM_CLASS] = sum;
81}
82
83/* some gems can have different colors */
84staticfn void

Callers 2

init_objectsFunction · 0.85
oinitFunction · 0.85

Calls 4

ledger_noFunction · 0.85
maxledgernoFunction · 0.85
wait_synchFunction · 0.85
raw_printfFunction · 0.70

Tested by

no test coverage detected