OSDN Git Service

[Refactor] #40236 Separated dump-util.c/h from cmd-dump.c
authorHourier <hourier@users.sourceforge.jp>
Thu, 23 Apr 2020 09:56:43 +0000 (18:56 +0900)
committerHourier <hourier@users.sourceforge.jp>
Thu, 23 Apr 2020 09:56:43 +0000 (18:56 +0900)
Hengband_vcs2017/Hengband/Hengband.vcxproj
Hengband_vcs2017/Hengband/Hengband.vcxproj.filters
src/Makefile.am
src/cmd/cmd-dump.c
src/cmd/dump-util.c [new file with mode: 0644]
src/cmd/dump-util.h [new file with mode: 0644]

index 0abb978..bf6ea0e 100644 (file)
     <ClCompile Include="..\..\src\avatar.c" />\r
     <ClCompile Include="..\..\src\birth.c" />\r
     <ClCompile Include="..\..\src\cmd\cmd-process-screen.c" />\r
+    <ClCompile Include="..\..\src\cmd\dump-util.c" />\r
     <ClCompile Include="..\..\src\main\music-definitions-table.c" />\r
     <ClCompile Include="..\..\src\main\sound-definitions-table.c" />\r
     <ClCompile Include="..\..\src\market\building.c" />\r
     <ClInclude Include="..\..\src\avatar.h" />\r
     <ClInclude Include="..\..\src\birth.h" />\r
     <ClInclude Include="..\..\src\cmd\cmd-process-screen.h" />\r
+    <ClInclude Include="..\..\src\cmd\dump-util.h" />\r
     <ClInclude Include="..\..\src\main\music-definitions-table.h" />\r
     <ClInclude Include="..\..\src\main\sound-definitions-table.h" />\r
     <ClInclude Include="..\..\src\market\building.h" />\r
index 2d896ff..58b41c1 100644 (file)
     <ClCompile Include="..\..\src\cmd\cmd-process-screen.c">
       <Filter>cmd</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\src\cmd\dump-util.c">
+      <Filter>cmd</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\src\gamevalue.h" />
     <ClInclude Include="..\..\src\cmd\cmd-process-screen.h">
       <Filter>cmd</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\cmd\dump-util.h">
+      <Filter>cmd</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\..\src\wall.bmp" />
index c29061a..0a81758 100644 (file)
@@ -148,7 +148,7 @@ hengband_SOURCES = \
        z-form.c z-form.h z-rand.c z-rand.h z-term.c z-term.h z-util.c z-util.h \
        z-virt.c z-virt.h \
        \
-       cmd/feeling-table.c cmd/feeling-table.h \
+       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 \
        cmd/object-group-table.c cmd/object-group-table.h \
index 72b3965..93dc3a9 100644 (file)
@@ -36,6 +36,7 @@
 #include "cmd/cmd-inventory.h"
 #include "cmd/lighting-level-table.h"
 #include "cmd/cmd-visuals.h"
+#include "cmd/dump-util.h"
 #include "gameterm.h"
 #include "core.h" // 暫定。後で消す.
 #include "core/show-file.h"
 #include "io/write-diary.h"
 #include "chuukei.h"
 
-// Clipboard variables for copy&paste in visual mode
-static TERM_COLOR attr_idx = 0;
-static SYMBOL_CODE char_idx = 0;
-
-static TERM_COLOR attr_idx_feat[F_LIT_MAX];
-static SYMBOL_CODE char_idx_feat[F_LIT_MAX];
-
 /*!
  * @brief prefファイルを選択して処理する /
  * Ask for a "user pref line" and process it
@@ -1278,129 +1272,6 @@ static void place_visual_list_cursor(TERM_LEN col, TERM_LEN row, TERM_COLOR a, b
 
 
 /*
- *  Do visual mode command -- Change symbols
- */
-static bool visual_mode_command(char ch, bool *visual_list_ptr,
-       int height, int width,
-       TERM_COLOR *attr_top_ptr, byte *char_left_ptr,
-       TERM_COLOR *cur_attr_ptr, SYMBOL_CODE *cur_char_ptr, bool *need_redraw)
-{
-       static TERM_COLOR attr_old = 0;
-       static SYMBOL_CODE char_old = 0;
-
-       switch (ch)
-       {
-       case ESCAPE:
-               if (*visual_list_ptr)
-               {
-                       *cur_attr_ptr = attr_old;
-                       *cur_char_ptr = char_old;
-                       *visual_list_ptr = FALSE;
-
-                       return TRUE;
-               }
-
-               break;
-
-       case '\n':
-       case '\r':
-               if (*visual_list_ptr)
-               {
-                       *visual_list_ptr = FALSE;
-                       *need_redraw = TRUE;
-
-                       return TRUE;
-               }
-
-               break;
-
-       case 'V':
-       case 'v':
-               if (!*visual_list_ptr)
-               {
-                       *visual_list_ptr = TRUE;
-
-                       *attr_top_ptr = MAX(0, (*cur_attr_ptr & 0x7f) - 5);
-                       *char_left_ptr = MAX(0, *cur_char_ptr - 10);
-
-                       attr_old = *cur_attr_ptr;
-                       char_old = *cur_char_ptr;
-
-                       return TRUE;
-               }
-
-               break;
-
-       case 'C':
-       case 'c':
-       {
-               attr_idx = *cur_attr_ptr;
-               char_idx = *cur_char_ptr;
-               for (int i = 0; i < F_LIT_MAX; i++)
-               {
-                       attr_idx_feat[i] = 0;
-                       char_idx_feat[i] = 0;
-               }
-       }
-
-       return TRUE;
-
-       case 'P':
-       case 'p':
-               if (attr_idx || (!(char_idx & 0x80) && char_idx))
-               {
-                       *cur_attr_ptr = attr_idx;
-                       *attr_top_ptr = MAX(0, (*cur_attr_ptr & 0x7f) - 5);
-                       if (!*visual_list_ptr) *need_redraw = TRUE;
-               }
-
-               if (char_idx)
-               {
-                       /* Set the char */
-                       *cur_char_ptr = char_idx;
-                       *char_left_ptr = MAX(0, *cur_char_ptr - 10);
-                       if (!*visual_list_ptr) *need_redraw = TRUE;
-               }
-
-               return TRUE;
-
-       default:
-               if (*visual_list_ptr)
-               {
-                       int eff_width;
-                       int d = get_keymap_dir(ch);
-                       TERM_COLOR a = (*cur_attr_ptr & 0x7f);
-                       SYMBOL_CODE c = *cur_char_ptr;
-
-                       if (use_bigtile) eff_width = width / 2;
-                       else eff_width = width;
-
-                       if ((a == 0) && (ddy[d] < 0)) d = 0;
-                       if ((c == 0) && (ddx[d] < 0)) d = 0;
-                       if ((a == 0x7f) && (ddy[d] > 0)) d = 0;
-                       if (((byte)c == 0xff) && (ddx[d] > 0)) d = 0;
-
-                       a += (TERM_COLOR)ddy[d];
-                       c += (SYMBOL_CODE)ddx[d];
-                       if (c & 0x80) a |= 0x80;
-
-                       *cur_attr_ptr = a;
-                       *cur_char_ptr = c;
-                       if ((ddx[d] < 0) && *char_left_ptr > MAX(0, (int)c - 10)) (*char_left_ptr)--;
-                       if ((ddx[d] > 0) && *char_left_ptr + eff_width < MIN(0xff, (int)c + 10)) (*char_left_ptr)++;
-                       if ((ddy[d] < 0) && *attr_top_ptr > MAX(0, (int)(a & 0x7f) - 4)) (*attr_top_ptr)--;
-                       if ((ddy[d] > 0) && *attr_top_ptr + height < MIN(0x7f, (a & 0x7f) + 4)) (*attr_top_ptr)++;
-                       return TRUE;
-               }
-
-               break;
-       }
-
-       return FALSE;
-}
-
-
-/*
  * Display the monsters in a group.
  */
 static void display_monster_list(int col, int row, int per_page, s16b mon_idx[], int mon_cur, int mon_top, bool visual_only)
diff --git a/src/cmd/dump-util.c b/src/cmd/dump-util.c
new file mode 100644 (file)
index 0000000..28ac7eb
--- /dev/null
@@ -0,0 +1,141 @@
+#include "angband.h"
+#include "feature.h"
+#include "dump-util.h"
+
+TERM_COLOR attr_idx = 0;
+SYMBOL_CODE char_idx = 0;
+
+TERM_COLOR attr_idx_feat[F_LIT_MAX];
+SYMBOL_CODE char_idx_feat[F_LIT_MAX];
+
+/*
+ * @brief シンボル変更処理 / Do visual mode command -- Change symbols
+ * @param ch
+ * @param visual_list_ptr
+ * @param height
+ * @param width
+ * @param attr_ptr_ptr
+ * @param char_left_ptr
+ * @param cur_attr_ptr
+ * @param cur_char_ptr
+ * @param need_redraw
+ * @return 何かコマンドを入れたらTRUE
+ */
+bool visual_mode_command(char ch, bool *visual_list_ptr,
+       int height, int width,
+       TERM_COLOR *attr_top_ptr, byte *char_left_ptr,
+       TERM_COLOR *cur_attr_ptr, SYMBOL_CODE *cur_char_ptr, bool *need_redraw)
+{
+       static TERM_COLOR attr_old = 0;
+       static SYMBOL_CODE char_old = 0;
+
+       switch (ch)
+       {
+       case ESCAPE:
+               if (*visual_list_ptr)
+               {
+                       *cur_attr_ptr = attr_old;
+                       *cur_char_ptr = char_old;
+                       *visual_list_ptr = FALSE;
+
+                       return TRUE;
+               }
+
+               break;
+
+       case '\n':
+       case '\r':
+               if (*visual_list_ptr)
+               {
+                       *visual_list_ptr = FALSE;
+                       *need_redraw = TRUE;
+
+                       return TRUE;
+               }
+
+               break;
+
+       case 'V':
+       case 'v':
+               if (!*visual_list_ptr)
+               {
+                       *visual_list_ptr = TRUE;
+
+                       *attr_top_ptr = MAX(0, (*cur_attr_ptr & 0x7f) - 5);
+                       *char_left_ptr = MAX(0, *cur_char_ptr - 10);
+
+                       attr_old = *cur_attr_ptr;
+                       char_old = *cur_char_ptr;
+
+                       return TRUE;
+               }
+
+               break;
+
+       case 'C':
+       case 'c':
+       {
+               attr_idx = *cur_attr_ptr;
+               char_idx = *cur_char_ptr;
+               for (int i = 0; i < F_LIT_MAX; i++)
+               {
+                       attr_idx_feat[i] = 0;
+                       char_idx_feat[i] = 0;
+               }
+       }
+
+       return TRUE;
+
+       case 'P':
+       case 'p':
+               if (attr_idx || (!(char_idx & 0x80) && char_idx))
+               {
+                       *cur_attr_ptr = attr_idx;
+                       *attr_top_ptr = MAX(0, (*cur_attr_ptr & 0x7f) - 5);
+                       if (!*visual_list_ptr) *need_redraw = TRUE;
+               }
+
+               if (char_idx)
+               {
+                       /* Set the char */
+                       *cur_char_ptr = char_idx;
+                       *char_left_ptr = MAX(0, *cur_char_ptr - 10);
+                       if (!*visual_list_ptr) *need_redraw = TRUE;
+               }
+
+               return TRUE;
+
+       default:
+               if (*visual_list_ptr)
+               {
+                       int eff_width;
+                       int d = get_keymap_dir(ch);
+                       TERM_COLOR a = (*cur_attr_ptr & 0x7f);
+                       SYMBOL_CODE c = *cur_char_ptr;
+
+                       if (use_bigtile) eff_width = width / 2;
+                       else eff_width = width;
+
+                       if ((a == 0) && (ddy[d] < 0)) d = 0;
+                       if ((c == 0) && (ddx[d] < 0)) d = 0;
+                       if ((a == 0x7f) && (ddy[d] > 0)) d = 0;
+                       if (((byte)c == 0xff) && (ddx[d] > 0)) d = 0;
+
+                       a += (TERM_COLOR)ddy[d];
+                       c += (SYMBOL_CODE)ddx[d];
+                       if (c & 0x80) a |= 0x80;
+
+                       *cur_attr_ptr = a;
+                       *cur_char_ptr = c;
+                       if ((ddx[d] < 0) && *char_left_ptr > MAX(0, (int)c - 10)) (*char_left_ptr)--;
+                       if ((ddx[d] > 0) && *char_left_ptr + eff_width < MIN(0xff, (int)c + 10)) (*char_left_ptr)++;
+                       if ((ddy[d] < 0) && *attr_top_ptr > MAX(0, (int)(a & 0x7f) - 4)) (*attr_top_ptr)--;
+                       if ((ddy[d] > 0) && *attr_top_ptr + height < MIN(0x7f, (a & 0x7f) + 4)) (*attr_top_ptr)++;
+                       return TRUE;
+               }
+
+               break;
+       }
+
+       return FALSE;
+}
diff --git a/src/cmd/dump-util.h b/src/cmd/dump-util.h
new file mode 100644 (file)
index 0000000..2a76e43
--- /dev/null
@@ -0,0 +1,12 @@
+#pragma once
+
+// Clipboard variables for copy&paste in visual mode
+extern TERM_COLOR attr_idx;
+extern SYMBOL_CODE char_idx;
+
+extern TERM_COLOR attr_idx_feat[F_LIT_MAX];
+extern SYMBOL_CODE char_idx_feat[F_LIT_MAX];
+
+bool visual_mode_command(char ch, bool *visual_list_ptr, int height, int width,
+       TERM_COLOR *attr_top_ptr, byte *char_left_ptr,
+       TERM_COLOR *cur_attr_ptr, SYMBOL_CODE *cur_char_ptr, bool *need_redraw);