OSDN Git Service

[Refactor] #38844 max_d_idx を world_type 構造体に加える. / Move max_d_idx to world_type...
[hengband/hengband.git] / src / init.c
index 0d79d94..b6c7481 100644 (file)
@@ -34,6 +34,9 @@
 
 #include "angband.h"
 #include "util.h"
+#include "files.h"
+#include "core.h"
+#include "term.h"
 
 #include "artifact.h"
 #include "bldg.h"
 #include "files.h"
 #include "feature.h"
 #include "floor.h"
+#include "floor-town.h"
 #include "dungeon.h"
 #include "rooms-vault.h"
 #include "player-skill.h"
 #include "player-class.h"
 #include "objectkind.h"
+#include "object-ego.h"
+#include "rooms-vault.h"
+#include "world.h"
 
 #ifndef MACINTOSH
 #ifdef CHECK_MODIFICATION_TIME
@@ -306,8 +313,6 @@ static errr check_modification_date(int fd, concptr template_file)
        char buf[1024];
 
        struct stat txt_stat, raw_stat;
-
-       /* Build the filename */
        path_build(buf, sizeof(buf), ANGBAND_DIR_EDIT, template_file);
 
        /* Access stats on text file */
@@ -471,8 +476,6 @@ static errr init_info(concptr filename, header *head,
 #ifdef ALLOW_TEMPLATES
 
        /*** Load the binary image file ***/
-
-       /* Build the filename */
        path_build(buf, sizeof(buf), ANGBAND_DIR_DATA, format(_("%s_j.raw", "%s.raw"), filename));
 
 
@@ -515,11 +518,7 @@ static errr init_info(concptr filename, header *head,
 
                /*** Load the ascii template file ***/
 
-               /* Build the filename */
-
                path_build(buf, sizeof(buf), ANGBAND_DIR_EDIT, format("%s.txt", filename));
-
-               /* Open the file */
                fp = my_fopen(buf, "r");
 
                /* Parse it */
@@ -573,8 +572,6 @@ static errr init_info(concptr filename, header *head,
 
                /* File type is "DATA" */
                FILE_TYPE(FILE_TYPE_DATA);
-
-               /* Build the filename */
                path_build(buf, sizeof(buf), ANGBAND_DIR_DATA, format(_("%s_j.raw", "%s.raw"), filename));
 
 
@@ -627,8 +624,6 @@ static errr init_info(concptr filename, header *head,
 
 
                /*** Load the binary image file ***/
-
-               /* Build the filename */
                path_build(buf, sizeof(buf), ANGBAND_DIR_DATA, format(_("%s_j.raw", "%s.raw"), filename));
 
                /* Attempt to open the "raw" file */
@@ -783,7 +778,7 @@ static errr init_r_info(void)
 static errr init_d_info(void)
 {
        /* Init the header */
-       init_header(&d_head, max_d_idx, sizeof(dungeon_type));
+       init_header(&d_head, current_world_ptr->max_d_idx, sizeof(dungeon_type));
 
 #ifdef ALLOW_TEMPLATES
 
@@ -1224,29 +1219,31 @@ static errr init_other(void)
 {
        int i, n;
 
+       p_ptr->current_floor_ptr = &floor_info; // TODO:本当はこんなところで初期化したくない
+
 
        /*** Prepare the "dungeon" information ***/
 
        /* Allocate and Wipe the object list */
-       C_MAKE(current_floor_ptr->o_list, current_floor_ptr->max_o_idx, object_type);
+       C_MAKE(p_ptr->current_floor_ptr->o_list, current_world_ptr->max_o_idx, object_type);
 
        /* Allocate and Wipe the monster list */
-       C_MAKE(current_floor_ptr->m_list, current_floor_ptr->max_m_idx, monster_type);
+       C_MAKE(p_ptr->current_floor_ptr->m_list, current_world_ptr->max_m_idx, monster_type);
 
        /* Allocate and Wipe the monster process list */
        for (i = 0; i < MAX_MTIMED; i++)
        {
-               C_MAKE(current_floor_ptr->mproc_list[i], current_floor_ptr->max_m_idx, s16b);
+               C_MAKE(p_ptr->current_floor_ptr->mproc_list[i], current_world_ptr->max_m_idx, s16b);
        }
 
        /* Allocate and Wipe the max dungeon level */
-       C_MAKE(max_dlv, max_d_idx, DEPTH);
+       C_MAKE(max_dlv, current_world_ptr->max_d_idx, DEPTH);
 
-       /* Allocate and wipe each line of the current_floor_ptr->grid_array */
+       /* Allocate and wipe each line of the p_ptr->current_floor_ptr->grid_array */
        for (i = 0; i < MAX_HGT; i++)
        {
-               /* Allocate one row of the current_floor_ptr->grid_array */
-               C_MAKE(current_floor_ptr->grid_array[i], MAX_WID, grid_type);
+               /* Allocate one row of the p_ptr->current_floor_ptr->grid_array */
+               C_MAKE(p_ptr->current_floor_ptr->grid_array[i], MAX_WID, grid_type);
        }
 
 
@@ -1270,13 +1267,6 @@ static errr init_other(void)
        /* Hack -- No messages yet */
        message__tail = MESSAGE_BUF;
 
-
-       /*** Prepare the Player p_ptr->inventory_list ***/
-
-       /* Allocate it */
-       C_MAKE(p_ptr->inventory_list, INVEN_TOTAL, object_type);
-
-
        /*** Prepare the options ***/
 
        /* Scan the options */
@@ -1297,11 +1287,8 @@ static errr init_other(void)
                                /* Set */
                                option_flag[os] |= (1L << ob);
                        }
-
-                       /* Clear */
                        else
                        {
-                               /* Clear */
                                option_flag[os] &= ~(1L << ob);
                        }
                }
@@ -1729,8 +1716,6 @@ void init_angband(void)
 
 
        /*** Verify the "news" file ***/
-
-       /* Build the filename */
        path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, _("news_j.txt", "news.txt"));
 
        /* Attempt to open the file */
@@ -1751,8 +1736,6 @@ void init_angband(void)
 
        /*** Display the "news" file ***/
        Term_clear();
-
-       /* Build the filename */
        path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, _("news_j.txt", "news.txt"));
 
        /* Open the News file */
@@ -1779,8 +1762,6 @@ void init_angband(void)
 
 
        /*** Verify (or create) the "high score" file ***/
-
-       /* Build the filename */
        path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
 
        /* Attempt to open the high score file */
@@ -1859,7 +1840,7 @@ void init_angband(void)
        if (init_d_info()) quit(_("ダンジョン初期化不能", "Cannot initialize dungeon"));
        {
                int i;
-               for (i = 1; i < max_d_idx; i++)
+               for (i = 1; i < current_world_ptr->max_d_idx; i++)
                        if (d_info[i].final_guardian)
                                r_info[d_info[i].final_guardian].flags7 |= RF7_GUARDIAN;
        }