From: Hourier Date: Thu, 20 Aug 2020 12:25:21 +0000 (+0900) Subject: [Refactor] #40635 Separated market/building-initializer.c/h from init.c/h X-Git-Url: http://git.osdn.net/view?p=hengband%2Fhengband.git;a=commitdiff_plain;h=46270c0d72bd1333e65c9803791bcc1b75068426 [Refactor] #40635 Separated market/building-initializer.c/h from init.c/h --- diff --git a/Hengband/Hengband/Hengband.vcxproj b/Hengband/Hengband/Hengband.vcxproj index f90d468f1..182e5907d 100644 --- a/Hengband/Hengband/Hengband.vcxproj +++ b/Hengband/Hengband/Hengband.vcxproj @@ -285,7 +285,8 @@ - + + @@ -917,7 +918,8 @@ - + + diff --git a/Hengband/Hengband/Hengband.vcxproj.filters b/Hengband/Hengband/Hengband.vcxproj.filters index 52a761eeb..fd11ea9c5 100644 --- a/Hengband/Hengband/Hengband.vcxproj.filters +++ b/Hengband/Hengband/Hengband.vcxproj.filters @@ -2117,9 +2117,12 @@ main - + main + + market + @@ -4588,9 +4591,12 @@ main - + main + + market + diff --git a/src/Makefile.am b/src/Makefile.am index 32bab91f4..ff88ef089 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -390,6 +390,7 @@ hengband_SOURCES = \ main/x11-type-string.c main/x11-type-string.h \ \ market/arena-info-table.c market/arena-info-table.h \ + market/building-initializer.c market/building-initializer.h \ market/building-util.c market/building-util.h \ market/play-gamble.c market/play-gamble.h \ market/poker.c market/poker.h \ diff --git a/src/floor/wild.c b/src/floor/wild.c index 695369608..ff9e64ac0 100644 --- a/src/floor/wild.c +++ b/src/floor/wild.c @@ -25,7 +25,7 @@ #include "info-reader/parse-error-types.h" #include "io/files-util.h" #include "io/tokenizer.h" -#include "main/init.h" +#include "market/building-initializer.h" #include "monster-floor/monster-generator.h" #include "monster-floor/monster-remover.h" #include "monster-floor/monster-summon.h" diff --git a/src/info-reader/info-reader-util.c b/src/info-reader/info-reader-util.c index ceb78ae2b..e89753fb3 100644 --- a/src/info-reader/info-reader-util.c +++ b/src/info-reader/info-reader-util.c @@ -3,6 +3,10 @@ #include "object-enchant/activation-info-table.h" #include "view/display-messages.h" +/* Help give useful error messages */ +int error_idx; /*!< データ読み込み/初期化時に汎用的にエラーコードを保存するグローバル変数 */ +int error_line; /*!< データ読み込み/初期化時に汎用的にエラー行数を保存するグローバル変数 */ + /*! * @brief データの可変文字列情報をテキストとして保管する / * Add a text to the text-storage and store offset to it. diff --git a/src/main/init.c b/src/main/init.c index e4d129b2c..a2c695d2a 100644 --- a/src/main/init.c +++ b/src/main/init.c @@ -60,6 +60,7 @@ #include "main/info-initializer.h" #include "main/init-error-messages-table.h" #include "market/articles-on-sale.h" +#include "market/building-initializer.h" #include "monster-race/monster-race.h" #include "monster-race/race-flags7.h" #include "object-enchant/object-ego.h" @@ -175,100 +176,6 @@ void init_file_paths(char *path) ANGBAND_DIR_XTRA = string_make(path); } -/* - * Hack -- help give useful error messages - */ -int error_idx; /*!< データ読み込み/初期化時に汎用的にエラーコードを保存するグローバル変数 */ -int error_line; /*!< データ読み込み/初期化時に汎用的にエラー行数を保存するグローバル変数 */ - -/*! - * @brief 町情報読み込みのメインルーチン / - * Initialize town array - * @return エラーコード - */ -static errr init_towns(void) -{ - C_MAKE(town_info, max_towns, town_type); - for (int i = 1; i < max_towns; i++) { - C_MAKE(town_info[i].store, MAX_STORES, store_type); - for (int j = 0; j < MAX_STORES; j++) { - store_type *store_ptr = &town_info[i].store[j]; - if ((i > 1) && (j == STORE_MUSEUM || j == STORE_HOME)) - continue; - - /* - * 我が家が 20 ページまで使える隠し機能のための準備。 - * オプションが有効でもそうでなくても一応スペースを作っておく。 - */ - if (j == STORE_HOME) { - store_ptr->stock_size = (STORE_INVEN_MAX * 10); - } else if (j == STORE_MUSEUM) { - store_ptr->stock_size = (STORE_INVEN_MAX * 50); - } else { - store_ptr->stock_size = STORE_INVEN_MAX; - } - - C_MAKE(store_ptr->stock, store_ptr->stock_size, object_type); - if ((j == STORE_BLACK) || (j == STORE_HOME) || (j == STORE_MUSEUM)) - continue; - - store_ptr->table_size = STORE_CHOICES; - C_MAKE(store_ptr->table, store_ptr->table_size, s16b); - for (int k = 0; k < STORE_CHOICES; k++) { - KIND_OBJECT_IDX k_idx; - int tv = store_table[j][k][0]; - int sv = store_table[j][k][1]; - for (k_idx = 1; k_idx < max_k_idx; k_idx++) { - object_kind *k_ptr = &k_info[k_idx]; - if ((k_ptr->tval == tv) && (k_ptr->sval == sv)) - break; - } - - if (k_idx == max_k_idx) - continue; - - store_ptr->table[store_ptr->table_num++] = k_idx; - } - } - } - - return 0; -} - -/*! - * @brief 店情報初期化のメインルーチン / - * Initialize buildings - * @return エラーコード - */ -errr init_buildings(void) -{ - for (int i = 0; i < MAX_BLDG; i++) { - building[i].name[0] = '\0'; - building[i].owner_name[0] = '\0'; - building[i].owner_race[0] = '\0'; - - for (int j = 0; j < 8; j++) { - building[i].act_names[j][0] = '\0'; - building[i].member_costs[j] = 0; - building[i].other_costs[j] = 0; - building[i].letters[j] = 0; - building[i].actions[j] = 0; - building[i].action_restr[j] = 0; - } - - for (int j = 0; j < MAX_CLASS; j++) - building[i].member_class[j] = 0; - - for (int j = 0; j < MAX_RACES; j++) - building[i].member_race[j] = 0; - - for (int j = 0; j < MAX_MAGIC + 1; j++) - building[i].member_realm[j] = 0; - } - - return 0; -} - /*! * @brief クエスト情報初期化のメインルーチン / * Initialize quest array diff --git a/src/main/init.h b/src/main/init.h index f42d35129..f68b1ae44 100644 --- a/src/main/init.h +++ b/src/main/init.h @@ -17,7 +17,5 @@ typedef void (*process_autopick_file_command_pf)(char *); void init_angband(player_type *player_ptr, process_autopick_file_command_pf process_autopick_file_command); void init_file_paths(char *path); -errr init_v_info(player_type *player_ptr); -errr init_buildings(void); #endif /* INCLUDED_INIT_H */ diff --git a/src/market/building-initializer.c b/src/market/building-initializer.c new file mode 100644 index 000000000..9ec3ee16f --- /dev/null +++ b/src/market/building-initializer.c @@ -0,0 +1,97 @@ +#include "market/building-initializer.h" +#include "floor/floor-town.h" +#include "market/articles-on-sale.h" +#include "object/object-kind.h" +#include "store/store-owners.h" +#include "store/store-util.h" +#include "store/store.h" +#include "system/building-type-definition.h" +#include "system/object-type-definition.h" + +/*! + * @brief ’¬î•ñ“ǂݍž‚݂̃ƒCƒ“ƒ‹[ƒ`ƒ“ / + * Initialize town array + * @return ƒGƒ‰[ƒR[ƒh + */ +errr init_towns(void) +{ + C_MAKE(town_info, max_towns, town_type); + for (int i = 1; i < max_towns; i++) { + C_MAKE(town_info[i].store, MAX_STORES, store_type); + for (int j = 0; j < MAX_STORES; j++) { + store_type *store_ptr = &town_info[i].store[j]; + if ((i > 1) && (j == STORE_MUSEUM || j == STORE_HOME)) + continue; + + /* + * ‰ä‚ª‰Æ‚ª 20 ƒy[ƒW‚Ü‚ÅŽg‚¦‚é‰B‚µ‹@”\‚Ì‚½‚߂̏€”õB + * ƒIƒvƒVƒ‡ƒ“‚ª—LŒø‚Å‚à‚»‚¤‚Å‚È‚­‚Ä‚àˆê‰žƒXƒy[ƒX‚ðì‚Á‚Ä‚¨‚­B + */ + if (j == STORE_HOME) { + store_ptr->stock_size = STORE_INVEN_MAX * 10; + } else if (j == STORE_MUSEUM) { + store_ptr->stock_size = STORE_INVEN_MAX * 50; + } else { + store_ptr->stock_size = STORE_INVEN_MAX; + } + + C_MAKE(store_ptr->stock, store_ptr->stock_size, object_type); + if ((j == STORE_BLACK) || (j == STORE_HOME) || (j == STORE_MUSEUM)) + continue; + + store_ptr->table_size = STORE_CHOICES; + C_MAKE(store_ptr->table, store_ptr->table_size, s16b); + for (int k = 0; k < STORE_CHOICES; k++) { + KIND_OBJECT_IDX k_idx; + int tv = store_table[j][k][0]; + int sv = store_table[j][k][1]; + for (k_idx = 1; k_idx < max_k_idx; k_idx++) { + object_kind *k_ptr = &k_info[k_idx]; + if ((k_ptr->tval == tv) && (k_ptr->sval == sv)) + break; + } + + if (k_idx == max_k_idx) + continue; + + store_ptr->table[store_ptr->table_num++] = k_idx; + } + } + } + + return 0; +} + +/*! + * @brief “Xî•ñ‰Šú‰»‚̃ƒCƒ“ƒ‹[ƒ`ƒ“ / + * Initialize buildings + * @return ƒGƒ‰[ƒR[ƒh + */ +errr init_buildings(void) +{ + for (int i = 0; i < MAX_BLDG; i++) { + building[i].name[0] = '\0'; + building[i].owner_name[0] = '\0'; + building[i].owner_race[0] = '\0'; + + for (int j = 0; j < 8; j++) { + building[i].act_names[j][0] = '\0'; + building[i].member_costs[j] = 0; + building[i].other_costs[j] = 0; + building[i].letters[j] = 0; + building[i].actions[j] = 0; + building[i].action_restr[j] = 0; + } + + for (int j = 0; j < MAX_CLASS; j++) + building[i].member_class[j] = 0; + + for (int j = 0; j < MAX_RACES; j++) + building[i].member_race[j] = 0; + + for (int j = 0; j < MAX_MAGIC + 1; j++) + building[i].member_realm[j] = 0; + } + + return 0; +} diff --git a/src/market/building-initializer.h b/src/market/building-initializer.h new file mode 100644 index 000000000..f56f75f2a --- /dev/null +++ b/src/market/building-initializer.h @@ -0,0 +1,6 @@ +#pragma once + +#include "system/angband.h" + +errr init_towns(void); +errr init_buildings(void);