OSDN Git Service

[Refactor] #39970 Separated dungeon-processor.c/h from core.c
authorHourier <hourier@users.sourceforge.jp>
Sun, 10 May 2020 13:42:07 +0000 (22:42 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sun, 10 May 2020 13:42:07 +0000 (22:42 +0900)
Hengband/Hengband/Hengband.vcxproj
Hengband/Hengband/Hengband.vcxproj.filters
src/Makefile.am
src/core.c
src/dungeon/dungeon-processor.c [new file with mode: 0644]
src/dungeon/dungeon-processor.h [new file with mode: 0644]

index 9d068ca..fbdbdfc 100644 (file)
     <ClCompile Include="..\..\src\cmd\cmd-knowledge.c" />\r
     <ClCompile Include="..\..\src\cmd\cmd-process-screen.c" />\r
     <ClCompile Include="..\..\src\cmd\dump-util.c" />\r
+    <ClCompile Include="..\..\src\dungeon\dungeon-processor.c" />\r
     <ClCompile Include="..\..\src\player\digestion-processor.c" />\r
     <ClCompile Include="..\..\src\core\player-processor.c" />\r
     <ClCompile Include="..\..\src\inventory\pack-overflow.c" />\r
     <ClInclude Include="..\..\src\cmd\cmd-knowledge.h" />\r
     <ClInclude Include="..\..\src\cmd\cmd-process-screen.h" />\r
     <ClInclude Include="..\..\src\cmd\dump-util.h" />\r
+    <ClInclude Include="..\..\src\dungeon\dungeon-processor.h" />\r
     <ClInclude Include="..\..\src\player\digestion-processor.h" />\r
     <ClInclude Include="..\..\src\core\player-processor.h" />\r
     <ClInclude Include="..\..\src\inventory\pack-overflow.h" />\r
index c18e884..b15f62b 100644 (file)
     <ClCompile Include="..\..\src\world\world.c">
       <Filter>world</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\src\dungeon\dungeon-processor.c">
+      <Filter>dungeon</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\src\gamevalue.h" />
     <ClInclude Include="..\..\src\world\world.h">
       <Filter>world</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\dungeon\dungeon-processor.h">
+      <Filter>dungeon</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\..\src\wall.bmp" />
     <Filter Include="world">
       <UniqueIdentifier>{cbd4a56f-0cd0-47a4-96be-a0a4d85ad7d1}</UniqueIdentifier>
     </Filter>
+    <Filter Include="dungeon">
+      <UniqueIdentifier>{b37a544f-cca2-4c1f-b069-f109a6b6b119}</UniqueIdentifier>
+    </Filter>
   </ItemGroup>
   <ItemGroup>
     <ResourceCompile Include="..\..\src\angband.rc" />
index e1283a0..fe6f53f 100644 (file)
@@ -102,7 +102,7 @@ hengband_SOURCES = \
        floor-save.h floor-save.c floor-town.h floor-town.c \
        floor-streams.c floor-streams.h \
        floor/pattern-walk.c floor/pattern-walk.h \
-       floor/dungeon-processor.c floor/dungeon-processor.h \
+       dungeon/dungeon-processor.c dungeon/dungeon-processor.h \
        \
        feature.c feature.h \
        geometry.c geometry.h \
@@ -286,9 +286,9 @@ CFLAGS += $(XFT_CFLAGS)
 LIBS += $(XFT_LIBS)
 COMPILE = $(srcdir)/gcc-wrap $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
        $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) \
-       -Iautopick -Ibirth -Icmd -Icombat -Icore -Ieffect -Ifloor -Iinventory -Iio \
-       -Iknowledge -Imarket -Imonster -Iobject -Iplayer -Irealm -Iroom -Ispell \
-       -Iview -Iwizard -Iworld
+       -Iautopick -Ibirth -Icmd -Icombat -Icore -Idungeon -Ieffect -Ifloor \
+       -Iinventory -Iio -Iknowledge -Imarket -Imonster -Iobject -Iplayer -Irealm \
+       -Iroom -Ispell -Iview -Iwizard -Iworld
 
 install-exec-hook:
 if SET_GID
index 81b187b..2da87e0 100644 (file)
@@ -23,7 +23,6 @@
 #include "birth/birth.h"
 #include "market/building.h"
 #include "io/write-diary.h"
-#include "dungeon.h"
 #include "feature.h"
 #include "floor.h"
 #include "floor-events.h"
 #include "world/world.h"
 #include "market/arena-info-table.h"
 #include "market/store-util.h"
-#include "quest.h"
 #include "view/display-player.h"
 #include "player/process-name.h"
-#include "player-move.h"
 #include "player-class.h"
 #include "player-race.h"
 #include "player-personality.h"
 #include "player-effects.h"
 #include "wild.h"
-#include "monster-process.h"
-#include "monster-status.h"
 #include "floor-save.h"
 #include "feature.h"
 #include "player-skill.h"
 #include "autopick/autopick-reader-writer.h"
 #include "save.h"
 #include "realm/realm.h"
-#include "realm/realm-song.h"
 #include "targeting.h"
 #include "core/output-updater.h"
 #include "core/game-closer.h"
-#include "core/turn-compensator.h"
-#include "core/hp-mp-regenerator.h"
 #include "io/input-key-processor.h"
 #include "core/player-processor.h"
-#include "world/world-turn-processor.h"
-
-#include "cmd/cmd-dump.h"
+#include "dungeon/dungeon-processor.h"
 
  /*!
   * todo どこからも呼ばれていない。main関数辺りに移設するか、そもそもコメントでいいと思われる
@@ -99,202 +89,6 @@ concptr ANGBAND_GRAF = "ascii";
 int init_flags;
 
 /*!
- * process_player()、process_world() をcore.c から移設するのが先.
- * process_upkeep_with_speed() はこの関数と同じところでOK
- * @brief 現在プレイヤーがいるダンジョンの全体処理 / Interact with the current dungeon level.
- * @return なし
- * @details
- * <p>
- * この関数から現在の階層を出る、プレイヤーがキャラが死ぬ、
- * ゲームを終了するかのいずれかまでループする。
- * </p>
- * <p>
- * This function will not exit until the level is completed,\n
- * the user dies, or the game is terminated.\n
- * </p>
- */
-static void dungeon(player_type *player_ptr, bool load_game)
-{
-       floor_type *floor_ptr = player_ptr->current_floor_ptr;
-       floor_ptr->base_level = floor_ptr->dun_level;
-       current_world_ptr->is_loading_now = FALSE;
-       player_ptr->leaving = FALSE;
-
-       command_cmd = 0;
-       command_rep = 0;
-       command_arg = 0;
-       command_dir = 0;
-
-       target_who = 0;
-       player_ptr->pet_t_m_idx = 0;
-       player_ptr->riding_t_m_idx = 0;
-       player_ptr->ambush_flag = FALSE;
-       health_track(player_ptr, 0);
-       repair_monsters = TRUE;
-
-       disturb(player_ptr, TRUE, TRUE);
-       int quest_num = quest_num = quest_number(player_ptr, floor_ptr->dun_level);
-       if (quest_num)
-       {
-               r_info[quest[quest_num].r_idx].flags1 |= RF1_QUESTOR;
-       }
-
-       if (player_ptr->max_plv < player_ptr->lev)
-       {
-               player_ptr->max_plv = player_ptr->lev;
-       }
-
-       if ((max_dlv[player_ptr->dungeon_idx] < floor_ptr->dun_level) && !floor_ptr->inside_quest)
-       {
-               max_dlv[player_ptr->dungeon_idx] = floor_ptr->dun_level;
-               if (record_maxdepth) exe_write_diary(player_ptr, DIARY_MAXDEAPTH, floor_ptr->dun_level, NULL);
-       }
-
-       (void)calculate_upkeep(player_ptr);
-       panel_bounds_center();
-       verify_panel(player_ptr);
-       msg_erase();
-
-       current_world_ptr->character_xtra = TRUE;
-       player_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER | PW_MONSTER | PW_OVERHEAD | PW_DUNGEON);
-       player_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_EQUIPPY | PR_MAP);
-       player_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS | PU_VIEW | PU_LITE | PU_MON_LITE | PU_TORCH | PU_MONSTERS | PU_DISTANCE | PU_FLOW);
-       handle_stuff(player_ptr);
-
-       current_world_ptr->character_xtra = FALSE;
-       player_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
-       player_ptr->update |= (PU_COMBINE | PU_REORDER);
-       handle_stuff(player_ptr);
-       Term_fresh();
-
-       if (quest_num && (is_fixed_quest_idx(quest_num) &&
-               !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) ||
-                       !(quest[quest_num].flags & QUEST_FLAG_PRESET))))
-               do_cmd_feeling(player_ptr);
-
-       if (player_ptr->phase_out)
-       {
-               if (load_game)
-               {
-                       player_ptr->energy_need = 0;
-                       update_gambling_monsters(player_ptr);
-               }
-               else
-               {
-                       msg_print(_("試合開始!", "Ready..Fight!"));
-                       msg_print(NULL);
-               }
-       }
-
-       if ((player_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(player_ptr) > MUSIC_DETECT))
-               SINGING_SONG_EFFECT(player_ptr) = MUSIC_DETECT;
-
-       if (!player_ptr->playing || player_ptr->is_dead) return;
-
-       if (!floor_ptr->inside_quest && (player_ptr->dungeon_idx == DUNGEON_ANGBAND))
-       {
-               quest_discovery(random_quest_number(player_ptr, floor_ptr->dun_level));
-               floor_ptr->inside_quest = random_quest_number(player_ptr, floor_ptr->dun_level);
-       }
-       if ((floor_ptr->dun_level == d_info[player_ptr->dungeon_idx].maxdepth) && d_info[player_ptr->dungeon_idx].final_guardian)
-       {
-               if (r_info[d_info[player_ptr->dungeon_idx].final_guardian].max_num)
-#ifdef JP
-                       msg_format("この階には%sの主である%sが棲んでいる。",
-                               d_name + d_info[player_ptr->dungeon_idx].name,
-                               r_name + r_info[d_info[player_ptr->dungeon_idx].final_guardian].name);
-#else
-                       msg_format("%^s lives in this level as the keeper of %s.",
-                               r_name + r_info[d_info[player_ptr->dungeon_idx].final_guardian].name,
-                               d_name + d_info[player_ptr->dungeon_idx].name);
-#endif
-       }
-
-       if (!load_game && (player_ptr->special_defense & NINJA_S_STEALTH)) set_superstealth(player_ptr, FALSE);
-
-       floor_ptr->monster_level = floor_ptr->base_level;
-       floor_ptr->object_level = floor_ptr->base_level;
-       current_world_ptr->is_loading_now = TRUE;
-       if (player_ptr->energy_need > 0 && !player_ptr->phase_out &&
-               (floor_ptr->dun_level || player_ptr->leaving_dungeon || floor_ptr->inside_arena))
-               player_ptr->energy_need = 0;
-
-       player_ptr->leaving_dungeon = FALSE;
-       mproc_init(floor_ptr);
-
-       while (TRUE)
-       {
-               if ((floor_ptr->m_cnt + 32 > current_world_ptr->max_m_idx) && !player_ptr->phase_out)
-                       compact_monsters(player_ptr, 64);
-
-               if ((floor_ptr->m_cnt + 32 < floor_ptr->m_max) && !player_ptr->phase_out)
-                       compact_monsters(player_ptr, 0);
-
-               if (floor_ptr->o_cnt + 32 > current_world_ptr->max_o_idx)
-                       compact_objects(player_ptr, 64);
-
-               if (floor_ptr->o_cnt + 32 < floor_ptr->o_max)
-                       compact_objects(player_ptr, 0);
-
-               process_player(player_ptr);
-               process_upkeep_with_speed(player_ptr);
-               handle_stuff(player_ptr);
-
-               move_cursor_relative(player_ptr->y, player_ptr->x);
-               if (fresh_after) Term_fresh();
-
-               if (!player_ptr->playing || player_ptr->is_dead) break;
-
-               process_monsters(player_ptr);
-               handle_stuff(player_ptr);
-
-               move_cursor_relative(player_ptr->y, player_ptr->x);
-               if (fresh_after) Term_fresh();
-
-               if (!player_ptr->playing || player_ptr->is_dead) break;
-
-               process_world(player_ptr);
-               handle_stuff(player_ptr);
-
-               move_cursor_relative(player_ptr->y, player_ptr->x);
-               if (fresh_after) Term_fresh();
-
-               if (!player_ptr->playing || player_ptr->is_dead) break;
-
-               current_world_ptr->game_turn++;
-               if (current_world_ptr->dungeon_turn < current_world_ptr->dungeon_turn_limit)
-               {
-                       if (!player_ptr->wild_mode || wild_regen) current_world_ptr->dungeon_turn++;
-                       else if (player_ptr->wild_mode && !(current_world_ptr->game_turn % ((MAX_HGT + MAX_WID) / 2))) current_world_ptr->dungeon_turn++;
-               }
-
-               prevent_turn_overflow(player_ptr);
-
-               if (player_ptr->leaving) break;
-
-               if (wild_regen) wild_regen--;
-       }
-
-       if (quest_num && !(r_info[quest[quest_num].r_idx].flags1 & RF1_UNIQUE))
-       {
-               r_info[quest[quest_num].r_idx].flags1 &= ~RF1_QUESTOR;
-       }
-
-       if (player_ptr->playing && !player_ptr->is_dead)
-       {
-               /*
-                * Maintain Unique monsters and artifact, save current
-                * floor, then prepare next floor
-                */
-               leave_floor(player_ptr);
-               reinit_wilderness = FALSE;
-       }
-
-       write_level = TRUE;
-}
-
-
-/*!
  * @brief 全ユーザプロファイルをロードする / Load some "user pref files"
  * @paaram player_ptr プレーヤーへの参照ポインタ
  * @return なし
@@ -616,7 +410,7 @@ void play_game(player_type *player_ptr, bool new_game)
 
        while (TRUE)
        {
-               dungeon(player_ptr, load_game);
+               process_dungeon(player_ptr, load_game);
                current_world_ptr->character_xtra = TRUE;
                handle_stuff(player_ptr);
 
diff --git a/src/dungeon/dungeon-processor.c b/src/dungeon/dungeon-processor.c
new file mode 100644 (file)
index 0000000..46bddd2
--- /dev/null
@@ -0,0 +1,211 @@
+#include "angband.h"
+#include "dungeon/dungeon-processor.h"
+#include "world/world.h"
+#include "targeting.h"
+#include "core/player-processor.h"
+#include "quest.h"
+#include "dungeon.h"
+#include "io/write-diary.h"
+#include "realm/realm-song.h"
+#include "core/hp-mp-regenerator.h"
+#include "player-move.h"
+#include "view/display-main-window.h"
+#include "core/stuff-handler.h"
+#include "cmd/cmd-dump.h"
+#include "player-effects.h"
+#include "monster-process.h"
+#include "monster-status.h"
+#include "world/world-turn-processor.h"
+#include "core/turn-compensator.h"
+
+/*!
+ * process_player()、process_world() をcore.c から移設するのが先.
+ * process_upkeep_with_speed() はこの関数と同じところでOK
+ * @brief 現在プレイヤーがいるダンジョンの全体処理 / Interact with the current dungeon level.
+ * @return なし
+ * @details
+ * <p>
+ * この関数から現在の階層を出る、プレイヤーがキャラが死ぬ、
+ * ゲームを終了するかのいずれかまでループする。
+ * </p>
+ * <p>
+ * This function will not exit until the level is completed,\n
+ * the user dies, or the game is terminated.\n
+ * </p>
+ */
+void process_dungeon(player_type* player_ptr, bool load_game)
+{
+    floor_type* floor_ptr = player_ptr->current_floor_ptr;
+    floor_ptr->base_level = floor_ptr->dun_level;
+    current_world_ptr->is_loading_now = FALSE;
+    player_ptr->leaving = FALSE;
+
+    command_cmd = 0;
+    command_rep = 0;
+    command_arg = 0;
+    command_dir = 0;
+
+    target_who = 0;
+    player_ptr->pet_t_m_idx = 0;
+    player_ptr->riding_t_m_idx = 0;
+    player_ptr->ambush_flag = FALSE;
+    health_track(player_ptr, 0);
+    repair_monsters = TRUE;
+
+    disturb(player_ptr, TRUE, TRUE);
+    int quest_num = quest_num = quest_number(player_ptr, floor_ptr->dun_level);
+    if (quest_num) {
+        r_info[quest[quest_num].r_idx].flags1 |= RF1_QUESTOR;
+    }
+
+    if (player_ptr->max_plv < player_ptr->lev) {
+        player_ptr->max_plv = player_ptr->lev;
+    }
+
+    if ((max_dlv[player_ptr->dungeon_idx] < floor_ptr->dun_level) && !floor_ptr->inside_quest) {
+        max_dlv[player_ptr->dungeon_idx] = floor_ptr->dun_level;
+        if (record_maxdepth)
+            exe_write_diary(player_ptr, DIARY_MAXDEAPTH, floor_ptr->dun_level, NULL);
+    }
+
+    (void)calculate_upkeep(player_ptr);
+    panel_bounds_center();
+    verify_panel(player_ptr);
+    msg_erase();
+
+    current_world_ptr->character_xtra = TRUE;
+    player_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER | PW_MONSTER | PW_OVERHEAD | PW_DUNGEON);
+    player_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_EQUIPPY | PR_MAP);
+    player_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS | PU_VIEW | PU_LITE | PU_MON_LITE | PU_TORCH | PU_MONSTERS | PU_DISTANCE | PU_FLOW);
+    handle_stuff(player_ptr);
+
+    current_world_ptr->character_xtra = FALSE;
+    player_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
+    player_ptr->update |= (PU_COMBINE | PU_REORDER);
+    handle_stuff(player_ptr);
+    Term_fresh();
+
+    if (quest_num && (is_fixed_quest_idx(quest_num) && !((quest_num == QUEST_OBERON) || (quest_num == QUEST_SERPENT) || !(quest[quest_num].flags & QUEST_FLAG_PRESET))))
+        do_cmd_feeling(player_ptr);
+
+    if (player_ptr->phase_out) {
+        if (load_game) {
+            player_ptr->energy_need = 0;
+            update_gambling_monsters(player_ptr);
+        } else {
+            msg_print(_("試合開始!", "Ready..Fight!"));
+            msg_print(NULL);
+        }
+    }
+
+    if ((player_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(player_ptr) > MUSIC_DETECT))
+        SINGING_SONG_EFFECT(player_ptr) = MUSIC_DETECT;
+
+    if (!player_ptr->playing || player_ptr->is_dead)
+        return;
+
+    if (!floor_ptr->inside_quest && (player_ptr->dungeon_idx == DUNGEON_ANGBAND)) {
+        quest_discovery(random_quest_number(player_ptr, floor_ptr->dun_level));
+        floor_ptr->inside_quest = random_quest_number(player_ptr, floor_ptr->dun_level);
+    }
+    if ((floor_ptr->dun_level == d_info[player_ptr->dungeon_idx].maxdepth) && d_info[player_ptr->dungeon_idx].final_guardian) {
+        if (r_info[d_info[player_ptr->dungeon_idx].final_guardian].max_num)
+#ifdef JP
+            msg_format("この階には%sの主である%sが棲んでいる。",
+                d_name + d_info[player_ptr->dungeon_idx].name,
+                r_name + r_info[d_info[player_ptr->dungeon_idx].final_guardian].name);
+#else
+            msg_format("%^s lives in this level as the keeper of %s.",
+                r_name + r_info[d_info[player_ptr->dungeon_idx].final_guardian].name,
+                d_name + d_info[player_ptr->dungeon_idx].name);
+#endif
+    }
+
+    if (!load_game && (player_ptr->special_defense & NINJA_S_STEALTH))
+        set_superstealth(player_ptr, FALSE);
+
+    floor_ptr->monster_level = floor_ptr->base_level;
+    floor_ptr->object_level = floor_ptr->base_level;
+    current_world_ptr->is_loading_now = TRUE;
+    if (player_ptr->energy_need > 0 && !player_ptr->phase_out && (floor_ptr->dun_level || player_ptr->leaving_dungeon || floor_ptr->inside_arena))
+        player_ptr->energy_need = 0;
+
+    player_ptr->leaving_dungeon = FALSE;
+    mproc_init(floor_ptr);
+
+    while (TRUE) {
+        if ((floor_ptr->m_cnt + 32 > current_world_ptr->max_m_idx) && !player_ptr->phase_out)
+            compact_monsters(player_ptr, 64);
+
+        if ((floor_ptr->m_cnt + 32 < floor_ptr->m_max) && !player_ptr->phase_out)
+            compact_monsters(player_ptr, 0);
+
+        if (floor_ptr->o_cnt + 32 > current_world_ptr->max_o_idx)
+            compact_objects(player_ptr, 64);
+
+        if (floor_ptr->o_cnt + 32 < floor_ptr->o_max)
+            compact_objects(player_ptr, 0);
+
+        process_player(player_ptr);
+        process_upkeep_with_speed(player_ptr);
+        handle_stuff(player_ptr);
+
+        move_cursor_relative(player_ptr->y, player_ptr->x);
+        if (fresh_after)
+            Term_fresh();
+
+        if (!player_ptr->playing || player_ptr->is_dead)
+            break;
+
+        process_monsters(player_ptr);
+        handle_stuff(player_ptr);
+
+        move_cursor_relative(player_ptr->y, player_ptr->x);
+        if (fresh_after)
+            Term_fresh();
+
+        if (!player_ptr->playing || player_ptr->is_dead)
+            break;
+
+        process_world(player_ptr);
+        handle_stuff(player_ptr);
+
+        move_cursor_relative(player_ptr->y, player_ptr->x);
+        if (fresh_after)
+            Term_fresh();
+
+        if (!player_ptr->playing || player_ptr->is_dead)
+            break;
+
+        current_world_ptr->game_turn++;
+        if (current_world_ptr->dungeon_turn < current_world_ptr->dungeon_turn_limit) {
+            if (!player_ptr->wild_mode || wild_regen)
+                current_world_ptr->dungeon_turn++;
+            else if (player_ptr->wild_mode && !(current_world_ptr->game_turn % ((MAX_HGT + MAX_WID) / 2)))
+                current_world_ptr->dungeon_turn++;
+        }
+
+        prevent_turn_overflow(player_ptr);
+
+        if (player_ptr->leaving)
+            break;
+
+        if (wild_regen)
+            wild_regen--;
+    }
+
+    if (quest_num && !(r_info[quest[quest_num].r_idx].flags1 & RF1_UNIQUE)) {
+        r_info[quest[quest_num].r_idx].flags1 &= ~RF1_QUESTOR;
+    }
+
+    if (player_ptr->playing && !player_ptr->is_dead) {
+        /*
+                * Maintain Unique monsters and artifact, save current
+                * floor, then prepare next floor
+                */
+        leave_floor(player_ptr);
+        reinit_wilderness = FALSE;
+    }
+
+    write_level = TRUE;
+}
diff --git a/src/dungeon/dungeon-processor.h b/src/dungeon/dungeon-processor.h
new file mode 100644 (file)
index 0000000..9fe9cef
--- /dev/null
@@ -0,0 +1,3 @@
+#pragma once
+
+void process_dungeon(player_type* player_ptr, bool load_game);