OSDN Git Service

[Refactor] #40467 Separated rd_bounty_uniques() from extra-loader.c to player-info...
authorHourier <hourier@users.sourceforge.jp>
Sun, 5 Jul 2020 05:48:32 +0000 (14:48 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sun, 5 Jul 2020 05:48:32 +0000 (14:48 +0900)
src/savedata/extra-loader.c
src/savedata/player-info-loader.c
src/savedata/player-info-loader.h

index 2a62d2e..e03ae85 100644 (file)
@@ -181,6 +181,20 @@ static void rd_dummy_monsters(player_type *creature_ptr)
     }
 }
 
+static void set_gambling_monsters(player_type *creature_ptr)
+{
+    const int max_gambling_monsters = 4;
+    for (int i = 0; i < max_gambling_monsters; i++) {
+        rd_s16b(&battle_mon[i]);
+        if (z_older_than(10, 3, 4)) {
+            s16b tmp16s;
+            rd_s16b(&tmp16s);
+            mon_odds[i] = tmp16s;
+        } else
+            rd_u32b(&mon_odds[i]);
+    }
+}
+
 /*!
  * @brief その他の情報を読み込む / Read the "extra" information
  * @param creature_ptr プレーヤーへの参照ポインタ
@@ -195,26 +209,11 @@ void rd_extra(player_type *creature_ptr)
     rd_skills(creature_ptr);
     rd_race(creature_ptr);
     set_imitation(creature_ptr);
-    if (z_older_than(10, 0, 3))
-        set_zangband_bounty_uniques(creature_ptr);
-    else
-        for (int i = 0; i < MAX_BOUNTY; i++)
-            rd_s16b(&current_world_ptr->bounty_r_idx[i]);
-
+    rd_bounty_uniques(creature_ptr);
     if (z_older_than(10, 0, 3)) {
         update_gambling_monsters(creature_ptr);
-    } else {
-        const int max_gambling_monsters = 4;
-        for (int i = 0; i < max_gambling_monsters; i++) {
-            rd_s16b(&battle_mon[i]);
-            if (z_older_than(10, 3, 4)) {
-                s16b tmp16s;
-                rd_s16b(&tmp16s);
-                mon_odds[i] = tmp16s;
-            } else
-                rd_u32b(&mon_odds[i]);
-        }
-    }
+    } else
+        set_gambling_monsters(creature_ptr);
 
     rd_s16b(&creature_ptr->town_num);
     rd_s16b(&creature_ptr->arena_number);
index 4a51bca..27e6430 100644 (file)
@@ -6,6 +6,7 @@
 #include "savedata/load-v1-3-0.h"
 #include "savedata/load-v1-7-0.h"
 #include "savedata/load-zangband.h"
+#include "world/world.h"
 
 void rd_base_info(player_type *creature_ptr)
 {
@@ -131,4 +132,15 @@ void rd_race(player_type *creature_ptr)
     }
     
     set_race(creature_ptr);
-}
\ No newline at end of file
+}
+
+void rd_bounty_uniques(player_type *creature_ptr)
+{
+    if (z_older_than(10, 0, 3)) {
+        set_zangband_bounty_uniques(creature_ptr);
+        return;
+    }
+
+    for (int i = 0; i < MAX_BOUNTY; i++)
+        rd_s16b(&current_world_ptr->bounty_r_idx[i]);
+}
index fecde00..6f1111f 100644 (file)
@@ -6,3 +6,4 @@ void rd_base_info(player_type *creature_ptr);
 void rd_experience(player_type *creature_ptr);
 void rd_skills(player_type *creature_ptr);
 void rd_race(player_type *creature_ptr);
+void rd_bounty_uniques(player_type *creature_ptr);