OSDN Git Service

[Refactor] #40460 Moved various variables from init.h to info-reader-util.h in order...
authorHourier <hourier@users.sourceforge.jp>
Sat, 6 Jun 2020 02:11:06 +0000 (11:11 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sat, 6 Jun 2020 02:11:06 +0000 (11:11 +0900)
src/info-reader/info-reader-util.h
src/main/init.c
src/main/init.h

index 5e44760..55f7b19 100644 (file)
@@ -1,7 +1,44 @@
 #pragma once
 
 #include "system/angband.h"
-#include "main/init.h"
+
+/*
+ * Size of memory reserved for initialization of some arrays
+ */
+#define FAKE_NAME_SIZE 40 * 1024L /*!< ゲーム情報の種別毎に用意される名前用バッファの容量 */
+#define FAKE_TEXT_SIZE 150 * 1024L /*!< ゲーム情報の種別毎に用意されるテキスト用バッファの容量 */
+#define FAKE_TAG_SIZE 10 * 1024L /*!< ゲーム情報の種別毎に用意されるタグ用バッファの容量 */
+
+/*!
+ * @brief 各初期データ用ヘッダ構造体 / Template file header information (see "init.c").
+ */
+typedef struct angband_header angband_header;
+typedef errr (*parse_info_txt_func)(char *buf, angband_header *head);
+
+struct angband_header {
+    byte v_major; /* Version -- major */
+    byte v_minor; /* Version -- minor */
+    byte v_patch; /* Version -- patch */
+    byte v_extra; /* Version -- extra */
+
+    u16b info_num; /* Number of "info" records */
+    int info_len; /* Size of each "info" record */
+    u16b head_size; /* Size of the "header" in bytes */
+
+    STR_OFFSET info_size; /* Size of the "info" array in bytes */
+    STR_OFFSET name_size; /* Size of the "name" array in bytes */
+    STR_OFFSET text_size; /* Size of the "text" array in bytes */
+    STR_OFFSET tag_size; /* Size of the "tag" array in bytes */
+
+    void *info_ptr;
+    char *name_ptr;
+    char *text_ptr;
+    char *tag_ptr;
+
+    parse_info_txt_func parse_info_txt;
+
+    void (*retouch)(angband_header *head);
+};
 
 bool add_text(u32b *offset, angband_header *head, concptr buf, bool normal_text);
 bool add_name(u32b *offset, angband_header *head, concptr buf);
index 77968ee..b4da783 100644 (file)
 #include <sys/stat.h>
 #include <sys/types.h>
 
+/*!
+ * @brief マクロ登録の最大数 / Maximum number of macros (see "io.c")
+ * @note Default: assume at most 256 macros are used
+ */
+static const int MACRO_MAX = 256;
+
 static void put_title(void);
 
 /*!
@@ -1625,6 +1631,7 @@ static void put_title(void)
                IS_STABLE_VERSION ? _("安定版", "Stable") : _("開発版", "Developing"));
        int col = (80 - strlen(title)) / 2;
        col = col < 0 ? 0 : col;
+    const int VER_INFO_ROW = 3; //!< タイトル表記(行)
        prt(title, VER_INFO_ROW, col);
 }
 
index 4ea4668..24acd62 100644 (file)
 #define INCLUDED_INIT_H
 
 #include "system/angband.h"
-
-typedef struct angband_header angband_header;
-
-typedef errr(*parse_info_txt_func)(char *buf, angband_header *head);
-
-/*
- * Size of memory reserved for initialization of some arrays
- */
-#define FAKE_NAME_SIZE  40 * 1024L /*!< ゲーム情報の種別毎に用意される名前用バッファの容量 */
-#define FAKE_TEXT_SIZE 150 * 1024L /*!< ゲーム情報の種別毎に用意されるテキスト用バッファの容量 */
-#define FAKE_TAG_SIZE   10 * 1024L /*!< ゲーム情報の種別毎に用意されるタグ用バッファの容量 */
-
-#define VER_INFO_ROW 3   //!< タイトル表記(行)
-
- /*!
-  * @brief マクロ登録の最大数 / Maximum number of macros (see "io.c")
-  * @note Default: assume at most 256 macros are used
-  */
-#define MACRO_MAX       256
-
-
-  /*!
-   * @brief 各初期データ用ヘッダ構造体 / Template file header information (see "init.c").  16 bytes.
-   * @details
-   * Note that the sizes of many of the "arrays" are between 32768 and
-   * 65535, and so we must use "unsigned" values to hold the "sizes" of
-   * these arrays below.  Normally, I try to avoid using unsigned values,
-   * since they can cause all sorts of bizarre problems, but I have no
-   * choice here, at least, until the "race" array is split into "normal"
-   * and "unique" monsters, which may or may not actually help.
-   *
-   * Note that, on some machines, for example, the Macintosh, the standard
-   * "read()" and "write()" functions cannot handle more than 32767 bytes
-   * at one time, so we need replacement functions, see "util.c" for details.
-   *
-   * Note that, on some machines, for example, the Macintosh, the standard
-   * "malloc()" function cannot handle more than 32767 bytes at one time,
-   * but we may assume that the "ralloc()" function can handle up to 65535
-   * butes at one time.  We should not, however, assume that the "ralloc()"
-   * function can handle more than 65536 bytes at a time, since this might
-   * result in segmentation problems on certain older machines, and in fact,
-   * we should not assume that it can handle exactly 65536 bytes at a time,
-   * since the internal functions may use an unsigned short to specify size.
-   *
-   * In general, these problems occur only on machines (such as most personal
-   * computers) which use 2 byte "int" values, and which use "int" for the
-   * arguments to the relevent functions.
-   */
-struct angband_header
-{
-       byte v_major;           /* Version -- major */
-       byte v_minor;           /* Version -- minor */
-       byte v_patch;           /* Version -- patch */
-       byte v_extra;           /* Version -- extra */
-
-       u16b info_num;          /* Number of "info" records */
-       int info_len;           /* Size of each "info" record */
-       u16b head_size;         /* Size of the "header" in bytes */
-
-       STR_OFFSET info_size;           /* Size of the "info" array in bytes */
-       STR_OFFSET name_size;           /* Size of the "name" array in bytes */
-       STR_OFFSET text_size;           /* Size of the "text" array in bytes */
-       STR_OFFSET tag_size;            /* Size of the "tag" array in bytes */
-
-       void *info_ptr;
-       char *name_ptr;
-       char *text_ptr;
-       char *tag_ptr;
-
-       parse_info_txt_func parse_info_txt;
-
-       void(*retouch)(angband_header *head);
-};
+#include "info-reader/info-reader-util.h"
 
 extern int error_idx;
 extern int error_line;