OSDN Git Service

[Fix] #963 Resolved the indication that update_player_turn_energy() should be divided...
[hengbandforosx/hengbandosx.git] / src / action / open-close-execution.cpp
index de8fc5a..7bfdf43 100644 (file)
@@ -1,4 +1,5 @@
 /*!
+ * @file open-close-execution.cpp 
  * @brief 扉や箱を開ける処理
  * @date 2020/07/11
  * @author Hourier
 #include "main/sound-definitions-table.h"
 #include "main/sound-of-music.h"
 #include "perception/object-perception.h"
+#include "player-status/player-energy.h"
 #include "player/player-status-table.h"
 #include "specific-object/chest.h"
 #include "status/bad-status-setter.h"
 #include "status/experience.h"
 #include "system/floor-type-definition.h"
 #include "system/object-type-definition.h"
+#include "system/player-type-definition.h"
 #include "term/screen-processor.h"
 #include "util/bit-flags-calculator.h"
 #include "view/display-messages.h"
@@ -36,9 +39,9 @@ bool exe_open(player_type *creature_ptr, POSITION y, POSITION x)
 {
     grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
     feature_type *f_ptr = &f_info[g_ptr->feat];
-    take_turn(creature_ptr, 100);
+    PlayerEnergy(creature_ptr).set_player_turn_energy(100);
     if (!has_flag(f_ptr->flags, FF_OPEN)) {
-        msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(g_ptr)].name);
+        msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_info[get_feat_mimic(g_ptr)].name.c_str());
         return FALSE;
     }
 
@@ -75,8 +78,7 @@ bool exe_open(player_type *creature_ptr, POSITION y, POSITION x)
     return FALSE;
 }
 
-/*
- * todo 常にFALSEを返している
+/*!
  * @brief 「閉じる」動作コマンドのサブルーチン /
  * Perform the basic "close" command
  * @param y 対象を行うマスのY座標
@@ -86,17 +88,18 @@ bool exe_open(player_type *creature_ptr, POSITION y, POSITION x)
  * Assume destination is an open/broken door
  * Assume there is no monster blocking the destination
  * Returns TRUE if repeated commands may continue
+ * @todo 常にFALSEを返している
  */
 bool exe_close(player_type *creature_ptr, POSITION y, POSITION x)
 {
     grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
     FEAT_IDX old_feat = g_ptr->feat;
     bool more = FALSE;
-    take_turn(creature_ptr, 100);
+    PlayerEnergy(creature_ptr).set_player_turn_energy(100);
     if (!has_flag(f_info[old_feat].flags, FF_CLOSE))
         return more;
 
-    s16b closed_feat = feat_state(creature_ptr, old_feat, FF_CLOSE);
+    s16b closed_feat = feat_state(creature_ptr->current_floor_ptr, old_feat, FF_CLOSE);
     if ((g_ptr->o_idx || (g_ptr->info & CAVE_OBJECT)) && (closed_feat != old_feat) && !has_flag(f_info[closed_feat].flags, FF_DROP)) {
         msg_print(_("何かがつっかえて閉まらない。", "Something prevents it from closing."));
     } else {
@@ -134,7 +137,7 @@ bool easy_open_door(player_type *creature_ptr, POSITION y, POSITION x)
         return FALSE;
 
     if (!has_flag(f_ptr->flags, FF_OPEN)) {
-        msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_name + f_info[get_feat_mimic(g_ptr)].name);
+        msg_format(_("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck."), f_info[get_feat_mimic(g_ptr)].name.c_str());
     } else if (f_ptr->power) {
         i = creature_ptr->skill_dis;
         if (creature_ptr->blind || no_lite(creature_ptr))
@@ -185,7 +188,7 @@ bool exe_disarm_chest(player_type *creature_ptr, POSITION y, POSITION x, OBJECT_
 {
     bool more = FALSE;
     object_type *o_ptr = &creature_ptr->current_floor_ptr->o_list[o_idx];
-    take_turn(creature_ptr, 100);
+    PlayerEnergy(creature_ptr).set_player_turn_energy(100);
     int i = creature_ptr->skill_dis;
     if (creature_ptr->blind || no_lite(creature_ptr))
         i = i / 10;
@@ -241,11 +244,11 @@ bool exe_disarm(player_type *creature_ptr, POSITION y, POSITION x, DIRECTION dir
 {
     grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
     feature_type *f_ptr = &f_info[g_ptr->feat];
-    concptr name = (f_name + f_ptr->name);
+    concptr name = f_ptr->name.c_str();
     int power = f_ptr->power;
     bool more = FALSE;
     int i = creature_ptr->skill_dis;
-    take_turn(creature_ptr, 100);
+    PlayerEnergy(creature_ptr).set_player_turn_energy(100);
     if (creature_ptr->blind || no_lite(creature_ptr))
         i = i / 10;
 
@@ -296,8 +299,8 @@ bool exe_bash(player_type *creature_ptr, POSITION y, POSITION x, DIRECTION dir)
     int bash = adj_str_blow[creature_ptr->stat_index[A_STR]];
     int temp = f_ptr->power;
     bool more = FALSE;
-    concptr name = f_name + f_info[get_feat_mimic(g_ptr)].name;
-    take_turn(creature_ptr, 100);
+    concptr name = f_info[get_feat_mimic(g_ptr)].name.c_str();
+    PlayerEnergy(creature_ptr).set_player_turn_energy(100);
     msg_format(_("%sに体当たりをした!", "You smash into the %s!"), name);
     temp = (bash - (temp * 10));
     if (creature_ptr->pclass == CLASS_BERSERKER)
@@ -309,7 +312,7 @@ bool exe_bash(player_type *creature_ptr, POSITION y, POSITION x, DIRECTION dir)
     if (randint0(100) < temp) {
         msg_format(_("%sを壊した!", "The %s crashes open!"), name);
         sound(has_flag(f_ptr->flags, FF_GLASS) ? SOUND_GLASS : SOUND_OPENDOOR);
-        if ((randint0(100) < 50) || (feat_state(creature_ptr, g_ptr->feat, FF_OPEN) == g_ptr->feat) || has_flag(f_ptr->flags, FF_GLASS)) {
+        if ((randint0(100) < 50) || (feat_state(creature_ptr->current_floor_ptr, g_ptr->feat, FF_OPEN) == g_ptr->feat) || has_flag(f_ptr->flags, FF_GLASS)) {
             cave_alter_feat(creature_ptr, y, x, FF_BASH);
         } else {
             cave_alter_feat(creature_ptr, y, x, FF_OPEN);
@@ -325,4 +328,4 @@ bool exe_bash(player_type *creature_ptr, POSITION y, POSITION x, DIRECTION dir)
     }
 
     return more;
-}
\ No newline at end of file
+}