--- deliantra/server/common/recipe.C 2007/02/16 19:43:41 1.18 +++ deliantra/server/common/recipe.C 2007/04/16 06:23:40 1.19 @@ -34,8 +34,9 @@ tl->total_chance = 0; tl->number = 0; - tl->items = NULL; - tl->next = NULL; + tl->items = 0; + tl->next = 0; + return tl; } @@ -243,10 +244,10 @@ LOG (llevDebug, "Checking formulae lists...\n"); - for (fl = formulalist; fl != NULL; fl = fl->next) + for (fl = formulalist; fl; fl = fl->next) { - for (formula = fl->items; formula != NULL; formula = formula->next) - for (check = formula->next; check != NULL; check = check->next) + for (formula = fl->items; formula; formula = formula->next) + for (check = formula->next; check; check = check->next) if (check->index == formula->index) { LOG (llevError, " ERROR: On %d ingred list: ", numb); @@ -275,7 +276,7 @@ { fprintf (logfile, "\n Formulae with %d ingredient%s %d Formulae with total_chance=%d\n", num_ingred, num_ingred > 1 ? "s." : ".", fl->number, fl->total_chance); - for (formula = fl->items; formula != NULL; formula = formula->next) + for (formula = fl->items; formula; formula = formula->next) { artifact *art = NULL; char buf[MAX_BUF]; @@ -338,9 +339,6 @@ archetype * find_treasure_by_name (const treasure *t, const char *name, int depth) { - treasurelist *tl; - archetype *at; - if (depth > 10) return 0; @@ -348,15 +346,10 @@ { if (t->name) { - tl = find_treasurelist (t->name); - - if (tl) - { - at = find_treasure_by_name (tl->items, name, depth + 1); - - if (at) + if (treasurelist *tl = treasurelist::find (t->name)) + if (tl->items) + if (archetype *at = find_treasure_by_name (tl->items, name, depth + 1)) return at; - } } else { @@ -365,20 +358,16 @@ } if (t->next_yes) - { - at = find_treasure_by_name (t->next_yes, name, depth); - if (at) - return at; - } + if (archetype *at = find_treasure_by_name (t->next_yes, name, depth)) + return at; if (t->next_no) - { - at = find_treasure_by_name (t->next_no, name, depth); - if (at) - return at; - } + if (archetype *at = find_treasure_by_name (t->next_no, name, depth)) + return at; + t = t->next; } + return 0; } @@ -437,16 +426,16 @@ part1[cp - name] = '\0'; strcpy (part2, cp + 4); /* find the first archetype matching the first part of the name */ - for (at = first_archetype; at != NULL; at = at->next) + for (at = first_archetype; at; at = at->next) if (!strcasecmp (at->clone.name, part1) && at->clone.title == NULL) break; if (at != NULL) { /* find the first artifact derived from that archetype (same type) */ - for (al = first_artifactlist; al != NULL; al = al->next) + for (al = first_artifactlist; al; al = al->next) if (al->type == at->clone.type) { - for (art = al->items; art != NULL; art = art->next) + for (art = al->items; art; art = art->next) if (!strcasecmp (art->item->name, part2)) return mult * at->clone.value * art->item->value; } @@ -461,10 +450,10 @@ part1[cp - name] = '\0'; strcpy (part2, cp + 3); /* examine all archetypes matching the first part of the name */ - for (at = first_archetype; at != NULL; at = at->next) + for (at = first_archetype; at; at = at->next) if (!strcasecmp (at->clone.name, part1) && at->clone.title == NULL) { - if (at->clone.randomitems != NULL) + if (at->clone.randomitems) { at2 = find_treasure_by_name (at->clone.randomitems->items, part2, 0); if (at2) @@ -494,7 +483,7 @@ { fprintf (logfile, "\n Formulae with %d ingredient%s %d Formulae with total_chance=%d\n", num_ingred, num_ingred > 1 ? "s." : ".", fl->number, fl->total_chance); - for (formula = fl->items; formula != NULL; formula = formula->next) + for (formula = fl->items; formula; formula = formula->next) { artifact *art = NULL; archetype *at = NULL;