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

Function ini_inv_obj_substitution

src/u_init.c:1181–1203  ·  view source on GitHub ↗

substitute object with something else based on race. only changes otyp, and returns it. */

Source from the content-addressed store, hash-verified

1179/* substitute object with something else based on race.
1180 only changes otyp, and returns it. */
1181staticfn short
1182ini_inv_obj_substitution(const struct trobj *trop, struct obj *obj)
1183{
1184 if (gu.urace.mnum != PM_HUMAN) {
1185 int i;
1186
1187 /* substitute race-specific items; this used to be in
1188 the 'if (otyp != UNDEF_TYP) { }' block above, but then
1189 substitutions didn't occur for randomly generated items
1190 (particularly food) which have racial substitutes */
1191 for (i = 0; inv_subs[i].race_pm != NON_PM; ++i)
1192 if (inv_subs[i].race_pm == gu.urace.mnum
1193 && obj->otyp == inv_subs[i].item_otyp) {
1194 debugpline3("ini_inv: substituting %s for %s%s",
1195 OBJ_NAME(objects[inv_subs[i].subs_otyp]),
1196 (trop->trotyp == UNDEF_TYP) ? "random " : "",
1197 OBJ_NAME(objects[obj->otyp]));
1198 obj->otyp = inv_subs[i].subs_otyp;
1199 break;
1200 }
1201 }
1202 return obj->otyp;
1203}
1204
1205/* returns: TRUE to stop generating items from this trobj,
1206 FALSE for normal behaviour */

Callers 1

ini_invFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected