OSDN Git Service

#37287 #37353 (2.2.0.89) 新しい型定義を全大文字化。 / New typedef change to full-large letter.
[hengband/hengband.git] / src / load.c
index 5b950a0..bd06158 100644 (file)
@@ -137,7 +137,7 @@ static bool z_older_than(byte x, byte y, byte z)
 
 /*!
  * @brief ゲームスクリーンにメッセージを表示する / Hack -- Show information on the screen, one line at a time.
- * @param cptr 表示文字列
+ * @param msg 表示文字列
  * @return なし
  * @details
  * Avoid the top two lines, to avoid interference with "msg_print()".
@@ -157,11 +157,13 @@ static void note(cptr msg)
 }
 
 
-/*
+/*!
+ * @brief ロードファイルポインタから1バイトを読み込む
+ * @return 読み込んだバイト値
+ * @details
  * The following functions are used to load the basic building blocks
  * of savefiles.  They also maintain the "checksum" info for 2.7.0+
  */
-
 static byte sf_get(void)
 {
        byte c, v;
@@ -179,22 +181,42 @@ static byte sf_get(void)
        return (v);
 }
 
+/*!
+ * @brief ロードファイルポインタから1バイトを読み込んでポインタに渡す
+ * @param ip 読み込みポインタ
+ * @return なし
+ */
 static void rd_byte(byte *ip)
 {
        *ip = sf_get();
 }
 
+/*!
+ * @brief ロードファイルポインタから符号なし16bit値を読み込んでポインタに渡す
+ * @param ip 読み込みポインタ
+ * @return なし
+ */
 static void rd_u16b(u16b *ip)
 {
        (*ip) = sf_get();
        (*ip) |= ((u16b)(sf_get()) << 8);
 }
 
+/*!
+ * @brief ロードファイルポインタから符号つき16bit値を読み込んでポインタに渡す
+ * @param ip 読み込みポインタ
+ * @return なし
+ */
 static void rd_s16b(s16b *ip)
 {
        rd_u16b((u16b*)ip);
 }
 
+/*!
+ * @brief ロードファイルポインタから符号なし32bit値を読み込んでポインタに渡す
+ * @param ip 読み込みポインタ
+ * @return なし
+ */
 static void rd_u32b(u32b *ip)
 {
        (*ip) = sf_get();
@@ -203,14 +225,22 @@ static void rd_u32b(u32b *ip)
        (*ip) |= ((u32b)(sf_get()) << 24);
 }
 
+/*!
+ * @brief ロードファイルポインタから符号つき32bit値を読み込んでポインタに渡す
+ * @param ip 読み込みポインタ
+ * @return なし
+ */
 static void rd_s32b(s32b *ip)
 {
        rd_u32b((u32b*)ip);
 }
 
 
-/*
- * Hack -- read a string
+/*!
+ * @brief ロードファイルポインタから文字列を読み込んでポインタに渡す / Hack -- read a string
+ * @param str 読み込みポインタ
+ * @param max 最大読み取りバイト数
+ * @return なし
  */
 static void rd_string(char *str, int max)
 {
@@ -271,8 +301,10 @@ static void rd_string(char *str, int max)
 }
 
 
-/*
- * Hack -- strip some bytes
+/*!
+ * @brief ロードファイルポインタを指定バイト分飛ばして進める / Hack -- strip some bytes
+ * @param n スキップバイト数
+ * @return なし
  */
 static void strip_bytes(int n)
 {
@@ -284,9 +316,11 @@ static void strip_bytes(int n)
 
 #define OLD_MAX_MANE 22
 
-/*
- * Read an object (Old method)
- *
+/*!
+ * @brief アイテムオブジェクト1件を読み込む(変愚ver1.5.0以前) / Read an object (Old method)
+ * @param o_ptr アイテムオブジェクト読み取り先ポインタ
+ * @return なし
+ * @details
  * This function attempts to "repair" old savefiles, and to extract
  * the most up to date values for various object fields.
  *
@@ -549,8 +583,10 @@ static void rd_item_old(object_type *o_ptr)
 }
 
 
-/*
- * Read an object (New method)
+/*!
+ * @brief アイテムオブジェクトを読み込む(現版) / Read an object (New method)
+ * @param o_ptr アイテムオブジェクト保存先ポインタ
+ * @return なし
  */
 static void rd_item(object_type *o_ptr)
 {
@@ -729,8 +765,10 @@ static void rd_item(object_type *o_ptr)
 }
 
 
-/*
- * Read a monster (Old method)
+/*!
+ * @brief モンスターを読み込む(変愚ver1.5.0以前) / Read a monster (Old method)
+ * @param m_ptr モンスター保存先ポインタ
+ * @return なし
  */
 static void rd_monster_old(monster_type *m_ptr)
 {
@@ -871,8 +909,10 @@ static void rd_monster_old(monster_type *m_ptr)
 }
 
 
-/*
- * Read a monster (New method)
+/*!
+ * @brief モンスターを読み込む(現版) / Read a monster (New method)
+ * @param m_ptr モンスター保存先ポインタ
+ * @return なし
  */
 static void rd_monster(monster_type *m_ptr)
 {
@@ -1032,8 +1072,11 @@ static void rd_monster(monster_type *m_ptr)
 #define RF4_BR_GRAV         0x00800000  /* Breathe Gravity */
 #define RF4_BR_SHAR         0x01000000  /* Breathe Shards */
 #define RF4_BR_WALL         0x04000000  /* Breathe Force */
-/*
- * Read the monster lore
+
+/*!
+ * @brief モンスターの思い出を読み込む / Read the monster lore
+ * @param r_idx 読み込み先モンスターID
+ * @return なし
  */
 static void rd_lore(int r_idx)
 {
@@ -1139,17 +1182,17 @@ static void rd_lore(int r_idx)
        r_ptr->r_flags2 &= r_ptr->flags2;
        r_ptr->r_flags3 &= r_ptr->flags3;
        r_ptr->r_flags4 &= r_ptr->flags4;
-       r_ptr->r_flags5 &= r_ptr->flags5;
-       r_ptr->r_flags6 &= r_ptr->flags6;
+       r_ptr->r_flags5 &= r_ptr->a_ability_flags1;
+       r_ptr->r_flags6 &= r_ptr->a_ability_flags2;
        r_ptr->r_flagsr &= r_ptr->flagsr;
 }
 
-
-
-
-/*
- * Add the item "o_ptr" to the inventory of the "Home"
- *
+/*!
+ * @brief 店置きのアイテムオブジェクトを読み込む / Add the item "o_ptr" to the inventory of the "Home"
+ * @param st_ptr 店舗の参照ポインタ
+ * @param o_ptr アイテムオブジェクト参照ポインタ
+ * @return なし
+ * @details
  * In all cases, return the slot (or -1) where the object was placed
  *
  * Note that this is a hacked up version of "inven_carry()".
@@ -1214,9 +1257,11 @@ static void home_carry(store_type *st_ptr, object_type *o_ptr)
        return;
 }
 
-
-/*
- * Read a store
+/*!
+ * @brief 店舗情報を読み込む / Read a store
+ * @param town_number 街ID 
+ * @param store_number 店舗ID
+ * @return エラーID
  */
 static errr rd_store(int town_number, int store_number)
 {
@@ -1300,9 +1345,9 @@ static errr rd_store(int town_number, int store_number)
 }
 
 
-
-/*
- * Read RNG state (added in 2.8.0)
+/*!
+ * @brief 乱数状態を読み込む / Read RNG state (added in 2.8.0)
+ * @return なし
  */
 static void rd_randomizer(void)
 {
@@ -1325,9 +1370,10 @@ static void rd_randomizer(void)
 
 
 
-/*
- * Read options (ignore most pre-2.8.0 options)
- *
+/*!
+ * @brief ゲームオプションを読み込む / Read options (ignore most pre-2.8.0 options)
+ * @return なし
+ * @details
  * Note that the normal options are now stored as a set of 256 bit flags,
  * plus a set of 256 bit masks to indicate which bit flags were defined
  * at the time the savefile was created.  This will allow new options
@@ -1390,6 +1436,8 @@ static void rd_options(void)
        cheat_know = (c & 0x1000) ? TRUE : FALSE;
        cheat_live = (c & 0x2000) ? TRUE : FALSE;
        cheat_save = (c & 0x4000) ? TRUE : FALSE;
+       cheat_diary_output = (c & 0x8000) ? TRUE : FALSE;
+       cheat_turn = (c & 0x0080) ? TRUE : FALSE;
 
        rd_byte((byte *)&autosave_l);
        rd_byte((byte *)&autosave_t);
@@ -1501,11 +1549,10 @@ static void rd_options(void)
 
 
 
-
-
-/*
- * Hack -- strip the "ghost" info
- *
+/*!
+ * @brief ダミー情報スキップ / Hack -- strip the "ghost" info
+ * @return なし
+ * @details
  * XXX XXX XXX This is such a nasty hack it hurts.
  */
 static void rd_ghost(void)
@@ -1520,8 +1567,9 @@ static void rd_ghost(void)
 }
 
 
-/*
- * Save quick start data
+/*!
+ * @brief クイックスタート情報を読み込む / Load quick start data
+ * @return なし
  */
 static void load_quick_start(void)
 {
@@ -1565,8 +1613,9 @@ static void load_quick_start(void)
        previous_char.quick_ok = (bool)tmp8u;
 }
 
-/*
- * Read the "extra" information
+/*!
+ * @brief その他の情報を読み込む / Read the "extra" information
+ * @return なし
  */
 static void rd_extra(void)
 {
@@ -1576,7 +1625,7 @@ static void rd_extra(void)
        s16b tmp16s;
        u16b tmp16u;
 
-       rd_string(player_name, sizeof(player_name));
+       rd_string(p_ptr->name, sizeof(p_ptr->name));
 
        rd_string(p_ptr->died_from, sizeof(p_ptr->died_from));
 
@@ -1657,7 +1706,7 @@ static void rd_extra(void)
                for (i = 0; i < 5; i++) for (j = 0; j < 60; j++) rd_s16b(&p_ptr->weapon_exp[i][j]);
        else
                for (i = 0; i < 5; i++) for (j = 0; j < 64; j++) rd_s16b(&p_ptr->weapon_exp[i][j]);
-       for (i = 0; i < 10; i++) rd_s16b(&p_ptr->skill_exp[i]);
+       for (i = 0; i < GINOU_MAX; i++) rd_s16b(&p_ptr->skill_exp[i]);
        if (z_older_than(10, 4, 1))
        {
                if (p_ptr->pclass != CLASS_BEASTMASTER) p_ptr->skill_exp[GINOU_RIDING] /= 2;
@@ -1702,7 +1751,7 @@ static void rd_extra(void)
 
        if (z_older_than(10, 0, 1))
        {
-               for (i = 0; i < OLD_MAX_MANE; i++)
+               for (i = 0; i < MAX_MANE; i++)
                {
                        p_ptr->mane_spell[i] = -1;
                        p_ptr->mane_dam[i] = 0;
@@ -2212,11 +2261,10 @@ static void rd_extra(void)
 }
 
 
-
-
-/*
- * Read the player inventory
- *
+/*!
+ * @brief プレイヤーの所持品情報を読み込む / Read the player inventory
+ * @return なし
+ * @details
  * Note that the inventory changed in Angband 2.7.4.  Two extra
  * pack slots were added and the equipment was rearranged.  Note
  * that these two features combine when parsing old save-files, in
@@ -2313,29 +2361,49 @@ static errr rd_inventory(void)
 }
 
 
-
-/*
- * Read the saved messages
+/*!
+ * @brief メッセージログを読み込む / Read the saved messages
+ * @return なし
  */
 static void rd_messages(void)
 {
        int i;
        char buf[128];
 
-       s16b num;
 
-       /* Total */
-       rd_s16b(&num);
+       if (h_older_than(2, 2, 0, 75))
+       {
+               u16b num;
+               /* Total */
+               rd_u16b(&num);
 
-       /* Read the messages */
-       for (i = 0; i < num; i++)
+               /* Read the messages */
+               for (i = 0; i < num; i++)
+               {
+                       /* Read the message */
+                       rd_string(buf, sizeof(buf));
+
+                       /* Save the message */
+                       message_add(buf);
+               }
+       }
+       else
        {
-               /* Read the message */
-               rd_string(buf, sizeof(buf));
+               u32b num;
+               /* Total */
+               rd_u32b(&num);
+
+               /* Read the messages */
+               for (i = 0; i < num; i++)
+               {
+                       /* Read the message */
+                       rd_string(buf, sizeof(buf));
 
-               /* Save the message */
-               message_add(buf);
+                       /* Save the message */
+                       message_add(buf);
+               }
        }
+
 }
 
 
@@ -2359,9 +2427,10 @@ static void rd_messages(void)
 #define QUEST_OLD_CASTLE  27
 #define QUEST_ROYAL_CRYPT 28
 
-/*
- * Read the dungeon (old method)
- *
+/*!
+ * @brief メッセージログを読み込む / Read the dungeon (old method)
+ * @return なし
+ * @details
  * The monsters/objects must be loaded in the same order
  * that they were stored, since the actual indexes matter.
  */
@@ -2390,17 +2459,17 @@ static errr rd_dungeon_old(void)
 
        rd_s16b(&num_repro);
        rd_s16b(&tmp16s);
-       py = (int)tmp16s;
+       p_ptr->y = (int)tmp16s;
        rd_s16b(&tmp16s);
-       px = (int)tmp16s;
-       if (z_older_than(10, 3, 13) && !dun_level && !p_ptr->inside_arena) {py = 33;px = 131;}
+       p_ptr->x = (int)tmp16s;
+       if (z_older_than(10, 3, 13) && !dun_level && !p_ptr->inside_arena) {p_ptr->y = 33;p_ptr->x = 131;}
        rd_s16b(&cur_hgt);
        rd_s16b(&cur_wid);
        rd_s16b(&tmp16s); /* max_panel_rows */
        rd_s16b(&tmp16s); /* max_panel_cols */
 
 #if 0
-       if (!py || !px) {py = 10;px = 10;}/* ダンジョン生成に失敗してセグメンテったときの復旧用 */
+       if (!p_ptr->y || !p_ptr->x) {p_ptr->y = 10;p_ptr->x = 10;}/* ダンジョン生成に失敗してセグメンテったときの復旧用 */
 #endif
 
        /* Maximal size */
@@ -2658,7 +2727,7 @@ static errr rd_dungeon_old(void)
        /* Read the dungeon items */
        for (i = 1; i < limit; i++)
        {
-               int o_idx;
+               IDX o_idx;
 
                object_type *o_ptr;
 
@@ -2772,10 +2841,10 @@ static errr rd_dungeon_old(void)
 }
 
 
-
-/*
- * Read the saved floor
- *
+/*!
+ * @brief 保存されたフロアを読み込む / Read the saved floor
+ * @return なし
+ * @details
  * The monsters/objects must be loaded in the same order
  * that they were stored, since the actual indexes matter.
  */
@@ -2840,10 +2909,10 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr)
        rd_s16b(&num_repro);
 
        rd_u16b(&tmp16u);
-       py = (int)tmp16u;
+       p_ptr->y = (int)tmp16u;
 
        rd_u16b(&tmp16u);
-       px = (int)tmp16u;
+       p_ptr->x = (int)tmp16u;
 
        rd_s16b(&cur_hgt);
        rd_s16b(&cur_wid);
@@ -3064,9 +3133,10 @@ static errr rd_saved_floor(saved_floor_type *sf_ptr)
 }
 
 
-/*
- * Read the dungeon (new method)
- *
+/*!
+ * @brief 保存されたフロアを読み込む(現版) / Read the dungeon (new method)
+ * @return なし
+ * @details
  * The monsters/objects must be loaded in the same order
  * that they were stored, since the actual indexes matter.
  */
@@ -3207,8 +3277,9 @@ static errr rd_dungeon(void)
 }
 
 
-/*
- * Actually read the savefile
+/*!
+ * @brief ロード処理全体のサブ関数 / Actually read the savefile
+ * @return エラーコード
  */
 static errr rd_savefile_new_aux(void)
 {
@@ -3228,12 +3299,6 @@ static errr rd_savefile_new_aux(void)
 #endif
 
 
-       /* Mention the savefile version */
-       note(format(
-                    _("バージョン %d.%d.%d のセーブ・ファイルをロード中...", "Loading a %d.%d.%d savefile..."),
-                    (z_major > 9) ? z_major - 10 : z_major, z_minor, z_patch));
-
-
        /* Strip the version bytes */
        strip_bytes(4);
 
@@ -3252,6 +3317,12 @@ static errr rd_savefile_new_aux(void)
        rd_byte(&h_ver_minor);
        rd_byte(&h_ver_major);
 
+       /* Mention the savefile version */
+       note(format(
+               _("バージョン %d.%d.%d.%d のセーブ・ファイルをロード中...", "Loading a %d.%d.%d.%d savefile..."),
+               (h_ver_major > 9) ? h_ver_major - 10 : h_ver_major, h_ver_minor, h_ver_patch, h_ver_extra));
+
+
        /* Operating system info */
        rd_u32b(&sf_system);
 
@@ -3335,7 +3406,6 @@ static errr rd_savefile_new_aux(void)
        /* Read the object memory */
        for (i = 0; i < tmp16u; i++)
        {
-               byte tmp8u;
                object_kind *k_ptr = &k_info[i];
 
                rd_byte(&tmp8u);
@@ -3792,9 +3862,9 @@ static errr rd_savefile_new_aux(void)
        return (0);
 }
 
-
-/*
- * Actually read the savefile
+/*!
+ * @brief ロード処理全体のメイン関数 / Actually read the savefile
+ * @return エラーコード
  */
 errr rd_savefile_new(void)
 {
@@ -3826,8 +3896,10 @@ errr rd_savefile_new(void)
 }
 
 
-/*
- * Actually load and verify a floor save data
+/*!
+ * @brief 保存フロア読み込みのサブ関数 / Actually load and verify a floor save data
+ * @param sf_ptr 保存フロア読み込み先
+ * @return 成功したらtrue
  */
 static bool load_floor_aux(saved_floor_type *sf_ptr)
 {
@@ -3887,8 +3959,11 @@ static bool load_floor_aux(saved_floor_type *sf_ptr)
 }
 
 
-/*
- * Attempt to load the temporally saved-floor data
+/*!
+ * @brief 一時保存フロア情報を読み込む / Attempt to load the temporally saved-floor data
+ * @param sf_ptr 保存フロア読み込み先
+ * @param mode オプション
+ * @return 成功したらtrue
  */
 bool load_floor(saved_floor_type *sf_ptr, u32b mode)
 {