OSDN Git Service

[Refactor] #40635 Separated market/building-initializer.c/h from init.c/h
authorHourier <hourier@users.sourceforge.jp>
Thu, 20 Aug 2020 12:25:21 +0000 (21:25 +0900)
committerHourier <hourier@users.sourceforge.jp>
Fri, 21 Aug 2020 00:51:15 +0000 (09:51 +0900)
Hengband/Hengband/Hengband.vcxproj
Hengband/Hengband/Hengband.vcxproj.filters
src/Makefile.am
src/floor/wild.c
src/info-reader/info-reader-util.c
src/main/init.c
src/main/init.h
src/market/building-initializer.c [new file with mode: 0644]
src/market/building-initializer.h [new file with mode: 0644]

index f90d468..182e590 100644 (file)
     <ClCompile Include="..\..\src\load\info-loader.c" />\r
     <ClCompile Include="..\..\src\main\angband-headers.c" />\r
     <ClCompile Include="..\..\src\main\info-initializer.c" />\r
-    <ClCompile Include="..\..\src\main\initialization-error-messages-table.c" />\r
+    <ClCompile Include="..\..\src\main\init-error-messages-table.c" />\r
+    <ClCompile Include="..\..\src\market\building-initializer.c" />\r
     <ClCompile Include="..\..\src\melee\melee-spell-flags-checker.c" />\r
     <ClCompile Include="..\..\src\melee\melee-spell-util.c" />\r
     <ClCompile Include="..\..\src\melee\melee-spell.c" />\r
     <ClInclude Include="..\..\src\locale\language-switcher.h" />\r
     <ClInclude Include="..\..\src\main\angband-headers.h" />\r
     <ClInclude Include="..\..\src\main\info-initializer.h" />\r
-    <ClInclude Include="..\..\src\main\initialization-error-messages-table.h" />\r
+    <ClInclude Include="..\..\src\main\init-error-messages-table.h" />\r
+    <ClInclude Include="..\..\src\market\building-initializer.h" />\r
     <ClInclude Include="..\..\src\melee\melee-spell-flags-checker.h" />\r
     <ClInclude Include="..\..\src\melee\melee-spell-util.h" />\r
     <ClInclude Include="..\..\src\melee\melee-spell.h" />\r
index 52a761e..fd11ea9 100644 (file)
     <ClCompile Include="..\..\src\main\angband-headers.c">
       <Filter>main</Filter>
     </ClCompile>
-    <ClCompile Include="..\..\src\main\initialization-error-messages-table.c">
+    <ClCompile Include="..\..\src\main\init-error-messages-table.c">
       <Filter>main</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\src\market\building-initializer.c">
+      <Filter>market</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\src\combat\shoot.h">
     <ClInclude Include="..\..\src\main\angband-headers.h">
       <Filter>main</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\src\main\initialization-error-messages-table.h">
+    <ClInclude Include="..\..\src\main\init-error-messages-table.h">
       <Filter>main</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\market\building-initializer.h">
+      <Filter>market</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\..\src\wall.bmp" />
index 32bab91..ff88ef0 100644 (file)
@@ -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 \
index 6953696..ff9e64a 100644 (file)
@@ -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"
index ceb78ae..e89753f 100644 (file)
@@ -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.
index e4d129b..a2c695d 100644 (file)
@@ -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
index f42d351..f68b1ae 100644 (file)
@@ -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 (file)
index 0000000..9ec3ee1
--- /dev/null
@@ -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 \92¬\8fî\95ñ\93Ç\82Ý\8d\9e\82Ý\82Ì\83\81\83C\83\93\83\8b\81[\83`\83\93 /
+ * Initialize town array
+ * @return \83G\83\89\81[\83R\81[\83h
+ */
+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;
+
+            /*
+             * \89ä\82ª\89Æ\82ª 20 \83y\81[\83W\82Ü\82Å\8eg\82¦\82é\89B\82µ\8b@\94\\82Ì\82½\82ß\82Ì\8f\80\94õ\81B
+             * \83I\83v\83V\83\87\83\93\82ª\97L\8cø\82Å\82à\82»\82¤\82Å\82È\82­\82Ä\82à\88ê\89\9e\83X\83y\81[\83X\82ð\8dì\82Á\82Ä\82¨\82­\81B
+             */
+            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 \93X\8fî\95ñ\8f\89\8aú\89»\82Ì\83\81\83C\83\93\83\8b\81[\83`\83\93 /
+ * Initialize buildings
+ * @return \83G\83\89\81[\83R\81[\83h
+ */
+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 (file)
index 0000000..f56f75f
--- /dev/null
@@ -0,0 +1,6 @@
+#pragma once
+
+#include "system/angband.h"
+
+errr init_towns(void);
+errr init_buildings(void);