--- deliantra/server/server/player.C 2009/11/05 14:56:06 1.236 +++ deliantra/server/server/player.C 2009/11/05 15:18:26 1.237 @@ -1657,18 +1657,8 @@ return true; } -/* find_key - * We try to find a key for the door as passed. If we find a key - * and successfully use it, we return the key, otherwise NULL - * This function merges both normal and locked door, since the logic - * for both is the same - just the specific key is different. - * pl is the player, - * inv is the objects inventory to searched - * door is the door we are trying to match against. - * This function can be called recursively to search containers. - */ -object * -find_key (object *pl, object *container, object *door) +static object * +find_key_ (object *pl, object *container, object *door) { object *tmp, *key; @@ -1699,7 +1689,7 @@ for (tmp = container->inv; tmp; tmp = tmp->below) /* No reason to search empty containers */ if (tmp->type == CONTAINER && tmp->inv) - if ((key = find_key (pl, tmp, door))) + if ((key = find_key_ (pl, tmp, door))) return key; if (!tmp) @@ -1741,6 +1731,31 @@ return tmp; } +/* find_key + * We try to find a key for the door as passed. If we find a key + * and successfully use it, we return the key, otherwise NULL + * This function merges both normal and locked door, since the logic + * for both is the same - just the specific key is different. + * pl is the player, + * inv is the objects inventory to searched + * door is the door we are trying to match against. + * This function can be called recursively to search containers. + */ +object * +find_key (object *pl, object *container, object *door) +{ + if (door->slaying && is_match_expr (door->slaying)) + { + // for match expressions, we try to find the key by applying the match + // to the op itself, which is supposed to find the "key", instead + // of searching through containers ourselves. + + return match_one (door->slaying, container, door, pl, pl); + } + else + return find_key_ (pl, container, door); +} + /* moved door processing out of move_player_attack. * returns 1 if player has opened the door with a key * such that the caller should not do anything more, @@ -1753,18 +1768,7 @@ * might as well return immediately as there is nothing more to do - * otherwise, we fall through to the rest of the code. */ - object *key; - - if (door->slaying && is_match_expr (door->slaying)) - { - // for match expressions, we try to find the key by applying the match - // to the op itself, which is supposed to find the "key", instead - // of searching through containers ourselves. - - key = match_one (door->slaying, op, door, op, op); - } - else - key = find_key (op, op, door); + object *key = find_key (op, op, door); /* If we found a key, do some extra work */ if (key)