more autopickup_exception

An optimization.

Split the patterns into two chains, one for things you want "always picked up", and one for things you want "never picked up".  That way, the
entire exception list isn't being checked twice, once for each type of
check.  The check for things to "always pick up" only checks the
chain at the AP_GRAB index, and the check for things to "never
pick up" only checks the chain at the AP_LEAVE index.

- Also modifies the toggle autopickup '@' message
appropriately for the AUTOPICKUP_EXCEPTIONS build.
(it just tacks on ", with some exceptions" if there are some)
This commit is contained in:
nethack.allison
2003-11-15 23:15:01 +00:00
parent f1129d502f
commit 94ff3505b4
3 changed files with 84 additions and 79 deletions

View File

@@ -606,10 +606,11 @@ boolean grab; /* forced pickup, rather than forced leave behind? */
* Does the text description of this match an exception?
*/
char *objdesc = makesingular(xname(obj));
struct autopickup_exception *ape = iflags.autopickup_exceptions;
struct autopickup_exception *ape = (grab) ?
iflags.autopickup_exceptions[AP_GRAB] :
iflags.autopickup_exceptions[AP_LEAVE];
while (ape) {
if (pmatch(ape->pattern, objdesc) &&
((grab && ape->grab) || (!grab && !ape->grab))) return TRUE;
if (pmatch(ape->pattern, objdesc)) return TRUE;
ape = ape->next;
}
return FALSE;