From bcd69917034c0ebdc59addc77e27b16d6db0ecff Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 19 May 2012 18:50:28 -0700 Subject: [PATCH] testing spells is a lot easier when you can disable fumbles all tun_tests tests pass --- scripts/tests/spells.lua | 1 + src/kernel/item.c | 4 +++- src/kernel/magic.c | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/tests/spells.lua b/scripts/tests/spells.lua index bad60c192..b5278e5f1 100644 --- a/scripts/tests/spells.lua +++ b/scripts/tests/spells.lua @@ -4,6 +4,7 @@ module("tests.spells", package.seeall, lunit.testcase) function setup() free_game() + settings.set("magic.fumble.enable", "0") end function test_roi() diff --git a/src/kernel/item.c b/src/kernel/item.c index 507fe1adf..525693a3c 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -1119,7 +1119,7 @@ const item_type *finditemtype(const char *name, const struct locale *lang) in->next = inames; in->lang = lang; do { - m = cb_find_prefix(&cb_items, "", 1, matches, CB_BATCHSIZE, offset); + m = cb_find_prefix(&cb_items, "", 0, matches, CB_BATCHSIZE, offset); if (m) { int i; offset += m; @@ -1207,6 +1207,8 @@ void test_clear_resources(void) r_hp = r_silver = r_aura = r_permaura = r_unit = 0; i_silver = 0; + + inames = 0; /* TODO: this is a terrible hack, the whole inames global state must die */ } #endif diff --git a/src/kernel/magic.c b/src/kernel/magic.c index 4f2ab435e..120760378 100644 --- a/src/kernel/magic.c +++ b/src/kernel/magic.c @@ -1314,7 +1314,11 @@ boolean fumble(region * r, unit * u, const spell * sp, int cast_grade) int patzer = (int)(((double)x * 40.0) - 20.0); struct building *b = inside_building(u); const struct building_type *btype = b ? b->type : NULL; + int fumble_enabled = get_param_int(global.parameters, "magic.fumble.enable", 1); + if (!fumble_enabled) { + return false; + } if (btype) patzer -= btype->fumblebonus; /* CHAOSPATZERCHANCE 10 : +10% Chance zu Patzern */