From 9a1056ab7e0feb88bb8bcf84411441de3dc32ba6 Mon Sep 17 00:00:00 2001 From: Adam Borowski Date: Wed, 25 Nov 2009 13:25:28 +0100 Subject: Be more nazi about illegal brands (like, reaping on melee weapons like scythes). --- crawl-ref/source/makeitem.cc | 24 +++++++++++++++++++++++- crawl-ref/source/makeitem.h | 1 + crawl-ref/source/mapdef.cc | 5 +++-- 3 files changed, 27 insertions(+), 3 deletions(-) (limited to 'crawl-ref') diff --git a/crawl-ref/source/makeitem.cc b/crawl-ref/source/makeitem.cc index c48f202e0d..3ad8f77048 100644 --- a/crawl-ref/source/makeitem.cc +++ b/crawl-ref/source/makeitem.cc @@ -1615,9 +1615,11 @@ static void _generate_weapon_item(item_def& item, bool allow_uniques, { item.sub_type = _determine_weapon_subtype(item_level); if (is_weapon_brand_ok(item.sub_type, item.special)) - break; + goto brand_ok; } + item.sub_type = SPWPN_NORMAL; // fall back to no brand } +brand_ok: // Forced randart. if (item_level == -6) @@ -1870,9 +1872,16 @@ static special_missile_type _determine_missile_brand(const item_def& item, if (item.sub_type == MI_THROWING_NET) rc = SPMSL_NORMAL; + ASSERT(is_missile_brand_ok(item.sub_type, rc)); return rc; } +bool is_missile_brand_ok(int type, int brand) +{ + // No checks for now... + return (true); +} + static void _generate_missile_item(item_def& item, int force_type, int item_level, int item_race) { @@ -3143,6 +3152,19 @@ int items(int allow_uniques, // not just true-false, break; } + if (item.base_type == OBJ_WEAPONS + && !is_weapon_brand_ok(item.sub_type, item.special) + || item.base_type == OBJ_ARMOUR + && !is_armour_brand_ok(item.sub_type, item.special) + || item.base_type == OBJ_MISSILES + && !is_missile_brand_ok(item.sub_type, item.special)) + { + mprf(MSGCH_ERROR, "Invalid brand on item %s, annulling.", + item.name(DESC_PLAIN, false, true, false, false, ISFLAG_KNOW_PLUSES + | ISFLAG_KNOW_CURSE).c_str()); + item.special = 0; + } + // Colour the item. item_colour(item); diff --git a/crawl-ref/source/makeitem.h b/crawl-ref/source/makeitem.h index d434143058..5313c57dcb 100644 --- a/crawl-ref/source/makeitem.h +++ b/crawl-ref/source/makeitem.h @@ -34,6 +34,7 @@ void item_set_appearance(item_def &item); bool is_weapon_brand_ok(int type, int brand); bool is_armour_brand_ok(int type, int brand); +bool is_missile_brand_ok(int type, int brand); bool got_curare_roll(const int item_level); diff --git a/crawl-ref/source/mapdef.cc b/crawl-ref/source/mapdef.cc index d791318c40..93310d481c 100644 --- a/crawl-ref/source/mapdef.cc +++ b/crawl-ref/source/mapdef.cc @@ -3410,8 +3410,9 @@ item_spec item_list::parse_single_spec(std::string s) else if (result.base_type == OBJ_WEAPONS && !is_weapon_brand_ok(result.sub_type, ego) || result.base_type == OBJ_ARMOUR - && !is_armour_brand_ok(result.sub_type, ego)) - // no missile brands are disallowed yet + && !is_armour_brand_ok(result.sub_type, ego) + || result.base_type == OBJ_MISSILES + && !is_missile_brand_ok(result.sub_type, ego)) { error = make_stringf("Ego '%s' is incompatible with item '%s'.", ego_str.c_str(), s.c_str()); -- cgit v1.2.3-54-g00ecf