summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/item_use.cc
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2008-08-06 10:39:34 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2008-08-06 10:39:34 +0000
commitc070e96a6ea1231489aaecbd809db857d4b1f021 (patch)
tree47d83d5d84c6f67f8641c821f2c72b7a88db43c3 /crawl-ref/source/item_use.cc
parent5a96a39b9d3c33a63bddcbbedb98b434e49a253f (diff)
downloadcrawl-ref-c070e96a6ea1231489aaecbd809db857d4b1f021.tar.gz
crawl-ref-c070e96a6ea1231489aaecbd809db857d4b1f021.zip
Fix 2039217: check shield status for non-weapons before allowing wield.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6778 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/item_use.cc')
-rw-r--r--crawl-ref/source/item_use.cc28
1 files changed, 19 insertions, 9 deletions
diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc
index ab2b917837..88fa351ec0 100644
--- a/crawl-ref/source/item_use.cc
+++ b/crawl-ref/source/item_use.cc
@@ -131,10 +131,17 @@ bool can_wield(const item_def *weapon, bool say_reason,
}
}
- // We don't have to check explicitly for staves - all staves are wieldable
- // by everyone.
+ // All non-weapons only need a shield check.
if (weapon->base_type != OBJ_WEAPONS)
- return (true);
+ {
+ if (!ignore_temporary_disability && is_shield_incompatible(*weapon))
+ {
+ SAY(mpr("You can't wield that with a shield."));
+ return (false);
+ }
+ else
+ return (true);
+ }
if (player_size(PSIZE_TORSO) < SIZE_LARGE && item_mass( *weapon ) >= 300)
{
@@ -293,11 +300,12 @@ bool wield_weapon(bool auto_wield, int slot, bool show_weff_messages)
{
if (you.equip[EQ_WEAPON] != -1)
{
+ item_def& wpn = *you.weapon();
// Can we safely unwield this item?
- if (has_warning_inscription(you.inv[you.equip[EQ_WEAPON]], OPER_WIELD))
+ if (has_warning_inscription(wpn, OPER_WIELD))
{
std::string prompt = "Really unwield ";
- prompt += you.inv[you.equip[EQ_WEAPON]].name(DESC_INVENTORY);
+ prompt += wpn.name(DESC_INVENTORY);
prompt += '?';
if (!yesno(prompt.c_str(), false, 'n'))
return (false);
@@ -318,15 +326,17 @@ bool wield_weapon(bool auto_wield, int slot, bool show_weff_messages)
return (true);
}
- if (!can_wield(&you.inv[item_slot], true))
+ item_def& new_wpn(you.inv[item_slot]);
+
+ if (!can_wield(&new_wpn, true))
return (false);
// For non-auto_wield cases checked above.
- if (auto_wield && !check_warning_inscriptions(you.inv[item_slot], OPER_WIELD))
+ if (auto_wield && !check_warning_inscriptions(new_wpn, OPER_WIELD))
return (false);
// Wield the weapon.
- if (!safe_to_remove_or_wear(you.inv[item_slot], false))
+ if (!safe_to_remove_or_wear(new_wpn, false))
return (false);
// Go ahead and wield the weapon.
@@ -338,7 +348,7 @@ bool wield_weapon(bool auto_wield, int slot, bool show_weff_messages)
// any oddness on wielding taken care of here
wield_effects(item_slot, show_weff_messages);
- mpr(you.inv[item_slot].name(DESC_INVENTORY_EQUIP).c_str());
+ mpr(new_wpn.name(DESC_INVENTORY_EQUIP).c_str());
// Warn player about low str/dex or throwing skill.
if (show_weff_messages)