OSDN Git Service

[Refactor] #38862 Moved artifact.c/h to object/
[hengband/hengband.git] / src / init.c
index c73c66a..c3951d7 100644 (file)
  * </pre>
  */
 
-#include "angband.h"
+#include "system/angband.h"
 #include "util.h"
+#include "io/uid-checker.h"
 #include "files.h"
-#include "core.h"
-#include "term.h"
+#include "system/system-variables.h"
+#include "core/angband-version.h"
+#include "io/read-pref-file.h"
+#include "gameterm.h"
 
-#include "artifact.h"
-#include "bldg.h"
+#include "object/artifact.h"
+#include "market/building.h"
 #include "init.h"
 #include "quest.h"
 #include "trap.h"
-#include "rooms.h"
-#include "store.h"
+#include "room/rooms.h"
+#include "market/store.h"
 #include "wild.h"
-#include "dungeon-file.h"
+#include "dungeon/dungeon-file.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"
-
-#ifdef CHECK_MODIFICATION_TIME
+#include "floor/floor.h"
+#include "floor/floor-town.h"
+#include "dungeon/dungeon.h"
+#include "room/rooms-vault.h"
+#include "player/player-skill.h"
+#include "player/player-class.h"
+#include "object/object-kind.h"
+#include "object/object-ego.h"
+#include "room/rooms-vault.h"
+#include "world/world.h"
+#include "market/articles-on-sale.h"
+#include "market/store-util.h"
+
 #include <sys/types.h>
 #include <sys/stat.h>
-#endif /* CHECK_MODIFICATION_TIME */
 
 static void put_title(void);
 
@@ -192,45 +195,6 @@ void init_file_paths(char *path)
        /* Build a path name */
        strcpy(tail, "xtra");
        ANGBAND_DIR_XTRA = string_make(path);
-
-
-#ifdef NeXT
-
-       /* Allow "fat binary" usage with NeXT */
-       if (TRUE)
-       {
-               concptr next = NULL;
-
-# if defined(m68k)
-               next = "m68k";
-# endif
-
-# if defined(i386)
-               next = "i386";
-# endif
-
-# if defined(sparc)
-               next = "sparc";
-# endif
-
-# if defined(hppa)
-               next = "hppa";
-# endif
-
-               /* Use special directory */
-               if (next)
-               {
-                       /* Forget the old path name */
-                       string_free(ANGBAND_DIR_DATA);
-
-                       /* Build a new path name */
-                       sprintf(tail, "data-%s", next);
-                       ANGBAND_DIR_DATA = string_make(path);
-               }
-       }
-
-#endif /* NeXT */
-
 }
 
 
@@ -286,8 +250,6 @@ header d_head; /*!< ダンジョン情報のヘッダ構造体 */
 header s_head; /*!< プレイヤー職業技能情報のヘッダ構造体 */
 header m_head; /*!< プレイヤー職業魔法情報のヘッダ構造体 */
 
-#ifdef CHECK_MODIFICATION_TIME
-
 /*!
  * @brief テキストファイルとrawファイルの更新時刻を比較する
  * Find the default paths to all of our important sub-directories.
@@ -322,7 +284,6 @@ static errr check_modification_date(int fd, concptr template_file)
        return 0;
 }
 
-#endif /* CHECK_MODIFICATION_TIME */
 
 /*** Initialize from binary image files ***/
 
@@ -456,12 +417,8 @@ static errr init_info(concptr filename, header *head, void **info, char **name,
        errr err = 1;
        if (fd >= 0)
        {
-#ifdef CHECK_MODIFICATION_TIME
-
                err = check_modification_date(fd, format("%s.txt", filename));
 
-#endif /* CHECK_MODIFICATION_TIME */
-
                /* Attempt to parse the "raw" file */
                if (!err)
                        err = init_info_raw(fd, head);
@@ -808,7 +765,7 @@ static errr init_towns(void)
                for (int j = 0; j < MAX_STORES; j++)
                {
                        /* Access the store */
-                       store_type *st_ptr = &town_info[i].store[j];
+                       store_type *store_ptr = &town_info[i].store[j];
 
                        if ((i > 1) && (j == STORE_MUSEUM || j == STORE_HOME)) continue;
 
@@ -820,28 +777,28 @@ static errr init_towns(void)
                         */
                        if (j == STORE_HOME)
                        {
-                               st_ptr->stock_size = (STORE_INVEN_MAX * 10);
+                               store_ptr->stock_size = (STORE_INVEN_MAX * 10);
                        }
                        else if (j == STORE_MUSEUM)
                        {
-                               st_ptr->stock_size = (STORE_INVEN_MAX * 50);
+                               store_ptr->stock_size = (STORE_INVEN_MAX * 50);
                        }
                        else
                        {
-                               st_ptr->stock_size = STORE_INVEN_MAX;
+                               store_ptr->stock_size = STORE_INVEN_MAX;
                        }
 
                        /* Allocate the stock */
-                       C_MAKE(st_ptr->stock, st_ptr->stock_size, object_type);
+                       C_MAKE(store_ptr->stock, store_ptr->stock_size, object_type);
 
                        /* No table for the black market or home */
                        if ((j == STORE_BLACK) || (j == STORE_HOME) || (j == STORE_MUSEUM)) continue;
 
                        /* Assume full table */
-                       st_ptr->table_size = STORE_CHOICES;
+                       store_ptr->table_size = STORE_CHOICES;
 
                        /* Allocate the stock */
-                       C_MAKE(st_ptr->table, st_ptr->table_size, s16b);
+                       C_MAKE(store_ptr->table, store_ptr->table_size, s16b);
 
                        /* Scan the choices */
                        for (int k = 0; k < STORE_CHOICES; k++)
@@ -865,7 +822,7 @@ static errr init_towns(void)
                                if (k_idx == max_k_idx) continue;
 
                                /* Add that item index to the table */
-                               st_ptr->table[st_ptr->table_num++] = k_idx;
+                               store_ptr->table[store_ptr->table_num++] = k_idx;
                        }
                }
        }
@@ -1322,9 +1279,6 @@ static errr init_object_alloc(void)
 static errr init_alloc(void)
 {
        monster_race *r_ptr;
-
-#ifdef SORT_R_INFO
-
        tag_type *elements;
 
        /* Allocate the "r_info" array */
@@ -1372,94 +1326,6 @@ static errr init_alloc(void)
 
        /* Free the "r_info" array */
        C_KILL(elements, max_r_idx, tag_type);
-
-#else /* SORT_R_INFO */
-
-       alloc_entry *table;
-       s16b num[MAX_DEPTH];
-       s16b aux[MAX_DEPTH];
-
-       /*** Analyze monster allocation info ***/
-
-       /* Clear the "aux" array */
-       C_WIPE(&aux, MAX_DEPTH, s16b);
-
-       /* Clear the "num" array */
-       C_WIPE(&num, MAX_DEPTH, s16b);
-
-       /* Size of "alloc_race_table" */
-       alloc_race_size = 0;
-
-       /* Scan the monsters */
-       for (int i = 1; i < max_r_idx; i++)
-       {
-               /* Get the i'th race */
-               r_ptr = &r_info[i];
-
-               /* Legal monsters */
-               if (r_ptr->rarity)
-               {
-                       /* Count the entries */
-                       alloc_race_size++;
-
-                       /* Group by level */
-                       num[r_ptr->level]++;
-               }
-       }
-
-       /* Collect the level indexes */
-       for (int i = 1; i < MAX_DEPTH; i++)
-       {
-               /* Group by level */
-               num[i] += num[i - 1];
-       }
-       if (!num[0]) quit(_("町のモンスターがない!", "No town monsters!"));
-
-       /*** Initialize monster allocation info ***/
-
-       /* Allocate the alloc_race_table */
-       C_MAKE(alloc_race_table, alloc_race_size, alloc_entry);
-
-       /* Access the table entry */
-       table = alloc_race_table;
-
-       /* Scan the monsters */
-       for (int i = 1; i < max_r_idx; i++)
-       {
-               /* Get the i'th race */
-               r_ptr = &r_info[i];
-
-               /* Count valid pairs */
-               if (r_ptr->rarity)
-               {
-                       int p, x, y, z;
-
-                       /* Extract the base level */
-                       x = r_ptr->level;
-
-                       /* Extract the base probability */
-                       p = (100 / r_ptr->rarity);
-
-                       /* Skip entries preceding our locale */
-                       y = (x > 0) ? num[x - 1] : 0;
-
-                       /* Skip previous entries at this locale */
-                       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;
-
-                       /* Another entry complete for this locale */
-                       aux[x]++;
-               }
-       }
-
-#endif /* SORT_R_INFO */
-
        (void)init_object_alloc();
        return 0;
 }
@@ -1568,7 +1434,7 @@ static void init_angband_aux(concptr why)
  * if needed, in the first (?) pass through "TERM_XTRA_REACT".
  * </pre>
  */
-void init_angband(player_type *player_ptr)
+void init_angband(player_type *player_ptr, void(*process_autopick_file_command)(char*))
 {
        /*** Verify the "news" file ***/
        char buf[1024];
@@ -1741,13 +1607,13 @@ void init_angband(player_type *player_ptr)
        strcpy(buf, "pref.prf");
 
        /* Process that file */
-       process_pref_file(player_ptr, buf);
+       process_pref_file(player_ptr, buf, process_autopick_file_command);
 
        /* Access the "basic" system pref file */
        sprintf(buf, "pref-%s.prf", ANGBAND_SYS);
 
        /* Process that file */
-       process_pref_file(player_ptr, buf);
+       process_pref_file(player_ptr, buf, process_autopick_file_command);
 
        note(_("[初期化終了]", "[Initialization complete]"));
 }