--- deliantra/server/common/treasure.C 2006/09/10 16:00:23 1.16 +++ deliantra/server/common/treasure.C 2006/12/12 20:53:02 1.23 @@ -1,9 +1,3 @@ - -/* - * static char *rcs_treasure_c = - * "$Id: treasure.C,v 1.16 2006/09/10 16:00:23 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 @@ -60,13 +54,13 @@ warn_archetypes = 1; if (ring_arch == NULL) - ring_arch = find_archetype ("ring"); + ring_arch = archetype::find ("ring"); if (amulet_arch == NULL) - amulet_arch = find_archetype ("amulet"); + amulet_arch = archetype::find ("amulet"); if (staff_arch == NULL) - staff_arch = find_archetype ("staff"); + staff_arch = archetype::find ("staff"); if (crown_arch == NULL) - crown_arch = find_archetype ("crown"); + crown_arch = archetype::find ("crown"); warn_archetypes = prev_warn; } @@ -121,7 +115,7 @@ if (sscanf (cp, "arch %s", variable)) { - if ((t->item = find_archetype (variable)) == NULL) + if ((t->item = archetype::find (variable)) == NULL) LOG (llevError, "Treasure lacks archetype: %s\n", variable); } else if (sscanf (cp, "list %s", variable)) @@ -261,18 +255,14 @@ treasurelist * find_treasurelist (const char *name) { - /* 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 archetypes, so for now, just return - second pass will - * init these values. - */ - if (!name) + shstr_cmp name_ (name); + + if (!name_) return 0; - if (const char *tmp = shstr::find (name)) - for (treasurelist * tl = first_treasurelist; tl != 0; tl = tl->next) - if (tmp == tl->name) - return tl; + for (treasurelist * tl = first_treasurelist; tl != 0; tl = tl->next) + if (name_ == tl->name) + return tl; if (first_treasurelist) LOG (llevError, "Couldn't find treasurelist %s\n", name); @@ -469,12 +459,12 @@ /* 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 (0); return tmp; } @@ -861,6 +851,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) @@ -1005,8 +1001,8 @@ case RING: if (op->arch == NULL) { - remove_ob (op); - free_object (op); + op->remove (); + op->destroy (0); op = NULL; break; } @@ -1519,8 +1515,8 @@ while (op->inv) { tmp_obj = op->inv; - remove_ob (tmp_obj); - free_object (tmp_obj); + tmp_obj->remove (); + tmp_obj->destroy (0); } tmp_obj = arch_to_object (change->other_arch); @@ -1568,12 +1564,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) { @@ -1861,7 +1853,7 @@ if (at->allowed) free_charlinks (at->allowed); - at->item->free (1); + at->item->destroy (1); delete at; } @@ -1871,7 +1863,7 @@ { artifactlist *nextal; - for (al = first_artifactlist; al != NULL; al = nextal) + for (al = first_artifactlist; al; al = nextal) { nextal = al->next;