--- deliantra/server/common/recipe.C 2006/09/14 21:16:11 1.6 +++ deliantra/server/common/recipe.C 2007/01/03 00:08:17 1.13 @@ -1,5 +1,3 @@ - - /* Basic stuff for use with the alchemy code. Clearly some of this stuff * could go into server/alchemy, but I left it here just in case it proves * more generally useful. @@ -20,9 +18,10 @@ * arch potion_generic */ +#include + #include #include -#include static void build_stringlist (const char *str, char ***result_list, size_t * result_size); @@ -97,13 +96,13 @@ if (!art && strcmp (rp->title, "NONE") != 0) { - LOG (llevError, "\nWARNING: Formula %s of %s has no artifact.\n", rp->arch_name[i], &rp->title); + LOG (llevError, "WARNING: Formula %s of %s has no artifact.\n", rp->arch_name[i], &rp->title); result = 0; } } else { - LOG (llevError, "\nWARNING: Can't find archetype %s for formula %s\n", rp->arch_name[i], &rp->title); + LOG (llevError, "WARNING: Can't find archetype %s for formula %s\n", rp->arch_name[i], &rp->title); result = 0; } } @@ -137,7 +136,7 @@ has_been_done = 1; sprintf (filename, "%s/formulae", settings.datadir); - LOG (llevDebug, "Reading alchemical formulae from %s...", filename); + LOG (llevDebug, "Reading alchemical formulae from %s...\n", filename); if ((fp = open_and_uncompress (filename, 0, &comp)) == NULL) { LOG (llevError, "Can't open %s.\n", filename); @@ -257,7 +256,7 @@ recipe *check, *formula; int numb = 1; - LOG (llevDebug, "Checking formulae lists..."); + LOG (llevDebug, "Checking formulae lists...\n"); for (fl = formulalist; fl != NULL; fl = fl->next) { @@ -358,36 +357,44 @@ archetype *at; if (depth > 10) - return NULL; - while (t != NULL) + return 0; + + while (t) { - if (t->name != NULL) + if (t->name) { tl = find_treasurelist (t->name); - at = find_treasure_by_name (tl->items, name, depth + 1); - if (at != NULL) - return at; + + if (tl) + { + at = find_treasure_by_name (tl->items, name, depth + 1); + + if (at) + return at; + } } else { if (!strcasecmp (t->item->clone.name, name)) return t->item; } - if (t->next_yes != NULL) + + if (t->next_yes) { at = find_treasure_by_name (t->next_yes, name, depth); - if (at != NULL) + if (at) return at; } - if (t->next_no != NULL) + + if (t->next_no) { at = find_treasure_by_name (t->next_no, name, depth); - if (at != NULL) + if (at) return at; } t = t->next; } - return NULL; + return 0; } /* If several archetypes have the same name, the value of the first @@ -471,7 +478,7 @@ if (at->clone.randomitems != NULL) { at2 = find_treasure_by_name (at->clone.randomitems->items, part2, 0); - if (at2 != NULL) + if (at2) return mult * at2->clone.value * isqrt (at->clone.level * 2); } } @@ -617,7 +624,7 @@ if (!strcmp (art->item->name, rp->title)) break; - free_object (item); + item->destroy (); return art; } @@ -739,7 +746,7 @@ size_t size; size_t i; - dup = strdup_local (str); + dup = strdup (str); if (dup == NULL) fatal (OUT_OF_MEMORY);