--- deliantra/server/server/spell_util.C 2012/11/12 03:48:34 1.125 +++ deliantra/server/server/spell_util.C 2012/11/21 12:12:03 1.126 @@ -257,7 +257,7 @@ return 0; } -/* +/* * Look at object 'op' and see if they know the spell * spname. This is pretty close to check_spell_known * above, but it uses a looser matching mechanism. @@ -266,52 +266,13 @@ * exact match, we also return NULL. */ object * -lookup_spell_by_name (object *op, const char *spname) +object::find_spell (shstr_cmp name) const { - object *spob1 = 0, *spob2 = 0; - int nummatch = 0; + for (object *spob = inv; spob; spob = spob->below) + if (spob->name == name && spob->type == SPELL) + return spob; - if (!spname) - return 0; - - /* Try to find the spell. We store the results in spob1 - * and spob2 - spob1 is only taking the length of - * the past spname, spob2 uses the length of the spell name. - */ - for (object *spob = op->inv; spob; spob = spob->below) - { - if (spob->type == SPELL) - { - // TODO: WTF? - if (!strncmp (spob->name, spname, strlen (spname))) - { - nummatch++; - spob1 = spob; - } - else if (!strncmp (spob->name, spname, strlen (spob->name))) - { - /* if spells have ambiguous names, it makes matching - * really difficult. (eg, fire and fireball would - * fall into this category). It shouldn't be hard to - * make sure spell names don't overlap in that fashion. - */ - if (spob2) - LOG (llevError, "Found multiple spells with overlapping base names: %s, %s\n", &spob2->name, &spob->name); - - spob2 = spob; - } - } - } - /* if we have best match, return it. Otherwise, if we have one match - * on the loser match, return that, otehrwise null - */ - if (spob2) - return spob2; - - if (spob1 && nummatch == 1) - return spob1; - - return NULL; + return 0; } /* reflwall - decides weither the (spell-)object sp_op will