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.5 by root, Sun Sep 10 16:00:23 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
89 int result; 87 int result;
90 88
91 result = 1; 89 result = 1;
92 for (i = 0; i < rp->arch_names; i++) 90 for (i = 0; i < rp->arch_names; i++)
93 { 91 {
94 if (find_archetype (rp->arch_name[i]) != NULL) 92 if (archetype::find (rp->arch_name[i]) != NULL)
95 { 93 {
96 artifact *art = locate_recipe_artifact (rp, i); 94 artifact *art = locate_recipe_artifact (rp, i);
97 95
98 if (!art && strcmp (rp->title, "NONE") != 0) 96 if (!art && strcmp (rp->title, "NONE") != 0)
99 { 97 {
299 297
300 for (i = 0; i < formula->arch_names; i++) 298 for (i = 0; i < formula->arch_names; i++)
301 { 299 {
302 const char *string = formula->arch_name[i]; 300 const char *string = formula->arch_name[i];
303 301
304 if (find_archetype (string) != NULL) 302 if (archetype::find (string) != NULL)
305 { 303 {
306 art = locate_recipe_artifact (formula, i); 304 art = locate_recipe_artifact (formula, i);
307 if (!art && strcmp (formula->title, "NONE")) 305 if (!art && strcmp (formula->title, "NONE"))
308 LOG (llevError, "Formula %s has no artifact\n", &formula->title); 306 LOG (llevError, "Formula %s has no artifact\n", &formula->title);
309 else 307 else
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 */
506 512
507 for (i = 0; i < formula->arch_names; i++) 513 for (i = 0; i < formula->arch_names; i++)
508 { 514 {
509 const char *string = formula->arch_name[i]; 515 const char *string = formula->arch_name[i];
510 516
511 if ((at = find_archetype (string)) != NULL) 517 if ((at = archetype::find (string)) != NULL)
512 { 518 {
513 art = locate_recipe_artifact (formula, i); 519 art = locate_recipe_artifact (formula, i);
514 if (!art && strcmp (formula->title, "NONE")) 520 if (!art && strcmp (formula->title, "NONE"))
515 LOG (llevError, "Formula %s has no artifact\n", &formula->title); 521 LOG (llevError, "Formula %s has no artifact\n", &formula->title);
516 else 522 else
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