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.21 by root, Mon May 28 21:21:40 2007 UTC vs.
Revision 1.22 by root, Mon Jun 4 13:04:00 2007 UTC

375 if (archetype *at = find_treasure_by_name (tl->items, name, depth + 1)) 375 if (archetype *at = find_treasure_by_name (tl->items, name, depth + 1))
376 return at; 376 return at;
377 } 377 }
378 else 378 else
379 { 379 {
380 if (t->item && !strcasecmp (t->item->clone.name, name)) 380 if (t->item && !strcasecmp (t->item->object::name, name))
381 return t->item; 381 return t->item;
382 } 382 }
383 383
384 if (t->next_yes) 384 if (t->next_yes)
385 if (archetype *at = find_treasure_by_name (t->next_yes, name, depth)) 385 if (archetype *at = find_treasure_by_name (t->next_yes, name, depth))
404 * body parts that we are looking for (e.g. big_dragon and 404 * body parts that we are looking for (e.g. big_dragon and
405 * big_dragon_worthless). */ 405 * big_dragon_worthless). */
406long 406long
407find_ingred_cost (const char *name) 407find_ingred_cost (const char *name)
408{ 408{
409 archetype *at;
410 archetype *at2; 409 archetype *at2;
411 artifactlist *al; 410 artifactlist *al;
412 artifact *art; 411 artifact *art;
413 long mult; 412 long mult;
414 char *cp; 413 char *cp;
427 name++; 426 name++;
428 else 427 else
429 mult = 1; 428 mult = 1;
430 429
431 /* first, try to match the name of an archetype */ 430 /* first, try to match the name of an archetype */
432 for (at = first_archetype; at != NULL; at = at->next) 431 for_all_archetypes (at)
433 { 432 {
434 if (at->clone.title != NULL) 433 if (at->title != NULL)
435 { 434 {
436 /* inefficient, but who cares? */ 435 /* inefficient, but who cares? */
437 sprintf (part1, "%s %s", &at->clone.name, &at->clone.title); 436 sprintf (part1, "%s %s", &at->object::name, &at->title);
438 if (!strcasecmp (part1, name)) 437 if (!strcasecmp (part1, name))
439 return mult * at->clone.value; 438 return mult * at->value;
440 } 439 }
441 if (!strcasecmp (at->clone.name, name)) 440 if (!strcasecmp (at->object::name, name))
442 return mult * at->clone.value; 441 return mult * at->value;
443 } 442 }
444 443
445 /* second, try to match an artifact ("arch of something") */ 444 /* second, try to match an artifact ("arch of something") */
446 cp = strstr (name, " of "); 445 cp = strstr (name, " of ");
447 if (cp != NULL) 446 if (cp != NULL)
448 { 447 {
449 strcpy (part1, name); 448 strcpy (part1, name);
450 part1[cp - name] = '\0'; 449 part1[cp - name] = '\0';
451 strcpy (part2, cp + 4); 450 strcpy (part2, cp + 4);
451
452 /* find the first archetype matching the first part of the name */ 452 /* find the first archetype matching the first part of the name */
453 for (at = first_archetype; at; at = at->next) 453 for_all_archetypes (at)
454 if (!strcasecmp (at->clone.name, part1) && at->clone.title == NULL) 454 if (!strcasecmp (at->object::name, part1) && at->title == NULL)
455 break;
456 if (at != NULL)
457 { 455 {
458 /* find the first artifact derived from that archetype (same type) */ 456 /* find the first artifact derived from that archetype (same type) */
459 for (al = first_artifactlist; al; al = al->next) 457 for (al = first_artifactlist; al; al = al->next)
460 if (al->type == at->clone.type) 458 if (al->type == at->type)
461 { 459 {
462 for (art = al->items; art; art = art->next) 460 for (art = al->items; art; art = art->next)
463 if (!strcasecmp (art->item->name, part2)) 461 if (!strcasecmp (art->item->name, part2))
464 return mult * at->clone.value * art->item->value; 462 return mult * at->value * art->item->value;
465 } 463 }
466 } 464 }
467 } 465 }
468 466
469 /* third, try to match a body part ("arch's something") */ 467 /* third, try to match a body part ("arch's something") */
470 cp = strstr (name, "'s "); 468 cp = strstr (name, "'s ");
471 if (cp) 469 if (cp)
472 { 470 {
473 strcpy (part1, name); 471 strcpy (part1, name);
474 part1[cp - name] = '\0'; 472 part1[cp - name] = '\0';
475 strcpy (part2, cp + 3); 473 strcpy (part2, cp + 3);
476 /* examine all archetypes matching the first part of the name */ 474 /* examine all archetypes matching the first part of the name */
477 for (at = first_archetype; at; at = at->next) 475 for_all_archetypes (at)
478 if (!strcasecmp (at->clone.name, part1) && at->clone.title == NULL) 476 if (!strcasecmp (at->object::name, part1) && at->title == NULL)
479 { 477 {
480 if (at->clone.randomitems) 478 if (at->randomitems)
481 { 479 {
482 at2 = find_treasure_by_name (at->clone.randomitems->items, part2, 0); 480 at2 = find_treasure_by_name (at->randomitems->items, part2, 0);
483 if (at2) 481 if (at2)
484 return mult * at2->clone.value * isqrt (at->clone.level * 2); 482 return mult * at2->value * isqrt (at->level * 2);
485 } 483 }
486 } 484 }
487 } 485 }
488 486
489 /* failed to find any matching items -- formula should be checked */ 487 /* failed to find any matching items -- formula should be checked */
543 tcost = -1; 541 tcost = -1;
544 else 542 else
545 tcost += cost; 543 tcost += cost;
546 } 544 }
547 if (art != NULL && art->item != NULL) 545 if (art != NULL && art->item != NULL)
548 cost = at->clone.value * art->item->value; 546 cost = at->value * art->item->value;
549 else 547 else
550 cost = at->clone.value; 548 cost = at->value;
551 fprintf (logfile, "\t\tBuying result costs: %5ld", cost); 549 fprintf (logfile, "\t\tBuying result costs: %5ld", cost);
552 if (formula->yield > 1) 550 if (formula->yield > 1)
553 { 551 {
554 fprintf (logfile, " to %ld (max %d items)\n", cost * formula->yield, formula->yield); 552 fprintf (logfile, " to %ld (max %d items)\n", cost * formula->yield, formula->yield);
555 cost = cost * (formula->yield + 1L) / 2L; 553 cost = cost * (formula->yield + 1L) / 2L;
616locate_recipe_artifact (const recipe *rp, size_t idx) 614locate_recipe_artifact (const recipe *rp, size_t idx)
617{ 615{
618 archetype *at = archetype::find (rp->arch_name [idx]); 616 archetype *at = archetype::find (rp->arch_name [idx]);
619 617
620 if (at) 618 if (at)
621 if (artifactlist *al = find_artifactlist (at->clone.type)) 619 if (artifactlist *al = find_artifactlist (at->type))
622 for (artifact *art = al->items; art; art = art->next) 620 for (artifact *art = al->items; art; art = art->next)
623 if (art->item->name == rp->title) 621 if (art->item->name == rp->title)
624 return art; 622 return art;
625 623
626 return 0; 624 return 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines