diff options
Diffstat (limited to 'crawl-ref/source')
-rw-r--r-- | crawl-ref/source/effects.cc | 37 | ||||
-rw-r--r-- | crawl-ref/source/effects.h | 2 | ||||
-rw-r--r-- | crawl-ref/source/spells1.cc | 4 |
3 files changed, 29 insertions, 14 deletions
diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc index 86cf3d4061..81c7edb13c 100644 --- a/crawl-ref/source/effects.cc +++ b/crawl-ref/source/effects.cc @@ -1403,6 +1403,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) @@ -1416,19 +1439,7 @@ 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: diff --git a/crawl-ref/source/effects.h b/crawl-ref/source/effects.h index 44d1ba56a5..5544eab617 100644 --- a/crawl-ref/source/effects.h +++ b/crawl-ref/source/effects.h @@ -92,4 +92,6 @@ void torment( int caster, int tx, int ty ); int torment_monsters(int x, int y, int pow, int caster); +bool remove_empty_inscription( item_def& item ); + #endif diff --git a/crawl-ref/source/spells1.cc b/crawl-ref/source/spells1.cc index 8e7eecc8e9..38373820a5 100644 --- a/crawl-ref/source/spells1.cc +++ b/crawl-ref/source/spells1.cc @@ -28,6 +28,7 @@ #include "beam.h" #include "cloud.h" #include "direct.h" +#include "effects.h" #include "invent.h" #include "it_use2.h" #include "itemname.h" @@ -413,7 +414,8 @@ void identify(int power) you.inv[item_slot].sub_type, ID_KNOWN_TYPE ); set_ident_flags( you.inv[item_slot], ISFLAG_IDENT_MASK ); - + remove_empty_inscription(you.inv[item_slot]); + // output identified item in_name( item_slot, DESC_INVENTORY_EQUIP, str_pass ); mpr( str_pass ); |