From 2dce29e965aa7eb9d72c6d3dec8a3ed2dd9201c8 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Sat, 18 Sep 2021 20:23:20 +0300 Subject: [PATCH] Move Pw regen into separate routine --- src/allmain.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/src/allmain.c b/src/allmain.c index 6270fada6..92f25d34b 100644 --- a/src/allmain.c +++ b/src/allmain.c @@ -17,6 +17,7 @@ static void u_calc_moveamt(int); #ifdef POSITIONBAR static void do_positionbar(void); #endif +static void regen_pw(int); static void regen_hp(int); static void interrupt_multi(const char *); static void debug_fields(const char *); @@ -258,19 +259,7 @@ moveloop_core(void) } } - if (u.uen < u.uenmax - && ((mvl_wtcap < MOD_ENCUMBER - && (!(g.moves % ((MAXULEV + 8 - u.ulevel) - * (Role_if(PM_WIZARD) ? 3 : 4) - / 6)))) || Energy_regeneration)) { - u.uen += rn1( - (int) (ACURR(A_WIS) + ACURR(A_INT)) / 15 + 1, 1); - if (u.uen > u.uenmax) - u.uen = u.uenmax; - g.context.botl = TRUE; - if (u.uen == u.uenmax) - interrupt_multi("You feel full of energy."); - } + regen_pw(mvl_wtcap); if (!u.uinvulnerable) { if (Teleportation && !rn2(85)) { @@ -506,6 +495,25 @@ moveloop(boolean resuming) } } +static void +regen_pw(int wtcap) +{ + if (u.uen < u.uenmax + && ((wtcap < MOD_ENCUMBER + && (!(g.moves % ((MAXULEV + 8 - u.ulevel) + * (Role_if(PM_WIZARD) ? 3 : 4) + / 6)))) || Energy_regeneration)) { + int upper = (int) (ACURR(A_WIS) + ACURR(A_INT)) / 15 + 1; + + u.uen += rn1(upper, 1); + if (u.uen > u.uenmax) + u.uen = u.uenmax; + g.context.botl = TRUE; + if (u.uen == u.uenmax) + interrupt_multi("You feel full of energy."); + } +} + #define U_CAN_REGEN() (Regeneration || (Sleepy && u.usleep)) /* maybe recover some lost health (or lose some when an eel out of water) */ -- 2.50.1