OSDN Git Service

[Refactor] #38824 グローバル変数 select_the_force を処理。 / Refactor select_the_force, a global...
authorDeskull <deskull@users.sourceforge.jp>
Sun, 30 Dec 2018 06:27:15 +0000 (15:27 +0900)
committerDeskull <deskull@users.sourceforge.jp>
Sun, 30 Dec 2018 06:27:15 +0000 (15:27 +0900)
src/cmd5.c
src/defines.h
src/object1.c

index 78235fe..92a0a11 100644 (file)
@@ -33,9 +33,6 @@ cptr spell_category_name(OBJECT_TYPE_VALUE tval)
        }
 }
 
-
-bool select_the_force = FALSE;
-
 /*!
  * @brief 領域魔法の閲覧、学習、使用選択するインターフェイス処理
  * Allow user to choose a spell/prayer from the given book.
@@ -458,7 +455,6 @@ void do_cmd_browse(void)
                        confirm_use_force(TRUE);
                        return;
                }
-               select_the_force = TRUE;
        }
 
        /* Restrict choices to "useful" books */
@@ -468,7 +464,7 @@ void do_cmd_browse(void)
        q = _("どの本を読みますか? ", "Browse which book? ");
        s = _("読める本がない。", "You have no books that you can read.");
 
-       o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
+       o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR | (p_ptr->pclass == CLASS_FORCETRAINER ? USE_FORCE : 0)));
        if (!o_ptr)
        {
                if (item == INVEN_FORCE) /* the_force */
@@ -476,10 +472,8 @@ void do_cmd_browse(void)
                        do_cmd_mind_browse();
                        return;
                }
-               select_the_force = FALSE;
                return;
        }
-       select_the_force = FALSE;
 
        /* Access the item's sval */
        sval = o_ptr->sval;
@@ -909,7 +903,6 @@ void do_cmd_cast(void)
                        confirm_use_force(FALSE);
                        return;
                }
-               select_the_force = TRUE;
        }
 
        prayer = spell_category_name(mp_ptr->spell_book);
@@ -920,7 +913,7 @@ void do_cmd_cast(void)
        q = _("どの呪文書を使いますか? ", "Use which book? ");
        s = _("呪文書がない!", "You have no spell books!");
 
-       o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
+       o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR | (p_ptr->pclass == CLASS_FORCETRAINER ? USE_FORCE : 0)));
        if (!o_ptr)
        {
                if (item == INVEN_FORCE) /* the_force */
@@ -928,10 +921,8 @@ void do_cmd_cast(void)
                        do_cmd_mind();
                        return;
                }
-               select_the_force = FALSE;
                return;
        }
-       select_the_force = FALSE;
 
        /* Access the item's sval */
        sval = o_ptr->sval;
index e50dff2..5826b74 100644 (file)
 #define USE_EQUIP      0x01    /*!< アイテム選択範囲: 装備品からの選択を許可する / Allow equip items */
 #define USE_INVEN      0x02    /*!< アイテム選択範囲: 所持品からの選択を許可する /  Allow inven items */
 #define USE_FLOOR      0x04    /*!< アイテム選択範囲: 床下のアイテムからの選択を許可する /  Allow floor items */
+#define USE_FORCE      0x08    /*!< 特殊: wキーで錬気術への切り替えを許可する */
 
 
 /*
index 2d23298..6eb8b28 100644 (file)
@@ -2726,9 +2726,6 @@ bool get_item(OBJECT_IDX *cp, cptr pmt, cptr str, BIT_FLAGS mode)
        char tmp_val[160];
        char out_val[160];
 
-       /* See cmd5.c */
-       extern bool select_the_force;
-
        int menu_line = (use_menu ? 1 : 0);
        int max_inven = 0;
        int max_equip = 0;
@@ -2747,7 +2744,7 @@ bool get_item(OBJECT_IDX *cp, cptr pmt, cptr str, BIT_FLAGS mode)
        if (repeat_pull(cp))
        {
                /* the_force */
-               if (select_the_force && (*cp == INVEN_FORCE))
+               if (mode & USE_FORCE && (*cp == INVEN_FORCE))
                {
                        item_tester_tval = 0;
                        item_tester_hook = NULL;
@@ -2893,12 +2890,10 @@ bool get_item(OBJECT_IDX *cp, cptr pmt, cptr str, BIT_FLAGS mode)
        {
                /* Cancel p_ptr->command_see */
                command_see = FALSE;
-
                oops = TRUE;
-
                done = TRUE;
 
-               if (select_the_force) {
+               if (mode & USE_FORCE) {
                    *cp = INVEN_FORCE;
                    item = TRUE;
                }
@@ -3052,7 +3047,7 @@ bool get_item(OBJECT_IDX *cp, cptr pmt, cptr str, BIT_FLAGS mode)
 
                /* Indicate legality of the "floor" item */
                if (allow_floor) strcat(out_val, _(" '-'床上,", " - for floor,"));
-               if (select_the_force) strcat(out_val, _(" 'w'練気術,", " w for the Force,"));
+               if (mode & USE_FORCE) strcat(out_val, _(" 'w'練気術,", " w for the Force,"));
 
                /* Finish the prompt */
                strcat(out_val, " ESC");
@@ -3162,7 +3157,7 @@ bool get_item(OBJECT_IDX *cp, cptr pmt, cptr str, BIT_FLAGS mode)
                        }
                        case 'w':
                        {
-                               if (select_the_force) {
+                               if (mode & USE_FORCE) {
                                        *cp = INVEN_FORCE;
                                        item = TRUE;
                                        done = TRUE;
@@ -3351,7 +3346,7 @@ bool get_item(OBJECT_IDX *cp, cptr pmt, cptr str, BIT_FLAGS mode)
 
                        case 'w':
                        {
-                               if (select_the_force) {
+                               if (mode & USE_FORCE) {
                                        *cp = INVEN_FORCE;
                                        item = TRUE;
                                        done = TRUE;
@@ -3718,6 +3713,7 @@ bool get_item_floor(COMMAND_CODE *cp, cptr pmt, cptr str, BIT_FLAGS mode)
        bool equip = (mode & USE_EQUIP) ? TRUE : FALSE;
        bool inven = (mode & USE_INVEN) ? TRUE : FALSE;
        bool floor = (mode & USE_FLOOR) ? TRUE : FALSE;
+       bool force = (mode & USE_FORCE) ? TRUE : FALSE;
 
        bool allow_equip = FALSE;
        bool allow_inven = FALSE;
@@ -3733,8 +3729,6 @@ bool get_item_floor(COMMAND_CODE *cp, cptr pmt, cptr str, BIT_FLAGS mode)
        int floor_top = 0;
        TERM_LEN min_width = 0;
 
-       extern bool select_the_force;
-
        int menu_line = (use_menu ? 1 : 0);
        int max_inven = 0;
        int max_equip = 0;
@@ -3746,7 +3740,7 @@ bool get_item_floor(COMMAND_CODE *cp, cptr pmt, cptr str, BIT_FLAGS mode)
        if (repeat_pull(cp))
        {
                /* the_force */
-               if (select_the_force && (*cp == INVEN_FORCE))
+               if (force && (*cp == INVEN_FORCE))
                {
                        item_tester_tval = 0;
                        item_tester_hook = NULL;
@@ -3913,12 +3907,10 @@ bool get_item_floor(COMMAND_CODE *cp, cptr pmt, cptr str, BIT_FLAGS mode)
        {
                /* Cancel p_ptr->command_see */
                command_see = FALSE;
-
                oops = TRUE;
-
                done = TRUE;
 
-               if (select_the_force) {
+               if (force) {
                    *cp = INVEN_FORCE;
                    item = TRUE;
                }
@@ -4171,7 +4163,7 @@ bool get_item_floor(COMMAND_CODE *cp, cptr pmt, cptr str, BIT_FLAGS mode)
                }
 
                /* Append */
-               if (select_the_force) strcat(out_val, _(" 'w'練気術,", " w for the Force,"));
+               if (force) strcat(out_val, _(" 'w'練気術,", " w for the Force,"));
 
                /* Finish the prompt */
                strcat(out_val, " ESC");
@@ -4370,7 +4362,7 @@ bool get_item_floor(COMMAND_CODE *cp, cptr pmt, cptr str, BIT_FLAGS mode)
                        }
                        case 'w':
                        {
-                               if (select_the_force) {
+                               if (force) {
                                        *cp = INVEN_FORCE;
                                        item = TRUE;
                                        done = TRUE;
@@ -4673,7 +4665,7 @@ bool get_item_floor(COMMAND_CODE *cp, cptr pmt, cptr str, BIT_FLAGS mode)
 
                        case 'w':
                        {
-                               if (select_the_force) {
+                               if (force) {
                                        *cp = INVEN_FORCE;
                                        item = TRUE;
                                        done = TRUE;