OSDN Git Service

[Refactor] #40742 Separated generate_wilderness() from play_game()
authorHourier <hourier@users.sourceforge.jp>
Tue, 22 Sep 2020 08:59:27 +0000 (17:59 +0900)
committerHourier <hourier@users.sourceforge.jp>
Tue, 22 Sep 2020 08:59:27 +0000 (17:59 +0900)
src/core/game-play.c
src/info-reader/fixed-map-parser.c

index 55d6179..457e6f3 100644 (file)
@@ -230,6 +230,18 @@ static void set_wizard_mode_by_argument(player_type *player_ptr)
         quit("Already dead.");
 }
 
+static void generate_wilderness(player_type *player_ptr)
+{
+    floor_type *floor_ptr = player_ptr->current_floor_ptr;
+    if ((floor_ptr->dun_level == 0) || floor_ptr->inside_quest)
+        return;
+
+    parse_fixed_map(player_ptr, "w_info.txt", 0, 0, current_world_ptr->max_wild_y, current_world_ptr->max_wild_x);
+    init_flags = INIT_ONLY_BUILDINGS;
+    parse_fixed_map(player_ptr, "t_info.txt", 0, 0, MAX_HGT, MAX_WID);
+    select_floor_music(player_ptr);
+}
+
 /*!
  * @brief 1ゲームプレイの主要ルーチン / Actually play a game
  * @param player_ptr プレーヤーへの参照ポインタ
@@ -274,13 +286,7 @@ void play_game(player_type *player_ptr, bool new_game, bool browsing_movie)
     prt(_("お待ち下さい...", "Please wait..."), 0, 0);
     term_fresh();
     set_wizard_mode_by_argument(player_ptr);
-    if (!floor_ptr->dun_level && !floor_ptr->inside_quest) {
-        parse_fixed_map(player_ptr, "w_info.txt", 0, 0, current_world_ptr->max_wild_y, current_world_ptr->max_wild_x);
-        init_flags = INIT_ONLY_BUILDINGS;
-        parse_fixed_map(player_ptr, "t_info.txt", 0, 0, MAX_HGT, MAX_WID);
-        select_floor_music(player_ptr);
-    }
-
+    generate_wilderness(player_ptr);
     if (!current_world_ptr->character_dungeon) {
         change_floor(player_ptr);
     } else {
index fb69e3b..a403738 100644 (file)
@@ -234,25 +234,22 @@ errr parse_fixed_map(player_type *player_ptr, concptr name, int ymin, int xmin,
 {
     char buf[1024];
     path_build(buf, sizeof(buf), ANGBAND_DIR_EDIT, name);
-    FILE *fp;
-    fp = angband_fopen(buf, "r");
+    FILE *fp = angband_fopen(buf, "r");
     if (fp == NULL)
         return -1;
 
     int num = -1;
     parse_error_type err = PARSE_ERROR_NONE;
     bool bypass = FALSE;
-    int x = xmin, y = ymin;
+    int x = xmin;
+    int y = ymin;
     qtwg_type tmp_qg;
     qtwg_type *qg_ptr = initialize_quest_generator_type(&tmp_qg, buf, ymin, xmin, ymax, xmax, &y, &x);
     while (angband_fgets(fp, buf, sizeof(buf)) == 0) {
         num++;
-        if (!buf[0])
-            continue;
-        if (iswspace(buf[0]))
-            continue;
-        if (buf[0] == '#')
+        if (!buf[0] || iswspace(buf[0]) || buf[0] == '#')
             continue;
+
         if ((buf[0] == '?') && (buf[1] == ':')) {
             char f;
             char *s;
@@ -266,7 +263,7 @@ errr parse_fixed_map(player_type *player_ptr, concptr name, int ymin, int xmin,
             continue;
 
         err = generate_fixed_map_floor(player_ptr, qg_ptr, parse_fixed_map);
-        if (err)
+        if (err != PARSE_ERROR_NONE)
             break;
     }