Skip to content

Commit

Permalink
Tighten the tests for throwing weapons in quiver_absorb_num() so they…
Browse files Browse the repository at this point in the history
… match the inscription requirements imposed by calc_inventory(). Should resolve #4642 , which was a regression introduced by 15cae66 .
  • Loading branch information
backwardsEric authored and NickMcConnell committed Feb 17, 2021
1 parent 14c105f commit 02ea738
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/obj-gear.c
Original file line number Diff line number Diff line change
Expand Up @@ -492,8 +492,10 @@ struct object *gear_object_for_use(struct object *obj, int num, bool message,
*/
static int quiver_absorb_num(const struct object *obj)
{
bool throwing = of_has(obj->flags, OF_THROWING);

/* Must be ammo or good for throwing */
if (tval_is_ammo(obj) || of_has(obj->flags, OF_THROWING)) {
if (tval_is_ammo(obj) || throwing) {
int i, quiver_count = 0, space_free = 0;

/* Count the current space this object could go into */
Expand All @@ -506,8 +508,22 @@ static int quiver_absorb_num(const struct object *obj)
if (object_stackable(quiver_obj, obj, OSTACK_PACK))
space_free += z_info->quiver_slot_size
- quiver_obj->number * mult;
} else {
} else if (!throwing) {
space_free += z_info->quiver_slot_size;
} else if (obj->note) {
/*
* Per calc_inventory(), throwing weapons
* will be added to the quiver if inscribed
* to go into an unoccupied slot. The
* inscription test should match what
* calc_inventory() uses.
*/
const char *s = strchr(quark_str(obj->note), '@');

if (s && (s[1] == 'f' || s[1] == 'v') &&
s[2] - '0' == i) {
space_free += z_info->quiver_slot_size;
}
}
}

Expand Down

0 comments on commit 02ea738

Please sign in to comment.