OSDN Git Service

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

index 787062b..9902cd3 100644 (file)
     <ClCompile Include="..\..\src\wizard\wizard-spoiler.c" />\r
     <ClCompile Include="..\..\src\wizard\wizard-special-process.c" />\r
     <ClCompile Include="..\..\src\world.c" />\r
+    <ClCompile Include="..\..\src\world\world-movement-processor.c" />\r
     <ClCompile Include="..\..\src\z-form.c" />\r
     <ClCompile Include="..\..\src\z-rand.c" />\r
     <ClCompile Include="..\..\src\z-term.c" />\r
     <ClInclude Include="..\..\src\view\status-first-page.h" />\r
     <ClInclude Include="..\..\src\wizard\wizard-special-process.h" />\r
     <ClInclude Include="..\..\src\wizard\wizard-spoiler.h" />\r
+    <ClInclude Include="..\..\src\world\world-movement-processor.h" />\r
     <ClInclude Include="japanese.h" />\r
   </ItemGroup>\r
   <ItemGroup>\r
index fcc43cb..5d7fedf 100644 (file)
     <ClCompile Include="..\..\src\player\digestion-processor.c">
       <Filter>player</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\src\world\world-movement-processor.c">
+      <Filter>world</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\src\gamevalue.h" />
     <ClInclude Include="..\..\src\player\digestion-processor.h">
       <Filter>player</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\world\world-movement-processor.h">
+      <Filter>world</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\..\src\wall.bmp" />
     <Filter Include="wizard">
       <UniqueIdentifier>{22328846-3669-435a-9731-f0998a1c3dfa}</UniqueIdentifier>
     </Filter>
+    <Filter Include="world">
+      <UniqueIdentifier>{cbd4a56f-0cd0-47a4-96be-a0a4d85ad7d1}</UniqueIdentifier>
+    </Filter>
   </ItemGroup>
   <ItemGroup>
     <ResourceCompile Include="..\..\src\angband.rc" />
index f8c7c66..0a812a6 100644 (file)
@@ -269,7 +269,9 @@ hengband_SOURCES = \
        combat/melee.h combat/melee.c combat/shoot.c combat/shoot.h \
        \
        wizard/wizard-spoiler.c wizard/wizard-spoiler.h\
-       wizard/wizard-special-process.c wizard/wizard-special-process.h
+       wizard/wizard-special-process.c wizard/wizard-special-process.h \
+       \
+       world/world-movement-processor.c world/world-movement-processor.h \
 
 EXTRA_hengband_SOURCES = \
        angband.ico angband.rc ang_eng.rc maid-x11.c main-win.c \
@@ -284,7 +286,7 @@ 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
+       -Iview -Iwizard -Iworld
 
 install-exec-hook:
 if SET_GID
index b27d381..2637f54 100644 (file)
@@ -12,7 +12,6 @@
 #include "angband.h"
 #include "io/signal-handlers.h"
 #include "util.h"
-#include "main/sound-definitions-table.h"
 #include "core.h"
 #include "core/angband-version.h"
 #include "core/stuff-handler.h"
@@ -75,6 +74,7 @@
 #include "io/input-key-processor.h"
 #include "core/player-processor.h"
 #include "player/digestion-processor.h"
+#include "world/world-movement-processor.h"
 
 #include "cmd/cmd-save.h"
 #include "cmd/cmd-dump.h"
@@ -109,145 +109,9 @@ concptr ANGBAND_GRAF = "ascii";
 int init_flags;
 
 /*!
- * @brief 10ゲームターンが進行するごとに帰還や現実変容などの残り時間カウントダウンと発動を処理する。
- * / Handle involuntary movement once every 10 game turns
- * @return なし
- */
-static void process_world_aux_movement(player_type *creature_ptr)
-{
-       floor_type *floor_ptr = creature_ptr->current_floor_ptr;
-       if (creature_ptr->word_recall)
-       {
-               /*
-                * HACK: Autosave BEFORE resetting the recall counter (rr9)
-                * The player is yanked up/down as soon as
-                * he loads the autosaved game.
-                */
-               if (autosave_l && (creature_ptr->word_recall == 1) && !creature_ptr->phase_out)
-                       do_cmd_save_game(creature_ptr, TRUE);
-
-               creature_ptr->word_recall--;
-               creature_ptr->redraw |= (PR_STATUS);
-               if (!creature_ptr->word_recall)
-               {
-                       disturb(creature_ptr, FALSE, TRUE);
-                       if (floor_ptr->dun_level || creature_ptr->current_floor_ptr->inside_quest || creature_ptr->enter_dungeon)
-                       {
-                               msg_print(_("上に引っ張りあげられる感じがする!", "You feel yourself yanked upwards!"));
-                               if (creature_ptr->dungeon_idx) creature_ptr->recall_dungeon = creature_ptr->dungeon_idx;
-                               if (record_stair)
-                                       exe_write_diary(creature_ptr, DIARY_RECALL, floor_ptr->dun_level, NULL);
-
-                               floor_ptr->dun_level = 0;
-                               creature_ptr->dungeon_idx = 0;
-                               leave_quest_check(creature_ptr);
-                               leave_tower_check(creature_ptr);
-                               creature_ptr->current_floor_ptr->inside_quest = 0;
-                               creature_ptr->leaving = TRUE;
-                       }
-                       else
-                       {
-                               msg_print(_("下に引きずり降ろされる感じがする!", "You feel yourself yanked downwards!"));
-                               creature_ptr->dungeon_idx = creature_ptr->recall_dungeon;
-                               if (record_stair)
-                                       exe_write_diary(creature_ptr, DIARY_RECALL, floor_ptr->dun_level, NULL);
-
-                               floor_ptr->dun_level = max_dlv[creature_ptr->dungeon_idx];
-                               if (floor_ptr->dun_level < 1) floor_ptr->dun_level = 1;
-                               if (ironman_nightmare && !randint0(666) && (creature_ptr->dungeon_idx == DUNGEON_ANGBAND))
-                               {
-                                       if (floor_ptr->dun_level < 50)
-                                       {
-                                               floor_ptr->dun_level *= 2;
-                                       }
-                                       else if (floor_ptr->dun_level < 99)
-                                       {
-                                               floor_ptr->dun_level = (floor_ptr->dun_level + 99) / 2;
-                                       }
-                                       else if (floor_ptr->dun_level > 100)
-                                       {
-                                               floor_ptr->dun_level = d_info[creature_ptr->dungeon_idx].maxdepth - 1;
-                                       }
-                               }
-
-                               if (creature_ptr->wild_mode)
-                               {
-                                       creature_ptr->wilderness_y = creature_ptr->y;
-                                       creature_ptr->wilderness_x = creature_ptr->x;
-                               }
-                               else
-                               {
-                                       creature_ptr->oldpx = creature_ptr->x;
-                                       creature_ptr->oldpy = creature_ptr->y;
-                               }
-
-                               creature_ptr->wild_mode = FALSE;
-
-                               /*
-                                * Clear all saved floors
-                                * and create a first saved floor
-                                */
-                               prepare_change_floor_mode(creature_ptr, CFM_FIRST_FLOOR);
-                               creature_ptr->leaving = TRUE;
-
-                               if (creature_ptr->dungeon_idx == DUNGEON_ANGBAND)
-                               {
-                                       for (int i = MIN_RANDOM_QUEST; i < MAX_RANDOM_QUEST + 1; i++)
-                                       {
-                                               quest_type* const q_ptr = &quest[i];
-                                               if ((q_ptr->type == QUEST_TYPE_RANDOM) &&
-                                                       (q_ptr->status == QUEST_STATUS_TAKEN) &&
-                                                       (q_ptr->level < floor_ptr->dun_level))
-                                               {
-                                                       q_ptr->status = QUEST_STATUS_FAILED;
-                                                       q_ptr->complev = (byte)creature_ptr->lev;
-                                                       update_playtime();
-                                                       q_ptr->comptime = current_world_ptr->play_time;
-                                                       r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
-                                               }
-                                       }
-                               }
-                       }
-
-                       sound(SOUND_TPLEVEL);
-               }
-       }
-
-       if (creature_ptr->alter_reality)
-       {
-               if (autosave_l && (creature_ptr->alter_reality == 1) && !creature_ptr->phase_out)
-                       do_cmd_save_game(creature_ptr, TRUE);
-
-               creature_ptr->alter_reality--;
-               creature_ptr->redraw |= (PR_STATUS);
-               if (!creature_ptr->alter_reality)
-               {
-                       disturb(creature_ptr, FALSE, TRUE);
-                       if (!quest_number(creature_ptr, floor_ptr->dun_level) && floor_ptr->dun_level)
-                       {
-                               msg_print(_("世界が変わった!", "The world changes!"));
-
-                               /*
-                                * Clear all saved floors
-                                * and create a first saved floor
-                                */
-                               prepare_change_floor_mode(creature_ptr, CFM_FIRST_FLOOR);
-                               creature_ptr->leaving = TRUE;
-                       }
-                       else
-                       {
-                               msg_print(_("世界が少しの間変化したようだ。", "The world seems to change for a moment!"));
-                       }
-
-                       sound(SOUND_TPLEVEL);
-               }
-       }
-}
-
-
-/*!
  * @brief 10ゲームターンが進行する毎にゲーム世界全体の処理を行う。
  * / Handle certain things once every 10 game turns
+ * @param player_ptr プレーヤーへの参照ポインタ
  * @return なし
  */
 static void process_world(player_type *player_ptr)
diff --git a/src/world/world-movement-processor.c b/src/world/world-movement-processor.c
new file mode 100644 (file)
index 0000000..8c92d7f
--- /dev/null
@@ -0,0 +1,126 @@
+#include "angband.h"
+#include "world/world-movement-processor.h"
+#include "main/sound-definitions-table.h"
+#include "io/write-diary.h"
+#include "dungeon.h"
+#include "quest.h"
+#include "world.h"
+#include "cmd/cmd-save.h"
+#include "player-move.h"
+#include "view/display-main-window.h"
+
+/*!
+ * todo 帰還と現実変容の関数を分けること
+ * @brief 10ゲームターンが進行するごとに帰還や現実変容などの残り時間カウントダウンと発動を処理する。
+ * / Handle involuntary movement once every 10 game turns
+ * @param creature_ptr プレーヤーへの参照ポインタ
+ * @return なし
+ */
+void process_world_aux_movement(player_type* creature_ptr)
+{
+    floor_type* floor_ptr = creature_ptr->current_floor_ptr;
+    if (creature_ptr->word_recall) {
+        /*
+                * HACK: Autosave BEFORE resetting the recall counter (rr9)
+                * The player is yanked up/down as soon as
+                * he loads the autosaved game.
+                */
+        if (autosave_l && (creature_ptr->word_recall == 1) && !creature_ptr->phase_out)
+            do_cmd_save_game(creature_ptr, TRUE);
+
+        creature_ptr->word_recall--;
+        creature_ptr->redraw |= (PR_STATUS);
+        if (!creature_ptr->word_recall) {
+            disturb(creature_ptr, FALSE, TRUE);
+            if (floor_ptr->dun_level || creature_ptr->current_floor_ptr->inside_quest || creature_ptr->enter_dungeon) {
+                msg_print(_("上に引っ張りあげられる感じがする!", "You feel yourself yanked upwards!"));
+                if (creature_ptr->dungeon_idx)
+                    creature_ptr->recall_dungeon = creature_ptr->dungeon_idx;
+                if (record_stair)
+                    exe_write_diary(creature_ptr, DIARY_RECALL, floor_ptr->dun_level, NULL);
+
+                floor_ptr->dun_level = 0;
+                creature_ptr->dungeon_idx = 0;
+                leave_quest_check(creature_ptr);
+                leave_tower_check(creature_ptr);
+                creature_ptr->current_floor_ptr->inside_quest = 0;
+                creature_ptr->leaving = TRUE;
+            } else {
+                msg_print(_("下に引きずり降ろされる感じがする!", "You feel yourself yanked downwards!"));
+                creature_ptr->dungeon_idx = creature_ptr->recall_dungeon;
+                if (record_stair)
+                    exe_write_diary(creature_ptr, DIARY_RECALL, floor_ptr->dun_level, NULL);
+
+                floor_ptr->dun_level = max_dlv[creature_ptr->dungeon_idx];
+                if (floor_ptr->dun_level < 1)
+                    floor_ptr->dun_level = 1;
+                if (ironman_nightmare && !randint0(666) && (creature_ptr->dungeon_idx == DUNGEON_ANGBAND)) {
+                    if (floor_ptr->dun_level < 50) {
+                        floor_ptr->dun_level *= 2;
+                    } else if (floor_ptr->dun_level < 99) {
+                        floor_ptr->dun_level = (floor_ptr->dun_level + 99) / 2;
+                    } else if (floor_ptr->dun_level > 100) {
+                        floor_ptr->dun_level = d_info[creature_ptr->dungeon_idx].maxdepth - 1;
+                    }
+                }
+
+                if (creature_ptr->wild_mode) {
+                    creature_ptr->wilderness_y = creature_ptr->y;
+                    creature_ptr->wilderness_x = creature_ptr->x;
+                } else {
+                    creature_ptr->oldpx = creature_ptr->x;
+                    creature_ptr->oldpy = creature_ptr->y;
+                }
+
+                creature_ptr->wild_mode = FALSE;
+
+                /*
+                                * Clear all saved floors
+                                * and create a first saved floor
+                                */
+                prepare_change_floor_mode(creature_ptr, CFM_FIRST_FLOOR);
+                creature_ptr->leaving = TRUE;
+
+                if (creature_ptr->dungeon_idx == DUNGEON_ANGBAND) {
+                    for (int i = MIN_RANDOM_QUEST; i < MAX_RANDOM_QUEST + 1; i++) {
+                        quest_type* const q_ptr = &quest[i];
+                        if ((q_ptr->type == QUEST_TYPE_RANDOM) && (q_ptr->status == QUEST_STATUS_TAKEN) && (q_ptr->level < floor_ptr->dun_level)) {
+                            q_ptr->status = QUEST_STATUS_FAILED;
+                            q_ptr->complev = (byte)creature_ptr->lev;
+                            update_playtime();
+                            q_ptr->comptime = current_world_ptr->play_time;
+                            r_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
+                        }
+                    }
+                }
+            }
+
+            sound(SOUND_TPLEVEL);
+        }
+    }
+
+    if (creature_ptr->alter_reality) {
+        if (autosave_l && (creature_ptr->alter_reality == 1) && !creature_ptr->phase_out)
+            do_cmd_save_game(creature_ptr, TRUE);
+
+        creature_ptr->alter_reality--;
+        creature_ptr->redraw |= (PR_STATUS);
+        if (!creature_ptr->alter_reality) {
+            disturb(creature_ptr, FALSE, TRUE);
+            if (!quest_number(creature_ptr, floor_ptr->dun_level) && floor_ptr->dun_level) {
+                msg_print(_("世界が変わった!", "The world changes!"));
+
+                /*
+                                * Clear all saved floors
+                                * and create a first saved floor
+                                */
+                prepare_change_floor_mode(creature_ptr, CFM_FIRST_FLOOR);
+                creature_ptr->leaving = TRUE;
+            } else {
+                msg_print(_("世界が少しの間変化したようだ。", "The world seems to change for a moment!"));
+            }
+
+            sound(SOUND_TPLEVEL);
+        }
+    }
+}
diff --git a/src/world/world-movement-processor.h b/src/world/world-movement-processor.h
new file mode 100644 (file)
index 0000000..093deda
--- /dev/null
@@ -0,0 +1,3 @@
+#pragma once
+
+void process_world_aux_movement(player_type* creature_ptr);