OSDN Git Service

[Refactor] #40467 Separated set_zangband_skill() from extra-loader.c to load-zangband.c/h
authorHourier <hourier@users.sourceforge.jp>
Sun, 5 Jul 2020 03:19:16 +0000 (12:19 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sun, 5 Jul 2020 03:19:16 +0000 (12:19 +0900)
src/savedata/extra-loader.c
src/savedata/load-zangband.c
src/savedata/load-zangband.h

index 4ed0076..6db3f2a 100644 (file)
@@ -122,24 +122,16 @@ void rd_extra(player_type *creature_ptr)
         for (int i = 0; i < 64; i++)
             creature_ptr->spell_exp[i] = SPELL_EXP_MASTER;
 
-    if (z_older_than(10, 3, 6))
-        for (int i = 0; i < 5; i++)
-            for (int j = 0; j < 60; j++)
-                rd_s16b(&creature_ptr->weapon_exp[i][j]);
-    else
-        for (int i = 0; i < 5; i++)
-            for (int j = 0; j < 64; j++)
-                rd_s16b(&creature_ptr->weapon_exp[i][j]);
+    const int max_weapon_exp_size = z_older_than(10, 3, 6) ? 60 : 64;
+    for (int i = 0; i < 5; i++)
+        for (int j = 0; j < max_weapon_exp_size; j++)
+            rd_s16b(&creature_ptr->weapon_exp[i][j]);
 
     for (int i = 0; i < GINOU_MAX; i++)
         rd_s16b(&creature_ptr->skill_exp[i]);
 
-    if (z_older_than(10, 4, 1)) {
-        if (creature_ptr->pclass != CLASS_BEASTMASTER)
-            creature_ptr->skill_exp[GINOU_RIDING] /= 2;
-
-        creature_ptr->skill_exp[GINOU_RIDING] = MIN(creature_ptr->skill_exp[GINOU_RIDING], s_info[creature_ptr->pclass].s_max[GINOU_RIDING]);
-    }
+    if (z_older_than(10, 4, 1))
+        set_zangband_skill(creature_ptr);
 
     if (z_older_than(10, 3, 14)) {
         for (int i = 0; i < 108; i++)
index 97fc453..a0a5911 100644 (file)
@@ -1,5 +1,6 @@
 #include "savedata/load-zangband.h"
 #include "game-option/option-flags.h"
+#include "player/player-skill.h"
 #include "realm/realm-types.h"
 
 void load_zangband_options(void)
@@ -64,3 +65,11 @@ void set_zangband_realm(player_type* creature_ptr)
     if (creature_ptr->realm2 == 10)
         creature_ptr->realm2 = REALM_HISSATSU;
 }
+
+void set_zangband_skill(player_type *creature_ptr)
+{
+    if (creature_ptr->pclass != CLASS_BEASTMASTER)
+        creature_ptr->skill_exp[GINOU_RIDING] /= 2;
+
+    creature_ptr->skill_exp[GINOU_RIDING] = MIN(creature_ptr->skill_exp[GINOU_RIDING], s_info[creature_ptr->pclass].s_max[GINOU_RIDING]);
+}
index 11ae27d..c4870ba 100644 (file)
@@ -3,4 +3,5 @@
 #include "system/angband.h"
 
 void load_zangband_options(void);
-void set_zangband_realm(player_type *player_ptr);
+void set_zangband_realm(player_type *creature_ptr);
+void set_zangband_skill(player_type *creature_ptr);