summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2006-12-17 09:15:53 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2006-12-17 09:15:53 +0000
commitf3e9d4302bde27f1acf11a21b61d367eeeb574f9 (patch)
treefbdbe285e78cae289da8e4b592e7a6ddd6f68bec /crawl-ref/source
parent1e056f2e741464486ae2d5bbe2c58f675fa3dcd5 (diff)
downloadcrawl-ref-f3e9d4302bde27f1acf11a21b61d367eeeb574f9.tar.gz
crawl-ref-f3e9d4302bde27f1acf11a21b61d367eeeb574f9.zip
Fixed 1616008, identify was not removing 'empty' inscription.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@645 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r--crawl-ref/source/effects.cc37
-rw-r--r--crawl-ref/source/effects.h2
-rw-r--r--crawl-ref/source/spells1.cc4
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 );