summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/wiz-fsim.cc
diff options
context:
space:
mode:
authorHaran Pilpel <haranp@users.sourceforge.net>2010-01-13 10:01:03 +0200
committerHaran Pilpel <haranp@users.sourceforge.net>2010-01-13 10:01:03 +0200
commitcce3c6e018e1ec88a1b49eaf2fbfde88f51ada01 (patch)
treed075743f82d153e2c17f5da43d5e5fb0dffb1636 /crawl-ref/source/wiz-fsim.cc
parent253d9973468723045300b5025e2de1e96e350a99 (diff)
downloadcrawl-ref-cce3c6e018e1ec88a1b49eaf2fbfde88f51ada01.tar.gz
crawl-ref-cce3c6e018e1ec88a1b49eaf2fbfde88f51ada01.zip
Various cleanups, use you.weapon() more often, fix a note in README.txt.
Diffstat (limited to 'crawl-ref/source/wiz-fsim.cc')
-rw-r--r--crawl-ref/source/wiz-fsim.cc37
1 files changed, 16 insertions, 21 deletions
diff --git a/crawl-ref/source/wiz-fsim.cc b/crawl-ref/source/wiz-fsim.cc
index 8a9929cdc8..b5451a7748 100644
--- a/crawl-ref/source/wiz-fsim.cc
+++ b/crawl-ref/source/wiz-fsim.cc
@@ -265,33 +265,28 @@ static std::string _fsim_wskill(int missile_slot)
static std::string _fsim_weapon(int missile_slot)
{
- std::string item_buf;
- if (you.equip[EQ_WEAPON] != -1 || missile_slot != -1)
+ if (const item_def* weapon = you.weapon())
{
- if (you.equip[EQ_WEAPON] != -1)
+ std::string item_buf = weapon->name(DESC_PLAIN, true);
+
+ // If it's a ranged weapon, add the description of the missile
+ // if applicable.
+ if (is_range_weapon(*weapon))
{
- const item_def &weapon = you.inv[ you.equip[EQ_WEAPON] ];
- item_buf = weapon.name(DESC_PLAIN, true);
- if (is_range_weapon(weapon))
- {
- const int missile =
- (missile_slot == -1 ? you.m_quiver->get_fire_item()
- : missile_slot);
+ const int missile =
+ (missile_slot == -1 ? you.m_quiver->get_fire_item()
+ : missile_slot);
- if (missile < ENDOFPACK && missile >= 0)
- {
- return item_buf + " with "
- + you.inv[missile].name(DESC_PLAIN);
- }
- }
+ if (missile < ENDOFPACK && missile >= 0)
+ item_buf += " with " + you.inv[missile].name(DESC_PLAIN);
}
- else
- return you.inv[missile_slot].name(DESC_PLAIN);
+
+ return item_buf;
}
+ else if (missile_slot != -1)
+ return you.inv[missile_slot].name(DESC_PLAIN);
else
return "unarmed";
-
- return item_buf;
}
static std::string _fsim_time_string()
@@ -518,7 +513,7 @@ int fsim_kit_equip(const std::string &kit)
}
}
}
- else if (you.equip[EQ_WEAPON] != -1)
+ else if (you.weapon())
unwield_item(false);
if (!missile.empty())