--- deliantra/server/common/recipe.C 2006/12/14 00:08:52 1.10 +++ deliantra/server/common/recipe.C 2007/02/05 01:24:45 1.16 @@ -18,9 +18,10 @@ * arch potion_generic */ +#include + #include #include -#include static void build_stringlist (const char *str, char ***result_list, size_t * result_size); @@ -95,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; } } @@ -135,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); @@ -255,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) { @@ -374,7 +375,7 @@ } else { - if (!strcasecmp (t->item->clone.name, name)) + if (t->item && !strcasecmp (t->item->clone.name, name)) return t->item; } @@ -423,10 +424,12 @@ mult = 10 * mult + (*name - '0'); name++; } + if (mult > 0) name++; else mult = 1; + /* first, try to match the name of an archetype */ for (at = first_archetype; at != NULL; at = at->next) { @@ -440,6 +443,7 @@ if (!strcasecmp (at->clone.name, name)) return mult * at->clone.value; } + /* second, try to match an artifact ("arch of something") */ cp = strstr (name, " of "); if (cp != NULL) @@ -463,9 +467,10 @@ } } } + /* third, try to match a body part ("arch's something") */ cp = strstr (name, "'s "); - if (cp != NULL) + if (cp) { strcpy (part1, name); part1[cp - name] = '\0'; @@ -482,6 +487,7 @@ } } } + /* failed to find any matching items -- formula should be checked */ return -1; } @@ -651,7 +657,7 @@ /* now, randomly choose one */ if (number > 0) - roll = RANDOM () % number; + roll = rndm (number); fl = get_formulalist (1); while (roll && fl) @@ -684,7 +690,7 @@ if (fl->total_chance > 0) { - r = RANDOM () % fl->total_chance; + r = rndm (fl->total_chance); for (rp = fl->items; rp; rp = rp->next) { r -= rp->chance; @@ -745,7 +751,7 @@ size_t size; size_t i; - dup = strdup_local (str); + dup = strdup (str); if (dup == NULL) fatal (OUT_OF_MEMORY);