OSDN Git Service

[Refactor] #37353 行動パワー消費解除を take_turn() で再定義。 / Redefine free_turn() for non-consump...
authorDeskull <deskull@users.sourceforge.jp>
Thu, 31 Jan 2019 15:07:58 +0000 (00:07 +0900)
committerDeskull <deskull@users.sourceforge.jp>
Thu, 31 Jan 2019 15:07:58 +0000 (00:07 +0900)
14 files changed:
src/bldg.c
src/cmd-activate.c
src/cmd-item.c
src/cmd-magiceat.c
src/cmd-pet.c
src/dungeon.c
src/mutation.c
src/player-move.c
src/player-status.c
src/player-status.h
src/racial.c
src/shoot.c
src/wild.c
src/wizard2.c

index ad8b82d..3a36eef 100644 (file)
@@ -4271,7 +4271,7 @@ void do_cmd_bldg(void)
                        command_new = SPECIAL_KEY_BUILDING;
 
                        /* No energy needed to re-enter the arena */
-                       p_ptr->energy_use = 0;
+                       free_turn(p_ptr);
                }
 
                return;
@@ -4288,7 +4288,7 @@ void do_cmd_bldg(void)
                command_new = SPECIAL_KEY_BUILDING;
 
                /* No energy needed to re-enter the arena */
-               p_ptr->energy_use = 0;
+               free_turn(p_ptr);
 
                return;
        }
index 4cc510a..3808389 100644 (file)
@@ -155,7 +155,7 @@ void do_cmd_activate_aux(INVENTORY_IDX item)
                ((o_ptr->sval == SV_LITE_TORCH) || (o_ptr->sval == SV_LITE_LANTERN)))
        {
                msg_print(_("燃料がない。", "It has no fuel."));
-               p_ptr->energy_use = 0;
+               free_turn(p_ptr);
                return;
        }
 
@@ -1639,7 +1639,7 @@ bool activate_artifact(object_type *o_ptr)
                        GAME_TEXT m_name[MAX_NLEN];
                        monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
                        msg_format(_("%sが邪魔だ!", "%^s is stand in your way."), m_name);
-                       p_ptr->energy_use = 0;
+                       free_turn(p_ptr);
                        return FALSE;
                }
                set_action(ACTION_FISH);
index 80bbf0d..6fd0679 100644 (file)
@@ -733,7 +733,7 @@ void do_cmd_destroy(void)
        /* Artifacts cannot be destroyed */
        if (!can_player_destroy_object(o_ptr))
        {
-               p_ptr->energy_use = 0;
+               free_turn(p_ptr);
 
                msg_format(_("%sは破壊不可能だ。", "You cannot destroy %s."), o_name);
                return;
index 59d99f0..d77a821 100644 (file)
@@ -518,7 +518,7 @@ bool do_cmd_magic_eater(bool only_browse, bool powerful)
        item = select_magic_eater(only_browse);
        if (item == -1)
        {
-               p_ptr->energy_use = 0;
+               free_turn(p_ptr);
                return FALSE;
        }
        if (item >= EATER_EXT*2) {tval = TV_ROD;sval = item - EATER_EXT*2;}
index c8a0113..222fe6d 100644 (file)
@@ -844,7 +844,7 @@ void do_cmd_pet(void)
                /* Abort if needed */
                if (!flag)
                {
-                       p_ptr->energy_use = 0;
+                       free_turn(p_ptr);
                        return;
                }
 
index 01eeabf..dcef50e 100644 (file)
@@ -593,7 +593,7 @@ static void pattern_teleport(void)
        if (record_stair) do_cmd_write_nikki(NIKKI_PAT_TELE, 0, NULL);
 
        p_ptr->inside_quest = 0;
-       p_ptr->energy_use = 0;
+       free_turn(p_ptr);
 
        /*
         * Clear all saved floors
@@ -4220,12 +4220,12 @@ static void process_command(void)
                                                which_power = _("祈り", "prayer");
 
                                        msg_format(_("反魔法バリアが%sを邪魔した!", "An anti-magic shell disrupts your %s!"), which_power);
-                                       p_ptr->energy_use = 0;
+                                       free_turn(p_ptr);
                                }
                                else if (p_ptr->shero && (p_ptr->pclass != CLASS_BERSERKER))
                                {
                                        msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
-                                       p_ptr->energy_use = 0;
+                                       free_turn(p_ptr);
                                }
                                else
                                {
@@ -4981,7 +4981,7 @@ static void process_player(void)
                if (!command_new) command_see = FALSE;
 
                /* Assume free turn */
-               p_ptr->energy_use = 0;
+               free_turn(p_ptr);
 
                if (p_ptr->inside_battle)
                {
index c5030e7..9295874 100644 (file)
@@ -17,6 +17,7 @@
 #include "selfinfo.h"
 #include "spells-summon.h"
 #include "avatar.h"
+#include "player-status.h"
 
 /*!
  * @brief プレイヤーに突然変異を与える
@@ -2348,7 +2349,7 @@ bool mutation_power_aux(int power)
                        break;
 
                default:
-                       p_ptr->energy_use = 0;
+                       free_turn(p_ptr);
                        msg_format(_("能力 %s は実装されていません。", "Power %s not implemented. Oops."), power);
        }
 
index 147ea2e..2210faa 100644 (file)
@@ -943,7 +943,7 @@ bool move_player_effect(POSITION ny, POSITION nx, BIT_FLAGS mpe_mode)
        {
                disturb(FALSE, TRUE);
 
-               p_ptr->energy_use = 0;
+               free_turn(p_ptr);
                /* Hack -- Enter store */
                command_new = SPECIAL_KEY_STORE;
        }
@@ -953,7 +953,7 @@ bool move_player_effect(POSITION ny, POSITION nx, BIT_FLAGS mpe_mode)
        {
                disturb(FALSE, TRUE);
 
-               p_ptr->energy_use = 0;
+               free_turn(p_ptr);
                /* Hack -- Enter building */
                command_new = SPECIAL_KEY_BUILDING;
        }
@@ -963,7 +963,7 @@ bool move_player_effect(POSITION ny, POSITION nx, BIT_FLAGS mpe_mode)
        {
                disturb(FALSE, TRUE);
 
-               p_ptr->energy_use = 0;
+               free_turn(p_ptr);
                /* Hack -- Enter quest level */
                command_new = SPECIAL_KEY_QUEST;
        }
@@ -1260,7 +1260,7 @@ void move_player(DIRECTION dir, bool do_pickup, bool break_trap)
                        else
                        {
                                msg_format(_("%^sが邪魔だ!", "%^s is in your way!"), m_name);
-                               p_ptr->energy_use = 0;
+                               free_turn(p_ptr);
                                oktomove = FALSE;
                        }
 
@@ -1278,7 +1278,7 @@ void move_player(DIRECTION dir, bool do_pickup, bool break_trap)
                if (riding_r_ptr->flags1 & RF1_NEVER_MOVE)
                {
                        msg_print(_("動けない!", "Can't move!"));
-                       p_ptr->energy_use = 0;
+                       free_turn(p_ptr);
                        oktomove = FALSE;
                        disturb(FALSE, TRUE);
                }
@@ -1308,21 +1308,21 @@ void move_player(DIRECTION dir, bool do_pickup, bool break_trap)
                        (have_flag(f_ptr->flags, FF_DEEP) || (riding_r_ptr->flags2 & RF2_AURA_FIRE)))
                {
                        msg_format(_("%sの上に行けない。", "Can't swim."), f_name + f_info[get_feat_mimic(c_ptr)].name);
-                       p_ptr->energy_use = 0;
+                       free_turn(p_ptr);
                        oktomove = FALSE;
                        disturb(FALSE, TRUE);
                }
                else if (!have_flag(f_ptr->flags, FF_WATER) && (riding_r_ptr->flags7 & RF7_AQUATIC))
                {
                        msg_format(_("%sから上がれない。", "Can't land."), f_name + f_info[get_feat_mimic(&cave[p_ptr->y][p_ptr->x])].name);
-                       p_ptr->energy_use = 0;
+                       free_turn(p_ptr);
                        oktomove = FALSE;
                        disturb(FALSE, TRUE);
                }
                else if (have_flag(f_ptr->flags, FF_LAVA) && !(riding_r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK))
                {
                        msg_format(_("%sの上に行けない。", "Too hot to go through."), f_name + f_info[get_feat_mimic(c_ptr)].name);
-                       p_ptr->energy_use = 0;
+                       free_turn(p_ptr);
                        oktomove = FALSE;
                        disturb(FALSE, TRUE);
                }
@@ -1344,7 +1344,7 @@ void move_player(DIRECTION dir, bool do_pickup, bool break_trap)
        else if (!have_flag(f_ptr->flags, FF_MOVE) && have_flag(f_ptr->flags, FF_CAN_FLY) && !p_ptr->levitation)
        {
                msg_format(_("空を飛ばないと%sの上には行けない。", "You need to fly to go through the %s."), f_name + f_info[get_feat_mimic(c_ptr)].name);
-               p_ptr->energy_use = 0;
+               free_turn(p_ptr);
                running = 0;
                oktomove = FALSE;
        }
@@ -1413,7 +1413,7 @@ void move_player(DIRECTION dir, bool do_pickup, bool break_trap)
                        {
                                msg_print(_("それ以上先には進めない。", "You cannot go any more."));
                                if (!(p_ptr->confused || p_ptr->stun || p_ptr->image))
-                                       p_ptr->energy_use = 0;
+                                       free_turn(p_ptr);
                        }
 
                        /* Wall (or secret door) */
@@ -1435,7 +1435,7 @@ void move_player(DIRECTION dir, bool do_pickup, bool break_trap)
                                 * typing mistakes should not cost you a turn...
                                 */
                                if (!(p_ptr->confused || p_ptr->stun || p_ptr->image))
-                                       p_ptr->energy_use = 0;
+                                       free_turn(p_ptr);
                        }
                }
 
@@ -1449,7 +1449,7 @@ void move_player(DIRECTION dir, bool do_pickup, bool break_trap)
        {
                if (!(p_ptr->confused || p_ptr->stun || p_ptr->image))
                {
-                       p_ptr->energy_use = 0;
+                       free_turn(p_ptr);
                }
 
                /* To avoid a loop with running */
index 0d19df6..a86c463 100644 (file)
@@ -3816,3 +3816,8 @@ void take_turn(player_type *creature_ptr, PERCENTAGE need_cost)
 {
        p_ptr->energy_use = (ENERGY)need_cost;
 }
+
+void free_turn(player_type *creature_ptr)
+{
+       p_ptr->energy_use = 0;
+}
index cf85b2e..10991db 100644 (file)
@@ -14,3 +14,4 @@ extern BIT_FLAGS16 empty_hands(bool riding_control);
 extern bool player_has_no_spellbooks(void);
 
 extern void take_turn(player_type *creature_ptr, PERCENTAGE need_cost);
+extern void free_turn(player_type *creature_ptr);
\ No newline at end of file
index 49fa292..7d6ff76 100644 (file)
@@ -310,13 +310,13 @@ static int racial_aux(power_desc_type *pd_ptr)
                msg_format(_("この能力を使用するにはレベル %d に達していなければなりません。", 
                                         "You need to attain level %d to use this power."), min_level);
 
-               p_ptr->energy_use = 0;
+               free_turn(p_ptr);
                return FALSE;
        }
 
        if (cmd_limit_confused(p_ptr))
        {
-               p_ptr->energy_use = 0;
+               free_turn(p_ptr);
                return FALSE;
        }
 
@@ -325,7 +325,7 @@ static int racial_aux(power_desc_type *pd_ptr)
        {
                if (!get_check(_("本当に今の衰弱した状態でこの能力を使いますか?", "Really use the power in your weakened state? ")))
                {
-                       p_ptr->energy_use = 0;
+                       free_turn(p_ptr);
                        return FALSE;
                }
        }
@@ -570,7 +570,7 @@ static bool cmd_racial_power_aux(s32b command)
                        {
                                set_action(ACTION_LEARN);
                        }
-                       p_ptr->energy_use = 0;
+                       free_turn(p_ptr);
                        break;
                }
                case CLASS_CAVALRY:
@@ -799,7 +799,7 @@ static bool cmd_racial_power_aux(s32b command)
 
                default:
                        msg_print(_("この種族は特殊な能力を持っていません。", "This race has no bonus power."));
-                       p_ptr->energy_use = 0;
+                       free_turn(p_ptr);
        }
        }
        return TRUE;
@@ -834,7 +834,7 @@ void do_cmd_racial_power(void)
 
        if (cmd_limit_confused(p_ptr))
        {
-               p_ptr->energy_use = 0;
+               free_turn(p_ptr);
                return;
        }
 
@@ -1818,7 +1818,7 @@ if (!repeat_pull(&i) || i<0 || i>=num) {
                                case '0':
                                {
                                        screen_load();
-                                       p_ptr->energy_use = 0;
+                                       free_turn(p_ptr);
                                        return;
                                }
 
@@ -1982,7 +1982,7 @@ if (!repeat_pull(&i) || i<0 || i>=num) {
        /* Abort if needed */
        if (!flag)
        {
-               p_ptr->energy_use = 0;
+               free_turn(p_ptr);
                return;
        }
        repeat_push(i);
@@ -2024,7 +2024,7 @@ if (!repeat_pull(&i) || i<0 || i>=num) {
                        p_ptr->window |= (PW_PLAYER | PW_SPELL);
                }
        }
-       else p_ptr->energy_use = 0;
+       else free_turn(p_ptr);
 
        /* Success */
        return;
index f4c6bfc..0b99807 100644 (file)
@@ -3,6 +3,7 @@
 #include "monster-status.h"
 #include "artifact.h"
 #include "avatar.h"
+#include "player-status.h"
 
 #include "shoot.h"
 /*!
@@ -420,7 +421,7 @@ void exe_fire(INVENTORY_IDX item, object_type *j_ptr)
        /* Get a direction (or cancel) */
        if (!get_aim_dir(&dir))
        {
-               p_ptr->energy_use = 0;
+               free_turn(p_ptr);
 
                if (snipe_type == SP_AWAY) snipe_type = SP_NONE;
 
@@ -448,7 +449,7 @@ void exe_fire(INVENTORY_IDX item, object_type *j_ptr)
        /* Don't shoot at my feet */
        if (tx == p_ptr->x && ty == p_ptr->y)
        {
-               p_ptr->energy_use = 0;
+               free_turn(p_ptr);
 
                /* project_length is already reset to 0 */
 
index 48e7712..68ebe46 100644 (file)
@@ -14,6 +14,7 @@
 #include "world.h"
 #include "monster.h"
 #include "realm-hex.h"
+#include "player-status.h"
 
 /*!
  * @brief 地形生成確率を決める要素100の配列を確率テーブルから作成する
@@ -1150,7 +1151,7 @@ bool change_wild_mode(void)
 #else
                msg_print("You cannot enter global map, since there is some monsters nearby!");
 #endif
-               p_ptr->energy_use = 0;
+               free_turn(p_ptr);
                return FALSE;
        }
 
@@ -1164,7 +1165,7 @@ bool change_wild_mode(void)
 
                if (!get_check_strict(msg, CHECK_OKAY_CANCEL))
                {
-                       p_ptr->energy_use = 0;
+                       free_turn(p_ptr);
                        return FALSE;
                }
        }
index ca8ab1b..b5f989e 100644 (file)
@@ -18,6 +18,7 @@
 #include "mutation.h"
 #include "quest.h"
 #include "artifact.h"
+#include "player-status.h"
 
 
 /*!
@@ -1472,7 +1473,7 @@ static void do_cmd_wiz_jump(void)
        if (record_stair) do_cmd_write_nikki(NIKKI_WIZ_TELE,0,NULL);
 
        p_ptr->inside_quest = 0;
-       p_ptr->energy_use = 0;
+       free_turn(p_ptr);
 
        /* Prevent energy_need from being too lower than 0 */
        p_ptr->energy_need = 0;