OSDN Git Service

[Refactor] #38997 inc_stat(), do_res_stat() に player_type * 引数を追加.
authordeskull <deskull@users.sourceforge.jp>
Thu, 20 Jun 2019 14:31:15 +0000 (23:31 +0900)
committerdeskull <deskull@users.sourceforge.jp>
Thu, 20 Jun 2019 14:37:06 +0000 (23:37 +0900)
src/cmd-eat.c
src/cmd-quaff.c
src/cmd-usestaff.c
src/player-effects.c
src/player-effects.h
src/spells-status.c

index f65a1af..03b9f52 100644 (file)
@@ -218,13 +218,13 @@ void exe_eat_food(INVENTORY_IDX item)
 
                case SV_FOOD_RESTORE_STR:
                {
-                       if (do_res_stat(A_STR)) ident = TRUE;
+                       if (do_res_stat(p_ptr, A_STR)) ident = TRUE;
                        break;
                }
 
                case SV_FOOD_RESTORE_CON:
                {
-                       if (do_res_stat(A_CON)) ident = TRUE;
+                       if (do_res_stat(p_ptr, A_CON)) ident = TRUE;
                        break;
                }
 
index ec0c638..a6e0b2e 100644 (file)
@@ -345,27 +345,27 @@ void exe_quaff_potion(INVENTORY_IDX item)
                        break;
 
                case SV_POTION_RES_STR:
-                       if (do_res_stat(A_STR)) ident = TRUE;
+                       if (do_res_stat(p_ptr, A_STR)) ident = TRUE;
                        break;
 
                case SV_POTION_RES_INT:
-                       if (do_res_stat(A_INT)) ident = TRUE;
+                       if (do_res_stat(p_ptr, A_INT)) ident = TRUE;
                        break;
 
                case SV_POTION_RES_WIS:
-                       if (do_res_stat(A_WIS)) ident = TRUE;
+                       if (do_res_stat(p_ptr, A_WIS)) ident = TRUE;
                        break;
 
                case SV_POTION_RES_DEX:
-                       if (do_res_stat(A_DEX)) ident = TRUE;
+                       if (do_res_stat(p_ptr, A_DEX)) ident = TRUE;
                        break;
 
                case SV_POTION_RES_CON:
-                       if (do_res_stat(A_CON)) ident = TRUE;
+                       if (do_res_stat(p_ptr, A_CON)) ident = TRUE;
                        break;
 
                case SV_POTION_RES_CHR:
-                       if (do_res_stat(A_CHR)) ident = TRUE;
+                       if (do_res_stat(p_ptr, A_CHR)) ident = TRUE;
                        break;
 
                case SV_POTION_INC_STR:
index 3eded54..95dc6cc 100644 (file)
@@ -177,7 +177,7 @@ int staff_effect(OBJECT_SUBTYPE_VALUE sval, bool *use_charge, bool powerful, boo
 
                case SV_STAFF_THE_MAGI:
                {
-                       if (do_res_stat(A_INT)) ident = TRUE;
+                       if (do_res_stat(p_ptr, A_INT)) ident = TRUE;
                        ident |= restore_mana(FALSE);
                        if (set_shero(0, TRUE)) ident = TRUE;
                        break;
index b83a71a..98dba22 100644 (file)
@@ -3213,15 +3213,15 @@ bool set_food(TIME_EFFECT v)
  * Note that this function (used by stat potions) now restores\n
  * the stat BEFORE increasing it.\n
  */
-bool inc_stat(int stat)
+bool inc_stat(player_type *creature_ptr, int stat)
 {
        BASE_STATUS value, gain;
 
        /* Then augment the current/max stat */
-       value = p_ptr->stat_cur[stat];
+       value = creature_ptr->stat_cur[stat];
 
        /* Cannot go above 18/100 */
-       if (value < p_ptr->stat_max_max[stat])
+       if (value < creature_ptr->stat_max_max[stat])
        {
                /* Gain one (sometimes two) points */
                if (value < 18)
@@ -3231,17 +3231,17 @@ bool inc_stat(int stat)
                }
 
                /* Gain 1/6 to 1/3 of distance to 18/100 */
-               else if (value < (p_ptr->stat_max_max[stat]-2))
+               else if (value < (creature_ptr->stat_max_max[stat]-2))
                {
                        /* Approximate gain value */
-                       gain = (((p_ptr->stat_max_max[stat]) - value) / 2 + 3) / 2;
+                       gain = (((creature_ptr->stat_max_max[stat]) - value) / 2 + 3) / 2;
                        if (gain < 1) gain = 1;
 
                        /* Apply the bonus */
                        value += randint1(gain) + gain / 2;
 
                        /* Maximal value */
-                       if (value > (p_ptr->stat_max_max[stat]-1)) value = p_ptr->stat_max_max[stat]-1;
+                       if (value > (creature_ptr->stat_max_max[stat]-1)) value = creature_ptr->stat_max_max[stat]-1;
                }
 
                /* Gain one point at a time */
@@ -3251,14 +3251,14 @@ bool inc_stat(int stat)
                }
 
                /* Save the new value */
-               p_ptr->stat_cur[stat] = value;
+               creature_ptr->stat_cur[stat] = value;
 
                /* Bring up the maximum too */
-               if (value > p_ptr->stat_max[stat])
+               if (value > creature_ptr->stat_max[stat])
                {
-                       p_ptr->stat_max[stat] = value;
+                       creature_ptr->stat_max[stat] = value;
                }
-               p_ptr->update |= (PU_BONUS);
+               creature_ptr->update |= (PU_BONUS);
 
                /* Success */
                return (TRUE);
@@ -3554,13 +3554,12 @@ bool do_dec_stat(player_type *creature_ptr, int stat)
 /*
  * Restore lost "points" in a stat
  */
-bool do_res_stat(int stat)
+bool do_res_stat(player_type *creature_ptr, int stat)
 {
        /* Attempt to increase */
-       if (res_stat(p_ptr, stat))
+       if (res_stat(creature_ptr, stat))
        {
                msg_format(_("元通りに%sなった気がする。", "You feel less %s."), desc_stat_pos[stat]);
-
                return (TRUE);
        }
 
@@ -3580,7 +3579,7 @@ bool do_inc_stat(int stat)
        res = res_stat(p_ptr, stat);
 
        /* Attempt to increase */
-       if (inc_stat(stat))
+       if (inc_stat(p_ptr, stat))
        {
                if (stat == A_WIS)
                {
index 8e4ace3..2610a26 100644 (file)
@@ -57,12 +57,12 @@ extern bool set_oppose_pois(TIME_EFFECT v, bool do_dec);
 extern bool set_stun(TIME_EFFECT v);
 extern bool set_cut(TIME_EFFECT v);
 extern bool set_food(TIME_EFFECT v);
-extern bool inc_stat(int stat);
+extern bool inc_stat(player_type *creature_ptr, int stat);
 extern bool dec_stat(player_type *creature_ptr, int stat, int amount, int permanent);
 extern bool res_stat(player_type *creature_ptr, int stat);
 extern bool hp_player(int num);
 extern bool do_dec_stat(player_type *creature_ptr, int stat);
-extern bool do_res_stat(int stat);
+extern bool do_res_stat(player_type *creature_ptr, int stat);
 extern bool do_inc_stat(int stat);
 extern bool restore_level(void);
 extern bool lose_all_info(void);
index 6fed51f..ba37074 100644 (file)
@@ -395,12 +395,12 @@ bool_hack restore_mana(bool_hack magic_eater)
 bool restore_all_status(void)
 {
        bool ident = FALSE;
-       if (do_res_stat(A_STR)) ident = TRUE;
-       if (do_res_stat(A_INT)) ident = TRUE;
-       if (do_res_stat(A_WIS)) ident = TRUE;
-       if (do_res_stat(A_DEX)) ident = TRUE;
-       if (do_res_stat(A_CON)) ident = TRUE;
-       if (do_res_stat(A_CHR)) ident = TRUE;
+       if (do_res_stat(p_ptr, A_STR)) ident = TRUE;
+       if (do_res_stat(p_ptr, A_INT)) ident = TRUE;
+       if (do_res_stat(p_ptr, A_WIS)) ident = TRUE;
+       if (do_res_stat(p_ptr, A_DEX)) ident = TRUE;
+       if (do_res_stat(p_ptr, A_CON)) ident = TRUE;
+       if (do_res_stat(p_ptr, A_CHR)) ident = TRUE;
        return ident;
 }