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.88 by root, Sun Dec 28 06:59:27 2008 UTC vs.
Revision 1.89 by root, Wed Dec 31 17:35:38 2008 UTC

270 * exact match, we also return NULL. 270 * exact match, we also return NULL.
271 */ 271 */
272object * 272object *
273lookup_spell_by_name (object *op, const char *spname) 273lookup_spell_by_name (object *op, const char *spname)
274{ 274{
275 object *spob1 = NULL, *spob2 = NULL, *spob; 275 object *spob1 = 0, *spob2 = 0;
276 int nummatch = 0; 276 int nummatch = 0;
277 277
278 if (spname == NULL) 278 if (!spname)
279 return NULL; 279 return 0;
280 280
281 /* Try to find the spell. We store the results in spob1 281 /* Try to find the spell. We store the results in spob1
282 * and spob2 - spob1 is only taking the length of 282 * and spob2 - spob1 is only taking the length of
283 * the past spname, spob2 uses the length of the spell name. 283 * the past spname, spob2 uses the length of the spell name.
284 */ 284 */
285 for (spob = op->inv; spob; spob = spob->below) 285 for (object *spob = op->inv; spob; spob = spob->below)
286 { 286 {
287 if (spob->type == SPELL) 287 if (spob->type == SPELL)
288 { 288 {
289 // TODO: WTF?
289 if (!strncmp (spob->name, spname, strlen (spname))) 290 if (!strncmp (spob->name, spname, strlen (spname)))
290 { 291 {
291 nummatch++; 292 nummatch++;
292 spob1 = spob; 293 spob1 = spob;
293 } 294 }
298 * fall into this category). It shouldn't be hard to 299 * fall into this category). It shouldn't be hard to
299 * make sure spell names don't overlap in that fashion. 300 * make sure spell names don't overlap in that fashion.
300 */ 301 */
301 if (spob2) 302 if (spob2)
302 LOG (llevError, "Found multiple spells with overlapping base names: %s, %s\n", &spob2->name, &spob->name); 303 LOG (llevError, "Found multiple spells with overlapping base names: %s, %s\n", &spob2->name, &spob->name);
304
303 spob2 = spob; 305 spob2 = spob;
304 } 306 }
305 } 307 }
306 } 308 }
307 /* if we have best match, return it. Otherwise, if we have one match 309 /* if we have best match, return it. Otherwise, if we have one match
308 * on the loser match, return that, otehrwise null 310 * on the loser match, return that, otehrwise null
309 */ 311 */
310 if (spob2) 312 if (spob2)
311 return spob2; 313 return spob2;
314
312 if (spob1 && nummatch == 1) 315 if (spob1 && nummatch == 1)
313 return spob1; 316 return spob1;
317
314 return NULL; 318 return NULL;
315} 319}
316 320
317/* reflwall - decides weither the (spell-)object sp_op will 321/* reflwall - decides weither the (spell-)object sp_op will
318 * be reflected from the given mapsquare. Returns 1 if true. 322 * be reflected from the given mapsquare. Returns 1 if true.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines