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

Comparing deliantra/server/common/recipe.C (file contents):
Revision 1.6 by root, Thu Sep 14 21:16:11 2006 UTC vs.
Revision 1.10 by elmex, Thu Dec 14 00:08:52 2006 UTC

1
2
3/* Basic stuff for use with the alchemy code. Clearly some of this stuff 1/* Basic stuff for use with the alchemy code. Clearly some of this stuff
4 * could go into server/alchemy, but I left it here just in case it proves 2 * could go into server/alchemy, but I left it here just in case it proves
5 * more generally useful. 3 * more generally useful.
6 * 4 *
7 * Nov 1995 - file created by b.t. thomas@astro.psu.edu 5 * Nov 1995 - file created by b.t. thomas@astro.psu.edu
356{ 354{
357 treasurelist *tl; 355 treasurelist *tl;
358 archetype *at; 356 archetype *at;
359 357
360 if (depth > 10) 358 if (depth > 10)
361 return NULL; 359 return 0;
362 while (t != NULL) 360
361 while (t)
363 { 362 {
364 if (t->name != NULL) 363 if (t->name)
365 { 364 {
366 tl = find_treasurelist (t->name); 365 tl = find_treasurelist (t->name);
366
367 if (tl)
368 {
367 at = find_treasure_by_name (tl->items, name, depth + 1); 369 at = find_treasure_by_name (tl->items, name, depth + 1);
368 if (at != NULL) 370
371 if (at)
369 return at; 372 return at;
373 }
370 } 374 }
371 else 375 else
372 { 376 {
373 if (!strcasecmp (t->item->clone.name, name)) 377 if (!strcasecmp (t->item->clone.name, name))
374 return t->item; 378 return t->item;
375 } 379 }
380
376 if (t->next_yes != NULL) 381 if (t->next_yes)
377 { 382 {
378 at = find_treasure_by_name (t->next_yes, name, depth); 383 at = find_treasure_by_name (t->next_yes, name, depth);
379 if (at != NULL) 384 if (at)
380 return at; 385 return at;
381 } 386 }
387
382 if (t->next_no != NULL) 388 if (t->next_no)
383 { 389 {
384 at = find_treasure_by_name (t->next_no, name, depth); 390 at = find_treasure_by_name (t->next_no, name, depth);
385 if (at != NULL) 391 if (at)
386 return at; 392 return at;
387 } 393 }
388 t = t->next; 394 t = t->next;
389 } 395 }
390 return NULL; 396 return 0;
391} 397}
392 398
393/* If several archetypes have the same name, the value of the first 399/* If several archetypes have the same name, the value of the first
394 * one with that name will be returned. This happens for the 400 * one with that name will be returned. This happens for the
395 * mushrooms (mushroom_1, mushroom_2 and mushroom_3). For the 401 * mushrooms (mushroom_1, mushroom_2 and mushroom_3). For the
469 if (!strcasecmp (at->clone.name, part1) && at->clone.title == NULL) 475 if (!strcasecmp (at->clone.name, part1) && at->clone.title == NULL)
470 { 476 {
471 if (at->clone.randomitems != NULL) 477 if (at->clone.randomitems != NULL)
472 { 478 {
473 at2 = find_treasure_by_name (at->clone.randomitems->items, part2, 0); 479 at2 = find_treasure_by_name (at->clone.randomitems->items, part2, 0);
474 if (at2 != NULL) 480 if (at2)
475 return mult * at2->clone.value * isqrt (at->clone.level * 2); 481 return mult * at2->clone.value * isqrt (at->clone.level * 2);
476 } 482 }
477 } 483 }
478 } 484 }
479 /* failed to find any matching items -- formula should be checked */ 485 /* failed to find any matching items -- formula should be checked */
615 if ((at = find_artifactlist (item->type))) 621 if ((at = find_artifactlist (item->type)))
616 for (art = at->items; art; art = art->next) 622 for (art = at->items; art; art = art->next)
617 if (!strcmp (art->item->name, rp->title)) 623 if (!strcmp (art->item->name, rp->title))
618 break; 624 break;
619 625
620 free_object (item); 626 item->destroy ();
621 627
622 return art; 628 return art;
623} 629}
624 630
625int 631int

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines