OSDN Git Service

[Refactor] #40413 Separated quarks.c/h from util.c/h
authorHourier <hourier@users.sourceforge.jp>
Sun, 14 Jun 2020 04:05:52 +0000 (13:05 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sun, 14 Jun 2020 04:05:52 +0000 (13:05 +0900)
26 files changed:
Hengband/Hengband/Hengband.vcxproj
Hengband/Hengband/Hengband.vcxproj.filters
src/Makefile.am
src/autopick/autopick-entry.c
src/autopick/autopick-util.c
src/cmd-action/cmd-pet.c
src/cmd-item/cmd-activate.c
src/cmd-item/cmd-item.c
src/inventory/inventory-curse.c
src/inventory/player-inventory.c
src/inventory/recharge-processor.c
src/io/interpret-pref-file.c
src/io/load.c
src/io/save.c
src/main/init.c
src/monster/monster-describer.c
src/object-enchant/artifact.c
src/object/object-flavor.c
src/player/player-status.c
src/store/store.c
src/term/gameterm.c
src/util/quarks.c [new file with mode: 0644]
src/util/quarks.h [new file with mode: 0644]
src/util/util.c
src/util/util.h
src/wizard/wizard-spoiler.c

index 807dd1d..1970ba9 100644 (file)
     <ClCompile Include="..\..\src\info-reader\skill-reader.c" />\r
     <ClCompile Include="..\..\src\info-reader\vault-reader.c" />\r
     <ClCompile Include="..\..\src\io\input-key-acceptor.c" />\r
+    <ClCompile Include="..\..\src\util\quarks.c" />\r
     <ClCompile Include="..\..\src\lore\combat-types-setter.c" />\r
     <ClCompile Include="..\..\src\lore\magic-types-setter.c" />\r
     <ClCompile Include="..\..\src\lore\lore-calculator.c" />\r
     <ClInclude Include="..\..\src\info-reader\skill-reader.h" />\r
     <ClInclude Include="..\..\src\info-reader\vault-reader.h" />\r
     <ClInclude Include="..\..\src\io\input-key-acceptor.h" />\r
+    <ClInclude Include="..\..\src\util\quarks.h" />\r
     <ClInclude Include="..\..\src\lore\combat-types-setter.h" />\r
     <ClInclude Include="..\..\src\lore\magic-types-setter.h" />\r
     <ClInclude Include="..\..\src\lore\lore-calculator.h" />\r
index 9dc093a..8c0e9d2 100644 (file)
     <ClCompile Include="..\..\src\io\input-key-acceptor.c">
       <Filter>io</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\src\util\quarks.c">
+      <Filter>util</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\src\cmd\cmd-basic.h">
     <ClInclude Include="..\..\src\io\input-key-acceptor.h">
       <Filter>io</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\util\quarks.h">
+      <Filter>util</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\..\src\wall.bmp" />
index 699d239..eadc70c 100644 (file)
@@ -547,6 +547,7 @@ hengband_SOURCES = \
        \
        util/angband-files.c util/angband-files.h \
        util/object-sort.c util/object-sort.h \
+       util/quarks.c util/quarks.h \
        util/string-processor.c util/string-processor.h \
        util/util.c util/util.h \
        \
index 79160f8..cdf25c0 100644 (file)
@@ -14,6 +14,7 @@
 #include "object/object-kind.h"
 #include "object/object-info.h"
 #include "perception/object-perception.h"
+#include "util/quarks.h"
 
 #ifdef JP
 static char kanji_colon[] = ":";
index 505b962..e2e9e8b 100644 (file)
@@ -4,6 +4,7 @@
 #include "main/sound-of-music.h"
 #include "monster-race/race-indice-types.h"
 #include "object-enchant/item-feeling.h"
+#include "util/quarks.h"
 
 /*
  * 自動拾い/破壊設定のリストに関する変数 / List for auto-picker/destroyer entries
index 8a13638..e2b4758 100644 (file)
@@ -32,6 +32,7 @@
 #include "player/player-skill.h"
 #include "player/player-status.h"
 #include "view/display-main-window.h"
+#include "util/quarks.h"
 #include "world/world.h"
 
 int total_friends = 0;
index c317aa1..a741802 100644 (file)
@@ -67,6 +67,7 @@
 #include "spell/spells3.h"
 #include "sv-definition/sv-lite-types.h"
 #include "sv-definition/sv-ring-types.h"
+#include "util/quarks.h"
 #include "world/world.h"
 
 /*!
index d26fbd5..fb3fadc 100644 (file)
@@ -58,6 +58,7 @@
 #include "realm/realm-hex-numbers.h"
 #include "spell/spells3.h"
 #include "sv-definition/sv-lite-types.h"
+#include "util/quarks.h"
 #include "view/display-main-window.h"
 
 /*!
index aa5b208..59e450c 100644 (file)
@@ -18,6 +18,7 @@
 #include "spell-kind/spells-random.h"
 #include "spell-kind/spells-teleport.h"
 #include "spell/spells-summon.h"
+#include "util/quarks.h"
 
 #define TRC_P_FLAG_MASK \
     (TRC_TELEPORT_SELF | TRC_CHAINSWORD | TRC_TY_CURSE | TRC_DRAIN_EXP | TRC_ADD_L_CURSE | TRC_ADD_H_CURSE | TRC_CALL_ANIMAL | TRC_CALL_DEMON \
index f2b08ac..09ad611 100644 (file)
@@ -20,6 +20,7 @@
 #include "player/player-move.h"
 #include "term/gameterm.h"
 #include "term/term-color-types.h"
+#include "util/quarks.h"
 #include "view/display-main-window.h"
 
 bool select_ring_slot;
index 3e478a3..28d347c 100644 (file)
@@ -4,6 +4,7 @@
 #include "object/object-hook.h"
 #include "object/object-kind.h"
 #include "player/player-move.h"
+#include "util/quarks.h"
 
 /*!
  * @brief
index b1d33d7..62c8c72 100644 (file)
@@ -14,6 +14,7 @@
 #include "object/object-kind.h"
 #include "system/game-option-types.h"
 #include "term/gameterm.h"
+#include "util/quarks.h"
 #include "util/string-processor.h"
 #include "view/display-main-window.h" // 暫定。apply_default_feat_lighting()。後で消す.
 #include "world/world.h"
index 867047d..1380dd4 100644 (file)
@@ -8,36 +8,6 @@
  * This software may be copied and distributed for educational, research,
  * and not for profit purposes provided that this copyright and statement
  * are included in all such copies.  Other copyrights may also apply.
- * @details
- * This file loads savefiles from Angband 2.7.X and 2.8.X
- *
- * Ancient savefiles (pre-2.7.0) are loaded by another file.
- *
- * Note that Angband 2.7.0 through 2.7.3 are now officially obsolete,
- * and savefiles from those versions may not be successfully converted.
- *
- * We attempt to prevent corrupt savefiles from inducing memory errors.
- *
- * Note that this file should not use the random number generator, the
- * object flavors, the visual attr/char mappings, or anything else which
- * is initialized *after* or *during* the "load character" function.
- *
- * This file assumes that the monster/object records are initialized
- * to zero, and the race/kind tables have been loaded correctly.  The
- * order of object stacks is currently not saved in the savefiles, but
- * the "next" pointers are saved, so all necessary knowledge is present.
- *
- * We should implement simple "savefile extenders" using some form of
- * "sized" chunks of bytes, with a {size,type,data} format, so everyone
- * can know the size, interested people can know the type, and the actual
- * data is available to the parsing routines that acknowledge the type.
- *
- * Consider changing the "globe of invulnerability" code so that it
- * takes some form of "maximum damage to protect from" in addition to
- * the existing "number of turns to protect for", and where each hit
- * by a monster will reduce the shield by that amount.
- *
- *
  */
 
 #include "io/load.h"
 #include "system/system-variables.h" // 暫定、init_flags の扱いを決めた上で消す.
 #include "util/angband-files.h"
 #include "util/object-sort.h"
+#include "util/quarks.h"
 #include "world/world-object.h"
 #include "world/world.h"
 
index 964cab6..612fe83 100644 (file)
@@ -42,6 +42,7 @@
 #include "store/store.h"
 #include "system/angband-version.h"
 #include "util/angband-files.h"
+#include "util/quarks.h"
 #include "view/display-main-window.h"
 #include "world/world.h"
 
index 1327bdd..23bb561 100644 (file)
@@ -73,6 +73,7 @@
 #include "term/gameterm.h"
 #include "term/term-color-types.h"
 #include "util/angband-files.h"
+#include "util/quarks.h"
 #include "world/world.h"
 
 #include <sys/stat.h>
index 94a88fe..2e56de7 100644 (file)
@@ -5,6 +5,7 @@
 #include "monster/monster-description-types.h"
 #include "monster/monster-flag-types.h"
 #include "monster/monster-info.h"
+#include "util/quarks.h"
 
 /*!
  * @brief モンスターの呼称を作成する / Build a string describing a monster in some way.
index 62f1a76..63ac7a3 100644 (file)
@@ -45,7 +45,7 @@
 #include "player/player-class.h"
 #include "player/player-personalities-types.h"
 #include "spell/spells-object.h"
-#include "util/util.h"
+#include "util/quarks.h"
 #include "view/display-main-window.h"
 #include "world/world.h"
 
index 0edb63e..f8888fa 100644 (file)
@@ -33,7 +33,7 @@
 #include "shoot.h"
 #include "sv-definition/sv-food-types.h"
 #include "sv-definition/sv-lite-types.h"
-#include "util/util.h"
+#include "util/quarks.h"
 #include "world/world.h"
 
  /*!
index 86e0500..932e046 100644 (file)
@@ -71,6 +71,7 @@
 #include "spell/technic-info-table.h"
 #include "sv-definition/sv-lite-types.h"
 #include "sv-definition/sv-weapon-types.h"
+#include "util/quarks.h"
 #include "view/display-main-window.h"
 #include "world/world.h"
 
index 55fb2c8..0a248ba 100644 (file)
@@ -77,6 +77,7 @@
 #include "system/angband.h"
 #include "term/gameterm.h"
 #include "util/object-sort.h"
+#include "util/quarks.h"
 #include "view/display-main-window.h"
 #include "view/object-describer.h"
 #include "world/world.h"
index 2ef2746..1d34ce6 100644 (file)
@@ -1,7 +1,7 @@
 #include "term/gameterm.h"
 #include "system/system-variables.h"
 #include "term/term-color-types.h"
-#include "util/util.h"
+#include "util/quarks.h"
 
  /*
  * Convert an "attr"/"char" pair into a "pict" (P)
diff --git a/src/util/quarks.c b/src/util/quarks.c
new file mode 100644 (file)
index 0000000..e2634aa
--- /dev/null
@@ -0,0 +1,58 @@
+#include "util/quarks.h"
+
+/*
+ * The number of quarks
+ */
+STR_OFFSET quark__num;
+
+/*
+ * The pointers to the quarks [QUARK_MAX]
+ */
+concptr *quark__str;
+
+/*
+ * Initialize the quark array
+ */
+void quark_init(void)
+{
+    C_MAKE(quark__str, QUARK_MAX, concptr);
+    quark__str[1] = string_make("");
+    quark__num = 2;
+}
+
+/*
+ * Add a new "quark" to the set of quarks.
+ */
+u16b quark_add(concptr str)
+{
+    u16b i;
+    for (i = 1; i < quark__num; i++) {
+        if (streq(quark__str[i], str))
+            return (i);
+    }
+
+    if (quark__num == QUARK_MAX)
+        return 1;
+
+    quark__num = i + 1;
+    quark__str[i] = string_make(str);
+    return (i);
+}
+
+/*
+ * This function looks up a quark
+ */
+concptr quark_str(STR_OFFSET i)
+{
+    concptr q;
+
+    /* Return NULL for an invalid index */
+    if ((i < 1) || (i >= quark__num))
+        return NULL;
+
+    /* Access the quark */
+    q = quark__str[i];
+
+    /* Return the quark */
+    return (q);
+}
diff --git a/src/util/quarks.h b/src/util/quarks.h
new file mode 100644 (file)
index 0000000..d91a1db
--- /dev/null
@@ -0,0 +1,18 @@
+#pragma once
+
+#include "system/angband.h"
+
+/*!
+ * @brief 銘情報の最大数 / Maximum number of "quarks" (see "io.c")
+ * @note
+ * Default: assume at most 512 different inscriptions are used<br>
+ * Was 512... 256 quarks added for random artifacts<br>
+ */
+#define QUARK_MAX 768
+
+extern STR_OFFSET quark__num;
+extern concptr *quark__str;
+
+concptr quark_str(STR_OFFSET num);
+void quark_init(void);
+u16b quark_add(concptr str);
index 712ebaf..09d007b 100644 (file)
@@ -38,6 +38,7 @@
 #include "system/system-variables.h"
 #include "term/gameterm.h"
 #include "term/term-color-types.h"
+#include "util/quarks.h"
 #include "util/string-processor.h"
 #include "view/display-main-window.h"
 #include "world/world.h"
@@ -106,16 +107,6 @@ bool use_menu;
 
 pos_list tmp_pos;
 
-/*
- * The number of quarks
- */
-STR_OFFSET quark__num;
-
-/*
- * The pointers to the quarks [QUARK_MAX]
- */
-concptr *quark__str;
-
 int max_macrotrigger = 0; /*!< 現在登録中のマクロ(トリガー)の数 */
 concptr macro_template = NULL; /*!< Angband設定ファイルのT: タグ情報から読み込んだ長いTコードを処理するために利用する文字列ポインタ */
 concptr macro_modifier_chr; /*!< &x# で指定されるマクロトリガーに関する情報を記録する文字列ポインタ */
@@ -153,58 +144,10 @@ void flush(void)
 }
 
 
-/*
- * Initialize the quark array
- */
-void quark_init(void)
-{
-       C_MAKE(quark__str, QUARK_MAX, concptr);
-       quark__str[1] = string_make("");
-       quark__num = 2;
-}
-
-
-/*
- * Add a new "quark" to the set of quarks.
- */
-u16b quark_add(concptr str)
-{
-       u16b i;
-       for (i = 1; i < quark__num; i++)
-       {
-               if (streq(quark__str[i], str)) return (i);
-       }
-
-       if (quark__num == QUARK_MAX) return 1;
-
-       quark__num = i + 1;
-       quark__str[i] = string_make(str);
-       return (i);
-}
-
-
-/*
- * This function looks up a quark
+/*!
+ * @brief 保存中の過去ゲームメッセージの数を返す。 / How many messages are "available"?
+ * @return 残っているメッセージの数
  */
-concptr quark_str(STR_OFFSET i)
-{
-       concptr q;
-
-       /* Return NULL for an invalid index */
-       if ((i < 1) || (i >= quark__num)) return NULL;
-
-       /* Access the quark */
-       q = quark__str[i];
-
-       /* Return the quark */
-       return (q);
-}
-
-
- /*!
-  * @brief 保存中の過去ゲームメッセージの数を返す。 / How many messages are "available"?
-  * @return 残っているメッセージの数
-  */
 s32b message_num(void)
 {
        int n;
index 7858ac0..45366c5 100644 (file)
@@ -125,8 +125,6 @@ extern bool use_menu;
 
 extern pos_list tmp_pos;
 
-extern STR_OFFSET quark__num;
-extern concptr *quark__str;
 /*
  * Automatically generated "variable" declarations
  */
@@ -148,14 +146,6 @@ extern s16b command_new;
 
 extern concptr keymap_act[KEYMAP_MODES][256];
 
-/*!
- * @brief 銘情報の最大数 / Maximum number of "quarks" (see "io.c")
- * @note
- * Default: assume at most 512 different inscriptions are used<br>
- * Was 512... 256 quarks added for random artifacts<br>
- */
-#define QUARK_MAX       768
-
 /*
  * OPTION: Maximum number of messages to remember (see "io.c")
  * Default: assume maximal memorization of 2048 total messages
@@ -217,9 +207,6 @@ extern const char hexsym[16];
 // todo ファイル処理関数・メッセージ処理関数・画面描画関数で最低限分割する.
 extern void flush(void);
 extern void move_cursor(int row, int col);
-extern concptr quark_str(STR_OFFSET num);
-extern void quark_init(void);
-extern u16b quark_add(concptr str);
 extern s32b message_num(void);
 extern concptr message_str(int age);
 extern void message_add(concptr msg);
index cc9df2c..7447e81 100644 (file)
@@ -37,6 +37,7 @@
 #include "system/angband-version.h"
 #include "term/term-color-types.h"
 #include "util/angband-files.h"
+#include "util/quarks.h"
 #include "view/display-lore.h"
 
  /*