summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/acr.cc
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2009-01-31 18:41:16 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2009-01-31 18:41:16 +0000
commit0ca19d27dea350d314c9aa6d6c733bc6d15b5af6 (patch)
treea5e76b1c45e527471c54ea788ba98b7c58cf426a /crawl-ref/source/acr.cc
parent522d82aa2e3f30bba891843b44904741ab790659 (diff)
downloadcrawl-ref-0ca19d27dea350d314c9aa6d6c733bc6d15b5af6.tar.gz
crawl-ref-0ca19d27dea350d314c9aa6d6c733bc6d15b5af6.zip
Code cleanups, mainly in clouds.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8865 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/acr.cc')
-rw-r--r--crawl-ref/source/acr.cc75
1 files changed, 39 insertions, 36 deletions
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc
index db19ec7c91..d1eb144496 100644
--- a/crawl-ref/source/acr.cc
+++ b/crawl-ref/source/acr.cc
@@ -274,10 +274,11 @@ int main( int argc, char *argv[] )
else
learned_something_new(TUT_LOAD_SAVED_GAME);
+ _prep_input();
+
// Catch up on any experience levels we did not assign last time. This
// can happen if Crawl sees SIGHUP while it is waiting for the player
// to dismiss a level-up prompt.
- _prep_input();
level_change();
while (true)
@@ -2492,6 +2493,41 @@ static void _check_sanctuary()
decrease_sanctuary_radius();
}
+static void _regenerate_hp_and_mp()
+{
+ // XXX: using an int tmp to fix the fact that hit_points_regeneration
+ // is only an unsigned char and is thus likely to overflow. -- bwr
+ int tmp = you.hit_points_regeneration;
+
+ if (you.hp < you.hp_max && !you.disease && !you.duration[DUR_DEATHS_DOOR])
+ tmp += player_regen();
+
+ while (tmp >= 100)
+ {
+ inc_hp(1, false);
+ tmp -= 100;
+ }
+
+ ASSERT( tmp >= 0 && tmp < 100 );
+ you.hit_points_regeneration = static_cast<unsigned char>(tmp);
+
+ // XXX: Doing the same as the above, although overflow isn't an
+ // issue with magic point regeneration, yet. -- bwr
+ tmp = you.magic_points_regeneration;
+
+ if (you.magic_points < you.max_magic_points)
+ tmp += 7 + you.max_magic_points / 2;
+
+ while (tmp >= 100)
+ {
+ inc_mp(1, false);
+ tmp -= 100;
+ }
+
+ ASSERT( tmp >= 0 && tmp < 100 );
+ you.magic_points_regeneration = static_cast<unsigned char>(tmp);
+}
+
void world_reacts()
{
crawl_state.clear_mon_acting();
@@ -2518,9 +2554,7 @@ void world_reacts()
}
_check_banished();
-
_check_shafts();
-
_check_sanctuary();
run_environment_effects();
@@ -2560,41 +2594,10 @@ void world_reacts()
_decrement_durations();
const int food_use = player_hunger_rate();
-
if (food_use > 0 && you.hunger >= 40)
- make_hungry( food_use, true );
-
- // XXX: using an int tmp to fix the fact that hit_points_regeneration
- // is only an unsigned char and is thus likely to overflow. -- bwr
- int tmp = static_cast< int >( you.hit_points_regeneration );
-
- if (you.hp < you.hp_max && !you.disease && !you.duration[DUR_DEATHS_DOOR])
- tmp += player_regen();
-
- while (tmp >= 100)
- {
- inc_hp(1, false);
- tmp -= 100;
- }
+ make_hungry(food_use, true);
- ASSERT( tmp >= 0 && tmp < 100 );
- you.hit_points_regeneration = static_cast< unsigned char >( tmp );
-
- // XXX: Doing the same as the above, although overflow isn't an
- // issue with magic point regeneration, yet. -- bwr
- tmp = static_cast< int >( you.magic_points_regeneration );
-
- if (you.magic_points < you.max_magic_points)
- tmp += 7 + you.max_magic_points / 2;
-
- while (tmp >= 100)
- {
- inc_mp(1, false);
- tmp -= 100;
- }
-
- ASSERT( tmp >= 0 && tmp < 100 );
- you.magic_points_regeneration = static_cast< unsigned char >( tmp );
+ _regenerate_hp_and_mp();
// If you're wielding a rod, it'll gradually recharge.
_recharge_rods();