--- deliantra/server/common/recipe.C 2007/02/05 01:24:45 1.16 +++ deliantra/server/common/recipe.C 2007/02/16 19:43:41 1.18 @@ -12,7 +12,7 @@ */ /* Example 'formula' entry in libdir/formulae: - * Object transparency + * object transparency * chance 10 * ingred dust of beholdereye,gem * arch potion_generic @@ -62,7 +62,6 @@ } /* get_formulalist() - returns pointer to the formula list */ - recipelist * get_formulalist (int i) { @@ -75,19 +74,18 @@ break; number--; } + return fl; } /* check_recipe() - makes sure we actually have the requested artifact * and archetype. */ - static int check_recipe (const recipe *rp) { size_t i; - int result; + int result = 1; - result = 1; for (i = 0; i < rp->arch_names; i++) { if (archetype::find (rp->arch_name[i]) != NULL) @@ -110,12 +108,10 @@ return result; } - /* * init_formulae() - Builds up the lists of formula from the file in * the libdir. -b.t. */ - void init_formulae (void) { @@ -153,35 +149,23 @@ while (*cp == ' ') /* Skip blanks */ cp++; - if (!strncmp (cp, "Object", 6)) + if (!strncmp (cp, "object", 6)) { formula = get_empty_formula (); formula->title = strchr (cp, ' ') + 1; } else if (!strncmp (cp, "keycode", 7)) - { - formula->keycode = strchr (cp, ' ') + 1; - } + formula->keycode = strchr (cp, ' ') + 1; else if (sscanf (cp, "trans %d", &value)) - { - formula->transmute = (uint16) value; - } + formula->transmute = (uint16) value; else if (sscanf (cp, "yield %d", &value)) - { - formula->yield = (uint16) value; - } + formula->yield = (uint16) value; else if (sscanf (cp, "chance %d", &value)) - { - formula->chance = (uint16) value; - } + formula->chance = (uint16) value; else if (sscanf (cp, "exp %d", &value)) - { - formula->exp = (uint16) value; - } + formula->exp = (uint16) value; else if (sscanf (cp, "diff %d", &value)) - { - formula->diff = (uint16) value; - } + formula->diff = (uint16) value; else if (!strncmp (cp, "ingred", 6)) { int numb_ingred = 1; @@ -194,6 +178,7 @@ *(next++) = '\0'; numb_ingred++; } + tmp = new linked_char; tmp->name = cp; @@ -206,15 +191,18 @@ formula->index += strtoint (cp); } while ((cp = next) != NULL); + /* now find the correct (# of ingred ordered) formulalist */ fl = formulalist; while (numb_ingred != 1) { if (!fl->next) fl->next = init_recipelist (); + fl = fl->next; numb_ingred--; } + fl->total_chance += formula->chance; fl->number++; formula->next = fl->items; @@ -226,16 +214,13 @@ check_recipe (formula); } else if (!strncmp (cp, "skill", 5)) - { - formula->skill = strchr (cp, ' ') + 1; - } + formula->skill = strchr (cp, ' ') + 1; else if (!strncmp (cp, "cauldron", 8)) - { - formula->cauldron = strchr (cp, ' ') + 1; - } + formula->cauldron = strchr (cp, ' ') + 1; else LOG (llevError, "Unknown input in file %s: %s\n", filename, buf); } + LOG (llevDebug, "done.\n"); close_and_delete (fp, comp); /* Lastly, lets check for problems in formula we got */ @@ -304,7 +289,7 @@ { art = locate_recipe_artifact (formula, i); if (!art && strcmp (formula->title, "NONE")) - LOG (llevError, "Formula %s has no artifact\n", &formula->title); + LOG (llevError, "Formula %s has no artifact!\n", &formula->title); else { if (strcmp (formula->title, "NONE")) @@ -617,21 +602,15 @@ artifact * locate_recipe_artifact (const recipe *rp, size_t idx) { - object *item = get_archetype (rp->arch_name[idx]); - artifactlist *at = NULL; - artifact *art = NULL; - - if (!item) - return (artifact *) NULL; - - if ((at = find_artifactlist (item->type))) - for (art = at->items; art; art = art->next) - if (!strcmp (art->item->name, rp->title)) - break; + archetype *at = archetype::find (rp->arch_name [idx]); - item->destroy (); + if (at) + if (artifactlist *al = find_artifactlist (at->clone.type)) + for (artifact *art = al->items; art; art = art->next) + if (art->item->name == rp->title) + return art; - return art; + return 0; } int