2 * @file game-data-initializer.cpp
3 * @brief 変愚蛮怒のゲームデータ初期化定義
6 #include "main/game-data-initializer.h"
7 #include "cmd-io/macro-util.h"
8 #include "dungeon/dungeon.h"
9 #include "dungeon/quest.h"
10 #include "floor/floor-util.h"
11 #include "game-option/option-flags.h"
12 #include "game-option/option-types-table.h"
13 #include "grid/grid.h"
14 #include "monster-race/monster-race.h"
15 #include "object/object-kind.h"
16 #include "system/alloc-entries.h"
17 #include "system/floor-type-definition.h"
18 #include "system/monster-race-definition.h"
19 #include "system/monster-type-definition.h"
20 #include "system/object-type-definition.h"
21 #include "system/player-type-definition.h"
22 #include "term/gameterm.h"
23 #include "util/angband-files.h"
24 #include "util/quarks.h"
25 #include "util/tag-sorter.h"
26 #include "view/display-messages.h"
27 #include "world/world.h"
30 * @brief マクロ登録の最大数 / Maximum number of macros (see "io.c")
31 * @note Default: assume at most 256 macros are used
33 static const int MACRO_MAX = 256;
36 * @brief クエスト情報初期化のメインルーチン /
37 * Initialize quest array
40 errr init_quests(void)
42 C_MAKE(quest, max_q_idx, quest_type);
43 for (int i = 0; i < max_q_idx; i++)
44 quest[i].status = QUEST_STATUS_UNTAKEN;
51 * Initialize some other arrays
54 errr init_other(player_type *player_ptr)
56 player_ptr->current_floor_ptr = &floor_info; // TODO:本当はこんなところで初期化したくない
57 floor_type *floor_ptr = player_ptr->current_floor_ptr;
58 C_MAKE(floor_ptr->o_list, current_world_ptr->max_o_idx, object_type);
59 C_MAKE(floor_ptr->m_list, current_world_ptr->max_m_idx, monster_type);
60 for (int i = 0; i < MAX_MTIMED; i++)
61 C_MAKE(floor_ptr->mproc_list[i], current_world_ptr->max_m_idx, s16b);
63 C_MAKE(max_dlv, current_world_ptr->max_d_idx, DEPTH);
64 for (int i = 0; i < MAX_HGT; i++)
65 C_MAKE(floor_ptr->grid_array[i], MAX_WID, grid_type);
67 C_MAKE(macro__pat, MACRO_MAX, concptr);
68 C_MAKE(macro__act, MACRO_MAX, concptr);
69 C_MAKE(macro__cmd, MACRO_MAX, bool);
70 C_MAKE(macro__buf, FILE_READ_BUFF_SIZE, char);
73 for (int i = 0; option_info[i].o_desc; i++) {
74 int os = option_info[i].o_set;
75 int ob = option_info[i].o_bit;
76 if (!option_info[i].o_var)
79 option_mask[os] |= (1UL << ob);
80 if (option_info[i].o_norm)
81 option_flag[os] |= (1UL << ob);
83 option_flag[os] &= ~(1UL << ob);
86 for (int n = 0; n < 8; n++)
87 for (int i = 0; i < 32; i++)
88 if (window_flag_desc[i])
89 window_mask[n] |= (1UL << i);
92 * Set the "default" window flags
93 * Window 1 : Display messages
94 * Window 2 : Display inven/equip
96 window_flag[1] = 1UL << A_MAX;
97 window_flag[2] = 1UL << 0;
98 (void)format("%s (%s).", "Mr.Hoge", MAINTAINER);
103 * @brief オブジェクト配列を初期化する /
104 * Initialize some other arrays
107 errr init_object_alloc(void)
110 (void)C_WIPE(aux, MAX_DEPTH, s16b);
113 (void)C_WIPE(num, MAX_DEPTH, s16b);
115 if (alloc_kind_table)
116 C_KILL(alloc_kind_table, alloc_kind_size, alloc_entry);
119 for (int i = 1; i < max_k_idx; i++) {
122 for (int j = 0; j < 4; j++) {
123 if (k_ptr->chance[j]) {
125 num[k_ptr->locale[j]]++;
130 for (int i = 1; i < MAX_DEPTH; i++)
131 num[i] += num[i - 1];
134 quit(_("町のアイテムがない!", "No town objects!"));
136 C_MAKE(alloc_kind_table, alloc_kind_size, alloc_entry);
138 table = alloc_kind_table;
139 for (int i = 1; i < max_k_idx; i++) {
142 for (int j = 0; j < 4; j++) {
143 if (k_ptr->chance[j] == 0)
146 int x = k_ptr->locale[j];
147 int p = (100 / k_ptr->chance[j]);
148 int y = (x > 0) ? num[x - 1] : 0;
150 table[z].index = (KIND_OBJECT_IDX)i;
151 table[z].level = (DEPTH)x;
152 table[z].prob1 = (PROB)p;
153 table[z].prob2 = (PROB)p;
162 * @brief モンスター配列と生成テーブルを初期化する /
163 * Initialize some other arrays
166 errr init_alloc(void)
170 C_MAKE(elements, max_r_idx, tag_type);
171 for (int i = 1; i < max_r_idx; i++) {
172 elements[i].tag = r_info[i].level;
173 elements[i].index = i;
176 tag_sort(elements, max_r_idx);
177 alloc_race_size = max_r_idx;
178 C_MAKE(alloc_race_table, alloc_race_size, alloc_entry);
179 for (int i = 1; i < max_r_idx; i++) {
180 r_ptr = &r_info[elements[i].index];
181 if (r_ptr->rarity == 0)
184 int x = r_ptr->level;
185 int p = (100 / r_ptr->rarity);
186 alloc_race_table[i].index = (KIND_OBJECT_IDX)elements[i].index;
187 alloc_race_table[i].level = (DEPTH)x;
188 alloc_race_table[i].prob1 = (PROB)p;
189 alloc_race_table[i].prob2 = (PROB)p;
192 C_KILL(elements, max_r_idx, tag_type);
193 (void)init_object_alloc();