--- deliantra/server/common/treasure.C 2008/04/15 03:16:02 1.71 +++ deliantra/server/common/treasure.C 2008/07/29 02:00:55 1.79 @@ -1,7 +1,7 @@ /* * This file is part of Deliantra, the Roguelike Realtime MMORPG. * - * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Deliantra team + * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team * Copyright (©) 1992,2007 Frank Tore Johansen * @@ -34,7 +34,6 @@ #include #include -#include #include extern char *spell_mapping[]; @@ -48,8 +47,7 @@ treasurelist *, str_hash, str_equal, - slice_allocator< std::pair >, - true + slice_allocator< std::pair > > tl_map_t; static tl_map_t tl_map; @@ -146,7 +144,14 @@ switch (f.kw) { case KW_arch: - t->item = archetype::get (f.get_str ()); + t->item = archetype::find (f.get_str ()); + + if (!t->item) + { + f.parse_warn ("treasure references unknown archetype"); + t->item = archetype::empty; + } + break; case KW_list: f.get (t->name); break; @@ -170,13 +175,19 @@ default: if (!f.parse_error ("treasurelist", t->name)) - return 0; + goto error; return t; } f.next (); } + + // not reached + +error: + delete t; + return 0; } /* @@ -245,7 +256,7 @@ op->expand_tail (); - if (op->blocked (creator->map, creator->x, creator->y)) + if (!creator->is_on_map () || op->blocked (creator->map, creator->x, creator->y)) op->destroy (); else { @@ -259,10 +270,6 @@ if ((flags & GT_APPLY) && QUERY_FLAG (creator, FLAG_MONSTER)) monster_check_apply (creator, op); - - if (flags & GT_UPDATE_INV) - if (object *tmp = creator->in_player ()) - esrv_send_item (tmp, op); } } @@ -572,14 +579,17 @@ if (magic < 0 && !(rndm (3))) /* You can't just check the weight always */ magic = (-magic); + op->weight = (op->arch->weight * (100 - magic * 10)) / 100; } else { if (op->type == ARMOUR) ARMOUR_SPEED (op) = (ARMOUR_SPEED (op) * (100 + magic * 10)) / 100; + if (magic < 0 && !(rndm (3))) /* You can't just check the weight always */ magic = (-magic); + op->weight = (op->weight * (100 - magic * 10)) / 100; } } @@ -818,7 +828,7 @@ if (!(flags & GT_MINIMAL)) { - if (op->arch == crown_arch) + if (IS_ARCH (op->arch, crown)) { set_magic (difficulty, op, max_magic, flags); num_enchantments = calc_item_power (op, 1); @@ -833,8 +843,7 @@ if ((!was_magic && !rndm (CHANCE_FOR_ARTIFACT)) || op->type == HORN - || difficulty >= settings.max_level) /* high difficulties always generate an artifact, - * used for shop_floors or treasures */ + || difficulty >= settings.max_level) /* high difficulties always generate an artifact, used for shop_floors or treasures */ generate_artifact (op, difficulty); } @@ -886,9 +895,7 @@ /* Handle healing and magic power potions */ if (op->stats.sp && !op->randomitems) { - object *tmp; - - tmp = get_archetype (spell_mapping[op->stats.sp]); + object *tmp = get_archetype (spell_mapping [op->stats.sp]); insert_ob_in_ob (tmp, op); op->stats.sp = 0; } @@ -956,18 +963,18 @@ } case AMULET: - if (op->arch == amulet_arch) + if (IS_ARCH (op->arch, amulet)) op->value *= 5; /* Since it's not just decoration */ case RING: - if (op->arch == NULL) + if (!op->arch) // wtf? schmorp { op->destroy (); op = 0; break; } - if (op->arch != ring_arch && op->arch != amulet_arch) /* It's a special artifact! */ + if (!IS_ARCH (op->arch, ring) && !IS_ARCH (op->arch, amulet)) /* It's a special artifact! */ break; if (!(flags & GT_ONLY_GOOD) && !(rndm (3)))