From ca238f51c8aa0e17acedeeb1025195b73bbe5c0e Mon Sep 17 00:00:00 2001 From: reaverb Date: Fri, 8 Aug 2014 02:06:59 -0400 Subject: Remove a parameter from items() (mundane) --- crawl-ref/source/butcher.cc | 4 +++- crawl-ref/source/dungeon.cc | 31 +++++++++++++++++++++---------- crawl-ref/source/makeitem.cc | 26 ++++++++++++++++---------- crawl-ref/source/makeitem.h | 3 ++- crawl-ref/source/xom.cc | 4 ++-- 5 files changed, 44 insertions(+), 24 deletions(-) (limited to 'crawl-ref') diff --git a/crawl-ref/source/butcher.cc b/crawl-ref/source/butcher.cc index cd3f212830..fa55bf47db 100644 --- a/crawl-ref/source/butcher.cc +++ b/crawl-ref/source/butcher.cc @@ -48,7 +48,9 @@ static void _create_monster_hide(const item_def corpse) die("an unknown hide drop"); } - int o = items(0, OBJ_ARMOUR, type, true, 0, 0, 0, -1, true); + int o = items(0, OBJ_ARMOUR, type, true, 0); + squash_plusses(o); + if (o == NON_ITEM) return; item_def& item = mitm[o]; diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc index 46b3e0ca0a..fb53789bc0 100644 --- a/crawl-ref/source/dungeon.cc +++ b/crawl-ref/source/dungeon.cc @@ -4648,14 +4648,22 @@ int dgn_place_item(const item_spec &spec, while (true) { - const int item_made = - (acquire ? - acquirement_create_item(base_type, spec.acquirement_source, - true, where) - : spec.corpselike() ? _dgn_item_corpse(spec, where) - : items(spec.allow_uniques, base_type, - spec.sub_type, true, level, 0, spec.ego, -1, - spec.level == ISPEC_MUNDANE)); + int item_made; + + if (acquire) + { + item_made = acquirement_create_item(base_type, + spec.acquirement_source, + true, where); + } + else if (spec.corpselike()) + item_made = _dgn_item_corpse(spec, where); + else + item_made = items(spec.allow_uniques, base_type, + spec.sub_type, true, level, 0, spec.ego); + + if (spec.level == ISPEC_MUNDANE) + squash_plusses(item_made); if (item_made == NON_ITEM || item_made == -1) return NON_ITEM; @@ -4779,8 +4787,11 @@ static void _dgn_give_mon_spec_items(mons_spec &mspec, else { item_made = items(spec.allow_uniques, spec.base_type, - spec.sub_type, true, item_level, 0, spec.ego, - -1, spec.level == ISPEC_MUNDANE); + spec.sub_type, true, item_level, 0, + spec.ego); + + if (spec.level == ISPEC_MUNDANE) + squash_plusses(item_made); } if (!(item_made == NON_ITEM || item_made == -1)) diff --git a/crawl-ref/source/makeitem.cc b/crawl-ref/source/makeitem.cc index 9bbaa0ac15..7995c272ae 100644 --- a/crawl-ref/source/makeitem.cc +++ b/crawl-ref/source/makeitem.cc @@ -2630,6 +2630,21 @@ static void _generate_misc_item(item_def& item, int force_type, int force_ego) } } +/** + * Alter the inputed item to have no "plusses" (mostly weapon/armour enchantment) + * + * @param[in,out] item_slot The item slot of the item to remove "plusses" from. + */ +void squash_plusses(int item_slot) +{ + item_def& item(mitm[item_slot]); + + ASSERT(!is_deck(item)); + item.plus = 0; + item.plus2 = 0; + item.special = 0; +} + // Returns item slot or NON_ITEM if it fails. int items(bool allow_uniques, object_class_type force_class, // desired OBJECTS class {dlb} @@ -2638,8 +2653,7 @@ int items(bool allow_uniques, int item_level, // level of the item, can differ from global uint32_t mapmask, int force_ego, // desired ego/brand - int agent, // acquirement agent, if not -1 - bool mundane) // no plusses + int agent) // acquirement agent, if not -1 { ASSERT(force_ego <= 0 || force_class == OBJ_WEAPONS @@ -2801,14 +2815,6 @@ int items(bool allow_uniques, break; } - if (mundane) - { - ASSERT(!is_deck(item)); - item.plus = 0; - item.plus2 = 0; - item.special = 0; - } - if (item.base_type == OBJ_WEAPONS && !is_weapon_brand_ok(item.sub_type, get_weapon_brand(item), false) || item.base_type == OBJ_ARMOUR diff --git a/crawl-ref/source/makeitem.h b/crawl-ref/source/makeitem.h index c6257a828a..eb1fc275cf 100644 --- a/crawl-ref/source/makeitem.h +++ b/crawl-ref/source/makeitem.h @@ -12,7 +12,7 @@ int create_item_named(string name, coord_def pos, string *error); int items(bool allow_uniques, object_class_type force_class, int force_type, bool dont_place, int item_level, uint32_t mapmask = 0, - int force_ego = 0, int agent = -1, bool mundane = false); + int force_ego = 0, int agent = -1); void item_colour(item_def &item); void init_rod_mp(item_def &item, int ncharges = -1, int item_level = -1); @@ -30,6 +30,7 @@ void reroll_brand(item_def &item, int item_level); bool is_high_tier_wand(int type); +void squash_plusses(int item_slot); #if defined(DEBUG_DIAGNOSTICS) || defined(DEBUG_TESTS) void makeitem_tests(); #endif diff --git a/crawl-ref/source/xom.cc b/crawl-ref/source/xom.cc index 83add871fa..f073961c06 100644 --- a/crawl-ref/source/xom.cc +++ b/crawl-ref/source/xom.cc @@ -1636,9 +1636,9 @@ static int _xom_snakes_to_sticks(int sever, bool debug = false) (x_chance_in_y(3,5) ? MI_ARROW : MI_JAVELIN) : _xom_random_stickable(mi->get_experience_level())); - int thing_created = items(0, base_type, sub_type, true, + int thing_created = items(false, base_type, sub_type, true, mi->get_experience_level() / 3 - 1, - 0, 0, -1, -1); + 0, 0, -1); if (thing_created == NON_ITEM) continue; -- cgit v1.2.3-54-g00ecf