summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/player-equip.cc
diff options
context:
space:
mode:
authorgammafunk <gammafunk@gmail.com>2014-03-17 20:10:33 -0500
committergammafunk <gammafunk@gmail.com>2014-03-18 00:16:40 -0500
commita18227ede66e02d668551662e35476ed00ef7e13 (patch)
tree7f6fca6ea4bf53148232bacfc35698eef069b604 /crawl-ref/source/player-equip.cc
parentfbd6e7ded89bf1ad2ebe2393fe0c11dd2e298bd0 (diff)
downloadcrawl-ref-a18227ede66e02d668551662e35476ed00ef7e13.tar.gz
crawl-ref-a18227ede66e02d668551662e35476ed00ef7e13.zip
Clean up the player hp change and calculation functions
Move calc_hp() to player.cc, and fix all but a couple instances where you.hp is changed directly to use set_hp() instead. We'll eventually just move these functions to inline methods for the player class, but this reorganization will do for now.
Diffstat (limited to 'crawl-ref/source/player-equip.cc')
-rw-r--r--crawl-ref/source/player-equip.cc7
1 files changed, 6 insertions, 1 deletions
diff --git a/crawl-ref/source/player-equip.cc b/crawl-ref/source/player-equip.cc
index 8520751cfd..ca3c3deff2 100644
--- a/crawl-ref/source/player-equip.cc
+++ b/crawl-ref/source/player-equip.cc
@@ -39,6 +39,11 @@ static void _unequip_effect(equipment_type slot, int item_slot, bool meld,
bool msg);
static void _mark_unseen_monsters();
+/**
+ * Recalculate the player's max hp and set the current hp based on the %change
+ * of max hp. This has resulted from our having equipped an artefact that
+ * changes max hp.
+ */
static void _calc_hp_artefact()
{
// Rounding must be down or Deep Dwarves would abuse certain values.
@@ -50,7 +55,7 @@ static void _calc_hp_artefact()
hp = hp * new_max / old_max;
if (hp < 100)
hp = 100;
- you.hp = min(hp / 100, you.hp_max);
+ set_hp(min(hp / 100, you.hp_max));
you.hit_points_regeneration = hp % 100;
if (you.hp_max <= 0) // Borgnjor's abusers...
ouch(0, NON_MONSTER, KILLED_BY_DRAINING);