summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crawl-ref/source/acr.cc1
-rw-r--r--crawl-ref/source/makeitem.cc68
-rw-r--r--crawl-ref/source/makeitem.h4
3 files changed, 68 insertions, 5 deletions
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc
index 4af8c5263f..4fecc5f067 100644
--- a/crawl-ref/source/acr.cc
+++ b/crawl-ref/source/acr.cc
@@ -3593,6 +3593,7 @@ static bool _initialise(void)
tiles.initialise_items();
#endif
Options.show_more_prompt = false;
+ makeitem_tests();
crawl_tests::run_tests(true);
// Superfluous, just to make it clear that this is the end of
// the line.
diff --git a/crawl-ref/source/makeitem.cc b/crawl-ref/source/makeitem.cc
index e124fa56dd..ad69b42beb 100644
--- a/crawl-ref/source/makeitem.cc
+++ b/crawl-ref/source/makeitem.cc
@@ -2272,12 +2272,12 @@ bool is_armour_brand_ok(int type, int brand)
case SPARM_DEXTERITY:
return (slot == EQ_GLOVES);
+ case SPARM_SEE_INVISIBLE:
+ if (type == ARM_WIZARD_HAT)
+ return (false);
case SPARM_INTELLIGENCE:
return (slot == EQ_HELMET);
- case SPARM_SEE_INVISIBLE:
- return (type == ARM_HELMET);
-
case SPARM_FIRE_RESISTANCE:
case SPARM_COLD_RESISTANCE:
if (slot == EQ_BOOTS && type != ARM_BOOTS) // both bardings
@@ -2294,8 +2294,7 @@ bool is_armour_brand_ok(int type, int brand)
return (slot == EQ_BODY_ARMOUR || slot == EQ_SHIELD);
case SPARM_SPIRIT_SHIELD:
- if (type == ARM_CAP || slot == EQ_SHIELD)
- return (true);
+ return (type == ARM_CAP || slot == EQ_SHIELD);
case NUM_SPECIAL_ARMOURS:
ASSERT(!"invalid armour brand");
@@ -4892,3 +4891,62 @@ void item_set_appearance(item_def &item)
break;
}
}
+
+#ifdef DEBUG_DIAGNOSTICS
+static int _test_item_level()
+{
+ switch(random2(10))
+ {
+ case 0:
+ return MAKE_GOOD_ITEM;
+ case 1:
+ return -4; // damaged
+ case 2:
+ return -5; // cursed
+ case 3:
+ return -6; // force randart
+ default:
+ return random2(50);
+ }
+}
+
+void makeitem_tests()
+{
+ int i, level;
+ item_def item;
+
+ mpr("Running generate_weapon_item tests.");
+ for (i=0;i<10000;i++)
+ {
+ item.clear();
+ level = _test_item_level();
+ item.base_type = OBJ_WEAPONS;
+ if (coinflip())
+ item.special = SPWPN_NORMAL;
+ else
+ item.special = random2(MAX_PAN_LORD_BRANDS);
+ _generate_weapon_item(item,
+ coinflip(),
+ coinflip() ? OBJ_RANDOM : random2(NUM_WEAPONS),
+ level,
+ MAKE_ITEM_RANDOM_RACE);
+ }
+
+ mpr("Running generate_armour_item tests.");
+ for (i=0;i<10000;i++)
+ {
+ item.clear();
+ level = _test_item_level();
+ item.base_type = OBJ_ARMOUR;
+ if (coinflip())
+ item.special = SPARM_NORMAL;
+ else
+ item.special = random2(NUM_SPECIAL_ARMOURS);
+ _generate_armour_item(item,
+ coinflip(),
+ coinflip() ? OBJ_RANDOM : random2(NUM_ARMOURS),
+ level,
+ MAKE_ITEM_RANDOM_RACE);
+ }
+}
+#endif
diff --git a/crawl-ref/source/makeitem.h b/crawl-ref/source/makeitem.h
index ad986a159f..4aaa150d6d 100644
--- a/crawl-ref/source/makeitem.h
+++ b/crawl-ref/source/makeitem.h
@@ -35,4 +35,8 @@ 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);
+
+#ifdef DEBUG_DIAGNOSTICS
+void makeitem_tests();
+#endif
#endif