OSDN Git Service

[Refactor] #37353 マジックナンバー修正(A_MAX) / Fix magic number (A_MAX).
[hengband/hengband.git] / src / init2.c
index 86c4133..7669de9 100644 (file)
@@ -35,6 +35,7 @@
 #include "angband.h"
 
 #include "init.h"
+#include "trap.h"
 
 #ifndef MACINTOSH
 #ifdef CHECK_MODIFICATION_TIME
@@ -43,8 +44,7 @@
 #endif /* CHECK_MODIFICATION_TIME */
 #endif
 
-
-
+static void put_title(void);
 
 /*!
  * @brief 各データファイルを読み取るためのパスを取得する
@@ -113,28 +113,6 @@ void init_file_paths(char *path)
        /* Prepare to append to the Base Path */
        tail = path + strlen(path);
 
-
-#ifdef VM
-
-       /*** Use "flat" paths with VM/ESA ***/
-
-       /* Use "blank" path names */
-       ANGBAND_DIR_APEX = string_make("");
-       ANGBAND_DIR_BONE = string_make("");
-       ANGBAND_DIR_DATA = string_make("");
-       ANGBAND_DIR_EDIT = string_make("");
-       ANGBAND_DIR_SCRIPT = string_make("");
-       ANGBAND_DIR_FILE = string_make("");
-       ANGBAND_DIR_HELP = string_make("");
-       ANGBAND_DIR_INFO = string_make("");
-       ANGBAND_DIR_SAVE = string_make("");
-       ANGBAND_DIR_USER = string_make("");
-       ANGBAND_DIR_XTRA = string_make("");
-
-
-#else /* VM */
-
-
        /*** Build the sub-directory names ***/
 
        /* Build a path name */
@@ -197,8 +175,6 @@ void init_file_paths(char *path)
        strcpy(tail, "xtra");
        ANGBAND_DIR_XTRA = string_make(path);
 
-#endif /* VM */
-
 
 #ifdef NeXT
 
@@ -429,7 +405,7 @@ static errr init_info_raw(int fd, header *head)
  * @param len データの長さ
  * @return エラーコード
  */
-static void init_header(header *head, int num, int len)
+static void init_header(header *head, IDX num, int len)
 {
        /* Save the "version" */
        head->v_major = FAKE_VER_MAJOR;
@@ -438,7 +414,7 @@ static void init_header(header *head, int num, int len)
        head->v_extra = 0;
 
        /* Save the "record" information */
-       head->info_num = num;
+       head->info_num = (IDX)num;
        head->info_len = len;
 
        /* Save the size of "*_head" and "*_info" */
@@ -466,7 +442,7 @@ static errr init_info(cptr filename, header *head,
 {
        int fd;
 
-       int mode = 0644;
+       BIT_FLAGS mode = 0644;
 
        errr err = 1;
 
@@ -550,7 +526,6 @@ static errr init_info(cptr filename, header *head,
                        /* Error string */
                        oops = (((err > 0) && (err < PARSE_ERROR_MAX)) ? err_str[err] : "未知の");
 
-                       /* Oops */
                        msg_format("'%s.txt'ファイルの %d 行目にエラー。", filename, error_line);
                        msg_format("レコード %d は '%s' エラーがあります。", error_idx, oops);
                        msg_format("構文 '%s'。", buf);
@@ -562,7 +537,6 @@ static errr init_info(cptr filename, header *head,
                        /* Error string */
                        oops = (((err > 0) && (err < PARSE_ERROR_MAX)) ? err_str[err] : "unknown");
 
-                       /* Oops */
                        msg_format("Error %d at line %d of '%s.txt'.", err, error_line, filename);
                        msg_format("Record %d contains a '%s' error.", error_idx, oops);
                        msg_format("Parsing '%s'.", buf);
@@ -1520,7 +1494,7 @@ static errr init_towns(void)
                        /* Scan the choices */
                        for (k = 0; k < STORE_CHOICES; k++)
                        {
-                               int k_idx;
+                               KIND_OBJECT_IDX k_idx;
 
                                /* Extract the tval/sval codes */
                                int tv = store_table[j][k][0];
@@ -1604,10 +1578,10 @@ static errr init_quests(void)
        /*** Prepare the quests ***/
 
        /* Allocate the quests */
-       C_MAKE(quest, max_quests, quest_type);
+       C_MAKE(quest, max_q_idx, quest_type);
 
        /* Set all quest to "untaken" */
-       for (i = 0; i < max_quests; i++)
+       for (i = 0; i < max_q_idx; i++)
        {
                quest[i].status = QUEST_STATUS_UNTAKEN;
        }
@@ -1625,7 +1599,7 @@ static bool feat_tag_is_not_found = FALSE;
  */
 s16b f_tag_to_index_in_init(cptr str)
 {
-       s16b feat = f_tag_to_index(str);
+       FEAT_IDX feat = f_tag_to_index(str);
 
        if (feat < 0) feat_tag_is_not_found = TRUE;
 
@@ -1640,7 +1614,7 @@ s16b f_tag_to_index_in_init(cptr str)
  */
 static errr init_feat_variables(void)
 {
-       int i;
+       FEAT_IDX i;
 
        /* Nothing */
        feat_none = f_tag_to_index_in_init("NONE");
@@ -1763,6 +1737,14 @@ static errr init_feat_variables(void)
        feat_shallow_water = f_tag_to_index_in_init("SHALLOW_WATER");
        feat_deep_lava = f_tag_to_index_in_init("DEEP_LAVA");
        feat_shallow_lava = f_tag_to_index_in_init("SHALLOW_LAVA");
+       feat_heavy_cold_zone = f_tag_to_index_in_init("HEAVY_COLD_ZONE");
+       feat_cold_zone = f_tag_to_index_in_init("COLD_ZONE");
+       feat_heavy_electrical_zone = f_tag_to_index_in_init("HEAVY_ELECTRICAL_ZONE");
+       feat_electrical_zone = f_tag_to_index_in_init("ELECTRICAL_ZONE");
+       feat_deep_acid_puddle = f_tag_to_index_in_init("DEEP_ACID_PUDDLE");
+       feat_shallow_acid_puddle = f_tag_to_index_in_init("SHALLOW_ACID_PUDDLE");
+       feat_deep_poisonous_puddle = f_tag_to_index_in_init("DEEP_POISONOUS_PUDDLE");
+       feat_shallow_poisonous_puddle = f_tag_to_index_in_init("SHALLOW_POISONOUS_PUDDLE");
        feat_dirt = f_tag_to_index_in_init("DIRT");
        feat_grass = f_tag_to_index_in_init("GRASS");
        feat_flower = f_tag_to_index_in_init("FLOWER");
@@ -1806,7 +1788,7 @@ static errr init_other(void)
        }
 
        /* Allocate and Wipe the max dungeon level */
-       C_MAKE(max_dlv, max_d_idx, s16b);
+       C_MAKE(max_dlv, max_d_idx, DEPTH);
 
        /* Allocate and wipe each line of the cave */
        for (i = 0; i < MAX_HGT; i++)
@@ -1830,7 +1812,7 @@ static errr init_other(void)
        quark_init();
 
        /* Message variables */
-       C_MAKE(message__ptr, MESSAGE_MAX, u16b);
+       C_MAKE(message__ptr, MESSAGE_MAX, u32b);
        C_MAKE(message__buf, MESSAGE_BUF, char);
 
        /* Hack -- No messages yet */
@@ -1893,7 +1875,7 @@ static errr init_other(void)
         *  Window 1 : Display messages
         *  Window 2 : Display inven/equip
         */
-       window_flag[1] = 1L << 6;
+       window_flag[1] = 1L << A_MAX;
        window_flag[2] = 1L << 0;
 
 
@@ -2003,11 +1985,11 @@ static errr init_object_alloc(void)
                                z = y + aux[x];
 
                                /* Load the entry */
-                               table[z].index = i;
-                               table[z].level = x;
-                               table[z].prob1 = p;
-                               table[z].prob2 = p;
-                               table[z].prob3 = p;
+                               table[z].index = (KIND_OBJECT_IDX)i;
+                               table[z].level = (DEPTH)x;
+                               table[z].prob1 = (PROB)p;
+                               table[z].prob2 = (PROB)p;
+                               table[z].prob3 = (PROB)p;
 
                                /* Another entry complete for this locale */
                                aux[x]++;
@@ -2072,11 +2054,11 @@ static errr init_alloc(void)
                        p = (100 / r_ptr->rarity);
 
                        /* Load the entry */
-                       alloc_race_table[i].index = elements[i].index;
-                       alloc_race_table[i].level = x;
-                       alloc_race_table[i].prob1 = p;
-                       alloc_race_table[i].prob2 = p;
-                       alloc_race_table[i].prob3 = p;
+                       alloc_race_table[i].index = (KIND_OBJECT_IDX)elements[i].index;
+                       alloc_race_table[i].level = (DEPTH)x;
+                       alloc_race_table[i].prob1 = (PROB)p;
+                       alloc_race_table[i].prob2 = (PROB)p;
+                       alloc_race_table[i].prob3 = (PROB)p;
                }
        }
 
@@ -2202,7 +2184,7 @@ static void note(cptr str)
  * @return なし
  * @note
  * <pre>
- * XXX XXX XXX This function is "messy" because various things
+ * This function is "messy" because various things
  * may or may not be initialized, but the "plog()" and "quit()"
  * functions are "supposed" to work under any conditions.
  * </pre>
@@ -2247,7 +2229,7 @@ static void init_angband_aux(cptr why)
  * @return なし
  * @note
  * <pre>
- * XXX XXX XXX This function is "messy" because various things
+ * This function is "messy" because various things
  * may or may not be initialized, but the "plog()" and "quit()"
  * functions are "supposed" to work under any conditions.
  * Verify some files, display the "news.txt" file, create
@@ -2291,7 +2273,7 @@ void init_angband(void)
 {
        int fd = -1;
 
-       int mode = 0664;
+       BIT_FLAGS mode = 0664;
 
        FILE *fp;
 
@@ -2311,7 +2293,6 @@ void init_angband(void)
        {
                char why[1024];
 
-               /* Message */
                sprintf(why, _("'%s'ファイルにアクセスできません!", "Cannot access the '%s' file!"), buf);
 
                /* Crash and burn */
@@ -2323,8 +2304,6 @@ void init_angband(void)
 
 
        /*** Display the "news" file ***/
-
-       /* Clear screen */
        Term_clear();
 
        /* Build the filename */
@@ -2381,7 +2360,6 @@ void init_angband(void)
                {
                        char why[1024];
 
-                       /* Message */
                        sprintf(why, _("'%s'ファイルを作成できません!", "Cannot create the '%s' file!"), buf);
 
                        /* Crash and burn */
@@ -2392,6 +2370,7 @@ void init_angband(void)
        /* Close it */
        (void)fd_close(fd);
 
+       put_title();
 
        /*** Initialize some arrays ***/
 
@@ -2500,11 +2479,29 @@ void init_angband(void)
        /* Process that file */
        process_pref_file(buf);
 
-       /* Done */
        note(_("[初期化終了]", "[Initialization complete]"));
 }
 
 /*!
+ * @brief タイトル記述
+ * @return なし
+ */
+static void put_title(void)
+{
+       char title[120];
+       int col;
+#if H_VER_EXTRA > 0
+       sprintf(title, _("変愚蛮怒 %d.%d.%d.%d(%s)", "Hengband %d.%d.%d.%d(%s)"), H_VER_MAJOR, H_VER_MINOR, H_VER_PATCH, H_VER_EXTRA,
+#else
+       sprintf(title, _("変愚蛮怒 %d.%d.%d(%s)", "Hengband %d.%d.%d(%s)"), H_VER_MAJOR, H_VER_MINOR, H_VER_PATCH,
+#endif
+       IS_STABLE_VERSION ? _("安定版", "Stable") : _("開発版", "Developing"));
+       col = (80 - strlen(title)) / 2;
+       col = col < 0 ? 0 : col;
+       prt(title, VER_INFO_ROW, col);
+}
+
+/*!
  * @brief サムチェック情報を出力 / Get check sum in string form
  * @return サムチェック情報の文字列
  */