From fd53b2e9dab9038ed34a419a1ee27c5314e13ddd Mon Sep 17 00:00:00 2001 From: pauldubois Date: Tue, 15 Apr 2008 09:01:37 +0000 Subject: Fix 1942290 git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@4237 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/quiver.cc | 29 ++++++++++------------------- crawl-ref/source/quiver.h | 1 - 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/crawl-ref/source/quiver.cc b/crawl-ref/source/quiver.cc index 3950aa9538..0c290671ea 100644 --- a/crawl-ref/source/quiver.cc +++ b/crawl-ref/source/quiver.cc @@ -49,28 +49,18 @@ player_quiver::player_quiver() // void player_quiver::get_desired_item(const item_def** item_out, int* slot_out) const { - ASSERT(m_last_used_type != AMMO_INVALID); - // I'd like to get rid of this first case - if (m_last_used_type == AMMO_INVALID) + const int slot = _get_pack_slot(m_last_used_of_type[m_last_used_type]); + if (slot == -1) { - if (item_out) *item_out = NULL; - if (slot_out) *slot_out = -1; + // Not in inv, but caller can at least get the type of the item. + if (item_out) *item_out = &m_last_used_of_type[m_last_used_type]; } else { - const int slot = _get_pack_slot(m_last_used_of_type[m_last_used_type]); - if (slot == -1) - { - // Not in inv, but caller can at least get the type of the item. - if (item_out) *item_out = &m_last_used_of_type[m_last_used_type]; - } - else - { - // Return the item in inv, since it will have an accurate count - if (item_out) *item_out = &you.inv[slot]; - } - if (slot_out) *slot_out = slot; + // Return the item in inv, since it will have an accurate count + if (item_out) *item_out = &you.inv[slot]; } + if (slot_out) *slot_out = slot; } // Return inv slot of item that should be fired by default. @@ -324,7 +314,7 @@ void player_quiver::load(reader& inf) unmarshallItem(inf, m_last_weapon); m_last_used_type = (ammo_t)unmarshallLong(inf); - ASSERT(m_last_used_type >= AMMO_INVALID && m_last_used_type < NUM_AMMO); + ASSERT(m_last_used_type >= AMMO_THROW && m_last_used_type < NUM_AMMO); const long count = unmarshallLong(inf); ASSERT(count <= ARRAYSIZE(m_last_used_of_type)); @@ -345,7 +335,8 @@ preserve_quiver_slots::preserve_quiver_slots() ARRAYSIZE(you.m_quiver->m_last_used_of_type), a); for (int i=0; iget_desired_item(NULL, &m_last_used_of_type[i]); + m_last_used_of_type[i] = + _get_pack_slot(you.m_quiver->m_last_used_of_type[i]); } } diff --git a/crawl-ref/source/quiver.h b/crawl-ref/source/quiver.h index 4b0e7f8993..e865cce099 100644 --- a/crawl-ref/source/quiver.h +++ b/crawl-ref/source/quiver.h @@ -24,7 +24,6 @@ enum ammo_t AMMO_HAND_CROSSBOW, // wielded hand crossbow -> darts AMMO_BLOWGUN, // wielded blowgun -> needles NUM_AMMO, - AMMO_INVALID=-1 }; class player_quiver -- cgit v1.2.3-54-g00ecf