OSDN Git Service

[Refactor] #37353 TRAP_* 定義を trap.h へ移動、関連要素も整理。 / Move TRAP_* definition to trap...
[hengband/hengband.git] / src / init2.c
index 5e01a23..eed984d 100644 (file)
@@ -35,6 +35,8 @@
 #include "angband.h"
 
 #include "init.h"
+#include "trap.h"
+#include "rooms.h"
 
 #ifndef MACINTOSH
 #ifdef CHECK_MODIFICATION_TIME
@@ -180,7 +182,7 @@ void init_file_paths(char *path)
        /* Allow "fat binary" usage with NeXT */
        if (TRUE)
        {
-               cptr next = NULL;
+               concptr next = NULL;
 
 # if defined(m68k)
                next = "m68k";
@@ -229,7 +231,7 @@ int error_line; /*!< データ読み込み/初期化時に汎用的にエラー
 /*!
  * エラーメッセージの名称定義 / Standard error message text
  */
-cptr err_str[PARSE_ERROR_MAX] =
+concptr err_str[PARSE_ERROR_MAX] =
 {
        NULL,
 #ifdef JP
@@ -284,7 +286,7 @@ header m_head; /*!< プレイヤー職業魔法情報のヘッダ構造体 */
  * @param template_file ファイル名
  * @return テキストの方が新しいか、rawファイルがなく更新の必要がある場合-1、更新の必要がない場合0。
  */
-static errr check_modification_date(int fd, cptr template_file)
+static errr check_modification_date(int fd, concptr template_file)
 {
        char buf[1024];
 
@@ -404,7 +406,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;
@@ -413,7 +415,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" */
@@ -436,12 +438,12 @@ static void init_header(header *head, int num, int len)
  * Note that we let each entry have a unique "name" and "text" string,
  * even if the string happens to be empty (everyone has a unique '\0').
  */
-static errr init_info(cptr filename, header *head,
+static errr init_info(concptr filename, header *head,
                      void **info, char **name, char **text, char **tag)
 {
        int fd;
 
-       int mode = 0644;
+       BIT_FLAGS mode = 0644;
 
        errr err = 1;
 
@@ -519,13 +521,12 @@ static errr init_info(cptr filename, header *head,
                /* Errors */
                if (err)
                {
-                       cptr oops;
+                       concptr oops;
 
 #ifdef JP
                        /* 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);
@@ -537,7 +538,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);
@@ -583,7 +583,7 @@ static errr init_info(cptr filename, header *head,
                if (fd >= 0)
                {
                        /* Dump it */
-                       fd_write(fd, (cptr)(head), head->head_size);
+                       fd_write(fd, (concptr)(head), head->head_size);
 
                        /* Dump the "*_info" array */
                        fd_write(fd, head->info_ptr, head->info_size);
@@ -1495,7 +1495,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];
@@ -1579,10 +1579,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;
        }
@@ -1598,9 +1598,9 @@ static bool feat_tag_is_not_found = FALSE;
  * Initialize quest array
  * @return 地形ID
  */
-s16b f_tag_to_index_in_init(cptr str)
+s16b f_tag_to_index_in_init(concptr 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;
 
@@ -1738,6 +1738,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");
@@ -1794,8 +1802,8 @@ static errr init_other(void)
        /*** Prepare the various "bizarre" arrays ***/
 
        /* Macro variables */
-       C_MAKE(macro__pat, MACRO_MAX, cptr);
-       C_MAKE(macro__act, MACRO_MAX, cptr);
+       C_MAKE(macro__pat, MACRO_MAX, concptr);
+       C_MAKE(macro__act, MACRO_MAX, concptr);
        C_MAKE(macro__cmd, MACRO_MAX, bool);
 
        /* Macro action buffer */
@@ -1868,7 +1876,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;
 
 
@@ -1978,7 +1986,7 @@ static errr init_object_alloc(void)
                                z = y + aux[x];
 
                                /* Load the entry */
-                               table[z].index = i;
+                               table[z].index = (KIND_OBJECT_IDX)i;
                                table[z].level = (DEPTH)x;
                                table[z].prob1 = (PROB)p;
                                table[z].prob2 = (PROB)p;
@@ -2047,7 +2055,7 @@ 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].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;
@@ -2162,7 +2170,7 @@ static errr init_alloc(void)
  * Hack -- take notes on line 23
  * @return なし
  */
-static void note(cptr str)
+static void note(concptr str)
 {
        Term_erase(0, 23, 255);
        Term_putstr(20, 23, -1, TERM_WHITE, str);
@@ -2177,12 +2185,12 @@ 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>
  */
-static void init_angband_aux(cptr why)
+static void init_angband_aux(concptr why)
 {
        /* Why */
        plog(why);
@@ -2222,7 +2230,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
@@ -2266,7 +2274,7 @@ void init_angband(void)
 {
        int fd = -1;
 
-       int mode = 0664;
+       BIT_FLAGS mode = 0664;
 
        FILE *fp;
 
@@ -2286,7 +2294,6 @@ void init_angband(void)
        {
                char why[1024];
 
-               /* Message */
                sprintf(why, _("'%s'ファイルにアクセスできません!", "Cannot access the '%s' file!"), buf);
 
                /* Crash and burn */
@@ -2298,8 +2305,6 @@ void init_angband(void)
 
 
        /*** Display the "news" file ***/
-
-       /* Clear screen */
        Term_clear();
 
        /* Build the filename */
@@ -2356,7 +2361,6 @@ void init_angband(void)
                {
                        char why[1024];
 
-                       /* Message */
                        sprintf(why, _("'%s'ファイルを作成できません!", "Cannot create the '%s' file!"), buf);
 
                        /* Crash and burn */
@@ -2476,7 +2480,6 @@ void init_angband(void)
        /* Process that file */
        process_pref_file(buf);
 
-       /* Done */
        note(_("[初期化終了]", "[Initialization complete]"));
 }
 
@@ -2503,7 +2506,7 @@ static void put_title(void)
  * @brief サムチェック情報を出力 / Get check sum in string form
  * @return サムチェック情報の文字列
  */
-cptr get_check_sum(void)
+concptr get_check_sum(void)
 {
        return format("%02x%02x%02x%02x%02x%02x%02x%02x%02x", 
                      f_head.v_extra,