OSDN Git Service

[Refactor] #38844 pet_t_m_idx, riding_t_m_idx を player_type 構造体に移動.
authordeskull <deskull@users.sourceforge.jp>
Mon, 10 Jun 2019 14:36:41 +0000 (23:36 +0900)
committerdeskull <deskull@users.sourceforge.jp>
Mon, 10 Jun 2019 14:36:41 +0000 (23:36 +0900)
src/cmd-pet.c
src/core.c
src/externs.h
src/melee1.c
src/monster-process.c
src/monster2.c
src/mspells2.c
src/player-status.h
src/variable.c

index 0b8e1cf..c493f4e 100644 (file)
@@ -500,10 +500,10 @@ void do_cmd_pet(void)
 
 #ifdef JP
        sprintf(target_buf, "ペットのターゲットを指定 (現在:%s)",
-               (pet_t_m_idx ? (p_ptr->image ? "何か奇妙な物" : (r_name + r_info[current_floor_ptr->m_list[pet_t_m_idx].ap_r_idx].name)) : "指定なし"));
+               (p_ptr->pet_t_m_idx ? (p_ptr->image ? "何か奇妙な物" : (r_name + r_info[current_floor_ptr->m_list[p_ptr->pet_t_m_idx].ap_r_idx].name)) : "指定なし"));
 #else
        sprintf(target_buf, "specify a target of pet (now:%s)",
-               (pet_t_m_idx ? (p_ptr->image ? "something strange" : (r_name + r_info[current_floor_ptr->m_list[pet_t_m_idx].ap_r_idx].name)) : "nothing"));
+               (p_ptr->pet_t_m_idx ? (p_ptr->image ? "something strange" : (r_name + r_info[current_floor_ptr->m_list[p_ptr->pet_t_m_idx].ap_r_idx].name)) : "nothing"));
 #endif
        power_desc[num] = target_buf;
        powers[num++] = PET_TARGET;
@@ -840,16 +840,16 @@ void do_cmd_pet(void)
        case PET_TARGET:
        {
                project_length = -1;
-               if (!target_set(TARGET_KILL)) pet_t_m_idx = 0;
+               if (!target_set(TARGET_KILL)) p_ptr->pet_t_m_idx = 0;
                else
                {
                        grid_type *g_ptr = &current_floor_ptr->grid_array[target_row][target_col];
                        if (g_ptr->m_idx && (current_floor_ptr->m_list[g_ptr->m_idx].ml))
                        {
-                               pet_t_m_idx = current_floor_ptr->grid_array[target_row][target_col].m_idx;
+                               p_ptr->pet_t_m_idx = current_floor_ptr->grid_array[target_row][target_col].m_idx;
                                p_ptr->pet_follow_distance = PET_DESTROY_DIST;
                        }
-                       else pet_t_m_idx = 0;
+                       else p_ptr->pet_t_m_idx = 0;
                }
                project_length = 0;
 
@@ -859,14 +859,14 @@ void do_cmd_pet(void)
        case PET_STAY_CLOSE:
        {
                p_ptr->pet_follow_distance = PET_CLOSE_DIST;
-               pet_t_m_idx = 0;
+               p_ptr->pet_t_m_idx = 0;
                break;
        }
        /* "Follow Me" */
        case PET_FOLLOW_ME:
        {
                p_ptr->pet_follow_distance = PET_FOLLOW_DIST;
-               pet_t_m_idx = 0;
+               p_ptr->pet_t_m_idx = 0;
                break;
        }
        /* "Seek and destoy" */
index 87d106c..235075e 100644 (file)
@@ -4949,8 +4949,8 @@ static void dungeon(bool load_game)
 
        /* Cancel the target */
        target_who = 0;
-       pet_t_m_idx = 0;
-       riding_t_m_idx = 0;
+       p_ptr->pet_t_m_idx = 0;
+       p_ptr->riding_t_m_idx = 0;
        p_ptr->ambush_flag = FALSE;
 
        /* Cancel the health bar */
index f089e07..7b78092 100644 (file)
@@ -56,6 +56,3 @@ extern bool repair_objects;
 
 
 extern player_type *p_ptr;
-
-extern MONSTER_IDX pet_t_m_idx;
-extern MONSTER_IDX riding_t_m_idx;
index 6561497..9747a89 100644 (file)
@@ -2306,7 +2306,7 @@ bool py_attack(POSITION y, POSITION x, COMBAT_OPTION_IDX mode)
                }
        }
 
-       riding_t_m_idx = g_ptr->m_idx;
+       p_ptr->riding_t_m_idx = g_ptr->m_idx;
        if (p_ptr->migite) py_attack_aux(y, x, &fear, &mdeath, 0, mode);
        if (p_ptr->hidarite && !mdeath) py_attack_aux(y, x, &fear, &mdeath, 1, mode);
 
index 45bfd8e..94f8d9b 100644 (file)
@@ -59,15 +59,15 @@ static bool get_enemy_dir(MONSTER_IDX m_idx, int *mm)
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
        monster_type *t_ptr;
 
-       if (riding_t_m_idx && player_bold(m_ptr->fy, m_ptr->fx))
+       if (p_ptr->riding_t_m_idx && player_bold(m_ptr->fy, m_ptr->fx))
        {
-               y = current_floor_ptr->m_list[riding_t_m_idx].fy;
-               x = current_floor_ptr->m_list[riding_t_m_idx].fx;
+               y = current_floor_ptr->m_list[p_ptr->riding_t_m_idx].fy;
+               x = current_floor_ptr->m_list[p_ptr->riding_t_m_idx].fx;
        }
-       else if (is_pet(m_ptr) && pet_t_m_idx)
+       else if (is_pet(m_ptr) && p_ptr->pet_t_m_idx)
        {
-               y = current_floor_ptr->m_list[pet_t_m_idx].fy;
-               x = current_floor_ptr->m_list[pet_t_m_idx].fx;
+               y = current_floor_ptr->m_list[p_ptr->pet_t_m_idx].fy;
+               x = current_floor_ptr->m_list[p_ptr->pet_t_m_idx].fx;
        }
        else
        {
index f5c71bf..3228ed1 100644 (file)
@@ -140,8 +140,8 @@ void delete_monster_idx(MONSTER_IDX i)
        /* Hack -- remove tracked monster */
        if (i == p_ptr->health_who) health_track(0);
 
-       if (pet_t_m_idx == i ) pet_t_m_idx = 0;
-       if (riding_t_m_idx == i) riding_t_m_idx = 0;
+       if (p_ptr->pet_t_m_idx == i ) p_ptr->pet_t_m_idx = 0;
+       if (p_ptr->riding_t_m_idx == i) p_ptr->riding_t_m_idx = 0;
        if (p_ptr->riding == i) p_ptr->riding = 0;
 
        /* Monster is gone */
@@ -237,8 +237,8 @@ static void compact_monsters_aux(MONSTER_IDX i1, MONSTER_IDX i2)
        if (target_who == i1) target_who = i2;
 
        /* Hack -- Update the target */
-       if (pet_t_m_idx == i1) pet_t_m_idx = i2;
-       if (riding_t_m_idx == i1) riding_t_m_idx = i2;
+       if (p_ptr->pet_t_m_idx == i1) p_ptr->pet_t_m_idx = i2;
+       if (p_ptr->riding_t_m_idx == i1) p_ptr->riding_t_m_idx = i2;
 
        /* Hack -- Update the riding */
        if (p_ptr->riding == i1) p_ptr->riding = i2;
@@ -434,8 +434,8 @@ void wipe_m_list(void)
 
        /* Hack -- no more target */
        target_who = 0;
-       pet_t_m_idx = 0;
-       riding_t_m_idx = 0;
+       p_ptr->pet_t_m_idx = 0;
+       p_ptr->riding_t_m_idx = 0;
 
        /* Hack -- no more tracking */
        health_track(0);
index 9967c8c..e71647b 100644 (file)
@@ -313,9 +313,9 @@ bool monst_spell_monst(MONSTER_IDX m_idx)
        f6 = r_ptr->a_ability_flags2;
 
        /* Target is given for pet? */
-       if (pet_t_m_idx && pet)
+       if (p_ptr->pet_t_m_idx && pet)
        {
-               target_idx = pet_t_m_idx;
+               target_idx = p_ptr->pet_t_m_idx;
                t_ptr = &current_floor_ptr->m_list[target_idx];
 
                /* Cancel if not projectable (for now) */
@@ -336,7 +336,7 @@ bool monst_spell_monst(MONSTER_IDX m_idx)
 
                        /* Cancel if neither enemy nor a given target */
                        if ((m_idx == target_idx) ||
-                           ((target_idx != pet_t_m_idx) && !are_enemies(m_ptr, t_ptr)))
+                           ((target_idx != p_ptr->pet_t_m_idx) && !are_enemies(m_ptr, t_ptr)))
                        {
                                target_idx = 0;
                        }
index 3356b4d..00c7628 100644 (file)
@@ -544,6 +544,8 @@ struct player_type
        POSITION run_px;
        DIRECTION fishing_dir;
 
+       MONSTER_IDX pet_t_m_idx;
+       MONSTER_IDX riding_t_m_idx;
 
        /*** Extracted fields ***/
 
index 6336fd4..589d292 100644 (file)
@@ -31,6 +31,3 @@ player_type p_body;
 player_type *p_ptr = &p_body;
 
 
-MONSTER_IDX pet_t_m_idx;
-MONSTER_IDX riding_t_m_idx;
-