OSDN Git Service

[Refactor] #963 Separated take_turn() and free_turn() from player-status.cpp/h to...
[hengbandforosx/hengbandosx.git] / src / action / open-close-execution.cpp
index 7f9b44a..ceb563c 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"
@@ -38,7 +41,7 @@ bool exe_open(player_type *creature_ptr, POSITION y, POSITION x)
     feature_type *f_ptr = &f_info[g_ptr->feat];
     take_turn(creature_ptr, 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,6 +88,7 @@ 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)
 {
@@ -96,7 +99,7 @@ bool exe_close(player_type *creature_ptr, POSITION y, POSITION x)
     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))
@@ -241,7 +244,7 @@ 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;
@@ -293,10 +296,10 @@ bool exe_bash(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];
-    int bash = adj_str_blow[creature_ptr->stat_ind[A_STR]];
+    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;
+    concptr name = f_info[get_feat_mimic(g_ptr)].name.c_str();
     take_turn(creature_ptr, 100);
     msg_format(_("%sに体当たりをした!", "You smash into the %s!"), name);
     temp = (bash - (temp * 10));
@@ -309,14 +312,14 @@ 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);
         }
 
         exe_movement(creature_ptr, dir, FALSE, FALSE);
-    } else if (randint0(100) < adj_dex_safe[creature_ptr->stat_ind[A_DEX]] + creature_ptr->lev) {
+    } else if (randint0(100) < adj_dex_safe[creature_ptr->stat_index[A_DEX]] + creature_ptr->lev) {
         msg_format(_("この%sは頑丈だ。", "The %s holds firm."), name);
         more = TRUE;
     } else {
@@ -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
+}