summaryrefslogtreecommitdiff
path: root/src/bldg.cc
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2015-04-15 19:12:41 +0200
committerBardur Arantsson <bardur@scientician.net>2015-04-15 19:12:41 +0200
commit8b2be5adc24ffdecc7bb5d8ed08be12a7590bc46 (patch)
tree52f137bd6e83baa12ad60b50c4710d04a7559cb2 /src/bldg.cc
parentedede30a361f34d8c2f1d5de45adeac9392f41b9 (diff)
Rework object list filters to avoid global variables
Diffstat (limited to 'src/bldg.cc')
-rw-r--r--src/bldg.cc36
1 files changed, 15 insertions, 21 deletions
diff --git a/src/bldg.cc b/src/bldg.cc
index 0c62a826..640c04f5 100644
--- a/src/bldg.cc
+++ b/src/bldg.cc
@@ -887,7 +887,7 @@ static void list_weapon(object_type *o_ptr, int row, int col)
/*
* Select melee weapons
*/
-static bool_ item_tester_hook_melee_weapon(object_type *o_ptr)
+static bool item_tester_hook_melee_weapon(object_type const *o_ptr)
{
return (wield_slot(o_ptr) == INVEN_WIELD);
}
@@ -897,34 +897,28 @@ static bool_ item_tester_hook_melee_weapon(object_type *o_ptr)
*/
static bool_ compare_weapons(void)
{
- int item, item2, i;
+ int item, i;
object_type *o1_ptr, *o2_ptr, *orig_ptr;
- object_type *i_ptr;
-
- cptr q, s;
-
-
clear_bldg(6, 18);
o1_ptr = NULL;
o2_ptr = NULL;
- i_ptr = NULL;
/* Store copy of original wielded weapon in pack slot */
- i_ptr = &p_ptr->inventory[INVEN_WIELD];
+ object_type *i_ptr = &p_ptr->inventory[INVEN_WIELD];
orig_ptr = &p_ptr->inventory[INVEN_PACK];
object_copy(orig_ptr, i_ptr);
i = 6;
- /* Get first weapon */
- /* Restrict choices to meele weapons */
- item_tester_hook = item_tester_hook_melee_weapon;
- q = "What is your first melee weapon? ";
- s = "You have nothing to compare.";
- if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN)))
+ /* Get first weapon */
+ if (!get_item(&item,
+ "What is your first melee weapon? ",
+ "You have nothing to compare.",
+ (USE_EQUIP | USE_INVEN),
+ item_tester_hook_melee_weapon))
{
object_wipe(orig_ptr);
return (FALSE);
@@ -935,12 +929,12 @@ static bool_ compare_weapons(void)
o1_ptr = &p_ptr->inventory[item];
/* Get second weapon */
- /* Restrict choices to melee weapons */
- item_tester_hook = item_tester_hook_melee_weapon;
-
- q = "What is your second melee weapon? ";
- s = "You have nothing to compare.";
- if (!get_item(&item2, q, s, (USE_EQUIP | USE_INVEN)))
+ int item2;
+ if (!get_item(&item2,
+ "What is your second melee weapon? ",
+ "You have nothing to compare.",
+ (USE_EQUIP | USE_INVEN),
+ item_tester_hook_melee_weapon))
{
object_wipe(orig_ptr);
return (FALSE);