|
From: <gi...@cr...> - 2013-07-29 19:00:18
|
via e34089980d670f1b2dcc6a88b6d6ddd4fb00a9c0 (commit)
from 2b2dd308415ef86a10c92876da334e6b2269b748 (commit)
-----------------------------------------------------------------------
commit e34089980d670f1b2dcc6a88b6d6ddd4fb00a9c0
Author: Chris Campbell <chr...@gm...>
Date: Mon Jul 29 19:54:01 2013 +0100
Fix an infinite loop when rebranding
-----------------------------------------------------------------------
Summary of changes:
crawl-ref/source/item_use.cc | 26 ++++++++++++++++++++++++--
1 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc
index 4af2692..182b51d 100644
--- a/crawl-ref/source/item_use.cc
+++ b/crawl-ref/source/item_use.cc
@@ -2347,6 +2347,27 @@ static void _explosion(coord_def where, actor *agent, beam_type flavour,
beam.explode(true, false);
}
+// XXX: Only checks brands that can be rebranded to,
+// there's probably a nicer way of doing this.
+static bool _god_hates_brand(const int brand)
+{
+ if (is_good_god(you.religion)
+ && (brand == SPWPN_DRAINING
+ || brand == SPWPN_VAMPIRICISM
+ || brand == SPWPN_CHAOS))
+ {
+ return true;
+ }
+
+ if (you_worship(GOD_SHINING_ONE) && brand == SPWPN_VENOM)
+ return true;
+
+ if (you_worship(GOD_CHEIBRIADOS) && brand == SPWPN_CHAOS)
+ return true;
+
+ return false;
+}
+
static void _rebrand_weapon(item_def& wpn)
{
const int old_brand = get_weapon_brand(wpn);
@@ -2369,7 +2390,7 @@ static void _rebrand_weapon(item_def& wpn)
}
// now try and find an appropriate brand
- while (old_brand == new_brand || god_hates_item(wpn))
+ while (old_brand == new_brand || _god_hates_brand(new_brand))
{
if (is_range_weapon(wpn))
{
@@ -2397,9 +2418,10 @@ static void _rebrand_weapon(item_def& wpn)
3, SPWPN_CHAOS,
0);
}
- set_item_ego_type(wpn, OBJ_WEAPONS, new_brand);
}
+ set_item_ego_type(wpn, OBJ_WEAPONS, new_brand);
+
if (old_brand == SPWPN_DISTORTION)
{
// you can't get rid of distortion this easily
--
Dungeon Crawl Stone Soup
|