summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/effects.cc
diff options
context:
space:
mode:
Diffstat (limited to 'crawl-ref/source/effects.cc')
-rw-r--r--crawl-ref/source/effects.cc39
1 files changed, 25 insertions, 14 deletions
diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc
index f3116be7f2..6af1957f31 100644
--- a/crawl-ref/source/effects.cc
+++ b/crawl-ref/source/effects.cc
@@ -1405,6 +1405,29 @@ bool acquirement(unsigned char force_class, int agent)
return (true);
} // end acquirement()
+// Remove the "empty" autoinscription, if present.
+// Return true if the inscription was there, false otherwise.
+bool remove_empty_inscription( item_def& item )
+{
+ const char* empty_inscription = "empty";
+ size_t p = item.inscription.find(empty_inscription);
+ if ( p != std::string::npos )
+ {
+ // found it, delete it
+ size_t prespace = 0;
+ // if preceded by a space, delete that too
+ if ( p != 0 && item.inscription[p-1] == ' ' )
+ prespace = 1;
+ item.inscription =
+ item.inscription.substr(0, p - prespace) +
+ item.inscription.substr(p + strlen(empty_inscription),
+ std::string::npos);
+ return true;
+ }
+ else
+ return false;
+}
+
bool recharge_wand(void)
{
if (you.equip[EQ_WEAPON] == -1)
@@ -1418,25 +1441,13 @@ bool recharge_wand(void)
int charge_gain = 0;
if (wand.base_type == OBJ_WANDS)
{
- // remove "empty" autoinscription
- const char* empty_inscription = "[empty]";
- size_t p = wand.inscription.find(empty_inscription);
- if ( p != std::string::npos ) {
- // found it, delete it
- size_t prespace = 0;
- if ( p != 0 && wand.inscription[p-1] == ' ' )
- prespace = 1;
- wand.inscription =
- wand.inscription.substr(0, p - prespace) +
- wand.inscription.substr(p + strlen(empty_inscription),
- std::string::npos);
- }
+ remove_empty_inscription(wand);
switch (wand.sub_type)
{
case WAND_INVISIBILITY:
case WAND_FIREBALL:
case WAND_HEALING:
- case WAND_HASTING:
+ case WAND_HASTING:
charge_gain = 3;
break;