--- deliantra/server/common/treasure.C 2006/12/26 20:04:09 1.29 +++ deliantra/server/common/treasure.C 2007/01/03 02:30:51 1.30 @@ -158,13 +158,11 @@ static void check_treasurelist (const treasure *t, const treasurelist * tl) { - if (t->item == NULL && t->name == NULL) - LOG (llevError, "Treasurelist %s has element with no name or archetype\n", &tl->name); if (t->chance >= 100 && t->next_yes && (t->next || t->next_no)) LOG (llevError, "Treasurelist %s has element that has 100%% generation, next_yes field as well as next or next_no\n", &tl->name); /* find_treasurelist will print out its own error message */ if (t->name && *t->name) - (void) find_treasurelist (t->name); + find_treasurelist (t->name); if (t->next) check_treasurelist (t->next, tl); if (t->next_yes) @@ -338,7 +336,7 @@ { if (t->name) { - if (strcmp (t->name, "NONE") && difficulty >= t->magic) + if (difficulty >= t->magic) { treasurelist *tl = find_treasurelist (t->name); if (tl) @@ -347,7 +345,7 @@ } else { - if (t->item->clone.invisible != 0 || !(flag & GT_INVISIBLE)) + if (t->item && (t->item->clone.invisible != 0 || !(flag & GT_INVISIBLE))) { tmp = arch_to_object (t->item); if (t->nrof && tmp->nrof <= 1) @@ -397,9 +395,6 @@ if (t->name) { - if (!strcmp (t->name, "NONE")) - return; - if (difficulty >= t->magic) { treasurelist *tl = find_treasurelist (t->name); @@ -412,7 +407,7 @@ return; } - if ((t->item && t->item->clone.invisible != 0) || flag != GT_INVISIBLE) + if (t->item && (t->item->clone.invisible != 0 || flag != GT_INVISIBLE)) { object *tmp = arch_to_object (t->item); @@ -436,7 +431,7 @@ * to do that. */ void -create_treasure (treasurelist * t, object *op, int flag, int difficulty, int tries) +create_treasure (treasurelist *tl, object *op, int flag, int difficulty, int tries) { if (tries++ > 100) @@ -444,10 +439,10 @@ LOG (llevDebug, "createtreasure: tries exceeded 100, returning without making treasure\n"); return; } - if (t->total_chance) - create_one_treasure (t, op, flag, difficulty, tries); + if (tl->total_chance) + create_one_treasure (tl, op, flag, difficulty, tries); else - create_all_treasures (t->items, op, flag, difficulty, tries); + create_all_treasures (tl->items, op, flag, difficulty, tries); } /* This is similar to the old generate treasure function. However, @@ -456,13 +451,13 @@ * inserted into, and then return that treausre */ object * -generate_treasure (treasurelist *t, int difficulty) +generate_treasure (treasurelist *tl, int difficulty) { difficulty = clamp (difficulty, 1, settings.max_level); object *ob = object::create (), *tmp; - create_treasure (t, ob, 0, difficulty, 0); + create_treasure (tl, ob, 0, difficulty, 0); /* Don't want to free the object we are about to return */ tmp = ob->inv; @@ -1178,14 +1173,14 @@ static artifactlist * get_empty_artifactlist (void) { - artifactlist *tl = (artifactlist *) malloc (sizeof (artifactlist)); + artifactlist *al = (artifactlist *) malloc (sizeof (artifactlist)); - if (tl == NULL) + if (al == NULL) fatal (OUT_OF_MEMORY); - tl->next = NULL; - tl->items = NULL; - tl->total_chance = 0; - return tl; + al->next = NULL; + al->items = NULL; + al->total_chance = 0; + return al; } /* @@ -1195,16 +1190,16 @@ static artifact * get_empty_artifact (void) { - artifact *t = (artifact *) malloc (sizeof (artifact)); + artifact *a = (artifact *) malloc (sizeof (artifact)); - if (t == NULL) + if (a == NULL) fatal (OUT_OF_MEMORY); - t->item = NULL; - t->next = NULL; - t->chance = 0; - t->difficulty = 0; - t->allowed = NULL; - return t; + a->item = NULL; + a->next = NULL; + a->chance = 0; + a->difficulty = 0; + a->allowed = NULL; + return a; } /* @@ -1264,9 +1259,9 @@ if (depth > 100) return; - while (t != NULL) + while (t) { - if (t->name != NULL) + if (t->name) { for (i = 0; i < depth; i++) fprintf (logfile, " "); @@ -1282,25 +1277,28 @@ { for (i = 0; i < depth; i++) fprintf (logfile, " "); - if (t->item->clone.type == FLESH) + if (t->item && t->item->clone.type == FLESH) fprintf (logfile, "%s's %s\n", name, &t->item->clone.name); else fprintf (logfile, "%s\n", &t->item->clone.name); } - if (t->next_yes != NULL) + + if (t->next_yes) { for (i = 0; i < depth; i++) fprintf (logfile, " "); fprintf (logfile, " (if yes)\n"); dump_monster_treasure_rec (name, t->next_yes, depth + 1); } - if (t->next_no != NULL) + + if (t->next_no) { for (i = 0; i < depth; i++) fprintf (logfile, " "); fprintf (logfile, " (if no)\n"); dump_monster_treasure_rec (name, t->next_no, depth + 1); } + t = t->next; } } @@ -1810,16 +1808,13 @@ int special_potion (object *op) { - - int i; - if (op->attacktype) return 1; if (op->stats.Str || op->stats.Dex || op->stats.Con || op->stats.Pow || op->stats.Wis || op->stats.Int || op->stats.Cha) return 1; - for (i = 0; i < NROFATTACKS; i++) + for (int i = 0; i < NROFATTACKS; i++) if (op->resist[i]) return 1;