OSDN Git Service

[Refactor] #40467 Separated load_store() from exe_reading_savefile()
authorHourier <hourier@users.sourceforge.jp>
Sun, 5 Jul 2020 12:44:47 +0000 (21:44 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sun, 5 Jul 2020 12:44:47 +0000 (21:44 +0900)
src/savedata/load-zangband.c
src/savedata/load-zangband.h
src/savedata/load.c

index 0049b93..2b237eb 100644 (file)
@@ -261,7 +261,7 @@ void set_zangband_class(player_type *creature_ptr)
     }
 }
 
-void set_zangband_spells(player_type *creature_ptr)
+void set_zangband_learnt_spells(player_type *creature_ptr)
 {
     creature_ptr->learned_spells = 0;
     for (int i = 0; i < 64; i++)
index c2b2c05..4f68e1c 100644 (file)
@@ -22,3 +22,4 @@ 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);
 void set_zangband_class(player_type *creature_ptr);
+void set_zangband_learnt_spells(player_type *creature_ptr);
index c5f1556..328536e 100644 (file)
@@ -410,7 +410,7 @@ static void load_spells(player_type *creature_ptr)
     rd_u32b(&creature_ptr->spell_forgotten2);
 
     if (z_older_than(10, 0, 5))
-        set_zangband_spells(creature_ptr);
+        set_zangband_learnt_spells(creature_ptr);
     else
         rd_s16b(&creature_ptr->learned_spells);
 
@@ -435,6 +435,20 @@ static errr load_inventory(player_type *creature_ptr)
     return 21;
 }
 
+static errr load_store(player_type *creature_ptr)
+{
+    u16b tmp16u;
+    rd_u16b(&tmp16u);
+    int town_count = tmp16u;
+    rd_u16b(&tmp16u);
+    for (int i = 1; i < town_count; i++)
+        for (int j = 0; j < tmp16u; j++)
+            if (rd_store(creature_ptr, i, j))
+                return 22;
+
+    return 0;
+}
+
 /*!
  * @brief セーブファイル読み込み処理の実体 / Actually read the savefile
  * @return エラーコード
@@ -485,14 +499,9 @@ static errr exe_reading_savefile(player_type *creature_ptr)
     if (load_inventory_result != 0)
         return load_inventory_result;
 
-    u16b tmp16u;
-    rd_u16b(&tmp16u);
-    int town_count = tmp16u;
-    rd_u16b(&tmp16u);
-    for (int i = 1; i < town_count; i++)
-        for (int j = 0; j < tmp16u; j++)
-            if (rd_store(creature_ptr, i, j))
-                return 22;
+    errr load_store_result = load_store(creature_ptr);
+    if (load_store_result != 0)
+        return load_store_result;
 
     rd_s16b(&creature_ptr->pet_follow_distance);
     byte tmp8u;
@@ -501,6 +510,7 @@ static errr exe_reading_savefile(player_type *creature_ptr)
         rd_byte(&tmp8u);
         if (tmp8u)
             creature_ptr->pet_extra_flags |= PF_OPEN_DOORS;
+
         rd_byte(&tmp8u);
         if (tmp8u)
             creature_ptr->pet_extra_flags |= PF_PICKUP_ITEMS;