OSDN Git Service

[Refactor] #39964 Separated cmd-autopick.c/h from autopick.c/h
authorHourier <hourier@users.sourceforge.jp>
Sun, 26 Apr 2020 03:06:14 +0000 (12:06 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sun, 26 Apr 2020 04:28:31 +0000 (13:28 +0900)
Hengband_vcs2017/Hengband/Hengband.vcxproj
Hengband_vcs2017/Hengband/Hengband.vcxproj.filters
src/Makefile.am
src/autopick/autopick.c
src/autopick/autopick.h
src/cmd/cmd-autopick.c [new file with mode: 0644]
src/cmd/cmd-autopick.h [new file with mode: 0644]
src/cmd/cmd-gameoption.c
src/core.c

index ed45913..0fa9185 100644 (file)
     <ClCompile Include="..\..\src\autopick\autopick.c" />\r
     <ClCompile Include="..\..\src\avatar.c" />\r
     <ClCompile Include="..\..\src\birth.c" />\r
+    <ClCompile Include="..\..\src\cmd\cmd-autopick.c" />\r
     <ClCompile Include="..\..\src\cmd\cmd-knowledge.c" />\r
     <ClCompile Include="..\..\src\cmd\cmd-process-screen.c" />\r
     <ClCompile Include="..\..\src\cmd\dump-util.c" />\r
     <ClInclude Include="..\..\src\autopick\autopick.h" />\r
     <ClInclude Include="..\..\src\avatar.h" />\r
     <ClInclude Include="..\..\src\birth.h" />\r
+    <ClInclude Include="..\..\src\cmd\cmd-autopick.h" />\r
     <ClInclude Include="..\..\src\cmd\cmd-knowledge.h" />\r
     <ClInclude Include="..\..\src\cmd\cmd-process-screen.h" />\r
     <ClInclude Include="..\..\src\cmd\dump-util.h" />\r
index 9b5f37e..732c137 100644 (file)
     <ClCompile Include="..\..\src\autopick\autopick-editor-command.c">
       <Filter>autopick</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\src\cmd\cmd-autopick.c">
+      <Filter>cmd</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\src\gamevalue.h" />
     <ClInclude Include="..\..\src\autopick\autopick-editor-command.h">
       <Filter>autopick</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\cmd\cmd-autopick.h">
+      <Filter>cmd</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\..\src\wall.bmp" />
index 0cc3de2..6a56aef 100644 (file)
@@ -189,6 +189,7 @@ hengband_SOURCES = \
        knowledge/knowledge-self.c knowledge/knowledge-self.h \
        knowledge/knowledge-quests.c knowledge/knowledge-quests.h \
        \
+       cmd/cmd-autopick.c cmd/cmd-autopick.c \
        cmd/dump-util.c cmd/dump-util.h cmd/feeling-table.c cmd/feeling-table.h \
        cmd/monster-group-table.c cmd/monster-group-table.h \
        cmd/diary-subtitle-table.c cmd/diary-subtitle-table.h \
index 2df26fe..5ee6f23 100644 (file)
 
 #include "angband.h"
 #include "util.h"
-#include "autopick/autopick-commands-table.h"
-#include "autopick/autopick-dirty-flags.h"
-#include "autopick/autopick-flags-table.h"
-#include "autopick/autopick-initializer.h"
-#include "autopick/autopick-key-flag-process.h"
 #include "autopick/autopick-menu-data-table.h"
 #include "autopick/autopick-methods-table.h"
 #include "autopick/autopick-destroyer.h"
-#include "autopick/autopick-entry.h"
-#include "autopick/autopick-reader-writer.h"
 #include "autopick/autopick-finder.h"
-#include "autopick/autopick-drawer.h"
-#include "autopick/autopick-searcher.h"
-#include "autopick/autopick-inserter-killer.h"
-#include "autopick/autopick-registry.h"
-#include "autopick/autopick-command-menu.h"
-#include "autopick/autopick-editor-util.h"
-#include "autopick/autopick-editor-command.h"
-#include "gameterm.h"
 #include "autopick/autopick.h"
-#include "core/show-file.h"
-#include "cmd/cmd-save.h"
-#include "io/read-pref-file.h"
-
-#include "mind.h"
-
-#include "market/store.h"
 #include "player-move.h"
-#include "player-class.h"
-#include "view/display-player.h" // 暫定。後で消す.
 #include "object-flavor.h"
 
-#include "world.h"
-#include "view/display-main-window.h" // 暫定。後で消す.
-
 /*
  *  Auto-destroy marked item
  */
@@ -170,197 +143,3 @@ void autopick_pickup_items(player_type* player_ptr, grid_type *g_ptr)
                py_pickup_aux(player_ptr, this_o_idx);
        }
 }
-
-
-/*
- * Check special key code and get a movement command id
- */
-static int analyze_move_key(text_body_type *tb, int skey)
-{
-       int com_id;
-       if (!(skey & SKEY_MASK)) return 0;
-
-       switch (skey & ~SKEY_MOD_MASK)
-       {
-       case SKEY_DOWN:   com_id = EC_DOWN;   break;
-       case SKEY_LEFT:   com_id = EC_LEFT;   break;
-       case SKEY_RIGHT:  com_id = EC_RIGHT;  break;
-       case SKEY_UP:     com_id = EC_UP;     break;
-       case SKEY_PGUP:   com_id = EC_PGUP;   break;
-       case SKEY_PGDOWN: com_id = EC_PGDOWN; break;
-       case SKEY_TOP:    com_id = EC_TOP;    break;
-       case SKEY_BOTTOM: com_id = EC_BOTTOM; break;
-       default:
-               return 0;
-       }
-
-       if (!(skey & SKEY_MOD_SHIFT))
-       {
-               /*
-                * Un-shifted cursor keys cancells
-                * selection created by shift+cursor.
-                */
-               if (tb->mark & MARK_BY_SHIFT)
-               {
-                       tb->mark = 0;
-                       tb->dirty_flags |= DIRTY_ALL;
-               }
-
-               return com_id;
-       }
-
-       if (tb->mark) return com_id;
-
-       int len = strlen(tb->lines_list[tb->cy]);
-       tb->mark = MARK_MARK | MARK_BY_SHIFT;
-       tb->my = tb->cy;
-       tb->mx = tb->cx;
-       if (tb->cx > len) tb->mx = len;
-
-       if (com_id == EC_UP || com_id == EC_DOWN)
-       {
-               tb->dirty_flags |= DIRTY_ALL;
-       }
-       else
-       {
-               tb->dirty_line = tb->cy;
-       }
-
-       return com_id;
-}
-
-/*
- * In-game editor of Object Auto-picker/Destoryer
- * @param player_ptr プレーヤーへの参照ポインタ
- */
-void do_cmd_edit_autopick(player_type *player_ptr)
-{
-       static int cx_save = 0;
-       static int cy_save = 0;
-       autopick_type an_entry, *entry = &an_entry;
-       char buf[MAX_LINELEN];
-       int i;
-       int key = -1;
-       static s32b old_autosave_turn = 0L;
-       byte quit = 0;
-
-       text_body_type text_body;
-       text_body_type *tb = &text_body;
-       tb->changed = FALSE;
-       tb->cx = cx_save;
-       tb->cy = cy_save;
-       tb->upper = tb->left = 0;
-       tb->mark = 0;
-       tb->mx = tb->my = 0;
-       tb->old_cy = tb->old_upper = tb->old_left = -1;
-       tb->old_wid = tb->old_hgt = -1;
-       tb->old_com_id = 0;
-
-       tb->yank = NULL;
-       tb->search_o_ptr = NULL;
-       tb->search_str = NULL;
-       tb->last_destroyed = NULL;
-       tb->dirty_flags = DIRTY_ALL | DIRTY_MODE | DIRTY_EXPRESSION;
-       tb->dirty_line = -1;
-       tb->filename_mode = PT_DEFAULT;
-
-       if (current_world_ptr->game_turn < old_autosave_turn)
-       {
-               while (old_autosave_turn > current_world_ptr->game_turn) old_autosave_turn -= TURNS_PER_TICK * TOWN_DAWN;
-       }
-
-       if (current_world_ptr->game_turn > old_autosave_turn + 100L)
-       {
-               do_cmd_save_game(player_ptr, TRUE);
-               old_autosave_turn = current_world_ptr->game_turn;
-       }
-
-       update_playtime();
-       init_autopick();
-       if (autopick_last_destroyed_object.k_idx)
-       {
-               autopick_entry_from_object(player_ptr, entry, &autopick_last_destroyed_object);
-               tb->last_destroyed = autopick_line_from_entry_kill(entry);
-       }
-
-       tb->lines_list = read_pickpref_text_lines(player_ptr, &tb->filename_mode);
-       for (i = 0; i < tb->cy; i++)
-       {
-               if (!tb->lines_list[i])
-               {
-                       tb->cy = tb->cx = 0;
-                       break;
-               }
-       }
-
-       screen_save();
-       while (!quit)
-       {
-               int com_id = 0;
-               draw_text_editor(player_ptr, tb);
-               prt(_("(^Q:終了 ^W:セーブして終了, ESC:メニュー, その他:入力)",
-                       "(^Q:Quit, ^W:Save&Quit, ESC:Menu, Other:Input text)"), 0, 0);
-               if (!tb->mark)
-               {
-                       prt(format("(%d,%d)", tb->cx, tb->cy), 0, 60);
-               }
-               else
-               {
-                       prt(format("(%d,%d)-(%d,%d)", tb->mx, tb->my, tb->cx, tb->cy), 0, 60);
-               }
-
-               Term_gotoxy(tb->cx - tb->left, tb->cy - tb->upper + 1);
-               tb->dirty_flags = 0;
-               tb->dirty_line = -1;
-               tb->old_cy = tb->cy;
-               tb->old_upper = tb->upper;
-               tb->old_left = tb->left;
-               tb->old_wid = tb->wid;
-               tb->old_hgt = tb->hgt;
-
-               key = inkey_special(TRUE);
-
-               if (key & SKEY_MASK)
-               {
-                       com_id = analyze_move_key(tb, key);
-               }
-               else if (key == ESCAPE)
-               {
-                       com_id = do_command_menu(0, 0);
-                       tb->dirty_flags |= DIRTY_SCREEN;
-               }
-               else if (!iscntrl((unsigned char)key))
-               {
-                       if (tb->mark)
-                       {
-                               tb->mark = 0;
-                               tb->dirty_flags |= DIRTY_ALL;
-                       }
-
-                       insert_single_letter(tb, key);
-                       continue;
-               }
-               else
-               {
-                       com_id = get_com_id((char)key);
-               }
-
-               if (com_id) quit = do_editor_command(player_ptr, tb, com_id);
-       }
-
-       screen_load();
-       strcpy(buf, pickpref_filename(player_ptr, tb->filename_mode));
-
-       if (quit == QUIT_AND_SAVE)
-               write_text_lines(buf, tb->lines_list);
-
-       free_text_lines(tb->lines_list);
-       string_free(tb->search_str);
-       string_free(tb->last_destroyed);
-       kill_yank_chain(tb);
-
-       process_autopick_file(player_ptr, buf);
-       current_world_ptr->start_time = (u32b)time(NULL);
-       cx_save = tb->cx;
-       cy_save = tb->cy;
-}
index 3fb2fbf..cc580cf 100644 (file)
@@ -5,4 +5,3 @@
 extern void autopick_alter_item(player_type *player_ptr, INVENTORY_IDX item, bool destroy);
 extern void autopick_delayed_alter(player_type *player_ptr);
 extern void autopick_pickup_items(player_type *player_ptr, grid_type *g_ptr);
-extern void do_cmd_edit_autopick(player_type *player_ptr);
diff --git a/src/cmd/cmd-autopick.c b/src/cmd/cmd-autopick.c
new file mode 100644 (file)
index 0000000..0f8e214
--- /dev/null
@@ -0,0 +1,210 @@
+#include "angband.h"
+#include "cmd/cmd-autopick.h"
+#include "cmd/cmd-save.h"
+#include "autopick/autopick-util.h"
+#include "autopick/autopick-commands-table.h"
+#include "autopick/autopick-dirty-flags.h"
+#include "autopick/autopick-initializer.h"
+#include "autopick/autopick-entry.h"
+#include "autopick/autopick-drawer.h"
+#include "autopick/autopick-reader-writer.h"
+#include "autopick/autopick-command-menu.h"
+#include "autopick/autopick-editor-command.h"
+#include "autopick/autopick-editor-util.h"
+#include "autopick/autopick-inserter-killer.h"
+#include "io/read-pref-file.h"
+#include "world.h"
+#include "view/display-main-window.h" // 暫定。後で消す.
+
+/*
+ * Check special key code and get a movement command id
+ */
+static int analyze_move_key(text_body_type *tb, int skey)
+{
+       int com_id;
+       if (!(skey & SKEY_MASK)) return 0;
+
+       switch (skey & ~SKEY_MOD_MASK)
+       {
+       case SKEY_DOWN:   com_id = EC_DOWN;   break;
+       case SKEY_LEFT:   com_id = EC_LEFT;   break;
+       case SKEY_RIGHT:  com_id = EC_RIGHT;  break;
+       case SKEY_UP:     com_id = EC_UP;     break;
+       case SKEY_PGUP:   com_id = EC_PGUP;   break;
+       case SKEY_PGDOWN: com_id = EC_PGDOWN; break;
+       case SKEY_TOP:    com_id = EC_TOP;    break;
+       case SKEY_BOTTOM: com_id = EC_BOTTOM; break;
+       default:
+               return 0;
+       }
+
+       if (!(skey & SKEY_MOD_SHIFT))
+       {
+               /*
+                * Un-shifted cursor keys cancells
+                * selection created by shift+cursor.
+                */
+               if (tb->mark & MARK_BY_SHIFT)
+               {
+                       tb->mark = 0;
+                       tb->dirty_flags |= DIRTY_ALL;
+               }
+
+               return com_id;
+       }
+
+       if (tb->mark) return com_id;
+
+       int len = strlen(tb->lines_list[tb->cy]);
+       tb->mark = MARK_MARK | MARK_BY_SHIFT;
+       tb->my = tb->cy;
+       tb->mx = tb->cx;
+       if (tb->cx > len) tb->mx = len;
+
+       if (com_id == EC_UP || com_id == EC_DOWN)
+       {
+               tb->dirty_flags |= DIRTY_ALL;
+       }
+       else
+       {
+               tb->dirty_line = tb->cy;
+       }
+
+       return com_id;
+}
+
+/*
+ * In-game editor of Object Auto-picker/Destoryer
+ * @param player_ptr プレーヤーへの参照ポインタ
+ */
+void do_cmd_edit_autopick(player_type *player_ptr)
+{
+       static int cx_save = 0;
+       static int cy_save = 0;
+       autopick_type an_entry, *entry = &an_entry;
+       char buf[MAX_LINELEN];
+       int i;
+       int key = -1;
+       static s32b old_autosave_turn = 0L;
+       byte quit = 0;
+
+       text_body_type text_body;
+       text_body_type *tb = &text_body;
+       tb->changed = FALSE;
+       tb->cx = cx_save;
+       tb->cy = cy_save;
+       tb->upper = tb->left = 0;
+       tb->mark = 0;
+       tb->mx = tb->my = 0;
+       tb->old_cy = tb->old_upper = tb->old_left = -1;
+       tb->old_wid = tb->old_hgt = -1;
+       tb->old_com_id = 0;
+
+       tb->yank = NULL;
+       tb->search_o_ptr = NULL;
+       tb->search_str = NULL;
+       tb->last_destroyed = NULL;
+       tb->dirty_flags = DIRTY_ALL | DIRTY_MODE | DIRTY_EXPRESSION;
+       tb->dirty_line = -1;
+       tb->filename_mode = PT_DEFAULT;
+
+       if (current_world_ptr->game_turn < old_autosave_turn)
+       {
+               while (old_autosave_turn > current_world_ptr->game_turn) old_autosave_turn -= TURNS_PER_TICK * TOWN_DAWN;
+       }
+
+       if (current_world_ptr->game_turn > old_autosave_turn + 100L)
+       {
+               do_cmd_save_game(player_ptr, TRUE);
+               old_autosave_turn = current_world_ptr->game_turn;
+       }
+
+       update_playtime();
+       init_autopick();
+       if (autopick_last_destroyed_object.k_idx)
+       {
+               autopick_entry_from_object(player_ptr, entry, &autopick_last_destroyed_object);
+               tb->last_destroyed = autopick_line_from_entry_kill(entry);
+       }
+
+       tb->lines_list = read_pickpref_text_lines(player_ptr, &tb->filename_mode);
+       for (i = 0; i < tb->cy; i++)
+       {
+               if (!tb->lines_list[i])
+               {
+                       tb->cy = tb->cx = 0;
+                       break;
+               }
+       }
+
+       screen_save();
+       while (!quit)
+       {
+               int com_id = 0;
+               draw_text_editor(player_ptr, tb);
+               prt(_("(^Q:終了 ^W:セーブして終了, ESC:メニュー, その他:入力)",
+                       "(^Q:Quit, ^W:Save&Quit, ESC:Menu, Other:Input text)"), 0, 0);
+               if (!tb->mark)
+               {
+                       prt(format("(%d,%d)", tb->cx, tb->cy), 0, 60);
+               }
+               else
+               {
+                       prt(format("(%d,%d)-(%d,%d)", tb->mx, tb->my, tb->cx, tb->cy), 0, 60);
+               }
+
+               Term_gotoxy(tb->cx - tb->left, tb->cy - tb->upper + 1);
+               tb->dirty_flags = 0;
+               tb->dirty_line = -1;
+               tb->old_cy = tb->cy;
+               tb->old_upper = tb->upper;
+               tb->old_left = tb->left;
+               tb->old_wid = tb->wid;
+               tb->old_hgt = tb->hgt;
+
+               key = inkey_special(TRUE);
+
+               if (key & SKEY_MASK)
+               {
+                       com_id = analyze_move_key(tb, key);
+               }
+               else if (key == ESCAPE)
+               {
+                       com_id = do_command_menu(0, 0);
+                       tb->dirty_flags |= DIRTY_SCREEN;
+               }
+               else if (!iscntrl((unsigned char)key))
+               {
+                       if (tb->mark)
+                       {
+                               tb->mark = 0;
+                               tb->dirty_flags |= DIRTY_ALL;
+                       }
+
+                       insert_single_letter(tb, key);
+                       continue;
+               }
+               else
+               {
+                       com_id = get_com_id((char)key);
+               }
+
+               if (com_id) quit = do_editor_command(player_ptr, tb, com_id);
+       }
+
+       screen_load();
+       strcpy(buf, pickpref_filename(player_ptr, tb->filename_mode));
+
+       if (quit == QUIT_AND_SAVE)
+               write_text_lines(buf, tb->lines_list);
+
+       free_text_lines(tb->lines_list);
+       string_free(tb->search_str);
+       string_free(tb->last_destroyed);
+       kill_yank_chain(tb);
+
+       process_autopick_file(player_ptr, buf);
+       current_world_ptr->start_time = (u32b)time(NULL);
+       cx_save = tb->cx;
+       cy_save = tb->cy;
+}
diff --git a/src/cmd/cmd-autopick.h b/src/cmd/cmd-autopick.h
new file mode 100644 (file)
index 0000000..fb26d9c
--- /dev/null
@@ -0,0 +1,3 @@
+#pragma once
+
+void do_cmd_edit_autopick(player_type *player_ptr);
index d58db90..3d390ae 100644 (file)
@@ -3,6 +3,7 @@
 #include "autopick/autopick.h"
 #include "io/write-diary.h"
 #include "cmd/cmd-gameoption.h"
+#include "cmd/cmd-autopick.h"
 #include "gameterm.h"
 #include "view/display-main-window.h"
 #include "cmd/cmd-dump.h"
index 421a22b..f3ca01e 100644 (file)
@@ -26,6 +26,7 @@
 #include "market/building.h"
 #include "io/write-diary.h"
 #include "cmd/cmd-activate.h"
+#include "cmd/cmd-autopick.h"
 #include "cmd/cmd-diary.h"
 #include "cmd/cmd-draw.h"
 #include "cmd/cmd-dump.h"