Merge branch 'NetHack-3.6'
This commit is contained in:
29
src/pickup.c
29
src/pickup.c
@@ -699,28 +699,22 @@ int what; /* should be a long */
|
||||
return (n_tried > 0);
|
||||
}
|
||||
|
||||
boolean
|
||||
is_autopickup_exception(obj, grab)
|
||||
struct autopickup_exception *
|
||||
check_autopickup_exceptions(obj)
|
||||
struct obj *obj;
|
||||
boolean grab; /* forced pickup, rather than forced leave behind? */
|
||||
{
|
||||
/*
|
||||
* Does the text description of this match an exception?
|
||||
*/
|
||||
struct autopickup_exception
|
||||
*ape = (grab) ? iflags.autopickup_exceptions[AP_GRAB]
|
||||
: iflags.autopickup_exceptions[AP_LEAVE];
|
||||
struct autopickup_exception *ape = g.apelist;
|
||||
|
||||
if (ape) {
|
||||
char *objdesc = makesingular(doname(obj));
|
||||
|
||||
while (ape) {
|
||||
if (regex_match(objdesc, ape->regex))
|
||||
return TRUE;
|
||||
while (ape && !regex_match(objdesc, ape->regex))
|
||||
ape = ape->next;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
return ape;
|
||||
}
|
||||
|
||||
boolean
|
||||
@@ -728,6 +722,7 @@ autopick_testobj(otmp, calc_costly)
|
||||
struct obj *otmp;
|
||||
boolean calc_costly;
|
||||
{
|
||||
struct autopickup_exception *ape;
|
||||
static boolean costly = FALSE;
|
||||
const char *otypes = flags.pickup_types;
|
||||
boolean pickit;
|
||||
@@ -743,12 +738,12 @@ boolean calc_costly;
|
||||
|
||||
/* check for pickup_types */
|
||||
pickit = (!*otypes || index(otypes, otmp->oclass));
|
||||
/* check for "always pick up */
|
||||
if (!pickit)
|
||||
pickit = is_autopickup_exception(otmp, TRUE);
|
||||
/* then for "never pick up */
|
||||
if (pickit)
|
||||
pickit = !is_autopickup_exception(otmp, FALSE);
|
||||
|
||||
/* check for autopickup exceptions */
|
||||
ape = check_autopickup_exceptions(otmp);
|
||||
if (ape)
|
||||
pickit = ape->grab;
|
||||
|
||||
/* pickup_thrown overrides pickup_types and exceptions */
|
||||
if (!pickit)
|
||||
pickit = (flags.pickup_thrown && otmp->was_thrown);
|
||||
|
||||
Reference in New Issue
Block a user