OSDN Git Service

[Refactor] #40467 Separated set_zangband_class() and set_zangband_spells() from exe_r...
authorHourier <hourier@users.sourceforge.jp>
Sun, 5 Jul 2020 12:36:03 +0000 (21:36 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sun, 5 Jul 2020 12:36:51 +0000 (21:36 +0900)
src/savedata/load-zangband.c
src/savedata/load-zangband.h
src/savedata/load.c

index a321607..0049b93 100644 (file)
@@ -9,9 +9,14 @@
 #include "player/attack-defense-types.h"
 #include "player/avatar.h"
 #include "player/patron.h"
+#include "player/player-class.h"
+#include "player/player-personality.h"
+#include "player/player-race.h"
 #include "player/player-skill.h"
 #include "realm/realm-types.h"
+#include "savedata/angband-version-comparer.h"
 #include "savedata/load-util.h"
+#include "spell/spells-status.h"
 #include "system/system-variables.h"
 #include "world/world.h"
 
@@ -232,3 +237,34 @@ void set_zangband_quest(player_type *creature_ptr, quest_type *const q_ptr, int
     parse_fixed_map(creature_ptr, "q_info.txt", 0, 0, 0, 0);
     creature_ptr->current_floor_ptr->inside_quest = old_inside_quest;
 }
+
+void set_zangband_class(player_type *creature_ptr)
+{
+    if (z_older_than(10, 2, 2) && (creature_ptr->pclass == CLASS_BEASTMASTER) && !creature_ptr->is_dead) {
+        creature_ptr->hitdie = rp_ptr->r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
+        roll_hitdice(creature_ptr, 0L);
+    }
+
+    if (z_older_than(10, 3, 2) && (creature_ptr->pclass == CLASS_ARCHER) && !creature_ptr->is_dead) {
+        creature_ptr->hitdie = rp_ptr->r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
+        roll_hitdice(creature_ptr, 0L);
+    }
+
+    if (z_older_than(10, 2, 6) && (creature_ptr->pclass == CLASS_SORCERER) && !creature_ptr->is_dead) {
+        creature_ptr->hitdie = rp_ptr->r_mhp / 2 + cp_ptr->c_mhp + ap_ptr->a_mhp;
+        roll_hitdice(creature_ptr, 0L);
+    }
+
+    if (z_older_than(10, 4, 7) && (creature_ptr->pclass == CLASS_BLUE_MAGE) && !creature_ptr->is_dead) {
+        creature_ptr->hitdie = rp_ptr->r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
+        roll_hitdice(creature_ptr, 0L);
+    }
+}
+
+void set_zangband_spells(player_type *creature_ptr)
+{
+    creature_ptr->learned_spells = 0;
+    for (int i = 0; i < 64; i++)
+        if ((i < 32) ? (creature_ptr->spell_learned1 & (1L << i)) : (creature_ptr->spell_learned2 & (1L << (i - 32))))
+            creature_ptr->learned_spells++;
+}
index a58bacc..c2b2c05 100644 (file)
@@ -21,3 +21,4 @@ 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);
+void set_zangband_class(player_type *creature_ptr);
index ec78c57..a09ec1d 100644 (file)
@@ -439,26 +439,7 @@ static errr exe_reading_savefile(player_type *creature_ptr)
     cp_ptr = &class_info[creature_ptr->pclass];
     ap_ptr = &personality_info[creature_ptr->pseikaku];
 
-    if (z_older_than(10, 2, 2) && (creature_ptr->pclass == CLASS_BEASTMASTER) && !creature_ptr->is_dead) {
-        creature_ptr->hitdie = rp_ptr->r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
-        roll_hitdice(creature_ptr, 0L);
-    }
-
-    if (z_older_than(10, 3, 2) && (creature_ptr->pclass == CLASS_ARCHER) && !creature_ptr->is_dead) {
-        creature_ptr->hitdie = rp_ptr->r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
-        roll_hitdice(creature_ptr, 0L);
-    }
-
-    if (z_older_than(10, 2, 6) && (creature_ptr->pclass == CLASS_SORCERER) && !creature_ptr->is_dead) {
-        creature_ptr->hitdie = rp_ptr->r_mhp / 2 + cp_ptr->c_mhp + ap_ptr->a_mhp;
-        roll_hitdice(creature_ptr, 0L);
-    }
-
-    if (z_older_than(10, 4, 7) && (creature_ptr->pclass == CLASS_BLUE_MAGE) && !creature_ptr->is_dead) {
-        creature_ptr->hitdie = rp_ptr->r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
-        roll_hitdice(creature_ptr, 0L);
-    }
-
+    set_zangband_class(creature_ptr);
     mp_ptr = &m_info[creature_ptr->pclass];
 
     rd_u32b(&creature_ptr->spell_learned1);
@@ -468,19 +449,14 @@ static errr exe_reading_savefile(player_type *creature_ptr)
     rd_u32b(&creature_ptr->spell_forgotten1);
     rd_u32b(&creature_ptr->spell_forgotten2);
 
-    if (z_older_than(10, 0, 5)) {
-        creature_ptr->learned_spells = 0;
-        for (int i = 0; i < 64; i++) {
-            if ((i < 32) ? (creature_ptr->spell_learned1 & (1L << i)) : (creature_ptr->spell_learned2 & (1L << (i - 32)))) {
-                creature_ptr->learned_spells++;
-            }
-        }
-    } else
+    if (z_older_than(10, 0, 5))
+        set_zangband_spells(creature_ptr);
+    else
         rd_s16b(&creature_ptr->learned_spells);
 
-    if (z_older_than(10, 0, 6)) {
+    if (z_older_than(10, 0, 6))
         creature_ptr->add_spells = 0;
-    else
+    else
         rd_s16b(&creature_ptr->add_spells);
 
     if (creature_ptr->pclass == CLASS_MINDCRAFTER)