OSDN Git Service

[Refactor] #40014 Separated cmd-lore.c/h from cmd-item.c/h
authorHourier <hourier@users.sourceforge.jp>
Tue, 9 Jun 2020 13:11:23 +0000 (22:11 +0900)
committerHourier <hourier@users.sourceforge.jp>
Tue, 9 Jun 2020 13:14:09 +0000 (22:14 +0900)
Hengband/Hengband/Hengband.vcxproj
Hengband/Hengband/Hengband.vcxproj.filters
src/Makefile.am
src/cmd-io/cmd-lore.c [new file with mode: 0644]
src/cmd-io/cmd-lore.h [new file with mode: 0644]
src/cmd-item/cmd-item.c
src/cmd-item/cmd-item.h
src/io/input-key-processor.c
src/store/store.c

index 110a834..141b456 100644 (file)
     <ClCompile Include="..\..\src\birth\inventory-initializer.c" />\r
     <ClCompile Include="..\..\src\birth\quick-start.c" />\r
     <ClCompile Include="..\..\src\cmd-action\cmd-attack.c" />\r
+    <ClCompile Include="..\..\src\cmd-io\cmd-lore.c" />\r
     <ClCompile Include="..\..\src\cmd-io\cmd-menu-content-table.c" />\r
     <ClCompile Include="..\..\src\core\visuals-reseter.c" />\r
     <ClCompile Include="..\..\src\floor\fixed-map-generator.c" />\r
     <ClInclude Include="..\..\src\birth\inventory-initializer.h" />\r
     <ClInclude Include="..\..\src\birth\quick-start.h" />\r
     <ClInclude Include="..\..\src\cmd-action\cmd-attack.h" />\r
+    <ClInclude Include="..\..\src\cmd-io\cmd-lore.h" />\r
     <ClInclude Include="..\..\src\cmd-io\cmd-menu-content-table.h" />\r
     <ClInclude Include="..\..\src\core\visuals-reseter.h" />\r
     <ClInclude Include="..\..\src\floor\fixed-map-generator.h" />\r
index ce6b9e7..d9e08d5 100644 (file)
     <ClCompile Include="..\..\src\view\display-monster-lore.c">
       <Filter>view</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\src\cmd-io\cmd-lore.c">
+      <Filter>cmd-io</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\src\cmd\cmd-basic.h">
     <ClInclude Include="..\..\src\view\display-monster-lore.h">
       <Filter>view</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\cmd-io\cmd-lore.h">
+      <Filter>cmd-io</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\..\src\wall.bmp" />
index 40e5c32..4690621 100644 (file)
@@ -73,6 +73,7 @@ hengband_SOURCES = \
        cmd-io/cmd-gameoption.c cmd-io/cmd-gameoption.h \
        cmd-io/cmd-help.c cmd-io/cmd-help.h \
        cmd-io/cmd-knowledge.c cmd-io/cmd-knowledge.h \
+       cmd-io/cmd-lore.c cmd-io/cmd-lore.h \
        cmd-io/cmd-macro.c cmd-io/cmd-macro.h \
        cmd-io/cmd-menu-content-table.c cmd-io/cmd-menu-content-table.h \
        cmd-io/cmd-process-screen.c cmd-io/cmd-process-screen.h \
@@ -548,9 +549,10 @@ COMPILE = $(srcdir)/gcc-wrap $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
        -Iart-definition -Iautopick -Ibirth -Icmd -Icmd-io -Icmd-item -Icombat \
        -Icore -Idungeon -Ieffect -Ifloor -Igrid -Iinfo-reader -Iinventory -Iio \
        -Iio-dump -Iknowledge -Imarket -Imelee -Imind -Imonster -Imonster-attack \
-       -Imonster-race -Imspell -Imutation -Iobject -Iobject-enchant -Ipet -Iplayer \
-       -Iplayer-attack -Irealm -Iroom -Ispecific-object -Ispell -Ispell-kind \
-       -Ispell-realm -Isv-definition -Isystem -Iterm -Iutil -Iview -Iwizard -Iworld
+       -Imonster-lore -Imonster-race -Imspell -Imutation -Iobject -Iobject-enchant \
+       -Ipet -Iplayer -Iplayer-attack -Irealm -Iroom -Ispecific-object -Ispell \
+       -Ispell-kind -Ispell-realm -Isv-definition -Isystem -Iterm -Iutil -Iview \
+       -Iwizard -Iworld
 
 install-exec-hook:
 if SET_GID
diff --git a/src/cmd-io/cmd-lore.c b/src/cmd-io/cmd-lore.c
new file mode 100644 (file)
index 0000000..6b2a692
--- /dev/null
@@ -0,0 +1,201 @@
+#include "cmd-io/cmd-lore.h"
+#include "core/sort.h"
+#include "core/stuff-handler.h"
+#include "monster-race/race-flags1.h"
+#include "monster-race/race-flags7.h"
+#include "term/gameterm.h"
+#include "term/term-color-types.h"
+#include "view/display-main-window.h"
+#include "view/display-monster-lore.h"
+
+/*!
+ * @brief モンスターの思い出を見るコマンドのメインルーチン
+ * Identify a character, allow recall of monsters
+ * @param player_ptr プレーヤーへの参照ポインタ
+ * @return なし
+ * @details
+ * <pre>
+ * Several "special" responses recall "multiple" monsters:
+ *   ^A (all monsters)
+ *   ^U (all unique monsters)
+ *   ^N (all non-unique monsters)
+ *
+ * The responses may be sorted in several ways, see below.
+ *
+ * Note that the player ghosts are ignored.
+ * </pre>
+ */
+void do_cmd_query_symbol(player_type *creature_ptr)
+{
+    IDX i;
+    int n;
+    MONRACE_IDX r_idx;
+    char sym, query;
+    char buf[128];
+
+    bool all = FALSE;
+    bool uniq = FALSE;
+    bool norm = FALSE;
+    bool ride = FALSE;
+    char temp[80] = "";
+
+    bool recall = FALSE;
+
+    u16b why = 0;
+    MONRACE_IDX *who;
+
+    if (!get_com(_("知りたい文字を入力して下さい(記号 or ^A全,^Uユ,^N非ユ,^R乗馬,^M名前): ",
+                     "Enter character to be identified(^A:All,^U:Uniqs,^N:Non uniqs,^M:Name): "),
+            &sym, FALSE))
+        return;
+
+    for (i = 0; ident_info[i]; ++i) {
+        if (sym == ident_info[i][0])
+            break;
+    }
+
+    if (sym == KTRL('A')) {
+        all = TRUE;
+        strcpy(buf, _("全モンスターのリスト", "Full monster list."));
+    } else if (sym == KTRL('U')) {
+        all = uniq = TRUE;
+        strcpy(buf, _("ユニーク・モンスターのリスト", "Unique monster list."));
+    } else if (sym == KTRL('N')) {
+        all = norm = TRUE;
+        strcpy(buf, _("ユニーク外モンスターのリスト", "Non-unique monster list."));
+    } else if (sym == KTRL('R')) {
+        all = ride = TRUE;
+        strcpy(buf, _("乗馬可能モンスターのリスト", "Ridable monster list."));
+    } else if (sym == KTRL('M')) {
+        all = TRUE;
+        if (!get_string(_("名前(英語の場合小文字で可)", "Enter name:"), temp, 70)) {
+            temp[0] = 0;
+            return;
+        }
+        sprintf(buf, _("名前:%sにマッチ", "Monsters with a name \"%s\""), temp);
+    } else if (ident_info[i]) {
+        sprintf(buf, "%c - %s.", sym, ident_info[i] + 2);
+    } else {
+        sprintf(buf, "%c - %s", sym, _("無効な文字", "Unknown Symbol"));
+    }
+
+    prt(buf, 0, 0);
+    C_MAKE(who, max_r_idx, MONRACE_IDX);
+    for (n = 0, i = 1; i < max_r_idx; i++) {
+        monster_race *r_ptr = &r_info[i];
+        if (!cheat_know && !r_ptr->r_sights)
+            continue;
+
+        if (norm && (r_ptr->flags1 & (RF1_UNIQUE)))
+            continue;
+
+        if (uniq && !(r_ptr->flags1 & (RF1_UNIQUE)))
+            continue;
+
+        if (ride && !(r_ptr->flags7 & (RF7_RIDING)))
+            continue;
+
+        if (temp[0]) {
+            TERM_LEN xx;
+            char temp2[80];
+
+            for (xx = 0; temp[xx] && xx < 80; xx++) {
+#ifdef JP
+                if (iskanji(temp[xx])) {
+                    xx++;
+                    continue;
+                }
+#endif
+                if (isupper(temp[xx]))
+                    temp[xx] = (char)tolower(temp[xx]);
+            }
+
+#ifdef JP
+            strcpy(temp2, r_name + r_ptr->E_name);
+#else
+            strcpy(temp2, r_name + r_ptr->name);
+#endif
+            for (xx = 0; temp2[xx] && xx < 80; xx++)
+                if (isupper(temp2[xx]))
+                    temp2[xx] = (char)tolower(temp2[xx]);
+
+#ifdef JP
+            if (my_strstr(temp2, temp) || my_strstr(r_name + r_ptr->name, temp))
+#else
+            if (my_strstr(temp2, temp))
+#endif
+                who[n++] = i;
+        }
+
+        else if (all || (r_ptr->d_char == sym))
+            who[n++] = i;
+    }
+
+    if (!n) {
+        C_KILL(who, max_r_idx, MONRACE_IDX);
+        return;
+    }
+
+    put_str(_("思い出を見ますか? (k:殺害順/y/n): ", "Recall details? (k/y/n): "), 0, _(36, 40));
+    query = inkey();
+    prt(buf, 0, 0);
+    why = 2;
+    ang_sort(who, &why, n, ang_sort_comp_hook, ang_sort_swap_hook);
+    if (query == 'k') {
+        why = 4;
+        query = 'y';
+    }
+
+    if (query != 'y') {
+        C_KILL(who, max_r_idx, MONRACE_IDX);
+        return;
+    }
+
+    if (why == 4) {
+        ang_sort(who, &why, n, ang_sort_comp_hook, ang_sort_swap_hook);
+    }
+
+    i = n - 1;
+    while (TRUE) {
+        r_idx = who[i];
+        monster_race_track(creature_ptr, r_idx);
+        handle_stuff(creature_ptr);
+        while (TRUE) {
+            if (recall) {
+                screen_save();
+                screen_roff(creature_ptr, who[i], 0);
+            }
+
+            roff_top(r_idx);
+            Term_addstr(-1, TERM_WHITE, _(" ['r'思い出, ESC]", " [(r)ecall, ESC]"));
+            query = inkey();
+            if (recall) {
+                screen_load();
+            }
+
+            if (query != 'r')
+                break;
+            recall = !recall;
+        }
+
+        if (query == ESCAPE)
+            break;
+
+        if (query == '-') {
+            if (++i == n) {
+                i = 0;
+                if (!expand_list)
+                    break;
+            }
+        } else {
+            if (i-- == 0) {
+                i = n - 1;
+                if (!expand_list)
+                    break;
+            }
+        }
+    }
+
+    C_KILL(who, max_r_idx, IDX);
+    prt(buf, 0, 0);
+}
diff --git a/src/cmd-io/cmd-lore.h b/src/cmd-io/cmd-lore.h
new file mode 100644 (file)
index 0000000..4a5e2aa
--- /dev/null
@@ -0,0 +1,5 @@
+#pragma once
+
+#include "system/angband.h"
+
+void do_cmd_query_symbol(player_type *creature_ptr);
index 506b944..3c5169d 100644 (file)
@@ -22,7 +22,6 @@
 #include "cmd-item/cmd-zaprod.h"
 #include "cmd-item/cmd-zapwand.h"
 #include "cmd/cmd-basic.h"
-#include "core/sort.h"
 #include "core/stuff-handler.h"
 #include "dungeon/quest.h"
 #include "floor/floor-object.h"
@@ -31,8 +30,6 @@
 #include "io/targeting.h"
 #include "main/sound-definitions-table.h"
 #include "mind/snipe-types.h"
-#include "monster-race/race-flags1.h"
-#include "monster-race/race-flags7.h"
 #include "object-enchant/item-feeling.h"
 #include "object-enchant/object-ego.h"
 #include "object-enchant/special-object-flags.h"
 #include "realm/realm-hex-numbers.h"
 #include "spell/spells3.h"
 #include "sv-definition/sv-lite-types.h"
-#include "term/gameterm.h"
-#include "term/term-color-types.h"
 #include "util/util.h"
 #include "view/display-main-window.h"
-#include "view/display-monster-lore.h"
 
 /*!
  * @brief 持ち物一覧を表示するコマンドのメインルーチン / Display inventory_list
@@ -1195,262 +1189,6 @@ void do_cmd_locate(player_type *creature_ptr)
        handle_stuff(creature_ptr);
 }
 
-
-/*!
- * @brief モンスターの思い出を見るコマンドのメインルーチン
- * Identify a character, allow recall of monsters
- * @param player_ptr プレーヤーへの参照ポインタ
- * @return なし
- * @details
- * <pre>
- * Several "special" responses recall "multiple" monsters:
- *   ^A (all monsters)
- *   ^U (all unique monsters)
- *   ^N (all non-unique monsters)
- *
- * The responses may be sorted in several ways, see below.
- *
- * Note that the player ghosts are ignored. 
- * </pre>
- */
-void do_cmd_query_symbol(player_type *creature_ptr)
-{
-       IDX i;
-       int n;
-       MONRACE_IDX r_idx;
-       char sym, query;
-       char buf[128];
-
-       bool all = FALSE;
-       bool uniq = FALSE;
-       bool norm = FALSE;
-       bool ride = FALSE;
-       char temp[80] = "";
-
-       bool recall = FALSE;
-
-       u16b why = 0;
-       MONRACE_IDX *who;
-
-       /* Get a character, or abort */
-       if (!get_com(_("知りたい文字を入力して下さい(記号 or ^A全,^Uユ,^N非ユ,^R乗馬,^M名前): ", 
-                                  "Enter character to be identified(^A:All,^U:Uniqs,^N:Non uniqs,^M:Name): "), &sym, FALSE)) return;
-
-       /* Find that character info, and describe it */
-       for (i = 0; ident_info[i]; ++i)
-       {
-               if (sym == ident_info[i][0]) break;
-       }
-       if (sym == KTRL('A'))
-       {
-               all = TRUE;
-               strcpy(buf, _("全モンスターのリスト", "Full monster list."));
-       }
-       else if (sym == KTRL('U'))
-       {
-               all = uniq = TRUE;
-               strcpy(buf, _("ユニーク・モンスターのリスト", "Unique monster list."));
-       }
-       else if (sym == KTRL('N'))
-       {
-               all = norm = TRUE;
-               strcpy(buf, _("ユニーク外モンスターのリスト", "Non-unique monster list."));
-       }
-       else if (sym == KTRL('R'))
-       {
-               all = ride = TRUE;
-               strcpy(buf, _("乗馬可能モンスターのリスト", "Ridable monster list."));
-       }
-       /* XTRA HACK WHATSEARCH */
-       else if (sym == KTRL('M'))
-       {
-               all = TRUE;
-               if (!get_string(_("名前(英語の場合小文字で可)", "Enter name:"),temp, 70))
-               {
-                       temp[0]=0;
-                       return;
-               }
-               sprintf(buf, _("名前:%sにマッチ", "Monsters with a name \"%s\""),temp);
-       }
-       else if (ident_info[i])
-       {
-               sprintf(buf, "%c - %s.", sym, ident_info[i] + 2);
-       }
-       else
-       {
-               sprintf(buf, "%c - %s", sym, _("無効な文字", "Unknown Symbol"));
-       }
-
-       /* Display the result */
-       prt(buf, 0, 0);
-
-       /* Allocate the "who" array */
-       C_MAKE(who, max_r_idx, MONRACE_IDX);
-
-       /* Collect matching monsters */
-       for (n = 0, i = 1; i < max_r_idx; i++)
-       {
-               monster_race *r_ptr = &r_info[i];
-
-               /* Nothing to recall */
-               if (!cheat_know && !r_ptr->r_sights) continue;
-
-               /* Require non-unique monsters if needed */
-               if (norm && (r_ptr->flags1 & (RF1_UNIQUE))) continue;
-
-               /* Require unique monsters if needed */
-               if (uniq && !(r_ptr->flags1 & (RF1_UNIQUE))) continue;
-
-               /* Require ridable monsters if needed */
-               if (ride && !(r_ptr->flags7 & (RF7_RIDING))) continue;
-
-               /* XTRA HACK WHATSEARCH */
-               if (temp[0])
-               {
-                       TERM_LEN xx;
-                       char temp2[80];
-
-                       for (xx = 0; temp[xx] && xx < 80; xx++)
-                       {
-#ifdef JP
-                               if (iskanji(temp[xx])) { xx++; continue; }
-#endif
-                               if (isupper(temp[xx])) temp[xx] = (char)tolower(temp[xx]);
-                       }
-
-#ifdef JP
-                       strcpy(temp2, r_name + r_ptr->E_name);
-#else
-                       strcpy(temp2, r_name + r_ptr->name);
-#endif
-                       for (xx = 0; temp2[xx] && xx < 80; xx++)
-                               if (isupper(temp2[xx])) temp2[xx] = (char)tolower(temp2[xx]);
-
-#ifdef JP
-                       if (my_strstr(temp2, temp) || my_strstr(r_name + r_ptr->name, temp))
-#else
-                       if (my_strstr(temp2, temp))
-#endif
-                               who[n++] = i;
-               }
-
-               /* Collect "appropriate" monsters */
-               else if (all || (r_ptr->d_char == sym)) who[n++] = i;
-       }
-
-       /* Nothing to recall */
-       if (!n)
-       {
-               C_KILL(who, max_r_idx, MONRACE_IDX);
-               return;
-       }
-
-       /* Prompt */
-       put_str(_("思い出を見ますか? (k:殺害順/y/n): ", "Recall details? (k/y/n): "), 0, _(36, 40));
-
-       /* Query */
-       query = inkey();
-       prt(buf, 0, 0);
-
-       why = 2;
-
-       /* Sort the array */
-       ang_sort(who, &why, n, ang_sort_comp_hook, ang_sort_swap_hook);
-
-       /* Sort by kills (and level) */
-       if (query == 'k')
-       {
-               why = 4;
-               query = 'y';
-       }
-
-       /* Catch "escape" */
-       if (query != 'y')
-       {
-               C_KILL(who, max_r_idx, MONRACE_IDX);
-               return;
-       }
-
-       /* Sort if needed */
-       if (why == 4)
-       {
-               ang_sort(who, &why, n, ang_sort_comp_hook, ang_sort_swap_hook);
-       }
-
-       /* Start at the end */
-       i = n - 1;
-
-       /* Scan the monster memory */
-       while (TRUE)
-       {
-               r_idx = who[i];
-
-               /* Hack -- Auto-recall */
-               monster_race_track(creature_ptr, r_idx);
-               handle_stuff(creature_ptr);
-
-               /* Interact */
-               while (TRUE)
-               {
-                       if (recall)
-                       {
-                               screen_save();
-
-                               /* Recall on screen */
-                               screen_roff(creature_ptr, who[i], 0);
-                       }
-
-                       /* Hack -- Begin the prompt */
-                       roff_top(r_idx);
-
-                       /* Hack -- Complete the prompt */
-                       Term_addstr(-1, TERM_WHITE, _(" ['r'思い出, ESC]", " [(r)ecall, ESC]"));
-
-                       query = inkey();
-
-                       /* Unrecall */
-                       if (recall)
-                       {
-                               screen_load();
-                       }
-
-                       /* Normal commands */
-                       if (query != 'r') break;
-
-                       recall = !recall;
-               }
-
-               /* Stop scanning */
-               if (query == ESCAPE) break;
-
-               /* Move to "prev" monster */
-               if (query == '-')
-               {
-                       if (++i == n)
-                       {
-                               i = 0;
-                               if (!expand_list) break;
-                       }
-               }
-
-               /* Move to "next" monster */
-               else
-               {
-                       if (i-- == 0)
-                       {
-                               i = n - 1;
-                               if (!expand_list) break;
-                       }
-               }
-       }
-
-       /* Free the "who" array */
-       C_KILL(who, max_r_idx, IDX);
-
-       /* Re-display the identity */
-       prt(buf, 0, 0);
-}
-
 /*!
  * @brief アイテムを汎用的に「使う」コマンドのメインルーチン /
  * Use an item
@@ -1527,4 +1265,3 @@ void do_cmd_use(player_type *creature_ptr)
                        break;
        }
 }
-
index deb5a0b..4855d8b 100644 (file)
@@ -15,5 +15,4 @@ void do_cmd_refill(player_type *creature_ptr);
 void do_cmd_target(player_type *creature_ptr);
 void do_cmd_look(player_type *creature_ptr);
 void do_cmd_locate(player_type *creature_ptr);
-void do_cmd_query_symbol(player_type *creature_ptr);
 void do_cmd_use(player_type *creature_ptr);
index 049e2f4..deff6f5 100644 (file)
@@ -17,6 +17,7 @@
 #include "cmd-io/cmd-dump.h"
 #include "cmd-io/cmd-help.h"
 #include "cmd-io/cmd-knowledge.h"
+#include "cmd-io/cmd-lore.h"
 #include "cmd-io/cmd-macro.h"
 #include "cmd-io/cmd-process-screen.h"
 #include "cmd-io/cmd-save.h"
index 1e394fb..17bc7dc 100644 (file)
@@ -18,6 +18,7 @@
 #include "cmd-io/cmd-dump.h"
 #include "cmd-io/cmd-help.h"
 #include "cmd-io/cmd-knowledge.h"
+#include "cmd-io/cmd-lore.h"
 #include "cmd-io/cmd-macro.h"
 #include "cmd-io/cmd-process-screen.h"
 #include "cmd-item/cmd-item.h"