OSDN Git Service

[Refactor] #37353 汎用的なポインタ命名 c_ptr を g_ptr に改名。 / Rename c_ptr, common pointer naming...
[hengband/hengband.git] / src / save.c
index d50c841..d7b1e86 100644 (file)
@@ -12,6 +12,9 @@
  */
 
 #include "angband.h"
+#include "sort.h"
+#include "quest.h"
+#include "store.h"
 
 
 
@@ -101,7 +104,7 @@ static void wr_s32b(s32b v)
  * @param str 書き込む文字列
  * @return なし
  */
-static void wr_string(cptr str)
+static void wr_string(concptr str)
 {
        while (*str)
        {
@@ -259,7 +262,7 @@ static void wr_monster(monster_type *m_ptr)
        if (flags & SAVE_MON_SUB_ALIGN) wr_byte(m_ptr->sub_align);
        if (flags & SAVE_MON_CSLEEP) wr_s16b(m_ptr->mtimed[MTIMED_CSLEEP]);
 
-       wr_byte(m_ptr->mspeed);
+       wr_byte((byte)m_ptr->mspeed);
        wr_s16b(m_ptr->energy_need);
 
        if (flags & SAVE_MON_FAST)
@@ -568,8 +571,8 @@ static void save_quick_start(void)
        wr_s16b(previous_char.sc);
        wr_s32b(previous_char.au);
 
-       for (i = 0; i < 6; i++) wr_s16b(previous_char.stat_max[i]);
-       for (i = 0; i < 6; i++) wr_s16b(previous_char.stat_max_max[i]);
+       for (i = 0; i < A_MAX; i++) wr_s16b(previous_char.stat_max[i]);
+       for (i = 0; i < A_MAX; i++) wr_s16b(previous_char.stat_max_max[i]);
 
        for (i = 0; i < PY_MAX_LEVEL; i++) wr_s16b((s16b)previous_char.player_hp[i]);
 
@@ -599,9 +602,7 @@ static void wr_extra(void)
        byte tmp8u;
 
        wr_string(p_ptr->name);
-
        wr_string(p_ptr->died_from);
-
        wr_string(p_ptr->last_message ? p_ptr->last_message : "");
 
        save_quick_start();
@@ -628,9 +629,9 @@ static void wr_extra(void)
        wr_s16b(p_ptr->wt);
 
        /* Dump the stats (maximum and current) */
-       for (i = 0; i < 6; ++i) wr_s16b(p_ptr->stat_max[i]);
-       for (i = 0; i < 6; ++i) wr_s16b(p_ptr->stat_max_max[i]);
-       for (i = 0; i < 6; ++i) wr_s16b(p_ptr->stat_cur[i]);
+       for (i = 0; i < A_MAX; ++i) wr_s16b(p_ptr->stat_max[i]);
+       for (i = 0; i < A_MAX; ++i) wr_s16b(p_ptr->stat_max_max[i]);
+       for (i = 0; i < A_MAX; ++i) wr_s16b(p_ptr->stat_cur[i]);
 
        /* Ignore the transient stats */
        for (i = 0; i < 12; ++i) wr_s16b(0);
@@ -649,7 +650,7 @@ static void wr_extra(void)
        for (i = 0; i < 108; i++) wr_s32b(p_ptr->magic_num1[i]);
        for (i = 0; i < 108; i++) wr_byte(p_ptr->magic_num2[i]);
 
-       wr_byte(p_ptr->start_race);
+       wr_byte((byte_hack)p_ptr->start_race);
        wr_s32b(p_ptr->old_race1);
        wr_s32b(p_ptr->old_race2);
        wr_s16b(p_ptr->old_realm);
@@ -850,8 +851,8 @@ static void wr_extra(void)
 
 
 /*!
- * @brief フロア保存時のcave情報テンプレートをソートするための比較処理
- * @param u caveテンプレートの参照ポインタ
+ * @brief フロア保存時のgrid_array情報テンプレートをソートするための比較処理
+ * @param u grid_arrayテンプレートの参照ポインタ
  * @param v 未使用
  * @param a スワップするモンスター種族のID1
  * @param b スワップするモンスター種族のID2
@@ -872,8 +873,8 @@ static bool ang_sort_comp_cave_temp(vptr u, vptr v, int a, int b)
 
 
 /*!
- * @brief フロア保存時のcave情報テンプレートをソートするためのスワップ処理 / Sorting hook -- Swap function
- * @param u caveテンプレートの参照ポインタ
+ * @brief フロア保存時のgrid_array情報テンプレートをソートするためのスワップ処理 / Sorting hook -- Swap function
+ * @param u grid_arrayテンプレートの参照ポインタ
  * @param v 未使用
  * @param a スワップするモンスター種族のID1
  * @param b スワップするモンスター種族のID2
@@ -948,7 +949,7 @@ static void wr_saved_floor(saved_floor_type *sf_ptr)
 
 
 
-       /*********** Make template for cave_type **********/
+       /*********** Make template for grid_type **********/
 
        /*
         * Usually number of templates are fewer than 255.  Even if
@@ -972,14 +973,14 @@ static void wr_saved_floor(saved_floor_type *sf_ptr)
        {
                for (x = 0; x < cur_wid; x++)
                {
-                       cave_type *c_ptr = &cave[y][x];
+                       grid_type *g_ptr = &grid_array[y][x];
 
                        for (i = 0; i < num_temp; i++)
                        {
-                               if (templates[i].info == c_ptr->info &&
-                                   templates[i].feat == c_ptr->feat &&
-                                   templates[i].mimic == c_ptr->mimic &&
-                                   templates[i].special == c_ptr->special)
+                               if (templates[i].info == g_ptr->info &&
+                                   templates[i].feat == g_ptr->feat &&
+                                   templates[i].mimic == g_ptr->mimic &&
+                                   templates[i].special == g_ptr->special)
                                {
                                        /* Same terrain is exist */
                                        templates[i].occurrence++;
@@ -1003,10 +1004,10 @@ static void wr_saved_floor(saved_floor_type *sf_ptr)
                        }
 
                        /* Add new template */
-                       templates[num_temp].info = c_ptr->info;
-                       templates[num_temp].feat = c_ptr->feat;
-                       templates[num_temp].mimic = c_ptr->mimic;
-                       templates[num_temp].special = c_ptr->special;
+                       templates[num_temp].info = g_ptr->info;
+                       templates[num_temp].feat = g_ptr->feat;
+                       templates[num_temp].mimic = g_ptr->mimic;
+                       templates[num_temp].special = g_ptr->special;
                        templates[num_temp].occurrence = 1;
 
                        /* Increase number of template */
@@ -1041,25 +1042,25 @@ static void wr_saved_floor(saved_floor_type *sf_ptr)
 
 
 
-       /*** "Run-Length-Encoding" of cave ***/
+       /*** "Run-Length-Encoding" of grid_array ***/
 
        /* Note that this will induce two wasted bytes */
        count = 0;
        prev_u16b = 0;
 
-       /* Dump the cave */
+       /* Dump the grid_array */
        for (y = 0; y < cur_hgt; y++)
        {
                for (x = 0; x < cur_wid; x++)
                {
-                       cave_type *c_ptr = &cave[y][x];
+                       grid_type *g_ptr = &grid_array[y][x];
 
                        for (i = 0; i < num_temp; i++)
                        {
-                               if (templates[i].info == c_ptr->info &&
-                                   templates[i].feat == c_ptr->feat &&
-                                   templates[i].mimic == c_ptr->mimic &&
-                                   templates[i].special == c_ptr->special)
+                               if (templates[i].info == g_ptr->info &&
+                                   templates[i].feat == g_ptr->feat &&
+                                   templates[i].mimic == g_ptr->mimic &&
+                                   templates[i].special == g_ptr->special)
                                        break;
                        }
 
@@ -1151,27 +1152,21 @@ static bool wr_dungeon(void)
        saved_floor_type *cur_sf_ptr;
        int i;
 
-       /* Forget the lite */
        forget_lite();
-
-       /* Forget the view */
        forget_view();
-
-       /* Forget the view */
        clear_mon_lite();
 
        /* Update lite/view */
        p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
        p_ptr->update |= (PU_MONSTERS | PU_DISTANCE | PU_FLOW);
 
-
        /*** Meta info ***/
 
        /* Number of floor_id used from birth */
        wr_s16b(max_floor_id);
 
        /* Current dungeon type */
-       wr_byte((byte_hack)dungeon_type);
+       wr_byte((byte_hack)p_ptr->dungeon_idx);
 
 
        /*** No saved floor (On the surface etc.) ***/
@@ -1501,7 +1496,7 @@ static bool wr_savefile_new(void)
        {
                for (j = 0; j < MAX_STORES; j++)
                {
-                       wr_store(&town[i].store[j]);
+                       wr_store(&town_info[i].store[j]);
                }
        }
 
@@ -1772,7 +1767,7 @@ bool load_player(void)
        struct stat     statbuf;
 #endif
 
-       cptr    what = "generic";
+       concptr    what = "generic";
 
 
        /* Paranoia */