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.128 by root, Wed Nov 16 23:42:03 2016 UTC

1/* 1/*
2 * This file is part of Deliantra, the Roguelike Realtime MMORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2001 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2001 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992 Frank Tore Johansen 6 * Copyright (©) 1992 Frank Tore Johansen
7 * 7 *
8 * Deliantra is free software: you can redistribute it and/or modify it under 8 * Deliantra is free software: you can redistribute it and/or modify it under
9 * the terms of the Affero GNU General Public License as published by the 9 * the terms of the Affero GNU General Public License as published by the
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