ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/spell_util.C
(Generate patch)

Comparing deliantra/server/server/spell_util.C (file contents):
Revision 1.126 by root, Wed Nov 21 12:12:03 2012 UTC vs.
Revision 1.127 by root, Sun Nov 25 14:59:25 2012 UTC

264 * returns the matching spell object, or NULL. 264 * returns the matching spell object, or NULL.
265 * If we match multiple spells but don't get an 265 * If we match multiple spells but don't get an
266 * exact match, we also return NULL. 266 * exact match, we also return NULL.
267 */ 267 */
268object * 268object *
269object::find_spell (shstr_cmp name) const 269object::find_spell (const_utf8_string prefix) const
270{ 270{
271 if (shstr_cmp name = prefix)
272 {
273 // case 1, match spell name exactly
271 for (object *spob = inv; spob; spob = spob->below) 274 for (object *spob = inv; spob; spob = spob->below)
272 if (spob->name == name && spob->type == SPELL) 275 if (spob->name == name && spob->type == SPELL)
273 return spob; 276 return spob;
277 }
278 else
279 {
280 // case 2, match prefix
281 int len = strlen (prefix);
282
283 for (object *spob = inv; spob; spob = spob->below)
284 if (spob->type == SPELL
285 && spob->name.length () < len
286 && prefix [spob->name.length ()] <= ' '
287 && !memcmp (prefix, spob->name, spob->name.length ()))
288 return spob;
289 }
274 290
275 return 0; 291 return 0;
276} 292}
277 293
278/* reflwall - decides weither the (spell-)object sp_op will 294/* reflwall - decides weither the (spell-)object sp_op will

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines