summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/quiver.cc
diff options
context:
space:
mode:
authorpauldubois <pauldubois@c06c8d41-db1a-0410-9941-cceddc491573>2008-04-15 09:01:37 +0000
committerpauldubois <pauldubois@c06c8d41-db1a-0410-9941-cceddc491573>2008-04-15 09:01:37 +0000
commitfd53b2e9dab9038ed34a419a1ee27c5314e13ddd (patch)
tree93411b450efd48f550fa88e534be449e3c971826 /crawl-ref/source/quiver.cc
parentb3878ade17db57b348d950892108b77ace2aa8f0 (diff)
downloadcrawl-ref-fd53b2e9dab9038ed34a419a1ee27c5314e13ddd.tar.gz
crawl-ref-fd53b2e9dab9038ed34a419a1ee27c5314e13ddd.zip
Fix 1942290
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@4237 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/quiver.cc')
-rw-r--r--crawl-ref/source/quiver.cc29
1 files changed, 10 insertions, 19 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; i<ARRAYSIZE(m_last_used_of_type); i++)
{
- you.m_quiver->get_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]);
}
}