summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/transform.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/transform.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/transform.cc')
-rw-r--r--crawl-ref/source/transform.cc18
1 files changed, 13 insertions, 5 deletions
diff --git a/crawl-ref/source/transform.cc b/crawl-ref/source/transform.cc
index f13383595b..b75848aa85 100644
--- a/crawl-ref/source/transform.cc
+++ b/crawl-ref/source/transform.cc
@@ -1246,6 +1246,13 @@ bool transform(int pow, transformation_type which_trans, bool involuntary,
return true;
}
+/**
+ * End the player's transformation and return them to their normal
+ * form.
+ * @param skip_wielding If true, don't swap the player's weapon back.
+ * @param skip_move If true, skip any move that was in progress before
+ * the transformation ended.
+ */
void untransform(bool skip_wielding, bool skip_move)
{
const flight_type old_flight = you.flight_mode();
@@ -1450,11 +1457,12 @@ void untransform(bool skip_wielding, bool skip_move)
if (hp_downscale != 10 && you.hp != you.hp_max)
{
- you.hp = you.hp * 10 / hp_downscale;
- if (you.hp < 1)
- you.hp = 1;
- else if (you.hp > you.hp_max)
- you.hp = you.hp_max;
+ int hp = you.hp * 10 / hp_downscale;
+ if (hp < 1)
+ hp = 1;
+ else if (hp > you.hp_max)
+ hp = you.hp_max;
+ set_hp(hp);
}
calc_hp();