OSDN Git Service

[Style] Apply clang-format to all *.cpp files
[hengbandforosx/hengbandosx.git] / src / market / building-initializer.cpp
1 #include "market/building-initializer.h"
2 #include "floor/floor-town.h"
3 #include "object/object-kind-hook.h"
4 #include "object/object-kind.h"
5 #include "player-info/class-types.h"
6 #include "store/articles-on-sale.h"
7 #include "store/store-owners.h"
8 #include "store/store-util.h"
9 #include "store/store.h"
10 #include "system/angband.h"
11 #include "system/building-type-definition.h"
12 #include "system/object-type-definition.h"
13 #include <vector>
14
15 /*!
16  * @brief 町情報読み込みのメインルーチン /
17  * Initialize town array
18  * @details 「我が家を拡張する」オプションのON/OFFとは無関係に、ON時の容量を確保しておく.
19  */
20 void init_towns(void)
21 {
22     town_info = std::vector<town_type>(max_towns);
23     for (auto i = 1; i < max_towns; i++) {
24         town_info[i].store = std::vector<store_type>(MAX_STORES);
25         for (auto sst : STORE_SALE_TYPE_LIST) {
26             auto *store_ptr = &town_info[i].store[enum2i(sst)];
27             if ((i > 1) && (sst == StoreSaleType::MUSEUM || sst == StoreSaleType::HOME)) {
28                 continue;
29             }
30
31             store_ptr->stock_size = store_get_stock_max(sst);
32             store_ptr->stock = std::make_unique<ObjectType[]>(store_ptr->stock_size);
33             if ((sst == StoreSaleType::BLACK) || (sst == StoreSaleType::HOME) || (sst == StoreSaleType::MUSEUM)) {
34                 continue;
35             }
36
37             for (auto k = 0; k < STORE_INVEN_MAX; k++) {
38                 auto tv = store_regular_table[enum2i(sst)][k].tval;
39                 auto sv = store_regular_table[enum2i(sst)][k].sval;
40                 if (tv == ItemKindType::NONE) {
41                     break;
42                 }
43
44                 auto k_idx = lookup_kind(tv, sv);
45                 if (k_idx == 0) {
46                     continue;
47                 }
48
49                 store_ptr->regular.push_back(k_idx);
50             }
51
52             for (auto k = 0; k < STORE_CHOICES; k++) {
53                 auto tv = store_table[enum2i(sst)][k].tval;
54                 auto sv = store_table[enum2i(sst)][k].sval;
55                 if (tv == ItemKindType::NONE) {
56                     break;
57                 }
58
59                 auto k_idx = lookup_kind(tv, sv);
60                 if (k_idx == 0) {
61                     continue;
62                 }
63
64                 store_ptr->table.push_back(k_idx);
65             }
66         }
67     }
68 }
69
70 /*!
71  * @brief 店情報初期化のメインルーチン /
72  * Initialize buildings
73  */
74 void init_buildings(void)
75 {
76     for (auto i = 0; i < MAX_BLDG; i++) {
77         building[i].name[0] = '\0';
78         building[i].owner_name[0] = '\0';
79         building[i].owner_race[0] = '\0';
80         for (auto j = 0; j < 8; j++) {
81             building[i].act_names[j][0] = '\0';
82             building[i].member_costs[j] = 0;
83             building[i].other_costs[j] = 0;
84             building[i].letters[j] = 0;
85             building[i].actions[j] = 0;
86             building[i].action_restr[j] = 0;
87         }
88
89         building[i].member_class.assign(PLAYER_CLASS_TYPE_MAX, static_cast<short>(PlayerClassType::WARRIOR));
90         building[i].member_race.assign(MAX_RACES, static_cast<short>(PlayerRaceType::HUMAN));
91         building[i].member_realm.assign(MAX_MAGIC + 1, 0);
92     }
93 }