Index: src/object/obj-util.c =================================================================== --- src/object/obj-util.c (revision 1984) +++ src/object/obj-util.c (working copy) @@ -2672,12 +2672,19 @@ * * Note that this code must remove any location/stack information * from the object once it is placed into the inventory. + * + * QUIVER: This function is responsible for making sure all ammo is + * placed in the quiver, not the pack. It should not be possible for ammo + * to end up in the pack. */ s16b inven_carry(object_type *o_ptr) { int i, j, k; int n = -1; + bool is_ammo = obj_is_ammo(o_ptr); + int slot; + object_type *j_ptr; /* Apply an autoinscription */ @@ -2717,18 +2724,33 @@ } } + if (is_ammo) + { + slot = wield_slot(o_ptr); + if (inventory[slot].k_idx && !object_similar(&inventory[slot], o_ptr)) + return -1; + } - /* Paranoia */ - if (p_ptr->inven_cnt > INVEN_MAX_PACK) return (-1); + /* Make sure we have room in the pack/quiver */ + if (p_ptr->inven_cnt > INVEN_MAX_PACK) + { + if (!is_ammo) + return -1; + else if (p_ptr->quiver_remainder + o_ptr->number > 99) + return -1; + } - + if (is_ammo) + { + /* Ammo goes in the quiver; we just need a temporary pack slot. */ + /* We checked for room earlier, so the last slot is guaranteed ok */ + j = INVEN_PACK; + } + else + { /* Find an empty slot */ for (j = 0; j <= INVEN_MAX_PACK; j++) - { - j_ptr = &inventory[j]; - - /* Use it if found */ - if (!j_ptr->k_idx) break; + if (!inventory[j].k_idx) break; } /* Use that slot */ @@ -2853,8 +2875,15 @@ /* Save quiver size */ save_quiver_size(); + if (is_ammo) + { + /* When ammo is picked up it gets wielded into the quiver */ + wield_item(o_ptr, i, slot); + return slot; + } + /* Return the slot */ - return (i); + return i; } Index: src/externs.h =================================================================== --- src/externs.h (revision 1982) +++ src/externs.h (working copy) @@ -304,6 +304,9 @@ extern byte py_pickup(int pickup); extern void move_player(int dir); +/* cmd3.c */ +void wield_item(object_type *o_ptr, int item, int slot); + /* cmd5.c */ s16b spell_chance(int spell); bool spell_okay(int spell, bool known, bool browse); Index: src/cmds.h =================================================================== --- src/cmds.h (revision 1982) +++ src/cmds.h (working copy) @@ -85,7 +85,6 @@ /* cmd3.c */ void do_cmd_inven(void); void do_cmd_equip(void); -void wield_item(object_type *o_ptr, int item, int slot); void wield_combine_ammo(object_type *o_ptr, int item, int slot); void do_cmd_destroy(cmd_code code, cmd_arg args[]); void textui_cmd_destroy(void); Index: src/cmd1.c =================================================================== --- src/cmd1.c (revision 1982) +++ src/cmd1.c (working copy) @@ -292,18 +292,6 @@ /* Handle errors (paranoia) */ if (slot < 0) return; - /* If we have picked up ammo which matches something in the quiver, note - * that it so that we can wield it later (and suppress pick up message) */ - if (obj_is_ammo(o_ptr)) { - int i; - for (i=QUIVER_START; i < QUIVER_END; i++) { - if (!inventory[i].k_idx) continue; - if (!object_similar(&inventory[i], o_ptr)) continue; - quiver_slot = i; - break; - } - } - /* Get the new object */ o_ptr = &inventory[slot]; @@ -318,7 +306,7 @@ history_add_artifact(o_ptr->name1, object_was_sensed(o_ptr)); /* Optionally, display a message */ - if (msg && !quiver_slot) + if (msg && slot < QUIVER_START) { /* Describe the object */ object_desc(o_name, sizeof(o_name), o_ptr, ODESC_PREFIX | ODESC_FULL); @@ -330,9 +318,6 @@ /* Delete the object */ delete_object_idx(o_idx); - - /* If we have a quiver slot that this ammo matches, use it */ - if (quiver_slot) wield_item(o_ptr, slot, quiver_slot); }