OSDN Git Service

Merge pull request #1780 from Hourier/Remove-Unnecessary-Return-Init-Buildings
[hengbandforosx/hengbandosx.git] / src / load / info-loader.cpp
1 #include "load/info-loader.h"
2 #include "game-option/runtime-arguments.h"
3 #include "load/angband-version-comparer.h"
4 #include "load/load-util.h"
5 #include "load/option-loader.h"
6 #include "system/angband.h"
7 #include "system/angband-version.h"
8 #include "view/display-messages.h"
9 #include "world/world.h"
10
11 /*!
12  * @brief セーブファイルからバージョン情報及びセーブ情報を取得する
13  * @details
14  * バージョン0.x.x時代のバージョン情報である場合、サポート対象外
15  * (FAKE_VERもH_VERも10台の数字のはず)
16  */
17 void rd_version_info(void)
18 {
19     byte fake_major = rd_byte();
20
21     strip_bytes(3);
22     load_xor_byte = w_ptr->sf_extra;
23     v_check = 0L;
24     x_check = 0L;
25
26     /* Old savefile will be version 0.0.0.3 */
27     w_ptr->h_ver_extra = rd_byte();
28     w_ptr->h_ver_patch = rd_byte();
29     w_ptr->h_ver_minor = rd_byte();
30     w_ptr->h_ver_major = rd_byte();
31
32     w_ptr->sf_system = rd_u32b();
33     w_ptr->sf_when = rd_u32b();
34     w_ptr->sf_lives = rd_u16b();
35     w_ptr->sf_saves = rd_u16b();
36
37     loading_savefile_version = rd_u32b();
38
39     /* h_ver_majorがfake_ver_majorと同じだったころへの対策 */
40     if (fake_major - w_ptr->h_ver_major < FAKE_VER_PLUS)
41         w_ptr->h_ver_major -= FAKE_VER_PLUS;
42
43     load_note(format(_("バージョン %d.%d.%d のセーブデータ(SAVE%lu形式)をロード中...", "Loading a Verison %d.%d.%d savefile (SAVE%lu format)..."),
44         w_ptr->h_ver_major, w_ptr->h_ver_minor, w_ptr->h_ver_patch,
45         loading_savefile_version));
46 }
47
48 /*!
49  * @brief 乱数状態を読み込む / Read RNG state (added in 2.8.0)
50  */
51 void rd_randomizer(void)
52 {
53     strip_bytes(4);
54
55     Xoshiro128StarStar::state_type state;
56     for (auto &s : state) {
57         s = rd_u32b();
58     }
59     w_ptr->rng.set_state(state);
60
61     strip_bytes(4 * (RAND_DEG - state.size()));
62 }
63
64 /*!
65  * @brief メッセージログを読み込む / Read the saved messages
66  */
67 void rd_messages(void)
68 {
69     if (h_older_than(2, 2, 0, 75)) {
70         auto num = rd_u16b();
71         int message_max;
72         message_max = (int)num;
73
74         for (int i = 0; i < message_max; i++) {
75             char buf[128];
76             rd_string(buf, sizeof(buf));
77             message_add(buf);
78         }
79     }
80
81     auto num = rd_u32b();
82     int message_max = (int)num;
83     for (int i = 0; i < message_max; i++) {
84         char buf[128];
85         rd_string(buf, sizeof(buf));
86         message_add(buf);
87     }
88 }
89
90 void rd_system_info(void)
91 {
92     kanji_code = rd_byte();
93     rd_randomizer();
94     load_note(_("乱数情報をロードしました", "Loaded Randomizer Info"));
95     rd_options();
96     load_note(_("オプションをロードしました", "Loaded Option Flags"));
97     rd_messages();
98     load_note(_("メッセージをロードしました", "Loaded Messages"));
99 }