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

Function wearslot

src/worn.c:281–351  ·  view source on GitHub ↗

return a bitmask of the equipment slot(s) a given item might be worn in */

Source from the content-addressed store, hash-verified

279
280/* return a bitmask of the equipment slot(s) a given item might be worn in */
281long
282wearslot(struct obj *obj)
283{
284 int otyp = obj->otyp;
285 /* practically any item can be wielded or quivered; it's up to
286 our caller to handle such things--we assume "normal" usage */
287 long res = 0L; /* default: can't be worn anywhere */
288
289 switch (obj->oclass) {
290 case AMULET_CLASS:
291 res = W_AMUL; /* WORN_AMUL */
292 break;
293 case RING_CLASS:
294 res = W_RINGL | W_RINGR; /* W_RING, BOTH_SIDES */
295 break;
296 case ARMOR_CLASS:
297 switch (objects[otyp].oc_armcat) {
298 case ARM_SUIT:
299 res = W_ARM;
300 break; /* WORN_ARMOR */
301 case ARM_SHIELD:
302 res = W_ARMS;
303 break; /* WORN_SHIELD */
304 case ARM_HELM:
305 res = W_ARMH;
306 break; /* WORN_HELMET */
307 case ARM_GLOVES:
308 res = W_ARMG;
309 break; /* WORN_GLOVES */
310 case ARM_BOOTS:
311 res = W_ARMF;
312 break; /* WORN_BOOTS */
313 case ARM_CLOAK:
314 res = W_ARMC;
315 break; /* WORN_CLOAK */
316 case ARM_SHIRT:
317 res = W_ARMU;
318 break; /* WORN_SHIRT */
319 }
320 break;
321 case WEAPON_CLASS:
322 res = W_WEP | W_SWAPWEP;
323 if (objects[otyp].oc_merge)
324 res |= W_QUIVER;
325 break;
326 case TOOL_CLASS:
327 if (otyp == BLINDFOLD || otyp == TOWEL || otyp == LENSES)
328 res = W_TOOL; /* WORN_BLINDF */
329 else if (is_weptool(obj) || otyp == TIN_OPENER)
330 res = W_WEP | W_SWAPWEP;
331 else if (otyp == SADDLE)
332 res = W_SADDLE;
333 break;
334 case FOOD_CLASS:
335 if (obj->otyp == MEAT_RING)
336 res = W_RINGL | W_RINGR;
337 break;
338 case GEM_CLASS:

Callers 1

poly_objFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected