OSDN Git Service

[Refactor] #37353 岩を喰う処理を mutation.c から eat_lock() へ分離。
authorDeskull <deskull@users.sourceforge.jp>
Fri, 9 Nov 2018 10:54:16 +0000 (19:54 +0900)
committerDeskull <deskull@users.sourceforge.jp>
Fri, 9 Nov 2018 10:54:16 +0000 (19:54 +0900)
Separate eat_lock() from mutation.c.

src/externs.h
src/mutation.c
src/spells3.c

index 0fc8538..c644887 100644 (file)
@@ -1081,6 +1081,7 @@ extern bool dimension_door(void);
 extern bool mirror_tunnel(void);
 extern bool summon_kin_player(DEPTH level, POSITION y, POSITION x, BIT_FLAGS mode);
 extern void massacre(void);
+extern bool eat_lock(void);
 
 /* store.c */
 extern bool combine_and_reorder_home(int store_num);
index 96cadc4..ec964a6 100644 (file)
@@ -2140,68 +2140,7 @@ bool mutation_power_aux(int power)
                        break;
 
                case MUT1_EAT_ROCK:
-                       {
-                               POSITION x, y;
-                               cave_type *c_ptr;
-                               feature_type *f_ptr, *mimic_f_ptr;
-
-                               if (!get_rep_dir2(&dir)) return FALSE;
-                               y = p_ptr->y + ddy[dir];
-                               x = p_ptr->x + ddx[dir];
-                               c_ptr = &cave[y][x];
-                               f_ptr = &f_info[c_ptr->feat];
-                               mimic_f_ptr = &f_info[get_feat_mimic(c_ptr)];
-
-                               stop_mouth();
-
-                               if (!have_flag(mimic_f_ptr->flags, FF_HURT_ROCK))
-                               {
-                                       msg_print(_("この地形は食べられない。", "You cannot eat this feature."));
-                                       break;
-                               }
-                               else if (have_flag(f_ptr->flags, FF_PERMANENT))
-                               {
-                                       msg_format(_("いてっ!この%sはあなたの歯より硬い!", "Ouch!  This %s is harder than your teeth!"), f_name + mimic_f_ptr->name);
-                                       break;
-                               }
-                               else if (c_ptr->m_idx)
-                               {
-                                       monster_type *m_ptr = &m_list[c_ptr->m_idx];
-                                       msg_print(_("何かが邪魔しています!", "There's something in the way!"));
-
-                                       if (!m_ptr->ml || !is_pet(m_ptr)) py_attack(y, x, 0);
-                                       break;
-                               }
-                               else if (have_flag(f_ptr->flags, FF_TREE))
-                               {
-                                       msg_print(_("木の味は好きじゃない!", "You don't like the woody taste!"));
-                                       break;
-                               }
-                               else if (have_flag(f_ptr->flags, FF_GLASS))
-                               {
-                                       msg_print(_("ガラスの味は好きじゃない!", "You don't like the glassy taste!"));
-                                       break;
-                               }
-                               else if (have_flag(f_ptr->flags, FF_DOOR) || have_flag(f_ptr->flags, FF_CAN_DIG))
-                               {
-                                       (void)set_food(p_ptr->food + 3000);
-                               }
-                               else if (have_flag(f_ptr->flags, FF_MAY_HAVE_GOLD) || have_flag(f_ptr->flags, FF_HAS_GOLD))
-                               {
-                                       (void)set_food(p_ptr->food + 5000);
-                               }
-                               else
-                               {
-                                       msg_format(_("この%sはとてもおいしい!", "This %s is very filling!"), f_name + mimic_f_ptr->name);
-                                       (void)set_food(p_ptr->food + 10000);
-                               }
-
-                               /* Destroy the wall */
-                               cave_alter_feat(y, x, FF_HURT_ROCK);
-
-                               /* Move the player */
-                               (void)move_player_effect(y, x, MPE_DONT_PICKUP);
-                       }
+                       return eat_lock();
                        break;
 
                case MUT1_SWAP_POS:
index 28aeca1..ffef072 100644 (file)
@@ -5635,3 +5635,64 @@ void massacre(void)
                        py_attack(y, x, 0);
        }
 }
+
+bool eat_lock(void)
+{
+       POSITION x, y;
+       cave_type *c_ptr;
+       feature_type *f_ptr, *mimic_f_ptr;
+       DIRECTION dir;
+
+       if (!get_rep_dir2(&dir)) return FALSE;
+       y = p_ptr->y + ddy[dir];
+       x = p_ptr->x + ddx[dir];
+       c_ptr = &cave[y][x];
+       f_ptr = &f_info[c_ptr->feat];
+       mimic_f_ptr = &f_info[get_feat_mimic(c_ptr)];
+
+       stop_mouth();
+
+       if (!have_flag(mimic_f_ptr->flags, FF_HURT_ROCK))
+       {
+               msg_print(_("この地形は食べられない。", "You cannot eat this feature."));
+       }
+       else if (have_flag(f_ptr->flags, FF_PERMANENT))
+       {
+               msg_format(_("いてっ!この%sはあなたの歯より硬い!", "Ouch!  This %s is harder than your teeth!"), f_name + mimic_f_ptr->name);
+       }
+       else if (c_ptr->m_idx)
+       {
+               monster_type *m_ptr = &m_list[c_ptr->m_idx];
+               msg_print(_("何かが邪魔しています!", "There's something in the way!"));
+
+               if (!m_ptr->ml || !is_pet(m_ptr)) py_attack(y, x, 0);
+       }
+       else if (have_flag(f_ptr->flags, FF_TREE))
+       {
+               msg_print(_("木の味は好きじゃない!", "You don't like the woody taste!"));
+       }
+       else if (have_flag(f_ptr->flags, FF_GLASS))
+       {
+               msg_print(_("ガラスの味は好きじゃない!", "You don't like the glassy taste!"));
+       }
+       else if (have_flag(f_ptr->flags, FF_DOOR) || have_flag(f_ptr->flags, FF_CAN_DIG))
+       {
+               (void)set_food(p_ptr->food + 3000);
+       }
+       else if (have_flag(f_ptr->flags, FF_MAY_HAVE_GOLD) || have_flag(f_ptr->flags, FF_HAS_GOLD))
+       {
+               (void)set_food(p_ptr->food + 5000);
+       }
+       else
+       {
+               msg_format(_("この%sはとてもおいしい!", "This %s is very filling!"), f_name + mimic_f_ptr->name);
+               (void)set_food(p_ptr->food + 10000);
+       }
+
+       /* Destroy the wall */
+       cave_alter_feat(y, x, FF_HURT_ROCK);
+
+       /* Move the player */
+       (void)move_player_effect(y, x, MPE_DONT_PICKUP);
+       return TRUE;
+}