OSDN Git Service

[Fix] #38997 wr_savefile_new() 内変数参照修正. / Fix variable references in wr_savefile_new().
[hengband/hengband.git] / src / save.c
index 7a362d3..18a9200 100644 (file)
@@ -677,7 +677,7 @@ static void wr_extra(player_type *creature_ptr)
        }
        wr_s16b(creature_ptr->mane_num);
 
-       for (i = 0; i < MAX_KUBI; i++)
+       for (i = 0; i < MAX_BOUNTY; i++)
        {
                wr_s16b(current_world_ptr->bounty_r_idx[i]);
        }
@@ -1108,9 +1108,10 @@ static void wr_saved_floor(saved_floor_type *sf_ptr)
 /*!
  * @brief 現在フロアの書き込み /
  * Write the current dungeon (new method)
- * @return なし
+ * @player_ptr プレーヤーへの参照ポインタ
+ * @return 保存に成功したらTRUE
  */
-static bool wr_dungeon(void)
+static bool wr_dungeon(player_type *player_ptr)
 {
        saved_floor_type *cur_sf_ptr;
        int i;
@@ -1180,7 +1181,7 @@ static bool wr_dungeon(void)
                if (!sf_ptr->floor_id) continue;
 
                /* Load temporal saved floor file */
-               if (load_floor(sf_ptr, (SLF_SECOND | SLF_NO_KILL)))
+               if (load_floor(player_ptr, sf_ptr, (SLF_SECOND | SLF_NO_KILL)))
                {
                        /* Mark success */
                        wr_byte(0);
@@ -1196,7 +1197,7 @@ static bool wr_dungeon(void)
        }
 
        /* Restore current floor */
-       if (!load_floor(cur_sf_ptr, (SLF_SECOND))) return FALSE;
+       if (!load_floor(player_ptr, cur_sf_ptr, (SLF_SECOND))) return FALSE;
 
        /* Success */
        return TRUE;
@@ -1206,9 +1207,10 @@ static bool wr_dungeon(void)
 /*!
  * @brief セーブデータの書き込み /
  * Actually write a save-file
+ * @param player_ptr プレーヤーへの参照ポインタ
  * @return 成功すればtrue
  */
-static bool wr_savefile_new(void)
+static bool wr_savefile_new(player_type *player_ptr)
 {
        int        i, j;
 
@@ -1222,7 +1224,7 @@ static bool wr_savefile_new(void)
        KIND_OBJECT_IDX k_idx;
 
        /* Compact the objects */
-       compact_objects(p_ptr->current_floor_ptr, 0);
+       compact_objects(player_ptr->current_floor_ptr, 0);
        /* Compact the monsters */
        compact_monsters(0);
 
@@ -1368,11 +1370,11 @@ static bool wr_savefile_new(void)
        }
 
        /* Dump the position in the wilderness */
-       wr_s32b(p_ptr->wilderness_x);
-       wr_s32b(p_ptr->wilderness_y);
+       wr_s32b(player_ptr->wilderness_x);
+       wr_s32b(player_ptr->wilderness_y);
 
-       wr_byte(p_ptr->wild_mode);
-       wr_byte(p_ptr->ambush_flag);
+       wr_byte(player_ptr->wild_mode);
+       wr_byte(player_ptr->ambush_flag);
 
        wr_s32b(current_world_ptr->max_wild_x);
        wr_s32b(current_world_ptr->max_wild_y);
@@ -1399,37 +1401,37 @@ static bool wr_savefile_new(void)
 
 
        /* Write the "extra" information */
-       wr_extra(p_ptr);
+       wr_extra(player_ptr);
 
        /* Dump the "player hp" entries */
        tmp16u = PY_MAX_LEVEL;
        wr_u16b(tmp16u);
        for (i = 0; i < tmp16u; i++)
        {
-               wr_s16b((s16b)p_ptr->player_hp[i]);
+               wr_s16b((s16b)player_ptr->player_hp[i]);
        }
 
 
        /* Write spell data */
-       wr_u32b(p_ptr->spell_learned1);
-       wr_u32b(p_ptr->spell_learned2);
-       wr_u32b(p_ptr->spell_worked1);
-       wr_u32b(p_ptr->spell_worked2);
-       wr_u32b(p_ptr->spell_forgotten1);
-       wr_u32b(p_ptr->spell_forgotten2);
+       wr_u32b(player_ptr->spell_learned1);
+       wr_u32b(player_ptr->spell_learned2);
+       wr_u32b(player_ptr->spell_worked1);
+       wr_u32b(player_ptr->spell_worked2);
+       wr_u32b(player_ptr->spell_forgotten1);
+       wr_u32b(player_ptr->spell_forgotten2);
 
-       wr_s16b(p_ptr->learned_spells);
-       wr_s16b(p_ptr->add_spells);
+       wr_s16b(player_ptr->learned_spells);
+       wr_s16b(player_ptr->add_spells);
 
        /* Dump the ordered spells */
        for (i = 0; i < 64; i++)
        {
-               wr_byte((byte_hack)p_ptr->spell_order[i]);
+               wr_byte((byte_hack)player_ptr->spell_order[i]);
        }
 
        for (i = 0; i < INVEN_TOTAL; i++)
        {
-               object_type *o_ptr = &p_ptr->inventory_list[i];
+               object_type *o_ptr = &player_ptr->inventory_list[i];
                if (!o_ptr->k_idx) continue;
 
                /* Dump index */
@@ -1460,11 +1462,11 @@ static bool wr_savefile_new(void)
        }
 
        /* Write the pet command settings */
-       wr_s16b(p_ptr->pet_follow_distance);
-       wr_s16b(p_ptr->pet_extra_flags);
+       wr_s16b(player_ptr->pet_follow_distance);
+       wr_s16b(player_ptr->pet_extra_flags);
 
        /* Write screen dump for sending score */
-       if (screen_dump && (p_ptr->wait_report_score || !p_ptr->is_dead))
+       if (screen_dump && (player_ptr->wait_report_score || !player_ptr->is_dead))
        {
                wr_string(screen_dump);
        }
@@ -1474,10 +1476,10 @@ static bool wr_savefile_new(void)
        }
 
        /* Player is not dead, write the dungeon */
-       if (!p_ptr->is_dead)
+       if (!player_ptr->is_dead)
        {
                /* Dump the dungeon */
-               if (!wr_dungeon()) return FALSE;
+               if (!wr_dungeon(player_ptr)) return FALSE;
 
                /* Dump the ghost */
                wr_ghost();
@@ -1505,11 +1507,12 @@ static bool wr_savefile_new(void)
 /*!
  * @brief セーブデータ書き込みのサブルーチン /
  * Medium level player saver
+ * @param player_ptr プレーヤーへの参照ポインタ
  * @return 成功すればtrue
  * @details
  * Angband 2.8.0 will use "fd" instead of "fff" if possible
  */
-static bool save_player_aux(char *name)
+static bool save_player_aux(player_type *player_ptr, char *name)
 {
        bool ok = FALSE;
        int fd = -1;
@@ -1549,7 +1552,7 @@ static bool save_player_aux(char *name)
                if (fff)
                {
                        /* Write the savefile */
-                       if (wr_savefile_new()) ok = TRUE;
+                       if (wr_savefile_new(player_ptr)) ok = TRUE;
 
                        /* Attempt to close it */
                        if (my_fclose(fff)) ok = FALSE;
@@ -1583,9 +1586,10 @@ static bool save_player_aux(char *name)
 /*!
  * @brief セーブデータ書き込みのメインルーチン /
  * Attempt to save the player in a savefile
+ * @param player_ptr プレーヤーへの参照ポインタ
  * @return 成功すればtrue
  */
-bool save_player(void)
+bool save_player(player_type *player_ptr)
 {
        bool result = FALSE;
 
@@ -1620,7 +1624,7 @@ bool save_player(void)
        update_playtime();
 
        /* Attempt to save the player */
-       if (save_player_aux(safe))
+       if (save_player_aux(player_ptr, safe))
        {
                char temp[1024];