OSDN Git Service

[Refactor] #2141 monster_race *r_ptrの宣言をautoに差し替えた
[hengbandforosx/hengbandosx.git] / src / spell-kind / earthquake.cpp
index 1ffd702..a2fa7f9 100644 (file)
@@ -32,6 +32,7 @@
 #include "player/special-defense-types.h"
 #include "status/bad-status-setter.h"
 #include "system/floor-type-definition.h"
+#include "system/grid-type-definition.h"
 #include "system/monster-race-definition.h"
 #include "system/monster-type-definition.h"
 #include "system/player-type-definition.h"
 /*!
  * @brief 地震処理
  * Induce an "earthquake" of the given radius at the given location.
- * @param caster_ptrプレーヤーへの参照ポインタ
+ * @param player_ptrプレイヤーへの参照ポインタ
  * @param cy 中心Y座標
  * @param cx 中心X座標
  * @param r 効果半径
  * @param m_idx 地震を起こしたモンスターID(0ならばプレイヤー)
  * @return 効力があった場合TRUEを返す
  */
-bool earthquake(player_type *caster_ptr, POSITION cy, POSITION cx, POSITION r, MONSTER_IDX m_idx)
+bool earthquake(PlayerType *player_ptr, POSITION cy, POSITION cx, POSITION r, MONSTER_IDX m_idx)
 {
-    floor_type *floor_ptr = caster_ptr->current_floor_ptr;
-    if ((floor_ptr->inside_quest && is_fixed_quest_idx(floor_ptr->inside_quest)) || !floor_ptr->dun_level) {
+    auto *floor_ptr = player_ptr->current_floor_ptr;
+    if ((inside_quest(floor_ptr->quest_number) && quest_type::is_fixed(floor_ptr->quest_number)) || !floor_ptr->dun_level) {
         return false;
     }
 
@@ -89,18 +90,18 @@ bool earthquake(player_type *caster_ptr, POSITION cy, POSITION cx, POSITION r, M
                 continue;
 
             map[16 + yy - cy][16 + xx - cx] = true;
-            if (player_bold(caster_ptr, yy, xx))
+            if (player_bold(player_ptr, yy, xx))
                 hurt = true;
         }
     }
 
     int sn = 0;
     POSITION sy = 0, sx = 0;
-    if (hurt && !has_pass_wall(caster_ptr) && !has_kill_wall(caster_ptr)) {
+    if (hurt && !has_pass_wall(player_ptr) && !has_kill_wall(player_ptr)) {
         for (DIRECTION i = 0; i < 8; i++) {
-            POSITION y = caster_ptr->y + ddy_ddd[i];
-            POSITION x = caster_ptr->x + ddx_ddd[i];
-            if (!is_cave_empty_bold(caster_ptr, y, x))
+            POSITION y = player_ptr->y + ddy_ddd[i];
+            POSITION x = player_ptr->x + ddx_ddd[i];
+            if (!is_cave_empty_bold(player_ptr, y, x))
                 continue;
 
             if (map[16 + y - cy][16 + x - cx])
@@ -136,6 +137,7 @@ bool earthquake(player_type *caster_ptr, POSITION cy, POSITION cx, POSITION r, M
             msg_print(_("あなたはひどい怪我を負った!", "You are severely crushed!"));
             damage = 200;
         } else {
+            BadStatusSetter bss(player_ptr);
             switch (randint1(3)) {
             case 1: {
                 msg_print(_("降り注ぐ岩をうまく避けた!", "You nimbly dodge the blast!"));
@@ -145,34 +147,34 @@ bool earthquake(player_type *caster_ptr, POSITION cy, POSITION cx, POSITION r, M
             case 2: {
                 msg_print(_("岩石があなたに直撃した!", "You are bashed by rubble!"));
                 damage = damroll(10, 4);
-                (void)set_stun(caster_ptr, caster_ptr->stun + randint1(50));
+                (void)bss.mod_stun(randint1(50));
                 break;
             }
             case 3: {
                 msg_print(_("あなたは床と壁との間に挟まれてしまった!", "You are crushed between the floor and ceiling!"));
                 damage = damroll(10, 4);
-                (void)set_stun(caster_ptr, caster_ptr->stun + randint1(50));
+                (void)bss.mod_stun(randint1(50));
                 break;
             }
             }
 
-            (void)move_player_effect(caster_ptr, sy, sx, MPE_DONT_PICKUP);
+            (void)move_player_effect(player_ptr, sy, sx, MPE_DONT_PICKUP);
         }
 
-        map[16 + caster_ptr->y - cy][16 + caster_ptr->x - cx] = false;
+        map[16 + player_ptr->y - cy][16 + player_ptr->x - cx] = false;
         if (damage) {
-            concptr killer;
+            std::string killer;
 
             if (m_idx) {
                 GAME_TEXT m_name[MAX_NLEN];
-                monster_type *m_ptr = &floor_ptr->m_list[m_idx];
-                monster_desc(caster_ptr, m_name, m_ptr, MD_WRONGDOER_NAME);
+                auto *m_ptr = &floor_ptr->m_list[m_idx];
+                monster_desc(player_ptr, m_name, m_ptr, MD_WRONGDOER_NAME);
                 killer = format(_("%sの起こした地震", "an earthquake caused by %s"), m_name);
             } else {
                 killer = _("地震", "an earthquake");
             }
 
-            take_hit(caster_ptr, DAMAGE_ATTACK, damage, killer);
+            take_hit(player_ptr, DAMAGE_ATTACK, damage, killer.c_str());
         }
     }
 
@@ -183,16 +185,16 @@ bool earthquake(player_type *caster_ptr, POSITION cy, POSITION cx, POSITION r, M
             if (!map[16 + yy - cy][16 + xx - cx])
                 continue;
 
-            grid_type *g_ptr;
-            g_ptr = &floor_ptr->grid_array[yy][xx];
-            if (g_ptr->m_idx == caster_ptr->riding)
+            grid_type *gg_ptr;
+            gg_ptr = &floor_ptr->grid_array[yy][xx];
+            if (gg_ptr->m_idx == player_ptr->riding)
                 continue;
 
-            if (!g_ptr->m_idx)
+            if (!gg_ptr->m_idx)
                 continue;
 
-            monster_type *m_ptr = &floor_ptr->m_list[g_ptr->m_idx];
-            monster_race *r_ptr = &r_info[m_ptr->r_idx];
+            auto *m_ptr = &floor_ptr->m_list[gg_ptr->m_idx];
+            auto *r_ptr = &r_info[m_ptr->r_idx];
             if (r_ptr->flags1 & RF1_QUESTOR) {
                 map[16 + yy - cy][16 + xx - cx] = false;
                 continue;
@@ -203,17 +205,18 @@ bool earthquake(player_type *caster_ptr, POSITION cy, POSITION cx, POSITION r, M
 
             GAME_TEXT m_name[MAX_NLEN];
             sn = 0;
-            if (!(r_ptr->flags1 & RF1_NEVER_MOVE)) {
+            if (r_ptr->behavior_flags.has_not(MonsterBehaviorType::NEVER_MOVE)) {
                 for (DIRECTION i = 0; i < 8; i++) {
                     POSITION y = yy + ddy_ddd[i];
                     POSITION x = xx + ddx_ddd[i];
-                    if (!is_cave_empty_bold(caster_ptr, y, x))
+                    if (!is_cave_empty_bold(player_ptr, y, x))
                         continue;
 
-                    if (is_rune_protection_grid(&floor_ptr->grid_array[y][x]))
+                    auto *g_ptr = &floor_ptr->grid_array[y][x];
+                    if (g_ptr->is_rune_protection())
                         continue;
 
-                    if (is_rune_explosion_grid(&floor_ptr->grid_array[y][x]))
+                    if (g_ptr->is_rune_explosion())
                         continue;
 
                     if (pattern_tile(floor_ptr, y, x))
@@ -225,7 +228,7 @@ bool earthquake(player_type *caster_ptr, POSITION cy, POSITION cx, POSITION r, M
                     if (floor_ptr->grid_array[y][x].m_idx)
                         continue;
 
-                    if (player_bold(caster_ptr, y, x))
+                    if (player_bold(player_ptr, y, x))
                         continue;
 
                     sn++;
@@ -238,27 +241,27 @@ bool earthquake(player_type *caster_ptr, POSITION cy, POSITION cx, POSITION r, M
                 }
             }
 
-            monster_desc(caster_ptr, m_name, m_ptr, 0);
-            if (!ignore_unview || is_seen(caster_ptr, m_ptr))
+            monster_desc(player_ptr, m_name, m_ptr, 0);
+            if (!ignore_unview || is_seen(player_ptr, m_ptr))
                 msg_format(_("%^sは苦痛で泣きわめいた!", "%^s wails out in pain!"), m_name);
 
             damage = (sn ? damroll(4, 8) : (m_ptr->hp + 1));
-            (void)set_monster_csleep(caster_ptr, g_ptr->m_idx, 0);
+            (void)set_monster_csleep(player_ptr, gg_ptr->m_idx, 0);
             m_ptr->hp -= damage;
             if (m_ptr->hp < 0) {
-                if (!ignore_unview || is_seen(caster_ptr, m_ptr))
+                if (!ignore_unview || is_seen(player_ptr, m_ptr))
                     msg_format(_("%^sは岩石に埋もれてしまった!", "%^s is embedded in the rock!"), m_name);
 
-                if (g_ptr->m_idx) {
-                    if (record_named_pet && is_pet(&floor_ptr->m_list[g_ptr->m_idx]) && floor_ptr->m_list[g_ptr->m_idx].nickname) {
+                if (gg_ptr->m_idx) {
+                    if (record_named_pet && is_pet(&floor_ptr->m_list[gg_ptr->m_idx]) && floor_ptr->m_list[gg_ptr->m_idx].nickname) {
                         char m2_name[MAX_NLEN];
 
-                        monster_desc(caster_ptr, m2_name, m_ptr, MD_INDEF_VISIBLE);
-                        exe_write_diary(caster_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_EARTHQUAKE, m2_name);
+                        monster_desc(player_ptr, m2_name, m_ptr, MD_INDEF_VISIBLE);
+                        exe_write_diary(player_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_EARTHQUAKE, m2_name);
                     }
                 }
 
-                delete_monster(caster_ptr, yy, xx);
+                delete_monster(player_ptr, yy, xx);
                 sn = 0;
             }
 
@@ -270,9 +273,9 @@ bool earthquake(player_type *caster_ptr, POSITION cy, POSITION cx, POSITION r, M
             floor_ptr->grid_array[sy][sx].m_idx = m_idx_aux;
             m_ptr->fy = sy;
             m_ptr->fx = sx;
-            update_monster(caster_ptr, m_idx_aux, TRUE);
-            lite_spot(caster_ptr, yy, xx);
-            lite_spot(caster_ptr, sy, sx);
+            update_monster(player_ptr, m_idx_aux, true);
+            lite_spot(player_ptr, yy, xx);
+            lite_spot(player_ptr, sy, sx);
         }
     }
 
@@ -287,24 +290,24 @@ bool earthquake(player_type *caster_ptr, POSITION cy, POSITION cx, POSITION r, M
             if (!cave_valid_bold(floor_ptr, yy, xx))
                 continue;
 
-            delete_all_items_from_floor(caster_ptr, yy, xx);
-            int t = cave_has_flag_bold(floor_ptr, yy, xx, FF_PROJECT) ? randint0(100) : 200;
+            delete_all_items_from_floor(player_ptr, yy, xx);
+            int t = cave_has_flag_bold(floor_ptr, yy, xx, FloorFeatureType::PROJECT) ? randint0(100) : 200;
             if (t < 20) {
-                cave_set_feat(caster_ptr, yy, xx, feat_granite);
+                cave_set_feat(player_ptr, yy, xx, feat_granite);
                 continue;
             }
 
             if (t < 70) {
-                cave_set_feat(caster_ptr, yy, xx, feat_quartz_vein);
+                cave_set_feat(player_ptr, yy, xx, feat_quartz_vein);
                 continue;
             }
 
             if (t < 100) {
-                cave_set_feat(caster_ptr, yy, xx, feat_magma_vein);
+                cave_set_feat(player_ptr, yy, xx, feat_magma_vein);
                 continue;
             }
 
-            cave_set_feat(caster_ptr, yy, xx, feat_ground_type[randint0(100)]);
+            cave_set_feat(player_ptr, yy, xx, feat_ground_type[randint0(100)]);
         }
     }
 
@@ -318,14 +321,13 @@ bool earthquake(player_type *caster_ptr, POSITION cy, POSITION cx, POSITION r, M
             if (distance(cy, cx, yy, xx) > r)
                 continue;
 
-            grid_type *g_ptr;
-            g_ptr = &floor_ptr->grid_array[yy][xx];
-            if (is_mirror_grid(g_ptr)) {
+            auto *g_ptr = &floor_ptr->grid_array[yy][xx];
+            if (g_ptr->is_mirror()) {
                 g_ptr->info |= CAVE_GLOW;
                 continue;
             }
 
-            if (d_info[caster_ptr->dungeon_idx].flags.has(DF::DARKNESS))
+            if (d_info[player_ptr->dungeon_idx].flags.has(DungeonFeatureType::DARKNESS))
                 continue;
 
             grid_type *cc_ptr;
@@ -335,7 +337,7 @@ bool earthquake(player_type *caster_ptr, POSITION cy, POSITION cx, POSITION r, M
                 if (!in_bounds2(floor_ptr, yyy, xxx))
                     continue;
                 cc_ptr = &floor_ptr->grid_array[yyy][xxx];
-                if (has_flag(f_info[get_feat_mimic(cc_ptr)].flags, FF_GLOW)) {
+                if (f_info[cc_ptr->get_feat_mimic()].flags.has(FloorFeatureType::GLOW)) {
                     g_ptr->info |= CAVE_GLOW;
                     break;
                 }
@@ -343,12 +345,11 @@ bool earthquake(player_type *caster_ptr, POSITION cy, POSITION cx, POSITION r, M
         }
     }
 
-    caster_ptr->update |= (PU_UN_VIEW | PU_UN_LITE | PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE | PU_MONSTERS);
-    caster_ptr->redraw |= (PR_HEALTH | PR_UHEALTH | PR_MAP);
-    caster_ptr->window_flags |= (PW_OVERHEAD | PW_DUNGEON);
-    if (caster_ptr->special_defense & NINJA_S_STEALTH) {
-        if (floor_ptr->grid_array[caster_ptr->y][caster_ptr->x].info & CAVE_GLOW)
-            set_superstealth(caster_ptr, FALSE);
+    player_ptr->update |= (PU_UN_VIEW | PU_UN_LITE | PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE | PU_MONSTERS);
+    player_ptr->redraw |= (PR_HEALTH | PR_UHEALTH | PR_MAP);
+    player_ptr->window_flags |= (PW_OVERHEAD | PW_DUNGEON);
+    if (floor_ptr->grid_array[player_ptr->y][player_ptr->x].info & CAVE_GLOW) {
+        set_superstealth(player_ptr, false);
     }
 
     return true;