The master and develop branches track hengband.
OS X development happens on the macos-1-6-2, macos-2-2-1, and macos-develop branches.
Revision | 62cb75f018e6c6dfe8120056445712b10ee8565b (tree) |
---|---|
Time | 2021-10-11 20:38:50 |
Author | Deskull <61610939+sikabane-works@user...> |
Commiter | GitHub |
Merge pull request #1760 from sikabane-works/feature/refactor-StoreSaleType
[Refactor] 店舗の種類を enum class StoreSaleType 型に変更しリファクタリング。
@@ -100,8 +100,8 @@ void player_birth(player_type *player_ptr) | ||
100 | 100 | |
101 | 101 | write_birth_diary(player_ptr); |
102 | 102 | for (int i = 1; i < max_towns; i++) { |
103 | - for (int j = 0; j < MAX_STORES; j++) { | |
104 | - store_init(i, j); | |
103 | + for (auto sst : StoreSaleType()) { | |
104 | + store_init(i, sst); | |
105 | 105 | } |
106 | 106 | } |
107 | 107 |
@@ -417,8 +417,8 @@ void play_game(player_type *player_ptr, bool new_game, bool browsing_movie) | ||
417 | 417 | calc_android_exp(player_ptr); |
418 | 418 | |
419 | 419 | init_riding_pet(player_ptr, new_game); |
420 | - (void)combine_and_reorder_home(player_ptr, STORE_HOME); | |
421 | - (void)combine_and_reorder_home(player_ptr, STORE_MUSEUM); | |
420 | + (void)combine_and_reorder_home(player_ptr, StoreSaleType::HOME); | |
421 | + (void)combine_and_reorder_home(player_ptr, StoreSaleType::MUSEUM); | |
422 | 422 | select_floor_music(player_ptr); |
423 | 423 | process_game_turn(player_ptr); |
424 | 424 | close_game(player_ptr); |
@@ -495,7 +495,7 @@ static void dump_aux_equipment_inventory(player_type *player_ptr, FILE *fff) | ||
495 | 495 | static void dump_aux_home_museum(player_type *player_ptr, FILE *fff) |
496 | 496 | { |
497 | 497 | store_type *store_ptr; |
498 | - store_ptr = &town_info[1].store[STORE_HOME]; | |
498 | + store_ptr = &town_info[1].store[enum2i(StoreSaleType::HOME)]; | |
499 | 499 | |
500 | 500 | GAME_TEXT o_name[MAX_NLEN]; |
501 | 501 | if (store_ptr->stock_num) { |
@@ -512,7 +512,7 @@ static void dump_aux_home_museum(player_type *player_ptr, FILE *fff) | ||
512 | 512 | fprintf(fff, "\n\n"); |
513 | 513 | } |
514 | 514 | |
515 | - store_ptr = &town_info[1].store[STORE_MUSEUM]; | |
515 | + store_ptr = &town_info[1].store[enum2i(StoreSaleType::MUSEUM)]; | |
516 | 516 | |
517 | 517 | if (store_ptr->stock_num == 0) |
518 | 518 | return; |
@@ -93,13 +93,13 @@ void spoil_random_artifact(player_type *player_ptr, concptr fname) | ||
93 | 93 | spoil_random_artifact_aux(player_ptr, q_ptr, tval); |
94 | 94 | } |
95 | 95 | |
96 | - store_ptr = &town_info[1].store[STORE_HOME]; | |
96 | + store_ptr = &town_info[1].store[enum2i(StoreSaleType::HOME)]; | |
97 | 97 | for (int i = 0; i < store_ptr->stock_num; i++) { |
98 | 98 | q_ptr = &store_ptr->stock[i]; |
99 | 99 | spoil_random_artifact_aux(player_ptr, q_ptr, tval); |
100 | 100 | } |
101 | 101 | |
102 | - store_ptr = &town_info[1].store[STORE_MUSEUM]; | |
102 | + store_ptr = &town_info[1].store[enum2i(StoreSaleType::MUSEUM)]; | |
103 | 103 | for (int i = 0; i < store_ptr->stock_num; i++) { |
104 | 104 | q_ptr = &store_ptr->stock[i]; |
105 | 105 | spoil_random_artifact_aux(player_ptr, q_ptr, tval); |
@@ -537,7 +537,7 @@ void process_command(player_type *player_ptr) | ||
537 | 537 | } |
538 | 538 | case '=': { |
539 | 539 | do_cmd_options(player_ptr); |
540 | - (void)combine_and_reorder_home(player_ptr, STORE_HOME); | |
540 | + (void)combine_and_reorder_home(player_ptr, StoreSaleType::HOME); | |
541 | 541 | do_cmd_redraw(player_ptr); |
542 | 542 | break; |
543 | 543 | } |
@@ -256,7 +256,7 @@ static void show_holding_equipment_resistances(player_type *player_ptr, tval_typ | ||
256 | 256 | static void show_home_equipment_resistances(player_type *player_ptr, tval_type tval, int *label_number, FILE *fff) |
257 | 257 | { |
258 | 258 | store_type *store_ptr; |
259 | - store_ptr = &town_info[1].store[STORE_HOME]; | |
259 | + store_ptr = &town_info[1].store[enum2i(StoreSaleType::HOME)]; | |
260 | 260 | char where[32]; |
261 | 261 | strcpy(where, _("家", "H ")); |
262 | 262 | for (int i = 0; i < store_ptr->stock_num; i++) { |
@@ -217,7 +217,7 @@ void do_cmd_knowledge_home(player_type *player_ptr) | ||
217 | 217 | return; |
218 | 218 | |
219 | 219 | store_type *store_ptr; |
220 | - store_ptr = &town_info[1].store[STORE_HOME]; | |
220 | + store_ptr = &town_info[1].store[enum2i(StoreSaleType::HOME)]; | |
221 | 221 | |
222 | 222 | if (store_ptr->stock_num) { |
223 | 223 | #ifdef JP |
@@ -36,7 +36,7 @@ static void home_carry_load(player_type *player_ptr, store_type *store_ptr, obje | ||
36 | 36 | return; |
37 | 37 | } |
38 | 38 | |
39 | - if (store_ptr->stock_num >= store_get_stock_max(STORE_HOME)) | |
39 | + if (store_ptr->stock_num >= store_get_stock_max(StoreSaleType::HOME)) | |
40 | 40 | return; |
41 | 41 | |
42 | 42 | int32_t value = object_value(o_ptr); |
@@ -66,7 +66,7 @@ static errr rd_store(player_type *player_ptr, int town_number, int store_number) | ||
66 | 66 | { |
67 | 67 | store_type *store_ptr; |
68 | 68 | bool sort = false; |
69 | - if (h_older_than(0, 3, 3) && (store_number == STORE_HOME)) { | |
69 | + if (h_older_than(0, 3, 3) && (i2enum<StoreSaleType>(store_number) == StoreSaleType::HOME)) { | |
70 | 70 | store_ptr = &town_info[1].store[store_number]; |
71 | 71 | if (store_ptr->stock_num) |
72 | 72 | sort = true; |
@@ -101,7 +101,7 @@ static errr rd_store(player_type *player_ptr, int town_number, int store_number) | ||
101 | 101 | |
102 | 102 | rd_item(q_ptr); |
103 | 103 | |
104 | - auto stock_max = store_get_stock_max(i2enum<STORE_TYPE_IDX>(store_number)); | |
104 | + auto stock_max = store_get_stock_max(i2enum<StoreSaleType>(store_number)); | |
105 | 105 | if (store_ptr->stock_num >= stock_max) |
106 | 106 | continue; |
107 | 107 |
@@ -19,24 +19,24 @@ errr init_towns(void) | ||
19 | 19 | town_info = std::vector<town_type>(max_towns); |
20 | 20 | for (int i = 1; i < max_towns; i++) { |
21 | 21 | town_info[i].store = std::vector<store_type>(MAX_STORES); |
22 | - for (int j = 0; j < MAX_STORES; j++) { | |
23 | - store_type *store_ptr = &town_info[i].store[j]; | |
24 | - if ((i > 1) && (j == STORE_MUSEUM || j == STORE_HOME)) | |
22 | + for (auto sst : StoreSaleType()) { | |
23 | + store_type *store_ptr = &town_info[i].store[enum2i(sst)]; | |
24 | + if ((i > 1) && (sst == StoreSaleType::MUSEUM || sst == StoreSaleType::HOME)) | |
25 | 25 | continue; |
26 | 26 | |
27 | 27 | /* |
28 | 28 | * 我が家が 20 ページまで使える隠し機能のための準備。 |
29 | 29 | * オプションが有効でもそうでなくても一応スペースを作っておく。 |
30 | 30 | */ |
31 | - store_ptr->stock_size = store_get_stock_max(i2enum<STORE_TYPE_IDX>(j)); | |
31 | + store_ptr->stock_size = store_get_stock_max(sst); | |
32 | 32 | |
33 | 33 | store_ptr->stock = std::make_unique<object_type[]>(store_ptr->stock_size); |
34 | - if ((j == STORE_BLACK) || (j == STORE_HOME) || (j == STORE_MUSEUM)) | |
34 | + if ((sst == StoreSaleType::BLACK) || (sst == StoreSaleType::HOME) || (sst == StoreSaleType::MUSEUM)) | |
35 | 35 | continue; |
36 | 36 | |
37 | 37 | for (int k = 0; k < STORE_INVEN_MAX; k++) { |
38 | - int tv = store_regular_table[j][k].tval; | |
39 | - int sv = store_regular_table[j][k].sval; | |
38 | + int tv = store_regular_table[enum2i(sst)][k].tval; | |
39 | + int sv = store_regular_table[enum2i(sst)][k].sval; | |
40 | 40 | if (tv == 0) |
41 | 41 | break; |
42 | 42 |
@@ -49,8 +49,8 @@ errr init_towns(void) | ||
49 | 49 | } |
50 | 50 | |
51 | 51 | for (int k = 0; k < STORE_CHOICES; k++) { |
52 | - int tv = store_table[j][k].tval; | |
53 | - int sv = store_table[j][k].sval; | |
52 | + int tv = store_table[enum2i(sst)][k].tval; | |
53 | + int sv = store_table[enum2i(sst)][k].sval; | |
54 | 54 | if (tv == 0) |
55 | 55 | break; |
56 | 56 |
@@ -244,13 +244,13 @@ void process_world_aux_mutation(player_type *player_ptr) | ||
244 | 244 | |
245 | 245 | banish_monsters(player_ptr, 100); |
246 | 246 | if (!is_in_dungeon(player_ptr) && player_ptr->town_num) { |
247 | - int n; | |
247 | + StoreSaleType sst; | |
248 | 248 | do { |
249 | - n = randint0(MAX_STORES); | |
250 | - } while ((n == STORE_HOME) || (n == STORE_MUSEUM)); | |
249 | + sst = i2enum<StoreSaleType>(randint0(MAX_STORES)); | |
250 | + } while ((sst == StoreSaleType::HOME) || (sst == StoreSaleType::MUSEUM)); | |
251 | 251 | |
252 | 252 | msg_print(_("店の主人が丘に向かって走っている!", "You see one of the shopkeepers running for the hills!")); |
253 | - store_shuffle(player_ptr, n); | |
253 | + store_shuffle(player_ptr, sst); | |
254 | 254 | } |
255 | 255 | msg_print(nullptr); |
256 | 256 | } |
@@ -270,7 +270,7 @@ static void home_aware(player_type *player_ptr) | ||
270 | 270 | object_type *o_ptr; |
271 | 271 | store_type *store_ptr; |
272 | 272 | for (int i = 1; i < max_towns; i++) { |
273 | - store_ptr = &town_info[i].store[STORE_HOME]; | |
273 | + store_ptr = &town_info[i].store[enum2i(StoreSaleType::HOME)]; | |
274 | 274 | for (int j = 0; j < store_ptr->stock_num; j++) { |
275 | 275 | o_ptr = &store_ptr->stock[j]; |
276 | 276 | if (!o_ptr->k_idx) |
@@ -317,7 +317,7 @@ static void show_dead_home_items(player_type *player_ptr) | ||
317 | 317 | { |
318 | 318 | for (int l = 1; l < max_towns; l++) { |
319 | 319 | store_type *store_ptr; |
320 | - store_ptr = &town_info[l].store[STORE_HOME]; | |
320 | + store_ptr = &town_info[l].store[enum2i(StoreSaleType::HOME)]; | |
321 | 321 | if (store_ptr->stock_num == 0) |
322 | 322 | continue; |
323 | 323 |
@@ -99,7 +99,7 @@ static void generate_fill_perm_bold(player_type *player_ptr, POSITION y1, POSITI | ||
99 | 99 | * @note |
100 | 100 | * Note: ltcy and ltcx indicate "left top corner". |
101 | 101 | */ |
102 | -static void build_stores(player_type *player_ptr, POSITION ltcy, POSITION ltcx, int stores[], int n, const std::vector<ugbldg_type>& ugbldg) | |
102 | +static void build_stores(player_type *player_ptr, POSITION ltcy, POSITION ltcx, StoreSaleType stores[], int n, const std::vector<ugbldg_type>& ugbldg) | |
103 | 103 | { |
104 | 104 | int i; |
105 | 105 | POSITION y, x; |
@@ -143,7 +143,7 @@ static void build_stores(player_type *player_ptr, POSITION ltcy, POSITION ltcx, | ||
143 | 143 | |
144 | 144 | if (auto it = std::find_if(f_info.begin(), f_info.end(), |
145 | 145 | [subtype = stores[i]](const feature_type &f_ref) { |
146 | - return f_ref.flags.has(FF::STORE) && (f_ref.subtype == subtype); | |
146 | + return f_ref.flags.has(FF::STORE) && (i2enum<StoreSaleType>(static_cast<int>(f_ref.subtype)) == subtype); | |
147 | 147 | }); |
148 | 148 | it != f_info.end()) { |
149 | 149 | cave_set_feat(player_ptr, ltcy + y, ltcx + x, (*it).idx); |
@@ -167,15 +167,15 @@ static void build_stores(player_type *player_ptr, POSITION ltcy, POSITION ltcx, | ||
167 | 167 | */ |
168 | 168 | bool build_type16(player_type *player_ptr, dun_data_type *dd_ptr) |
169 | 169 | { |
170 | - int stores[] = { | |
171 | - STORE_GENERAL, | |
172 | - STORE_ARMOURY, | |
173 | - STORE_WEAPON, | |
174 | - STORE_TEMPLE, | |
175 | - STORE_ALCHEMIST, | |
176 | - STORE_MAGIC, | |
177 | - STORE_BLACK, | |
178 | - STORE_BOOK, | |
170 | + StoreSaleType stores[] = { | |
171 | + StoreSaleType::GENERAL, | |
172 | + StoreSaleType::ARMOURY, | |
173 | + StoreSaleType::WEAPON, | |
174 | + StoreSaleType::TEMPLE, | |
175 | + StoreSaleType::ALCHEMIST, | |
176 | + StoreSaleType::MAGIC, | |
177 | + StoreSaleType::BLACK, | |
178 | + StoreSaleType::BOOK, | |
179 | 179 | }; |
180 | 180 | int n = sizeof stores / sizeof(int); |
181 | 181 | POSITION y1, x1, yval, xval; |
@@ -426,7 +426,7 @@ static void build_vault( | ||
426 | 426 | /* Black market in a dungeon */ |
427 | 427 | case 'S': |
428 | 428 | set_cave_feat(floor_ptr, y, x, feat_black_market); |
429 | - store_init(NO_TOWN, STORE_BLACK); | |
429 | + store_init(NO_TOWN, StoreSaleType::BLACK); | |
430 | 430 | break; |
431 | 431 | |
432 | 432 | /* The Pattern */ |
@@ -31,14 +31,13 @@ bool black_market_crap(player_type *player_ptr, object_type *o_ptr) | ||
31 | 31 | if (o_ptr->to_d > 0) |
32 | 32 | return false; |
33 | 33 | |
34 | - for (int i = 0; i < MAX_STORES; i++) { | |
35 | - if (i == STORE_HOME) | |
36 | - continue; | |
37 | - if (i == STORE_MUSEUM) | |
34 | + for (auto sst : StoreSaleType()) { | |
35 | + if (sst == StoreSaleType::HOME || sst == StoreSaleType::MUSEUM) { | |
38 | 36 | continue; |
37 | + } | |
39 | 38 | |
40 | - for (int j = 0; j < town_info[player_ptr->town_num].store[i].stock_num; j++) { | |
41 | - object_type *j_ptr = &town_info[player_ptr->town_num].store[i].stock[j]; | |
39 | + for (int j = 0; j < town_info[player_ptr->town_num].store[enum2i(sst)].stock_num; j++) { | |
40 | + object_type *j_ptr = &town_info[player_ptr->town_num].store[enum2i(sst)].stock[j]; | |
42 | 41 | if (o_ptr->k_idx == j_ptr->k_idx) |
43 | 42 | return true; |
44 | 43 | } |
@@ -76,27 +76,27 @@ void do_cmd_store(player_type *player_ptr) | ||
76 | 76 | // inner_town_num は、施設内で C コマンドなどを使ったときにそのままでは現在地の偽装がバレる |
77 | 77 | // ため、それを糊塗するためのグローバル変数。 |
78 | 78 | // この辺はリファクタしたい。 |
79 | - int which = f_info[g_ptr->feat].subtype; | |
79 | + StoreSaleType which = i2enum<StoreSaleType>(f_info[g_ptr->feat].subtype); | |
80 | 80 | old_town_num = player_ptr->town_num; |
81 | - if ((which == STORE_HOME) || (which == STORE_MUSEUM)) | |
81 | + if ((which == StoreSaleType::HOME) || (which == StoreSaleType::MUSEUM)) | |
82 | 82 | player_ptr->town_num = 1; |
83 | 83 | if (is_in_dungeon(player_ptr)) |
84 | 84 | player_ptr->town_num = NO_TOWN; |
85 | 85 | inner_town_num = player_ptr->town_num; |
86 | 86 | |
87 | - if ((town_info[player_ptr->town_num].store[which].store_open >= w_ptr->game_turn) || ironman_shops) { | |
87 | + if ((town_info[player_ptr->town_num].store[enum2i(which)].store_open >= w_ptr->game_turn) || ironman_shops) { | |
88 | 88 | msg_print(_("ドアに鍵がかかっている。", "The doors are locked.")); |
89 | 89 | player_ptr->town_num = old_town_num; |
90 | 90 | return; |
91 | 91 | } |
92 | 92 | |
93 | - int maintain_num = (w_ptr->game_turn - town_info[player_ptr->town_num].store[which].last_visit) / (TURNS_PER_TICK * STORE_TICKS); | |
93 | + int maintain_num = (w_ptr->game_turn - town_info[player_ptr->town_num].store[enum2i(which)].last_visit) / (TURNS_PER_TICK * STORE_TICKS); | |
94 | 94 | if (maintain_num > 10) |
95 | 95 | maintain_num = 10; |
96 | 96 | if (maintain_num) { |
97 | 97 | store_maintenance(player_ptr, player_ptr->town_num, which, maintain_num); |
98 | 98 | |
99 | - town_info[player_ptr->town_num].store[which].last_visit = w_ptr->game_turn; | |
99 | + town_info[player_ptr->town_num].store[enum2i(which)].last_visit = w_ptr->game_turn; | |
100 | 100 | } |
101 | 101 | |
102 | 102 | forget_lite(player_ptr->current_floor_ptr); |
@@ -108,8 +108,8 @@ void do_cmd_store(player_type *player_ptr) | ||
108 | 108 | get_com_no_macros = true; |
109 | 109 | cur_store_num = which; |
110 | 110 | cur_store_feat = g_ptr->feat; |
111 | - st_ptr = &town_info[player_ptr->town_num].store[cur_store_num]; | |
112 | - ot_ptr = &owners[cur_store_num][st_ptr->owner]; | |
111 | + st_ptr = &town_info[player_ptr->town_num].store[enum2i(cur_store_num)]; | |
112 | + ot_ptr = &owners[enum2i(cur_store_num)][st_ptr->owner]; | |
113 | 113 | store_top = 0; |
114 | 114 | play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_BUILD); |
115 | 115 | display_store(player_ptr); |
@@ -124,11 +124,11 @@ void do_cmd_store(player_type *player_ptr) | ||
124 | 124 | prt(_(" スペース) 次ページ", " SPACE) Next page"), 23 + xtra_stock, 0); |
125 | 125 | } |
126 | 126 | |
127 | - if (cur_store_num == STORE_HOME) { | |
127 | + if (cur_store_num == StoreSaleType::HOME) { | |
128 | 128 | prt(_("g) アイテムを取る", "g) Get an item."), 21 + xtra_stock, 27); |
129 | 129 | prt(_("d) アイテムを置く", "d) Drop an item."), 22 + xtra_stock, 27); |
130 | 130 | prt(_("x) 家のアイテムを調べる", "x) eXamine an item in the home."), 23 + xtra_stock, 27); |
131 | - } else if (cur_store_num == STORE_MUSEUM) { | |
131 | + } else if (cur_store_num == StoreSaleType::MUSEUM) { | |
132 | 132 | prt(_("d) アイテムを置く", "d) Drop an item."), 21 + xtra_stock, 27); |
133 | 133 | prt(_("r) アイテムの展示をやめる", "r) order to Remove an item."), 22 + xtra_stock, 27); |
134 | 134 | prt(_("x) 博物館のアイテムを調べる", "x) eXamine an item in the museum."), 23 + xtra_stock, 27); |
@@ -154,8 +154,8 @@ void do_cmd_store(player_type *player_ptr) | ||
154 | 154 | if (player_ptr->inventory_list[INVEN_PACK].k_idx) { |
155 | 155 | INVENTORY_IDX item = INVEN_PACK; |
156 | 156 | object_type *o_ptr = &player_ptr->inventory_list[item]; |
157 | - if (cur_store_num != STORE_HOME) { | |
158 | - if (cur_store_num == STORE_MUSEUM) | |
157 | + if (cur_store_num != StoreSaleType::HOME) { | |
158 | + if (cur_store_num == StoreSaleType::MUSEUM) | |
159 | 159 | msg_print(_("ザックからアイテムがあふれそうなので、あわてて博物館から出た...", "Your pack is so full that you flee the Museum...")); |
160 | 160 | else |
161 | 161 | msg_print(_("ザックからアイテムがあふれそうなので、あわてて店から出た...", "Your pack is so full that you flee the store...")); |
@@ -27,7 +27,7 @@ int home_carry(player_type *player_ptr, object_type *o_ptr) | ||
27 | 27 | { |
28 | 28 | bool old_stack_force_notes = stack_force_notes; |
29 | 29 | bool old_stack_force_costs = stack_force_costs; |
30 | - if (cur_store_num != STORE_HOME) { | |
30 | + if (cur_store_num != StoreSaleType::HOME) { | |
31 | 31 | stack_force_notes = false; |
32 | 32 | stack_force_costs = false; |
33 | 33 | } |
@@ -37,7 +37,7 @@ int home_carry(player_type *player_ptr, object_type *o_ptr) | ||
37 | 37 | j_ptr = &st_ptr->stock[slot]; |
38 | 38 | if (object_similar(j_ptr, o_ptr)) { |
39 | 39 | object_absorb(j_ptr, o_ptr); |
40 | - if (cur_store_num != STORE_HOME) { | |
40 | + if (cur_store_num != StoreSaleType::HOME) { | |
41 | 41 | stack_force_notes = old_stack_force_notes; |
42 | 42 | stack_force_costs = old_stack_force_costs; |
43 | 43 | } |
@@ -46,7 +46,7 @@ int home_carry(player_type *player_ptr, object_type *o_ptr) | ||
46 | 46 | } |
47 | 47 | } |
48 | 48 | |
49 | - if (cur_store_num != STORE_HOME) { | |
49 | + if (cur_store_num != StoreSaleType::HOME) { | |
50 | 50 | stack_force_notes = old_stack_force_notes; |
51 | 51 | stack_force_costs = old_stack_force_costs; |
52 | 52 | } |
@@ -56,7 +56,7 @@ int home_carry(player_type *player_ptr, object_type *o_ptr) | ||
56 | 56 | * 隠し機能: オプション powerup_home が設定されていると |
57 | 57 | * 我が家が 20 ページまで使える |
58 | 58 | */ |
59 | - if ((cur_store_num != STORE_HOME) || powerup_home) { | |
59 | + if ((cur_store_num != StoreSaleType::HOME) || powerup_home) { | |
60 | 60 | if (st_ptr->stock_num >= st_ptr->stock_size) { |
61 | 61 | return -1; |
62 | 62 | } |
@@ -164,14 +164,14 @@ static void exe_reorder_store_item(player_type *player_ptr, bool *flag) | ||
164 | 164 | * @param store_num 店舗ID |
165 | 165 | * @return 実際に整理が行われたならばTRUEを返す。 |
166 | 166 | */ |
167 | -bool combine_and_reorder_home(player_type *player_ptr, const int store_num) | |
167 | +bool combine_and_reorder_home(player_type *player_ptr, const StoreSaleType store_num) | |
168 | 168 | { |
169 | 169 | bool old_stack_force_notes = stack_force_notes; |
170 | 170 | bool old_stack_force_costs = stack_force_costs; |
171 | 171 | store_type *old_st_ptr = st_ptr; |
172 | - st_ptr = &town_info[1].store[store_num]; | |
172 | + st_ptr = &town_info[1].store[enum2i(store_num)]; | |
173 | 173 | bool flag = false; |
174 | - if (store_num != STORE_HOME) { | |
174 | + if (store_num != StoreSaleType::HOME) { | |
175 | 175 | stack_force_notes = false; |
176 | 176 | stack_force_costs = false; |
177 | 177 | } |
@@ -193,7 +193,7 @@ bool combine_and_reorder_home(player_type *player_ptr, const int store_num) | ||
193 | 193 | |
194 | 194 | exe_reorder_store_item(player_ptr, &flag); |
195 | 195 | st_ptr = old_st_ptr; |
196 | - if (store_num != STORE_HOME) { | |
196 | + if (store_num != StoreSaleType::HOME) { | |
197 | 197 | stack_force_notes = old_stack_force_notes; |
198 | 198 | stack_force_costs = old_stack_force_costs; |
199 | 199 | } |
@@ -1,6 +1,7 @@ | ||
1 | 1 | #pragma once |
2 | 2 | |
3 | -struct object_type;; | |
3 | +struct object_type; | |
4 | 4 | struct player_type; |
5 | +enum class StoreSaleType; | |
5 | 6 | int home_carry(player_type *player_ptr, object_type *o_ptr); |
6 | -bool combine_and_reorder_home(player_type *player_ptr, const int store_num); | |
7 | +bool combine_and_reorder_home(player_type *player_ptr, const StoreSaleType store_num); |
@@ -44,7 +44,7 @@ void museum_remove_object(player_type *player_ptr) | ||
44 | 44 | msg_format(_("%sの展示をやめさせた。", "You ordered to remove %s."), o_name); |
45 | 45 | store_item_increase(item, -o_ptr->number); |
46 | 46 | store_item_optimize(item); |
47 | - (void)combine_and_reorder_home(player_ptr, STORE_MUSEUM); | |
47 | + (void)combine_and_reorder_home(player_ptr, StoreSaleType::MUSEUM); | |
48 | 48 | if (st_ptr->stock_num == 0) |
49 | 49 | store_top = 0; |
50 | 50 | else if (store_top >= st_ptr->stock_num) |
@@ -45,7 +45,7 @@ PRICE price_item(player_type *player_ptr, object_type *o_ptr, int greed, bool fl | ||
45 | 45 | if (adjust > 100) |
46 | 46 | adjust = 100; |
47 | 47 | |
48 | - if (cur_store_num == STORE_BLACK) | |
48 | + if (cur_store_num == StoreSaleType::BLACK) | |
49 | 49 | price = price / 2; |
50 | 50 | |
51 | 51 | price = (price * adjust + 50L) / 100L; |
@@ -54,7 +54,7 @@ PRICE price_item(player_type *player_ptr, object_type *o_ptr, int greed, bool fl | ||
54 | 54 | if (adjust < 100) |
55 | 55 | adjust = 100; |
56 | 56 | |
57 | - if (cur_store_num == STORE_BLACK) | |
57 | + if (cur_store_num == StoreSaleType::BLACK) | |
58 | 58 | price = price * 2; |
59 | 59 | |
60 | 60 | price = (int32_t)(((uint32_t)price * (uint32_t)adjust + 50UL) / 100UL); |
@@ -73,10 +73,10 @@ static bool show_store_select_item(COMMAND_CODE *item, const int i) | ||
73 | 73 | char out_val[160]; |
74 | 74 | |
75 | 75 | switch (cur_store_num) { |
76 | - case STORE_HOME: | |
76 | + case StoreSaleType::HOME: | |
77 | 77 | sprintf(out_val, _("どのアイテムを取りますか? ", "Which item do you want to take? ")); |
78 | 78 | break; |
79 | - case STORE_BLACK: | |
79 | + case StoreSaleType::BLACK: | |
80 | 80 | sprintf(out_val, _("どれ? ", "Which item, huh? ")); |
81 | 81 | break; |
82 | 82 | default: |
@@ -112,7 +112,7 @@ static void take_item_from_home(player_type *player_ptr, object_type *o_ptr, obj | ||
112 | 112 | store_item_increase(item, -amt); |
113 | 113 | store_item_optimize(item); |
114 | 114 | |
115 | - auto combined_or_reordered = combine_and_reorder_home(player_ptr, STORE_HOME); | |
115 | + auto combined_or_reordered = combine_and_reorder_home(player_ptr, StoreSaleType::HOME); | |
116 | 116 | |
117 | 117 | if (i == st_ptr->stock_num) { |
118 | 118 | if (combined_or_reordered) |
@@ -177,13 +177,13 @@ static void switch_store_stock(player_type *player_ptr, const int i, const COMMA | ||
177 | 177 | */ |
178 | 178 | void store_purchase(player_type *player_ptr) |
179 | 179 | { |
180 | - if (cur_store_num == STORE_MUSEUM) { | |
180 | + if (cur_store_num == StoreSaleType::MUSEUM) { | |
181 | 181 | msg_print(_("博物館から取り出すことはできません。", "Items cannot be taken out of the Museum.")); |
182 | 182 | return; |
183 | 183 | } |
184 | 184 | |
185 | 185 | if (st_ptr->stock_num <= 0) { |
186 | - if (cur_store_num == STORE_HOME) | |
186 | + if (cur_store_num == StoreSaleType::HOME) | |
187 | 187 | msg_print(_("我が家には何も置いてありません。", "Your home is empty.")); |
188 | 188 | else |
189 | 189 | msg_print(_("現在商品の在庫を切らしています。", "I am currently out of stock.")); |
@@ -220,7 +220,7 @@ void store_purchase(player_type *player_ptr) | ||
220 | 220 | |
221 | 221 | PRICE best = price_item(player_ptr, j_ptr, ot_ptr->inflate, false); |
222 | 222 | if (o_ptr->number > 1) { |
223 | - if (cur_store_num != STORE_HOME) { | |
223 | + if (cur_store_num != StoreSaleType::HOME) { | |
224 | 224 | msg_format(_("一つにつき $%ldです。", "That costs %ld gold per item."), (long)(best)); |
225 | 225 | } |
226 | 226 |
@@ -243,7 +243,7 @@ void store_purchase(player_type *player_ptr) | ||
243 | 243 | return; |
244 | 244 | } |
245 | 245 | |
246 | - if (cur_store_num == STORE_HOME) { | |
246 | + if (cur_store_num == StoreSaleType::HOME) { | |
247 | 247 | take_item_from_home(player_ptr, o_ptr, j_ptr, item); |
248 | 248 | return; |
249 | 249 | } |
@@ -269,9 +269,9 @@ void store_purchase(player_type *player_ptr) | ||
269 | 269 | } |
270 | 270 | |
271 | 271 | store_owner_says_comment(player_ptr); |
272 | - if (cur_store_num == STORE_BLACK) | |
272 | + if (cur_store_num == StoreSaleType::BLACK) | |
273 | 273 | chg_virtue(player_ptr, V_JUSTICE, -1); |
274 | - if ((o_ptr->tval == TV_BOTTLE) && (cur_store_num != STORE_HOME)) | |
274 | + if ((o_ptr->tval == TV_BOTTLE) && (cur_store_num != StoreSaleType::HOME)) | |
275 | 275 | chg_virtue(player_ptr, V_NATURE, -1); |
276 | 276 | |
277 | 277 | sound(SOUND_BUY); |
@@ -17,7 +17,7 @@ | ||
17 | 17 | */ |
18 | 18 | void store_owner_says_comment(player_type *player_ptr) |
19 | 19 | { |
20 | - if (cur_store_num == STORE_BLACK) | |
20 | + if (cur_store_num == StoreSaleType::BLACK) | |
21 | 21 | msg_print(comment_1_B[randint0(MAX_COMMENT_1)]); |
22 | 22 | else |
23 | 23 | msg_print(comment_1[randint0(MAX_COMMENT_1)]); |
@@ -73,12 +73,12 @@ void store_sell(player_type *player_ptr) | ||
73 | 73 | concptr s_none; //!< @note 売る/置くものがない場合のメッセージ |
74 | 74 | concptr s_full; //!< @note もう置けない場合のメッセージ |
75 | 75 | switch (cur_store_num) { |
76 | - case STORE_HOME: | |
76 | + case StoreSaleType::HOME: | |
77 | 77 | q = _("どのアイテムを置きますか? ", "Drop which item? "); |
78 | 78 | s_none = _("置けるアイテムを持っていません。", "You don't have any items to drop."); |
79 | 79 | s_full = _("我が家にはもう置く場所がない。", "Your home is full."); |
80 | 80 | break; |
81 | - case STORE_MUSEUM: | |
81 | + case StoreSaleType::MUSEUM: | |
82 | 82 | q = _("どのアイテムを寄贈しますか? ", "Give which item? "); |
83 | 83 | s_none = _("寄贈できるアイテムを持っていません。", "You don't have any items to give."); |
84 | 84 | s_full = _("博物館はもう満杯だ。", "The Museum is full."); |
@@ -118,7 +118,7 @@ void store_sell(player_type *player_ptr) | ||
118 | 118 | |
119 | 119 | GAME_TEXT o_name[MAX_NLEN]; |
120 | 120 | describe_flavor(player_ptr, o_name, q_ptr, 0); |
121 | - if ((cur_store_num != STORE_HOME) && (cur_store_num != STORE_MUSEUM)) { | |
121 | + if ((cur_store_num != StoreSaleType::HOME) && (cur_store_num != StoreSaleType::MUSEUM)) { | |
122 | 122 | q_ptr->inscription = 0; |
123 | 123 | q_ptr->feeling = FEEL_NONE; |
124 | 124 | } |
@@ -129,7 +129,7 @@ void store_sell(player_type *player_ptr) | ||
129 | 129 | } |
130 | 130 | |
131 | 131 | bool placed = false; |
132 | - if ((cur_store_num != STORE_HOME) && (cur_store_num != STORE_MUSEUM)) { | |
132 | + if ((cur_store_num != StoreSaleType::HOME) && (cur_store_num != StoreSaleType::MUSEUM)) { | |
133 | 133 | msg_format(_("%s(%c)を売却する。", "Selling %s (%c)."), o_name, index_to_label(item)); |
134 | 134 | msg_print(nullptr); |
135 | 135 |
@@ -140,10 +140,10 @@ void store_sell(player_type *player_ptr) | ||
140 | 140 | store_owner_says_comment(player_ptr); |
141 | 141 | |
142 | 142 | sound(SOUND_SELL); |
143 | - if (cur_store_num == STORE_BLACK) | |
143 | + if (cur_store_num == StoreSaleType::BLACK) | |
144 | 144 | chg_virtue(player_ptr, V_JUSTICE, -1); |
145 | 145 | |
146 | - if ((o_ptr->tval == TV_BOTTLE) && (cur_store_num != STORE_HOME)) | |
146 | + if ((o_ptr->tval == TV_BOTTLE) && (cur_store_num != StoreSaleType::HOME)) | |
147 | 147 | chg_virtue(player_ptr, V_NATURE, 1); |
148 | 148 | |
149 | 149 | player_ptr->au += price; |
@@ -183,7 +183,7 @@ void store_sell(player_type *player_ptr) | ||
183 | 183 | display_store_inventory(player_ptr); |
184 | 184 | } |
185 | 185 | } |
186 | - } else if (cur_store_num == STORE_MUSEUM) { | |
186 | + } else if (cur_store_num == StoreSaleType::MUSEUM) { | |
187 | 187 | char o2_name[MAX_NLEN]; |
188 | 188 | describe_flavor(player_ptr, o2_name, q_ptr, OD_NAME_ONLY); |
189 | 189 |
@@ -183,19 +183,19 @@ static bool check_store_book(const object_type *o_ptr) | ||
183 | 183 | static bool switch_store_check(const object_type *o_ptr) |
184 | 184 | { |
185 | 185 | switch (cur_store_num) { |
186 | - case STORE_GENERAL: | |
186 | + case StoreSaleType::GENERAL: | |
187 | 187 | return check_store_general(o_ptr); |
188 | - case STORE_ARMOURY: | |
188 | + case StoreSaleType::ARMOURY: | |
189 | 189 | return check_store_armoury(o_ptr); |
190 | - case STORE_WEAPON: | |
190 | + case StoreSaleType::WEAPON: | |
191 | 191 | return check_store_weapon(o_ptr); |
192 | - case STORE_TEMPLE: | |
192 | + case StoreSaleType::TEMPLE: | |
193 | 193 | return check_store_temple(o_ptr); |
194 | - case STORE_ALCHEMIST: | |
194 | + case StoreSaleType::ALCHEMIST: | |
195 | 195 | return check_store_alchemist(o_ptr); |
196 | - case STORE_MAGIC: | |
196 | + case StoreSaleType::MAGIC: | |
197 | 197 | return check_store_magic(o_ptr); |
198 | - case STORE_BOOK: | |
198 | + case StoreSaleType::BOOK: | |
199 | 199 | return check_store_book(o_ptr); |
200 | 200 | default: |
201 | 201 | return true; |
@@ -212,7 +212,7 @@ static bool switch_store_check(const object_type *o_ptr) | ||
212 | 212 | */ |
213 | 213 | bool store_will_buy(player_type *, const object_type *o_ptr) |
214 | 214 | { |
215 | - if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) | |
215 | + if ((cur_store_num == StoreSaleType::HOME) || (cur_store_num == StoreSaleType::MUSEUM)) | |
216 | 216 | return true; |
217 | 217 | |
218 | 218 | if (!switch_store_check(o_ptr)) |
@@ -311,7 +311,7 @@ static int mass_figurine_produce(const PRICE cost) | ||
311 | 311 | static int mass_magic_produce(const PRICE cost) |
312 | 312 | { |
313 | 313 | int size = 1; |
314 | - if ((cur_store_num != STORE_BLACK) || !one_in_(3)) | |
314 | + if ((cur_store_num != StoreSaleType::BLACK) || !one_in_(3)) | |
315 | 315 | return size; |
316 | 316 | |
317 | 317 | if (cost < 1601L) |
@@ -71,7 +71,7 @@ void store_process_command(player_type *player_ptr) | ||
71 | 71 | if (store_top < 0) |
72 | 72 | store_top = ((st_ptr->stock_num - 1) / store_bottom) * store_bottom; |
73 | 73 | |
74 | - if ((cur_store_num == STORE_HOME) && !powerup_home) | |
74 | + if ((cur_store_num == StoreSaleType::HOME) && !powerup_home) | |
75 | 75 | if (store_top >= store_bottom) |
76 | 76 | store_top = store_bottom; |
77 | 77 |
@@ -90,7 +90,7 @@ void store_process_command(player_type *player_ptr) | ||
90 | 90 | * 隠しオプション(powerup_home)がセットされていないときは |
91 | 91 | * 我が家では 2 ページまでしか表示しない |
92 | 92 | */ |
93 | - auto inven_max = store_get_stock_max(STORE_HOME, powerup_home); | |
93 | + auto inven_max = store_get_stock_max(StoreSaleType::HOME, powerup_home); | |
94 | 94 | if (store_top >= st_ptr->stock_num || store_top >= inven_max) |
95 | 95 | store_top = 0; |
96 | 96 |
@@ -217,7 +217,7 @@ void store_process_command(player_type *player_ptr) | ||
217 | 217 | } |
218 | 218 | case '=': { |
219 | 219 | do_cmd_options(player_ptr); |
220 | - (void)combine_and_reorder_home(player_ptr, STORE_HOME); | |
220 | + (void)combine_and_reorder_home(player_ptr, StoreSaleType::HOME); | |
221 | 221 | do_cmd_redraw(player_ptr); |
222 | 222 | display_store(player_ptr); |
223 | 223 | break; |
@@ -259,7 +259,7 @@ void store_process_command(player_type *player_ptr) | ||
259 | 259 | break; |
260 | 260 | } |
261 | 261 | default: { |
262 | - if ((cur_store_num == STORE_MUSEUM) && (command_cmd == 'r')) { | |
262 | + if ((cur_store_num == StoreSaleType::MUSEUM) && (command_cmd == 'r')) { | |
263 | 263 | museum_remove_object(player_ptr); |
264 | 264 | } else { |
265 | 265 | msg_print(_("そのコマンドは店の中では使えません。", "That command does not work in stores.")); |
@@ -17,9 +17,29 @@ | ||
17 | 17 | #include "system/object-type-definition.h" |
18 | 18 | #include "world/world-object.h" |
19 | 19 | |
20 | -int cur_store_num = 0; | |
20 | +StoreSaleType cur_store_num = StoreSaleType::GENERAL; | |
21 | 21 | store_type *st_ptr = nullptr; |
22 | 22 | |
23 | +StoreSaleType begin(StoreSaleType) | |
24 | +{ | |
25 | + return StoreSaleType::GENERAL; | |
26 | +} | |
27 | + | |
28 | +StoreSaleType end(StoreSaleType) | |
29 | +{ | |
30 | + return StoreSaleType::MAX; | |
31 | +} | |
32 | + | |
33 | +StoreSaleType operator*(StoreSaleType s) | |
34 | +{ | |
35 | + return s; | |
36 | +} | |
37 | + | |
38 | +StoreSaleType operator++(StoreSaleType &s) | |
39 | +{ | |
40 | + return s = StoreSaleType(std::underlying_type<StoreSaleType>::type(s) + 1); | |
41 | +} | |
42 | + | |
23 | 43 | /*! |
24 | 44 | * @brief 店舗のオブジェクト数を増やす / |
25 | 45 | * Add the item "o_ptr" to a real stores inventory. |
@@ -135,7 +155,7 @@ void store_create( | ||
135 | 155 | for (int tries = 0; tries < 4; tries++) { |
136 | 156 | KIND_OBJECT_IDX k_idx; |
137 | 157 | DEPTH level; |
138 | - if (cur_store_num == STORE_BLACK) { | |
158 | + if (cur_store_num == StoreSaleType::BLACK) { | |
139 | 159 | level = 25 + randint0(25); |
140 | 160 | k_idx = get_obj_num(player_ptr, level, 0x00000000); |
141 | 161 | if (k_idx == 0) |
@@ -175,7 +195,7 @@ void store_create( | ||
175 | 195 | if (q_ptr->tval == TV_CHEST) |
176 | 196 | continue; |
177 | 197 | |
178 | - if (cur_store_num == STORE_BLACK) { | |
198 | + if (cur_store_num == StoreSaleType::BLACK) { | |
179 | 199 | if (black_market_crap(player_ptr, q_ptr) || (object_value(q_ptr) < 10)) |
180 | 200 | continue; |
181 | 201 | } else { |
@@ -7,20 +7,25 @@ | ||
7 | 7 | |
8 | 8 | #define STORE_OBJ_LEVEL 5 //!< 通常店舗の階層レベル / Magic Level for normal stores |
9 | 9 | |
10 | -enum STORE_TYPE_IDX { | |
11 | - STORE_GENERAL = 0, //!< 店舗の種類: 雑貨屋 | |
12 | - STORE_ARMOURY = 1, //!< 店舗の種類: 防具屋 | |
13 | - STORE_WEAPON = 2, //!< 店舗の種類: 武器屋 | |
14 | - STORE_TEMPLE = 3, //!< 店舗の種類: 寺院 | |
15 | - STORE_ALCHEMIST = 4, //!< 店舗の種類: 錬金術の店 | |
16 | - STORE_MAGIC = 5, //!< 店舗の種類: 魔道具屋 | |
17 | - STORE_BLACK = 6, //!< 店舗の種類: ブラック・マーケット | |
18 | - STORE_HOME = 7, //!< 店舗の種類: 我が家 | |
19 | - STORE_BOOK = 8, //!< 店舗の種類: 書店 | |
20 | - STORE_MUSEUM = 9, //!< 店舗の種類: 博物館 | |
21 | - STORE_MAX = 10 | |
10 | +enum class StoreSaleType { | |
11 | + GENERAL = 0, //!< 店舗の種類: 雑貨屋 | |
12 | + ARMOURY = 1, //!< 店舗の種類: 防具屋 | |
13 | + WEAPON = 2, //!< 店舗の種類: 武器屋 | |
14 | + TEMPLE = 3, //!< 店舗の種類: 寺院 | |
15 | + ALCHEMIST = 4, //!< 店舗の種類: 錬金術の店 | |
16 | + MAGIC = 5, //!< 店舗の種類: 魔道具屋 | |
17 | + BLACK = 6, //!< 店舗の種類: ブラック・マーケット | |
18 | + HOME = 7, //!< 店舗の種類: 我が家 | |
19 | + BOOK = 8, //!< 店舗の種類: 書店 | |
20 | + MUSEUM = 9, //!< 店舗の種類: 博物館 | |
21 | + MAX = 10 | |
22 | 22 | }; |
23 | 23 | |
24 | +StoreSaleType begin(StoreSaleType); | |
25 | +StoreSaleType end(StoreSaleType); | |
26 | +StoreSaleType operator*(StoreSaleType s); | |
27 | +StoreSaleType operator++(StoreSaleType &s); | |
28 | + | |
24 | 29 | using store_k_idx = std::vector<KIND_OBJECT_IDX>; |
25 | 30 | |
26 | 31 | /*! |
@@ -47,7 +52,7 @@ struct store_type { | ||
47 | 52 | store_type &operator=(const store_type &) = delete; |
48 | 53 | }; |
49 | 54 | |
50 | -extern int cur_store_num; | |
55 | +extern StoreSaleType cur_store_num; | |
51 | 56 | extern store_type *st_ptr; |
52 | 57 | |
53 | 58 | struct player_type; |
@@ -53,12 +53,12 @@ bool allow_inc = false; | ||
53 | 53 | * @param store_idx 店舗ID |
54 | 54 | * @return 店舗の最大スロット数 |
55 | 55 | */ |
56 | -int16_t store_get_stock_max(STORE_TYPE_IDX store_idx, bool powerup) | |
56 | +int16_t store_get_stock_max(StoreSaleType sst, bool powerup) | |
57 | 57 | { |
58 | - switch (store_idx) { | |
59 | - case STORE_HOME: | |
58 | + switch (sst) { | |
59 | + case StoreSaleType::HOME: | |
60 | 60 | return powerup ? STORE_INVEN_MAX * 10 : STORE_INVEN_MAX; |
61 | - case STORE_MUSEUM: | |
61 | + case StoreSaleType::MUSEUM: | |
62 | 62 | return STORE_INVEN_MAX * 50; |
63 | 63 | default: |
64 | 64 | return STORE_INVEN_MAX * 3 / 2; |
@@ -76,7 +76,7 @@ int16_t store_get_stock_max(STORE_TYPE_IDX store_idx, bool powerup) | ||
76 | 76 | */ |
77 | 77 | static int check_free_space(void) |
78 | 78 | { |
79 | - if ((cur_store_num == STORE_HOME) && !powerup_home) { | |
79 | + if ((cur_store_num == StoreSaleType::HOME) && !powerup_home) { | |
80 | 80 | if (st_ptr->stock_num < ((st_ptr->stock_size) / 10)) |
81 | 81 | return 1; |
82 | 82 | } else if (st_ptr->stock_num < st_ptr->stock_size) |
@@ -103,10 +103,10 @@ static int check_free_space(void) | ||
103 | 103 | int store_check_num(object_type *o_ptr) |
104 | 104 | { |
105 | 105 | object_type *j_ptr; |
106 | - if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) { | |
106 | + if ((cur_store_num == StoreSaleType::HOME) || (cur_store_num == StoreSaleType::MUSEUM)) { | |
107 | 107 | bool old_stack_force_notes = stack_force_notes; |
108 | 108 | bool old_stack_force_costs = stack_force_costs; |
109 | - if (cur_store_num != STORE_HOME) { | |
109 | + if (cur_store_num != StoreSaleType::HOME) { | |
110 | 110 | stack_force_notes = false; |
111 | 111 | stack_force_costs = false; |
112 | 112 | } |
@@ -116,7 +116,7 @@ int store_check_num(object_type *o_ptr) | ||
116 | 116 | if (!object_similar(j_ptr, o_ptr)) |
117 | 117 | continue; |
118 | 118 | |
119 | - if (cur_store_num != STORE_HOME) { | |
119 | + if (cur_store_num != StoreSaleType::HOME) { | |
120 | 120 | stack_force_notes = old_stack_force_notes; |
121 | 121 | stack_force_costs = old_stack_force_costs; |
122 | 122 | } |
@@ -124,7 +124,7 @@ int store_check_num(object_type *o_ptr) | ||
124 | 124 | return -1; |
125 | 125 | } |
126 | 126 | |
127 | - if (cur_store_num != STORE_HOME) { | |
127 | + if (cur_store_num != StoreSaleType::HOME) { | |
128 | 128 | stack_force_notes = old_stack_force_notes; |
129 | 129 | stack_force_costs = old_stack_force_costs; |
130 | 130 | } |
@@ -159,7 +159,7 @@ int get_stock(COMMAND_CODE *com_val, concptr pmt, int i, int j) | ||
159 | 159 | char hi = (j > 25) ? toupper(I2A(j - 26)) : I2A(j); |
160 | 160 | char out_val[160]; |
161 | 161 | #ifdef JP |
162 | - (void)sprintf(out_val, "(%s:%c-%c, ESCで中断) %s", (((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) ? "アイテム" : "商品"), lo, hi, pmt); | |
162 | + (void)sprintf(out_val, "(%s:%c-%c, ESCで中断) %s", (((cur_store_num == StoreSaleType::HOME) || (cur_store_num == StoreSaleType::MUSEUM)) ? "アイテム" : "商品"), lo, hi, pmt); | |
163 | 163 | #else |
164 | 164 | (void)sprintf(out_val, "(Items %c-%c, ESC to exit) %s", lo, hi, pmt); |
165 | 165 | #endif |
@@ -200,9 +200,9 @@ int get_stock(COMMAND_CODE *com_val, concptr pmt, int i, int j) | ||
200 | 200 | void store_examine(player_type *player_ptr) |
201 | 201 | { |
202 | 202 | if (st_ptr->stock_num <= 0) { |
203 | - if (cur_store_num == STORE_HOME) | |
203 | + if (cur_store_num == StoreSaleType::HOME) | |
204 | 204 | msg_print(_("我が家には何も置いてありません。", "Your home is empty.")); |
205 | - else if (cur_store_num == STORE_MUSEUM) | |
205 | + else if (cur_store_num == StoreSaleType::MUSEUM) | |
206 | 206 | msg_print(_("博物館には何も置いてありません。", "The Museum is empty.")); |
207 | 207 | else |
208 | 208 | msg_print(_("現在商品の在庫を切らしています。", "I am currently out of stock.")); |
@@ -239,13 +239,13 @@ void store_examine(player_type *player_ptr) | ||
239 | 239 | * Shuffle one of the stores. |
240 | 240 | * @param which 店舗種類のID |
241 | 241 | */ |
242 | -void store_shuffle(player_type *player_ptr, int which) | |
242 | +void store_shuffle(player_type *player_ptr, StoreSaleType which) | |
243 | 243 | { |
244 | - if ((which == STORE_HOME) || (which == STORE_MUSEUM)) | |
244 | + if ((which == StoreSaleType::HOME) || (which == StoreSaleType::MUSEUM)) | |
245 | 245 | return; |
246 | 246 | |
247 | 247 | cur_store_num = which; |
248 | - st_ptr = &town_info[player_ptr->town_num].store[cur_store_num]; | |
248 | + st_ptr = &town_info[player_ptr->town_num].store[enum2i(cur_store_num)]; | |
249 | 249 | int j = st_ptr->owner; |
250 | 250 | while (true) { |
251 | 251 | st_ptr->owner = (byte)randint0(MAX_OWNERS); |
@@ -257,7 +257,7 @@ void store_shuffle(player_type *player_ptr, int which) | ||
257 | 257 | if (i == player_ptr->town_num) |
258 | 258 | continue; |
259 | 259 | |
260 | - if (st_ptr->owner == town_info[i].store[cur_store_num].owner) | |
260 | + if (st_ptr->owner == town_info[i].store[enum2i(cur_store_num)].owner) | |
261 | 261 | break; |
262 | 262 | } |
263 | 263 |
@@ -265,7 +265,7 @@ void store_shuffle(player_type *player_ptr, int which) | ||
265 | 265 | break; |
266 | 266 | } |
267 | 267 | |
268 | - ot_ptr = &owners[cur_store_num][st_ptr->owner]; | |
268 | + ot_ptr = &owners[enum2i(cur_store_num)][st_ptr->owner]; | |
269 | 269 | st_ptr->insult_cur = 0; |
270 | 270 | st_ptr->store_open = 0; |
271 | 271 | st_ptr->good_buy = 0; |
@@ -289,16 +289,16 @@ void store_shuffle(player_type *player_ptr, int which) | ||
289 | 289 | * @param store_num 店舗種類のID |
290 | 290 | * @param chance 更新商品数 |
291 | 291 | */ |
292 | -void store_maintenance(player_type *player_ptr, int town_num, int store_num, int chance) | |
292 | +void store_maintenance(player_type *player_ptr, int town_num, StoreSaleType store_num, int chance) | |
293 | 293 | { |
294 | 294 | cur_store_num = store_num; |
295 | - if ((store_num == STORE_HOME) || (store_num == STORE_MUSEUM)) | |
295 | + if ((store_num == StoreSaleType::HOME) || (store_num == StoreSaleType::MUSEUM)) | |
296 | 296 | return; |
297 | 297 | |
298 | - st_ptr = &town_info[town_num].store[store_num]; | |
299 | - ot_ptr = &owners[store_num][st_ptr->owner]; | |
298 | + st_ptr = &town_info[town_num].store[enum2i(store_num)]; | |
299 | + ot_ptr = &owners[enum2i(store_num)][st_ptr->owner]; | |
300 | 300 | st_ptr->insult_cur = 0; |
301 | - if (store_num == STORE_BLACK) { | |
301 | + if (store_num == StoreSaleType::BLACK) { | |
302 | 302 | for (INVENTORY_IDX j = st_ptr->stock_num - 1; j >= 0; j--) { |
303 | 303 | object_type *o_ptr = &st_ptr->stock[j]; |
304 | 304 | if (black_market_crap(player_ptr, o_ptr)) { |
@@ -358,17 +358,17 @@ void store_maintenance(player_type *player_ptr, int town_num, int store_num, int | ||
358 | 358 | * @param town_num 町のID |
359 | 359 | * @param store_num 店舗種類のID |
360 | 360 | */ |
361 | -void store_init(int town_num, int store_num) | |
361 | +void store_init(int town_num, StoreSaleType store_num) | |
362 | 362 | { |
363 | 363 | cur_store_num = store_num; |
364 | - st_ptr = &town_info[town_num].store[store_num]; | |
364 | + st_ptr = &town_info[town_num].store[enum2i(store_num)]; | |
365 | 365 | while (true) { |
366 | 366 | st_ptr->owner = (byte)randint0(MAX_OWNERS); |
367 | 367 | int i; |
368 | 368 | for (i = 1; i < max_towns; i++) { |
369 | 369 | if (i == town_num) |
370 | 370 | continue; |
371 | - if (st_ptr->owner == town_info[i].store[store_num].owner) | |
371 | + if (st_ptr->owner == town_info[i].store[enum2i(store_num)].owner) | |
372 | 372 | break; |
373 | 373 | } |
374 | 374 |
@@ -376,7 +376,7 @@ void store_init(int town_num, int store_num) | ||
376 | 376 | break; |
377 | 377 | } |
378 | 378 | |
379 | - ot_ptr = &owners[store_num][st_ptr->owner]; | |
379 | + ot_ptr = &owners[enum2i(store_num)][st_ptr->owner]; | |
380 | 380 | st_ptr->store_open = 0; |
381 | 381 | st_ptr->insult_cur = 0; |
382 | 382 | st_ptr->good_buy = 0; |
@@ -386,3 +386,4 @@ void store_init(int town_num, int store_num) | ||
386 | 386 | for (int k = 0; k < st_ptr->stock_size; k++) |
387 | 387 | (&st_ptr->stock[k])->wipe(); |
388 | 388 | } |
389 | + |
@@ -23,10 +23,10 @@ extern int cur_store_feat; | ||
23 | 23 | extern bool allow_inc; |
24 | 24 | |
25 | 25 | struct player_type; |
26 | -int16_t store_get_stock_max(STORE_TYPE_IDX store_idx, bool powerup = true); | |
27 | -void store_shuffle(player_type *player_ptr, int which); | |
28 | -void store_maintenance(player_type *player_ptr, int town_num, int store_num, int chance); | |
29 | -void store_init(int town_num, int store_num); | |
26 | +int16_t store_get_stock_max(StoreSaleType sst, bool powerup = true); | |
27 | +void store_shuffle(player_type *player_ptr, StoreSaleType which); | |
28 | +void store_maintenance(player_type *player_ptr, int town_num, StoreSaleType store_num, int chance); | |
29 | +void store_init(int town_num, StoreSaleType store_num); | |
30 | 30 | void store_examine(player_type *player_ptr); |
31 | 31 | int store_check_num(object_type *o_ptr); |
32 | 32 | int get_stock(COMMAND_CODE *com_val, concptr pmt, int i, int j); |
@@ -64,7 +64,7 @@ void display_entry(player_type *player_ptr, int pos) | ||
64 | 64 | |
65 | 65 | /* Describe an item in the home */ |
66 | 66 | int maxwid = 75; |
67 | - if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) { | |
67 | + if ((cur_store_num == StoreSaleType::HOME) || (cur_store_num == StoreSaleType::MUSEUM)) { | |
68 | 68 | maxwid = 75; |
69 | 69 | if (show_weights) |
70 | 70 | maxwid -= 10; |
@@ -129,9 +129,9 @@ void display_store_inventory(player_type *player_ptr) | ||
129 | 129 | put_str(format(_("(%dページ) ", "(Page %d) "), store_top / store_bottom + 1), 5, _(20, 22)); |
130 | 130 | } |
131 | 131 | |
132 | - if (cur_store_num == STORE_HOME || cur_store_num == STORE_MUSEUM) { | |
132 | + if (cur_store_num == StoreSaleType::HOME || cur_store_num == StoreSaleType::MUSEUM) { | |
133 | 133 | k = st_ptr->stock_size; |
134 | - if (cur_store_num == STORE_HOME && !powerup_home) | |
134 | + if (cur_store_num == StoreSaleType::HOME && !powerup_home) | |
135 | 135 | k /= 10; |
136 | 136 | |
137 | 137 | put_str(format(_("アイテム数: %4d/%4d", "Objects: %4d/%4d"), st_ptr->stock_num, k), 19 + xtra_stock, _(27, 30)); |
@@ -147,7 +147,7 @@ void display_store_inventory(player_type *player_ptr) | ||
147 | 147 | void display_store(player_type *player_ptr) |
148 | 148 | { |
149 | 149 | term_clear(); |
150 | - if (cur_store_num == STORE_HOME) { | |
150 | + if (cur_store_num == StoreSaleType::HOME) { | |
151 | 151 | put_str(_("我が家", "Your Home"), 3, 31); |
152 | 152 | put_str(_("アイテムの一覧", "Item Description"), 5, 4); |
153 | 153 | if (show_weights) { |
@@ -159,7 +159,7 @@ void display_store(player_type *player_ptr) | ||
159 | 159 | return; |
160 | 160 | } |
161 | 161 | |
162 | - if (cur_store_num == STORE_MUSEUM) { | |
162 | + if (cur_store_num == StoreSaleType::MUSEUM) { | |
163 | 163 | put_str(_("博物館", "Museum"), 3, 31); |
164 | 164 | put_str(_("アイテムの一覧", "Item Description"), 5, 4); |
165 | 165 | if (show_weights) { |
@@ -275,7 +275,7 @@ void WorldTurnProcessor::shuffle_shopkeeper() | ||
275 | 275 | int n; |
276 | 276 | do { |
277 | 277 | n = randint0(MAX_STORES); |
278 | - if ((n == STORE_HOME) || (n == STORE_MUSEUM)) { | |
278 | + if ((n == enum2i(StoreSaleType::HOME)) || (n == enum2i(StoreSaleType::MUSEUM))) { | |
279 | 279 | break; |
280 | 280 | } |
281 | 281 | } while (true); |
@@ -292,7 +292,7 @@ void WorldTurnProcessor::shuffle_shopkeeper() | ||
292 | 292 | msg_format(_("%sの店主をシャッフルします。", "Shuffle a Shopkeeper of %s."), f_ref.name.c_str()); |
293 | 293 | } |
294 | 294 | |
295 | - store_shuffle(this->player_ptr, n); | |
295 | + store_shuffle(this->player_ptr, i2enum<StoreSaleType>(n)); | |
296 | 296 | break; |
297 | 297 | } |
298 | 298 | } |