--- deliantra/server/common/treasure.C 2006/09/14 21:16:11 1.18 +++ deliantra/server/common/treasure.C 2006/12/12 22:37:05 1.25 @@ -1,9 +1,3 @@ - -/* - * static char *rcs_treasure_c = - * "$Id: treasure.C,v 1.18 2006/09/14 21:16:11 root Exp $"; - */ - /* CrossFire, A Multiplayer game for X-windows @@ -24,7 +18,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - The authors can be reached via e-mail at crossfire-devel@real-time.com + The authors can be reached via e-mail at */ #define ALLOWED_COMBINATION @@ -456,21 +450,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); + LOG (llevError, "In generate treasure, created multiple objects.\n"); + + ob->destroy (); return tmp; } @@ -857,6 +853,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) @@ -1001,9 +1003,8 @@ case RING: if (op->arch == NULL) { - remove_ob (op); - free_object (op); - op = NULL; + op->destroy (); + op = 0; break; } @@ -1392,7 +1393,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"); @@ -1513,11 +1514,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); @@ -1564,12 +1561,8 @@ op->item_power = change->item_power; for (i = 0; i < NROFATTACKS; i++) - { - if (change->resist[i]) - { - op->resist[i] += change->resist[i]; - } - } + if (change->resist[i]) + op->resist[i] += change->resist[i]; if (change->stats.dam) { @@ -1857,7 +1850,7 @@ if (at->allowed) free_charlinks (at->allowed); - at->item->free (1); + at->item->destroy (1); delete at; } @@ -1867,7 +1860,7 @@ { artifactlist *nextal; - for (al = first_artifactlist; al != NULL; al = nextal) + for (al = first_artifactlist; al; al = nextal) { nextal = al->next;