From c83c83056ee1f25c7caba5301ef17adcf142b56c Mon Sep 17 00:00:00 2001 From: dshaligram Date: Fri, 28 Sep 2007 07:58:50 +0000 Subject: Fixed issues with substring matches of item names (spears being generated for pears) in maps (David). The change also means that item names have to be specified in full in map definitions. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2233 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/dat/entry.des | 2 +- crawl-ref/source/dat/float.des | 2 +- crawl-ref/source/dat/mini.des | 2 +- crawl-ref/source/dat/orc.des | 2 +- crawl-ref/source/items.cc | 16 +++------------- 5 files changed, 7 insertions(+), 17 deletions(-) (limited to 'crawl-ref/source') diff --git a/crawl-ref/source/dat/entry.des b/crawl-ref/source/dat/entry.des index 7ccbf2c6e8..519517580f 100644 --- a/crawl-ref/source/dat/entry.des +++ b/crawl-ref/source/dat/entry.des @@ -1556,7 +1556,7 @@ TAGS: entry no_monster_gen ORIENT: float FLAGS: no_rotate MONS: worm / giant beetle, worm / giant beetle -ITEM: nothing / ring of hunger / protection from fire / protection from cold +ITEM: nothing / ring of hunger / ring of protection from fire / ring of protection from cold ITEM: nothing / choko / pear / apple / sausage / banana / any scroll SHUFFLE: dD1AB/yyyyy, eE2FG/yyyyy, AB, FG SUBST: y=x, A==, B=x, D=., F==, G=x, E=. diff --git a/crawl-ref/source/dat/float.des b/crawl-ref/source/dat/float.des index 6a15baf56b..f96fd9edf6 100644 --- a/crawl-ref/source/dat/float.des +++ b/crawl-ref/source/dat/float.des @@ -84,7 +84,7 @@ ORIENT: float SHUFFLE: 1X / 1X / 2l / 3Y SUBST: X=x, Y:x. MONS: ogre, iron devil, nothing -ITEM: potion of heal wounds / speed / berserk rage / scroll of blinking +ITEM: potion of heal wounds / potion of speed / potion of berserk rage / scroll of blinking MAP xx@xx x...x diff --git a/crawl-ref/source/dat/mini.des b/crawl-ref/source/dat/mini.des index 240df45c53..748b9df9fd 100644 --- a/crawl-ref/source/dat/mini.des +++ b/crawl-ref/source/dat/mini.des @@ -1126,7 +1126,7 @@ KMONS: 1 = yaktaur captain KMONS: 2 = grey snake KMONS: 3 = storm dragon ITEM: potion of cure mutation/potion of gain dexterity/potion of gain strength -ITEM: potion of gain intelligence/potion of experience/w:40 potion of heal wound +ITEM: potion of gain intelligence/potion of experience/w:40 potion of heal wounds SHUFFLE: de, !; KFEAT: 3 = w / . KFEAT: | = W / . diff --git a/crawl-ref/source/dat/orc.des b/crawl-ref/source/dat/orc.des index 497fef00ef..ac2c7eed05 100644 --- a/crawl-ref/source/dat/orc.des +++ b/crawl-ref/source/dat/orc.des @@ -23,7 +23,7 @@ ENDMAP NAME: david_orc_1_choice TAGS: orc_entry MONS: orc, warg / orc priest / orc warrior, orc warrior / orc -ITEM: % / scroll of teleport / scroll of remove curse / scroll of identify +ITEM: % / scroll of teleportation / scroll of remove curse / scroll of identify ITEM: % / w:2 * / scroll of blinking / scroll of recharging / scroll of fear SHUFFLE: %1 ORIENT: float diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc index 94212b9335..60bacbd15b 100644 --- a/crawl-ref/source/items.cc +++ b/crawl-ref/source/items.cc @@ -2953,24 +2953,14 @@ static bool find_subtype_by_name(item_def &item, return (true); int type_wanted = -1; - int best_index = 10000; - const char *ptr; for (int i = 0; i < ntypes; i++) { item.sub_type = i; - char obj_name[ITEMNAME_SIZE]; - strncpy(obj_name, item.name(DESC_PLAIN).c_str(), sizeof obj_name); - - ptr = strstr( strlwr(obj_name), name.c_str() ); - if (ptr != NULL) + if (name == lowercase_string(item.name(DESC_PLAIN))) { - // earliest match is the winner - if (ptr - obj_name < best_index) - { - type_wanted = i; - best_index = ptr - obj_name; - } + type_wanted = i; + break; } } -- cgit v1.2.3-54-g00ecf