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

Function autopick_testobj

src/pickup.c:929–965  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

927}
928
929boolean
930autopick_testobj(struct obj *otmp, boolean calc_costly)
931{
932 struct autopickup_exception *ape;
933 static boolean costly = FALSE;
934 const char *otypes = flags.pickup_types;
935 boolean pickit;
936
937 /* calculate 'costly' just once for a given autopickup operation */
938 if (calc_costly)
939 costly = (otmp->where == OBJ_FLOOR
940 && costly_spot(otmp->ox, otmp->oy));
941
942 /* first check: reject if an unpaid item in a shop */
943 if (costly && !otmp->no_charge)
944 return FALSE;
945
946 /* pickup_thrown/pickup_stolen/nopick_dropped override pickup_types and
947 exceptions */
948 if ((flags.pickup_thrown && otmp->how_lost == LOST_THROWN)
949 || (flags.pickup_stolen && otmp->how_lost == LOST_STOLEN))
950 return TRUE;
951 if (flags.nopick_dropped && otmp->how_lost == LOST_DROPPED)
952 return FALSE;
953 if (otmp->how_lost == LOST_EXPLODING)
954 return FALSE;
955
956 /* check for pickup_types */
957 pickit = (!*otypes || strchr(otypes, otmp->oclass));
958
959 /* check for autopickup exceptions */
960 ape = check_autopickup_exceptions(otmp);
961 if (ape)
962 pickit = ape->grab;
963
964 return pickit;
965}
966
967/*
968 * Pick from the given list using flags.pickup_types. Return the number

Callers 2

cannot_pushFunction · 0.85
autopickFunction · 0.85

Calls 2

costly_spotFunction · 0.85

Tested by

no test coverage detected