--- deliantra/server/common/treasure.C 2006/09/27 00:36:08 1.21 +++ deliantra/server/common/treasure.C 2006/12/20 09:14:21 1.27 @@ -260,7 +260,7 @@ if (!name_) return 0; - for (treasurelist * tl = first_treasurelist; tl != 0; tl = tl->next) + for (treasurelist *tl = first_treasurelist; tl != 0; tl = tl->next) if (name_ == tl->name) return tl; @@ -282,8 +282,6 @@ * abilities. This is used by summon spells, thus no summoned monsters * start with equipment, but only their abilities). */ - - static void put_treasure (object *op, object *creator, int flags) { @@ -304,9 +302,11 @@ else { op = insert_ob_in_ob (op, creator); + if ((flags & GT_APPLY) && QUERY_FLAG (creator, FLAG_MONSTER)) monster_check_apply (creator, op); - if ((flags & GT_UPDATE_INV) && (tmp = is_player_inv (creator)) != NULL) + + if ((flags & GT_UPDATE_INV) && (tmp = creator->in_player ())) esrv_send_item (tmp, op); } } @@ -341,7 +341,11 @@ if (t->name) { if (strcmp (t->name, "NONE") && difficulty >= t->magic) - create_treasure (find_treasurelist (t->name), op, flag, difficulty, tries); + { + treasurelist *tl = find_treasurelist (t->name); + if (tl) + create_treasure (tl, op, flag, difficulty, tries); + } } else { @@ -399,7 +403,11 @@ return; if (difficulty >= t->magic) - create_treasure (find_treasurelist (t->name), op, flag, difficulty, tries); + { + treasurelist *tl = find_treasurelist (t->name); + if (tl) + create_treasure (tl, op, flag, difficulty, tries); + } else if (t->nrof) create_one_treasure (tl, op, flag, difficulty, tries); @@ -450,21 +458,23 @@ * inserted into, and then return that treausre */ object * -generate_treasure (treasurelist * t, int difficulty) +generate_treasure (treasurelist *t, int difficulty) { - object *ob = get_object (), *tmp; + difficulty = clamp (difficulty, 1, settings.max_level); + + object *ob = object::create (), *tmp; create_treasure (t, ob, 0, difficulty, 0); /* Don't want to free the object we are about to return */ tmp = ob->inv; if (tmp != NULL) - remove_ob (tmp); + tmp->remove (); if (ob->inv) LOG (llevError, "In generate treasure, created multiple objects.\n"); - free_object (ob); + ob->destroy (); return tmp; } @@ -851,6 +861,12 @@ if (difficulty < 1) difficulty = 1; + if (INVOKE_OBJECT (ADD_BONUS, op, + ARG_OBJECT (creator != op ? creator : 0), + ARG_INT (difficulty), ARG_INT (max_magic), + ARG_INT (flags))) + return; + if (!(flags & GT_MINIMAL)) { if (op->arch == crown_arch) @@ -995,9 +1011,8 @@ case RING: if (op->arch == NULL) { - remove_ob (op); - free_object (op); - op = NULL; + op->destroy (); + op = 0; break; } @@ -1259,7 +1274,8 @@ fprintf (logfile, " "); fprintf (logfile, "{ (list: %s)\n", &t->name); tl = find_treasurelist (t->name); - dump_monster_treasure_rec (name, tl->items, depth + 2); + if (tl) + dump_monster_treasure_rec (name, tl->items, depth + 2); for (i = 0; i < depth; i++) fprintf (logfile, " "); fprintf (logfile, "} (end of list: %s)\n", &t->name); @@ -1386,7 +1402,7 @@ art->difficulty = (uint8) value; else if (!strncmp (cp, "Object", 6)) { - art->item = get_object (); + art->item = object::create (); if (!load_object (thawer, art->item, 0)) LOG (llevError, "Init_Artifacts: Could not load object.\n"); @@ -1507,11 +1523,7 @@ /* Remove any spells this object currently has in it */ while (op->inv) - { - tmp_obj = op->inv; - remove_ob (tmp_obj); - free_object (tmp_obj); - } + op->inv->destroy (); tmp_obj = arch_to_object (change->other_arch); insert_ob_in_ob (tmp_obj, op);