summaryrefslogtreecommitdiff
path: root/src/spells2.c
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2012-03-04 14:48:15 +0100
committerBardur Arantsson <bardur@scientician.net>2012-03-29 20:41:39 +0200
commit120fed37d8974553e25e5c83ba74c1bb08d71404 (patch)
tree3153c48c7a0e8283ce108577bd6160add7b437e6 /src/spells2.c
parenta27236516b0aa8761f70f009c78f4272dc0b735d (diff)
Refactor: Remove duplicate code for reducing item stacks
Diffstat (limited to 'src/spells2.c')
-rw-r--r--src/spells2.c49
1 files changed, 5 insertions, 44 deletions
diff --git a/src/spells2.c b/src/spells2.c
index c365bb5b..d6bfe629 100644
--- a/src/spells2.c
+++ b/src/spells2.c
@@ -670,21 +670,8 @@ bool_ alchemy(void) /* Turns an object into gold, gain some of its value in a sh
}
- /* Eliminate the item (from the pack) */
- if (item >= 0)
- {
- inven_item_increase(item, -amt);
- inven_item_describe(item);
- inven_item_optimize(item);
- }
-
- /* Eliminate the item (from the floor) */
- else
- {
- floor_item_increase(0 - item, -amt);
- floor_item_describe(0 - item);
- floor_item_optimize(0 - item);
- }
+ /* Eliminate the item */
+ inc_stack_size(item, -amt);
return TRUE;
}
@@ -4758,21 +4745,8 @@ bool_ recharge(int power)
/* Reduce rod stack maximum timeout, drain wands. */
if (o_ptr->tval == TV_WAND) o_ptr->pval = 0;
- /* Reduce and describe inventory */
- if (item >= 0)
- {
- inven_item_increase(item, -1);
- inven_item_describe(item);
- inven_item_optimize(item);
- }
-
- /* Reduce and describe floor item */
- else
- {
- floor_item_increase(0 - item, -1);
- floor_item_describe(0 - item);
- floor_item_optimize(0 - item);
- }
+ /* Reduce and describe */
+ inc_stack_size(item, -1);
}
/* Destroy all memebers of a stack of objects. */
@@ -4785,20 +4759,7 @@ bool_ recharge(int power)
/* Reduce and describe inventory */
- if (item >= 0)
- {
- inven_item_increase(item, -999);
- inven_item_describe(item);
- inven_item_optimize(item);
- }
-
- /* Reduce and describe floor item */
- else
- {
- floor_item_increase(0 - item, -999);
- floor_item_describe(0 - item);
- floor_item_optimize(0 - item);
- }
+ inc_stack_size(item, -999);
}
}
}