OSDN Git Service

練気術師が魔法書を持たなかったり盲目で魔法書を使えない場合は'w'かESC
authornothere <nothere@0568b783-4c39-0410-ac80-bf13821ea2a2>
Fri, 26 Dec 2003 14:44:24 +0000 (14:44 +0000)
committernothere <nothere@0568b783-4c39-0410-ac80-bf13821ea2a2>
Fri, 26 Dec 2003 14:44:24 +0000 (14:44 +0000)
だけを受け付けるプロンプトを通すように変更. これにより, マクロやキー
入力スタックを壊すことがなくなる. 関連して, 以下の修正を含む.
* easy_floor有効時に床上アイテムを選択する画面にすると, "'w'練気術"
  が表示されなくなるバグを修正. また, easy_floor有効時と無効時両方で,
  プロンプト中の "'w'練気術" の位置は "ESC" の直前になるように統一.

src/cmd5.c
src/object1.c

index a74e48e..c815845 100644 (file)
@@ -51,7 +51,7 @@ cptr spell_category_name(int tval)
  * The "known" should be TRUE for cast/pray, FALSE for study
  */
 
-bool select_the_force=FALSE;
+bool select_the_force = FALSE;
 
 static int get_spell(int *sn, cptr prompt, int sval, bool learned, int use_realm)
 {
@@ -361,6 +361,79 @@ static bool item_tester_learn_spell(object_type *o_ptr)
 }
 
 
+static bool player_has_no_spellbooks(void)
+{
+       int         i;
+       object_type *o_ptr;
+
+       for (i = 0; i < INVEN_PACK; i++)
+       {
+               o_ptr = &inventory[i];
+               if (o_ptr->k_idx && check_book_realm(o_ptr->tval, o_ptr->sval)) return FALSE;
+       }
+
+       for (i = cave[py][px].o_idx; i; i = o_ptr->next_o_idx)
+       {
+               o_ptr = &o_list[i];
+               if (o_ptr->k_idx && check_book_realm(o_ptr->tval, o_ptr->sval)) return FALSE;
+       }
+
+       return TRUE;
+}
+
+
+static void confirm_use_force(bool browse_only)
+{
+       int  item;
+       char which;
+
+#ifdef ALLOW_REPEAT
+
+       /* Get the item index */
+       if (repeat_pull(&item) && (item == INVEN_FORCE))
+       {
+               browse_only ? do_cmd_mind_browse() : do_cmd_mind();
+               return;
+       }
+
+#endif /* ALLOW_REPEAT */
+
+       /* Show the prompt */
+#ifdef JP
+       prt("('w'Îýµ¤½Ñ, ESC) 'w'¤«ESC¤ò²¡¤·¤Æ¤¯¤À¤µ¤¤¡£ ", 0, 0);
+#else
+       prt("(w for the Force, ESC) Hit 'w' or ESC. ", 0, 0);
+#endif
+
+       while (1)
+       {
+               /* Get a key */
+               which = inkey();
+
+               if (which == ESCAPE) break;
+               else if (which == 'w')
+               {
+
+#ifdef ALLOW_REPEAT
+
+                       repeat_push(INVEN_FORCE);
+
+#endif /* ALLOW_REPEAT */
+
+                       break;
+               }
+       }
+
+       /* Clear the prompt line */
+       prt("", 0, 0);
+
+       if (which == 'w')
+       {
+               browse_only ? do_cmd_mind_browse() : do_cmd_mind();
+       }
+}
+
+
 /*
  * Peruse the spells/prayers in a book
  *
@@ -386,7 +459,7 @@ void do_cmd_browse(void)
        if (!(p_ptr->realm1 || p_ptr->realm2) && (p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE))
        {
 #ifdef JP
-msg_print("ËܤòÆɤळ¤È¤¬¤Ç¤­¤Ê¤¤¡ª");
+               msg_print("ËܤòÆɤळ¤È¤¬¤Ç¤­¤Ê¤¤¡ª");
 #else
                msg_print("You cannot read books!");
 #endif
@@ -399,37 +472,48 @@ msg_print("
                set_action(ACTION_NONE);
        }
 
+       if (p_ptr->pclass == CLASS_FORCETRAINER)
+       {
+               if (player_has_no_spellbooks())
+               {
+                       confirm_use_force(TRUE);
+                       return;
+               }
+               select_the_force = TRUE;
+       }
+
        /* Restrict choices to "useful" books */
        if (p_ptr->realm2 == REALM_NONE) item_tester_tval = mp_ptr->spell_book;
        else item_tester_hook = item_tester_learn_spell;
 
        /* Get an item */
 #ifdef JP
-q = "¤É¤ÎËܤòÆɤߤޤ¹¤«? ";
+       q = "¤É¤ÎËܤòÆɤߤޤ¹¤«? ";
 #else
        q = "Browse which book? ";
 #endif
 
 #ifdef JP
-s = "Æɤá¤ëËܤ¬¤Ê¤¤¡£";
+       s = "Æɤá¤ëËܤ¬¤Ê¤¤¡£";
 #else
        s = "You have no books that you can read.";
 #endif
 
-       if (p_ptr->pclass == CLASS_FORCETRAINER)
-               select_the_force = TRUE;
-       if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))){
-           select_the_force = FALSE;
-           return;
+       if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR)))
+       {
+               select_the_force = FALSE;
+               return;
        }
        select_the_force = FALSE;
 
-       if (item == INVEN_FORCE) { /* the_force */
-           do_cmd_mind_browse();
-           return;
-       } else
+       if (item == INVEN_FORCE) /* the_force */
+       {
+               do_cmd_mind_browse();
+               return;
+       }
+
        /* Get the item (in the pack) */
-       if (item >= 0)
+       else if (item >= 0)
        {
                o_ptr = &inventory[item];
        }
@@ -4671,7 +4755,7 @@ void do_cmd_cast(void)
        if (!p_ptr->realm1 && (p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE))
        {
 #ifdef JP
-msg_print("¼öʸ¤ò¾§¤¨¤é¤ì¤Ê¤¤¡ª");
+               msg_print("¼öʸ¤ò¾§¤¨¤é¤ì¤Ê¤¤¡ª");
 #else
                msg_print("You cannot cast spells!");
 #endif
@@ -4682,15 +4766,16 @@ msg_print("
        /* Require lite */
        if (p_ptr->blind || no_lite())
        {
+               if (p_ptr->pclass == CLASS_FORCETRAINER) confirm_use_force(FALSE);
+               else
+               {
 #ifdef JP
-msg_print("Ìܤ¬¸«¤¨¤Ê¤¤¡ª");
+                       msg_print("Ìܤ¬¸«¤¨¤Ê¤¤¡ª");
 #else
-               msg_print("You cannot see!");
+                       msg_print("You cannot see!");
 #endif
-               if (p_ptr->pclass == CLASS_FORCETRAINER)
-                   do_cmd_mind();
-               else
                        flush();
+               }
                return;
        }
 
@@ -4698,7 +4783,7 @@ msg_print("
        if (p_ptr->confused)
        {
 #ifdef JP
-msg_print("º®Í𤷤Ƥ¤¤Æ¾§¤¨¤é¤ì¤Ê¤¤¡ª");
+               msg_print("º®Í𤷤Ƥ¤¤Æ¾§¤¨¤é¤ì¤Ê¤¤¡ª");
 #else
                msg_print("You are too confused!");
 #endif
@@ -4706,6 +4791,16 @@ msg_print("
                return;
        }
 
+       if (p_ptr->pclass == CLASS_FORCETRAINER)
+       {
+               if (player_has_no_spellbooks())
+               {
+                       confirm_use_force(FALSE);
+                       return;
+               }
+               select_the_force = TRUE;
+       }
+
        prayer = spell_category_name(mp_ptr->spell_book);
 
        /* Restrict choices to spell books */
@@ -4713,31 +4808,32 @@ msg_print("
 
        /* Get an item */
 #ifdef JP
-q = "¤É¤Î¼öʸ½ñ¤ò»È¤¤¤Þ¤¹¤«? ";
+       q = "¤É¤Î¼öʸ½ñ¤ò»È¤¤¤Þ¤¹¤«? ";
 #else
        q = "Use which book? ";
 #endif
 
 #ifdef JP
-s = "¼öʸ½ñ¤¬¤Ê¤¤¡ª";
+       s = "¼öʸ½ñ¤¬¤Ê¤¤¡ª";
 #else
        s = "You have no spell books!";
 #endif
 
-       if (p_ptr->pclass == CLASS_FORCETRAINER)
-               select_the_force = TRUE;
-       if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))){
-           select_the_force = FALSE;
-           return;
+       if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR)))
+       {
+               select_the_force = FALSE;
+               return;
        }
        select_the_force = FALSE;
 
-       if (item == INVEN_FORCE) { /* the_force */
-           do_cmd_mind();
-           return;
-       } else
+       if (item == INVEN_FORCE) /* the_force */
+       {
+               do_cmd_mind();
+               return;
+       }
+
        /* Get the item (in the pack) */
-       if (item >= 0)
+       else if (item >= 0)
        {
                o_ptr = &inventory[item];
        }
index f6ffcc0..7e61655 100644 (file)
@@ -5692,22 +5692,20 @@ bool get_item(int *cp, cptr pmt, cptr str, int mode)
                {
                        /* Begin the prompt */
 #ifdef JP
-sprintf(out_val, "»ý¤Áʪ:");
+                       sprintf(out_val, "»ý¤Áʪ:");
 #else
                        sprintf(out_val, "Inven:");
 #endif
 
-
                        /* Some legal items */
                        if ((i1 <= i2) && !use_menu)
                        {
                                /* Build the prompt */
 #ifdef JP
-sprintf(tmp_val, "%c-%c,'(',')',",
+                               sprintf(tmp_val, "%c-%c,'(',')',",
 #else
                                sprintf(tmp_val, " %c-%c,'(',')',",
 #endif
-
                                        index_to_label(i1), index_to_label(i2));
 
                                /* Append */
@@ -5716,23 +5714,17 @@ sprintf(tmp_val, "%c-%c,'(',')',",
 
                        /* Indicate ability to "view" */
 #ifdef JP
-if (!command_see && !use_menu) strcat(out_val, " '*'°ìÍ÷,");
+                       if (!command_see && !use_menu) strcat(out_val, " '*'°ìÍ÷,");
 #else
                        if (!command_see && !use_menu) strcat(out_val, " * to see,");
 #endif
 
-
                        /* Append */
 #ifdef JP
-if (equip) strcat(out_val, format(" %s ÁõÈ÷ÉÊ,", use_menu ? "'4'or'6'" : "'/'"));
-else if (select_the_force)
-       strcat(out_val, " 'w'Îýµ¤½Ñ,");
+                       if (equip) strcat(out_val, format(" %s ÁõÈ÷ÉÊ,", use_menu ? "'4'or'6'" : "'/'"));
 #else
-if (equip) strcat(out_val, format(" %s for Equip,", use_menu ? "4 or 6" : "/"));
-else if (select_the_force)
-       strcat(out_val, " w for the Force,");
+                       if (equip) strcat(out_val, format(" %s for Equip,", use_menu ? "4 or 6" : "/"));
 #endif
-
                }
 
                /* Viewing equipment */
@@ -5740,22 +5732,20 @@ else if (select_the_force)
                {
                        /* Begin the prompt */
 #ifdef JP
-sprintf(out_val, "ÁõÈ÷ÉÊ:");
+                       sprintf(out_val, "ÁõÈ÷ÉÊ:");
 #else
                        sprintf(out_val, "Equip:");
 #endif
 
-
                        /* Some legal items */
                        if ((e1 <= e2) && !use_menu)
                        {
                                /* Build the prompt */
 #ifdef JP
-sprintf(tmp_val, "%c-%c,'(',')',",
+                               sprintf(tmp_val, "%c-%c,'(',')',",
 #else
                                sprintf(tmp_val, " %c-%c,'(',')',",
 #endif
-
                                        index_to_label(e1), index_to_label(e2));
 
                                /* Append */
@@ -5764,29 +5754,28 @@ sprintf(tmp_val, "%c-%c,'(',')',",
 
                        /* Indicate ability to "view" */
 #ifdef JP
-if (!command_see && !use_menu) strcat(out_val, " '*'°ìÍ÷,");
+                       if (!command_see && !use_menu) strcat(out_val, " '*'°ìÍ÷,");
 #else
                        if (!command_see) strcat(out_val, " * to see,");
 #endif
 
-
                        /* Append */
 #ifdef JP
-if (inven) strcat(out_val, format(" %s »ý¤Áʪ,", use_menu ? "'4'or'6'" : "'/'"));
+                       if (inven) strcat(out_val, format(" %s »ý¤Áʪ,", use_menu ? "'4'or'6'" : "'/'"));
 #else
-if (inven) strcat(out_val, format(" %s for Inven,", use_menu ? "4 or 6" : "'/'"));
+                       if (inven) strcat(out_val, format(" %s for Inven,", use_menu ? "4 or 6" : "'/'"));
 #endif
-
                }
 
                /* Indicate legality of the "floor" item */
 #ifdef JP
-if (allow_floor) strcat(out_val, " '-'¾²¾å,");
+               if (allow_floor) strcat(out_val, " '-'¾²¾å,");
+               if (select_the_force) strcat(out_val, " 'w'Îýµ¤½Ñ,");
 #else
                if (allow_floor) strcat(out_val, " - for floor,");
+               if (select_the_force) strcat(out_val, " w for the Force,");
 #endif
 
-
                /* Finish the prompt */
                strcat(out_val, " ESC");
 
@@ -5796,7 +5785,6 @@ if (allow_floor) strcat(out_val, " '-'
                /* Show the prompt */
                prt(tmp_val, 0, 0);
 
-
                /* Get a key */
                which = inkey();
 
@@ -6747,7 +6735,7 @@ bool get_item_floor(int *cp, cptr pmt, cptr str, int mode)
                {
                        /* Begin the prompt */
 #ifdef JP
-sprintf(out_val, "»ý¤Áʪ:");
+                       sprintf(out_val, "»ý¤Áʪ:");
 #else
                        sprintf(out_val, "Inven:");
 #endif
@@ -6756,11 +6744,10 @@ sprintf(out_val, "
                        {
                                /* Build the prompt */
 #ifdef JP
-sprintf(tmp_val, "%c-%c,'(',')',",
+                               sprintf(tmp_val, "%c-%c,'(',')',",
 #else
                                sprintf(tmp_val, " %c-%c,'(',')',",
 #endif
-
                                        index_to_label(i1), index_to_label(i2));
 
                                /* Append */
@@ -6769,38 +6756,30 @@ sprintf(tmp_val, "%c-%c,'(',')',",
 
                        /* Indicate ability to "view" */
 #ifdef JP
-if (!command_see && !use_menu) strcat(out_val, " '*'°ìÍ÷,");
+                       if (!command_see && !use_menu) strcat(out_val, " '*'°ìÍ÷,");
 #else
                        if (!command_see && !use_menu) strcat(out_val, " * to see,");
 #endif
 
-
                        /* Append */
-#ifdef JP
                        if (allow_equip)
                        {
+#ifdef JP
                                if (!use_menu)
                                        strcat(out_val, " '/' ÁõÈ÷ÉÊ,");
                                else if (allow_floor)
                                        strcat(out_val, " '6' ÁõÈ÷ÉÊ,");
                                else
                                        strcat(out_val, " '4'or'6' ÁõÈ÷ÉÊ,");
-                       }
-                       else if (select_the_force)
-                               strcat(out_val, " 'w'Îýµ¤½Ñ,");
 #else
-                       if (allow_equip)
-                       {
                                if (!use_menu)
                                        strcat(out_val, " / for Equip,");
                                else if (allow_floor)
                                        strcat(out_val, " 6 for Equip,");
                                else
                                        strcat(out_val, " 4 or 6 for Equip,");
-                       }
-                       else if (select_the_force)
-                               strcat(out_val, " w for the Force,");
 #endif
+                       }
 
                        /* Append */
                        if (allow_floor)
@@ -6821,7 +6800,6 @@ if (!command_see && !use_menu) strcat(out_val, " '*'
                                        strcat(out_val, " 4 or 6 for floor,");
 #endif
                        }
-
                }
 
                /* Viewing equipment */
@@ -6829,21 +6807,19 @@ if (!command_see && !use_menu) strcat(out_val, " '*'
                {
                        /* Begin the prompt */
 #ifdef JP
-sprintf(out_val, "ÁõÈ÷ÉÊ:");
+                       sprintf(out_val, "ÁõÈ÷ÉÊ:");
 #else
                        sprintf(out_val, "Equip:");
 #endif
 
-
                        if (!use_menu)
                        {
                                /* Build the prompt */
 #ifdef JP
-sprintf(tmp_val, "%c-%c,'(',')',",
+                               sprintf(tmp_val, "%c-%c,'(',')',",
 #else
                                sprintf(tmp_val, " %c-%c,'(',')',",
 #endif
-
                                        index_to_label(e1), index_to_label(e2));
 
                                /* Append */
@@ -6852,12 +6828,11 @@ sprintf(tmp_val, "%c-%c,'(',')',",
 
                        /* Indicate ability to "view" */
 #ifdef JP
-if (!command_see && !use_menu) strcat(out_val, " '*'°ìÍ÷,");
+                       if (!command_see && !use_menu) strcat(out_val, " '*'°ìÍ÷,");
 #else
                        if (!command_see && !use_menu) strcat(out_val, " * to see,");
 #endif
 
-
                        /* Append */
                        if (allow_inven)
                        {
@@ -6869,7 +6844,6 @@ if (!command_see && !use_menu) strcat(out_val, " '*'
                                else
                                        strcat(out_val, " '4'or'6' »ý¤Áʪ,");
 #else
-
                                if (!use_menu)
                                        strcat(out_val, " / for Inven,");
                                else if (allow_floor)
@@ -6910,29 +6884,26 @@ if (!command_see && !use_menu) strcat(out_val, " '*'
                        sprintf(out_val, "Floor:");
 #endif
 
-
                        if (!use_menu)
                        {
                                /* Build the prompt */
 #ifdef JP
-sprintf(tmp_val, "%c-%c,'(',')',", n1, n2);
+                               sprintf(tmp_val, "%c-%c,'(',')',", n1, n2);
 #else
                                sprintf(tmp_val, " %c-%c,'(',')',", n1, n2);
 #endif
 
-
                                /* Append */
                                strcat(out_val, tmp_val);
                        }
 
                        /* Indicate ability to "view" */
 #ifdef JP
-if (!command_see && !use_menu) strcat(out_val, " '*'°ìÍ÷,");
+                       if (!command_see && !use_menu) strcat(out_val, " '*'°ìÍ÷,");
 #else
                        if (!command_see && !use_menu) strcat(out_val, " * to see,");
 #endif
 
-
                        if (use_menu)
                        {
                                if (allow_inven && allow_equip)
@@ -6942,7 +6913,6 @@ if (!command_see && !use_menu) strcat(out_val, " '*'
 #else
                                        strcat(out_val, " 4 for Equip, 6 for Inven,");
 #endif
-
                                }
                                else if (allow_inven)
                                {
@@ -6951,7 +6921,6 @@ if (!command_see && !use_menu) strcat(out_val, " '*'
 #else
                                        strcat(out_val, " 4 or 6 for Inven,");
 #endif
-
                                }
                                else if (allow_equip)
                                {
@@ -6960,7 +6929,6 @@ if (!command_see && !use_menu) strcat(out_val, " '*'
 #else
                                        strcat(out_val, " 4 or 6 for Equip,");
 #endif
-
                                }
                        }
                        /* Append */
@@ -6971,7 +6939,6 @@ if (!command_see && !use_menu) strcat(out_val, " '*'
 #else
                                strcat(out_val, " / for Inven,");
 #endif
-
                        }
                        else if (allow_equip)
                        {
@@ -6980,7 +6947,6 @@ if (!command_see && !use_menu) strcat(out_val, " '*'
 #else
                                strcat(out_val, " / for Equip,");
 #endif
-
                        }
 
                        /* Append */
@@ -6994,6 +6960,13 @@ if (!command_see && !use_menu) strcat(out_val, " '*'
                        }
                }
 
+               /* Append */
+#ifdef JP
+               if (select_the_force) strcat(out_val, " 'w'Îýµ¤½Ñ,");
+#else
+               if (select_the_force) strcat(out_val, " w for the Force,");
+#endif
+
                /* Finish the prompt */
                strcat(out_val, " ESC");