--- deliantra/server/common/treasure.C 2006/09/04 11:07:59 1.11 +++ deliantra/server/common/treasure.C 2006/09/04 13:55:54 1.12 @@ -1,7 +1,7 @@ /* * static char *rcs_treasure_c = - * "$Id: treasure.C,v 1.11 2006/09/04 11:07:59 root Exp $"; + * "$Id: treasure.C,v 1.12 2006/09/04 13:55:54 root Exp $"; */ /* @@ -257,28 +257,23 @@ treasurelist * find_treasurelist (const char *name) { - const char *tmp = shstr::find (name); - treasurelist *tl; - - /* Special cases - randomitems of none is to override default. If + /* Special cases - randomitems of NULL is to override default. If * first_treasurelist is null, it means we are on the first pass of - * of loading archetyps, so for now, just return - second pass will + * of loading archetypes, so for now, just return - second pass will * init these values. */ - if (!name || !*name) - return NULL; + if (!name) + return 0; - if (tmp != NULL) - for (tl = first_treasurelist; tl != NULL; tl = tl->next) - { - if (tmp == tl->name) - return tl; - } + if (const char *tmp = shstr::find (name)) + for (treasurelist *tl = first_treasurelist; tl != 0; tl = tl->next) + if (tmp == tl->name) + return tl; if (first_treasurelist) - LOG (llevError, "Couldn't find treasurelist %s(%s)\n", name, tmp); + LOG (llevError, "Couldn't find treasurelist %s\n", name); - return NULL; + return 0; } @@ -326,7 +321,7 @@ * in the generated object */ static void -change_treasure (treasure * t, object * op) +change_treasure (treasure *t, object *op) { /* CMD: change_name xxxx */ if (t->change_arch.name) @@ -343,11 +338,10 @@ } void -create_all_treasures (treasure * t, object * op, int flag, int difficulty, int tries) +create_all_treasures (treasure *t, object *op, int flag, int difficulty, int tries) { object *tmp; - if ((int) t->chance >= 100 || (RANDOM () % 100 + 1) < (int) t->chance) { if (t->name) @@ -367,17 +361,19 @@ put_treasure (tmp, op, flag); } } + if (t->next_yes != NULL) create_all_treasures (t->next_yes, op, flag, difficulty, tries); } else if (t->next_no != NULL) create_all_treasures (t->next_no, op, flag, difficulty, tries); + if (t->next != NULL) create_all_treasures (t->next, op, flag, difficulty, tries); } void -create_one_treasure (treasurelist * tl, object * op, int flag, int difficulty, int tries) +create_one_treasure (treasurelist *tl, object * op, int flag, int difficulty, int tries) { int value = RANDOM () % tl->total_chance; treasure *t; @@ -387,9 +383,11 @@ LOG (llevDebug, "create_one_treasure: tries exceeded 100, returning without making treasure\n"); return; } + for (t = tl->items; t != NULL; t = t->next) { value -= t->chance; + if (value < 0) break; } @@ -400,25 +398,32 @@ abort (); return; } + if (t->name) { if (!strcmp (t->name, "NONE")) return; + if (difficulty >= t->magic) create_treasure (find_treasurelist (t->name), op, flag, difficulty, tries); else if (t->nrof) create_one_treasure (tl, op, flag, difficulty, tries); + return; } + if ((t->item && t->item->clone.invisible != 0) || flag != GT_INVISIBLE) { object *tmp = arch_to_object (t->item); + if (!tmp) return; + if (t->nrof && tmp->nrof <= 1) tmp->nrof = RANDOM () % ((int) t->nrof) + 1; - fix_generated_item (tmp, op, difficulty, t->magic, flag); - change_treasure (t, tmp); + +// fix_generated_item (tmp, op, difficulty, t->magic, flag); +// change_treasure (t, tmp); put_treasure (tmp, op, flag); } } @@ -1475,6 +1480,7 @@ /* so artifacts will join */ if (!QUERY_FLAG (op, FLAG_ALIVE)) op->speed = 0.0; + update_ob_speed (op); } @@ -1653,7 +1659,7 @@ */ void -give_artifact_abilities (object * op, object * artifct) +give_artifact_abilities (object *op, object *artifct) { char new_name[MAX_BUF];