OSDN Git Service

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

index 2b237eb..dd636ad 100644 (file)
@@ -6,6 +6,7 @@
 #include "info-reader/fixed-map-parser.h"
 #include "market/bounty.h"
 #include "monster-race/monster-race.h"
+#include "pet/pet-util.h"
 #include "player/attack-defense-types.h"
 #include "player/avatar.h"
 #include "player/patron.h"
@@ -268,3 +269,47 @@ void set_zangband_learnt_spells(player_type *creature_ptr)
         if ((i < 32) ? (creature_ptr->spell_learned1 & (1L << i)) : (creature_ptr->spell_learned2 & (1L << (i - 32))))
             creature_ptr->learned_spells++;
 }
+
+void set_zangband_pet(player_type *creature_ptr)
+{
+    creature_ptr->pet_extra_flags = 0;
+    byte tmp8u;
+    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;
+
+    if (z_older_than(10, 0, 4))
+        creature_ptr->pet_extra_flags |= PF_TELEPORT;
+    else {
+        rd_byte(&tmp8u);
+        if (tmp8u)
+            creature_ptr->pet_extra_flags |= PF_TELEPORT;
+    }
+
+    if (z_older_than(10, 0, 7))
+        creature_ptr->pet_extra_flags |= PF_ATTACK_SPELL;
+    else {
+        rd_byte(&tmp8u);
+        if (tmp8u)
+            creature_ptr->pet_extra_flags |= PF_ATTACK_SPELL;
+    }
+
+    if (z_older_than(10, 0, 8))
+        creature_ptr->pet_extra_flags |= PF_SUMMON_SPELL;
+    else {
+        rd_byte(&tmp8u);
+        if (tmp8u)
+            creature_ptr->pet_extra_flags |= PF_SUMMON_SPELL;
+    }
+
+    if (z_older_than(10, 0, 8))
+        return;
+
+    rd_byte(&tmp8u);
+    if (tmp8u)
+        creature_ptr->pet_extra_flags |= PF_BALL_SPELL;
+}
index 4f68e1c..7369c73 100644 (file)
@@ -23,3 +23,4 @@ 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);
+void set_zangband_pet(player_type *creature_ptr);
index 328536e..ae3cb85 100644 (file)
@@ -504,49 +504,10 @@ static errr exe_reading_savefile(player_type *creature_ptr)
         return load_store_result;
 
     rd_s16b(&creature_ptr->pet_follow_distance);
-    byte tmp8u;
-    if (z_older_than(10, 4, 10)) {
-        creature_ptr->pet_extra_flags = 0;
-        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;
-
-        if (z_older_than(10, 0, 4))
-            creature_ptr->pet_extra_flags |= PF_TELEPORT;
-        else {
-            rd_byte(&tmp8u);
-            if (tmp8u)
-                creature_ptr->pet_extra_flags |= PF_TELEPORT;
-        }
-
-        if (z_older_than(10, 0, 7))
-            creature_ptr->pet_extra_flags |= PF_ATTACK_SPELL;
-        else {
-            rd_byte(&tmp8u);
-            if (tmp8u)
-                creature_ptr->pet_extra_flags |= PF_ATTACK_SPELL;
-        }
-
-        if (z_older_than(10, 0, 8))
-            creature_ptr->pet_extra_flags |= PF_SUMMON_SPELL;
-        else {
-            rd_byte(&tmp8u);
-            if (tmp8u)
-                creature_ptr->pet_extra_flags |= PF_SUMMON_SPELL;
-        }
-
-        if (!z_older_than(10, 0, 8)) {
-            rd_byte(&tmp8u);
-            if (tmp8u)
-                creature_ptr->pet_extra_flags |= PF_BALL_SPELL;
-        }
-    } else {
+    if (z_older_than(10, 4, 10))
+        set_zangband_pet(creature_ptr);
+    else
         rd_s16b(&creature_ptr->pet_extra_flags);
-    }
 
     if (!z_older_than(11, 0, 9)) {
         char buf[SCREEN_BUF_MAX_SIZE];