--- deliantra/server/common/treasure.C 2007/04/21 17:34:23 1.54 +++ deliantra/server/common/treasure.C 2007/09/12 11:10:10 1.66 @@ -1,25 +1,24 @@ /* - * CrossFire, A Multiplayer game for X-windows + * This file is part of Crossfire TRT, the Roguelike Realtime MORPG. * - * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team - * Copyright (C) 2002 Mark Wedel & Crossfire Development Team - * Copyright (C) 1992 Frank Tore Johansen + * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team + * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team + * Copyright (©) 1992,2007 Frank Tore Johansen * - * This program is free software; you can redistribute it and/or modify + * Crossfire TRT is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * 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 + * along with this program. If not, see . + * + * The authors can be reached via e-mail to */ /* TREASURE_DEBUG does some checking on the treasurelists after loading. @@ -199,15 +198,13 @@ * Add up the chance total, and check to make sure the yes & no * fields of the treasures are not being used. */ - tl->total_chance = 0; - if (one) { for (treasure *t = tl->items; t; t = t->next) { if (t->next_yes || t->next_no) { - LOG (llevError, "Treasure %s is one item, but on treasure %s\n", &tl->name, t->item ? &t->item->name : &t->name); + LOG (llevError, "Treasure %s is one item, but on treasure %s\n", &tl->name, t->item ? &t->item->archname : &t->name); LOG (llevError, " the next_yes or next_no field is set\n"); } @@ -232,16 +229,23 @@ static void put_treasure (object *op, object *creator, int flags) { - /* Bit of a hack - spells should never be put onto the map. The entire - * treasure stuff is a problem - there is no clear idea of knowing - * this is the original object, or if this is an object that should be created - * by another object. - */ - if (flags & GT_ENVIRONMENT && op->type != SPELL) + if (flags & GT_ENVIRONMENT) { + /* Bit of a hack - spells should never be put onto the map. The entire + * treasure stuff is a problem - there is no clear idea of knowing + * this is the original object, or if this is an object that should be created + * by another object. + */ + //TODO: flag such as objects... as such (no drop, anybody?) + if (op->type == SPELL) + { + op->destroy (); + return; + } + op->expand_tail (); - if (ob_blocked (op, creator->map, creator->x, creator->y)) + if (op->blocked (creator->map, creator->x, creator->y)) op->destroy (); else { @@ -297,7 +301,7 @@ } else { - if (t->item && (t->item->clone.invisible != 0 || !(flag & GT_INVISIBLE))) + if (t->item && (t->item->invisible != 0 || !(flag & GT_INVISIBLE))) { object *tmp = arch_to_object (t->item); @@ -354,7 +358,7 @@ else if (t->nrof) create_one_treasure (tl, op, flag, difficulty, tries); } - else if (t->item && (t->item->clone.invisible != 0 || flag != GT_INVISIBLE)) + else if (t->item && (t->item->invisible != 0 || flag != GT_INVISIBLE)) { if (object *tmp = arch_to_object (t->item)) { @@ -368,6 +372,12 @@ } } +void +object::create_treasure (treasurelist *tl, int flags) +{ + ::create_treasure (tl, this, flags, map ? map->difficulty : 0); +} + /* This calls the appropriate treasure creation function. tries is passed * to determine how many list transitions or attempts to create treasure * have been made. It is really in place to prevent infinite loops with @@ -388,6 +398,15 @@ return; } + if (op->flag [FLAG_TREASURE_ENV]) + { + // do not generate items when there already is something above the object + if (op->flag [FLAG_IS_FLOOR] && op->above) + return; + + flag |= GT_ENVIRONMENT; + } + if (tl->total_chance) create_one_treasure (tl, op, flag, difficulty, tries); else @@ -554,11 +573,11 @@ if (op->arch) { if (op->type == ARMOUR) - ARMOUR_SPEED (op) = (ARMOUR_SPEED (&op->arch->clone) * (100 + magic * 10)) / 100; + ARMOUR_SPEED (op) = (ARMOUR_SPEED (op->arch) * (100 + magic * 10)) / 100; if (magic < 0 && !(rndm (3))) /* You can't just check the weight always */ magic = (-magic); - op->weight = (op->arch->clone.weight * (100 - magic * 10)) / 100; + op->weight = (op->arch->weight * (100 - magic * 10)) / 100; } else { @@ -630,7 +649,7 @@ case 4: case 5: case 6: - set_attr_value (&op->stats, r, (signed char) (bonus + get_attr_value (&op->stats, r))); + op->stats.stat (r) += bonus; break; case 7: @@ -1206,10 +1225,10 @@ for (i = 0; i < depth; i++) fprintf (logfile, " "); - if (t->item && t->item->clone.type == FLESH) - fprintf (logfile, "%s's %s\n", name, &t->item->clone.name); + if (t->item && t->item->type == FLESH) + fprintf (logfile, "%s's %s\n", name, &t->item->object::name); else - fprintf (logfile, "%s\n", &t->item->clone.name); + fprintf (logfile, "%s\n", &t->item->object::name); } if (t->next_yes) @@ -1247,12 +1266,12 @@ found = 0; fprintf (logfile, "\n"); - for (at = first_archetype; at != NULL; at = at->next) - if (!strcasecmp (at->clone.name, name) && at->clone.title == NULL) + for_all_archetypes (at) + if (!strcasecmp (at->object::name, name) && at->title == NULL) { - fprintf (logfile, "treasures for %s (arch: %s)\n", &at->clone.name, &at->name); - if (at->clone.randomitems != NULL) - dump_monster_treasure_rec (at->clone.name, at->clone.randomitems->items, 1); + fprintf (logfile, "treasures for %s (arch: %s)\n", &at->object::name, &at->archname); + if (at->randomitems != NULL) + dump_monster_treasure_rec (at->object::name, at->randomitems->items, 1); else fprintf (logfile, "(nothing)\n"); @@ -1286,8 +1305,6 @@ if (!f) return; - f.next (); - for (;;) { switch (f.kw) @@ -1400,7 +1417,7 @@ } for (i = 0; i < NUM_STATS; i++) - change_attr_value (&(op->stats), i, get_attr_value (&(change->stats), i)); + change_attr_value (&(op->stats), i, change->stats.stat (i)); op->attacktype |= change->attacktype; op->path_attuned |= change->path_attuned; @@ -1594,7 +1611,7 @@ name = tmp->name, neg = 0; /* If we match name, then return the opposite of 'neg' */ - if (!strcmp (name, op->name) || (op->arch && !strcmp (name, op->arch->name))) + if (!strcmp (name, op->name) || (op->arch && !strcmp (name, op->arch->archname))) return !neg; /* Set success as true, since if the match was an inverse, it means