OSDN Git Service

[Refactor] #40467 Separated set_zangband_quest() from load.c to load-zangband.c/h
authorHourier <hourier@users.sourceforge.jp>
Sun, 5 Jul 2020 11:30:58 +0000 (20:30 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sun, 5 Jul 2020 11:30:58 +0000 (20:30 +0900)
src/savedata/load-zangband.c
src/savedata/load-zangband.h
src/savedata/load.c

index 97b5955..063c31f 100644 (file)
@@ -1,6 +1,7 @@
 #include "savedata/load-zangband.h"
 #include "cmd-building/cmd-building.h"
 #include "dungeon/dungeon.h"
+#include "dungeon/quest.h"
 #include "floor/floor.h"
 #include "game-option/option-flags.h"
 #include "market/bounty.h"
@@ -11,6 +12,7 @@
 #include "player/player-skill.h"
 #include "realm/realm-types.h"
 #include "savedata/load-util.h"
+#include "system/system-variables.h"
 #include "world/world.h"
 
 void load_zangband_options(void)
@@ -217,3 +219,16 @@ void set_zangband_visited_towns(player_type *creature_ptr)
     rd_s32b(&tmp32s);
     creature_ptr->visit = 1L;
 }
+
+void set_zangband_quest(player_type *creature_ptr, quest_type *const q_ptr, int loading_quest_index, const QUEST_IDX old_inside_quest)
+{
+    if (q_ptr->flags & QUEST_FLAG_PRESET) {
+        q_ptr->dungeon = 0;
+        return;
+    }
+
+    init_flags = INIT_ASSIGN;
+    creature_ptr->current_floor_ptr->inside_quest = (QUEST_IDX)loading_quest_index;
+    parse_fixed_map(creature_ptr, "q_info.txt", 0, 0, 0, 0);
+    creature_ptr->current_floor_ptr->inside_quest = old_inside_quest;
+}
index 03b819a..da65e3a 100644 (file)
@@ -19,3 +19,4 @@ void set_zangband_special_attack(player_type *creature_ptr);
 void set_zangband_special_defense(player_type *creature_ptr);
 void set_zangband_action(player_type *creature_ptr);
 void set_zangband_visited_towns(player_type *creature_ptr);
+void set_zangband_quest(player_type *creature_ptr, quest_type *const q_ptr, int loading_quest_index, const QUEST_IDX old_inside_quest);
index b59d199..a732996 100644 (file)
 #include "savedata/load-util.h"
 #include "savedata/load-v1-5-0.h"
 #include "savedata/lore-loader.h"
+#include "savedata/load-zangband.h"
 #include "savedata/option-loader.h"
-#include "savedata/store-loader.h"
 #include "savedata/player-info-loader.h"
+#include "savedata/store-loader.h"
 #include "savedata/world-loader.h"
 #include "spell/spells-status.h"
 #include "system/system-variables.h"
@@ -252,12 +253,11 @@ static errr exe_reading_savefile(player_type *creature_ptr)
         return load_item_result;
 
     byte tmp8u;
-    if (!z_older_than(12, 1, 3))
-    {
+    if (!z_older_than(12, 1, 3)) {
         errr load_town_result = load_town();
         if (load_town_result != 0)
             return load_town_result;
-        
+
         u16b max_quests_load;
         byte max_rquests_load;
         errr load_quest_result = load_quest_info(&max_quests_load, &max_rquests_load);
@@ -278,17 +278,9 @@ static errr exe_reading_savefile(player_type *creature_ptr)
                 continue;
 
             load_quest_details(creature_ptr, q_ptr, i);
-            if (z_older_than(10, 3, 11)) {
-                if (q_ptr->flags & QUEST_FLAG_PRESET) {
-                    q_ptr->dungeon = 0;
-                } else {
-                    init_flags = INIT_ASSIGN;
-                    creature_ptr->current_floor_ptr->inside_quest = (QUEST_IDX)i;
-
-                    parse_fixed_map(creature_ptr, "q_info.txt", 0, 0, 0, 0);
-                    creature_ptr->current_floor_ptr->inside_quest = old_inside_quest;
-                }
-            } else {
+            if (z_older_than(10, 3, 11))
+                set_zangband_quest(creature_ptr, q_ptr, i, old_inside_quest);
+            else {
                 rd_byte(&tmp8u);
                 q_ptr->dungeon = tmp8u;
             }