1 #include "load/load-util.h"
2 #include "locale/japanese.h"
3 #include "term/screen-processor.h"
5 FILE *loading_savefile;
6 uint32_t loading_savefile_version;
7 byte load_xor_byte; // Old "encryption" byte.
8 uint32_t v_check = 0L; // Simple "checksum" on the actual values.
9 uint32_t x_check = 0L; // Simple "checksum" on the encoded bytes.
21 * @brief ゲームスクリーンにメッセージを表示する / Hack -- Show information on the screen, one line at a time.
24 * Avoid the top two lines, to avoid interference with "msg_print()".
26 void load_note(concptr msg)
28 static TERM_LEN y = 2;
38 * @brief ロードファイルポインタから1バイトを読み込む
41 * The following functions are used to load the basic building blocks
42 * of savefiles. They also maintain the "checksum" info for 2.7.0+
46 byte c = getc(loading_savefile) & 0xFF;
47 byte v = c ^ load_xor_byte;
51 x_check += load_xor_byte;
56 * @brief ロードファイルポインタから1バイトを読み込む
64 * @brief ロードファイルポインタから符号なし16bit値を読み込む
68 uint16_t val = sf_get();
69 val |= (static_cast<uint16_t>(sf_get()) << 8);
75 * @brief ロードファイルポインタから符号つき16bit値を読み込む
79 return static_cast<int16_t>(rd_u16b());
83 * @brief ロードファイルポインタから符号なし32bit値を読み込む
87 uint32_t val = sf_get();
88 val |= (static_cast<uint32_t>(sf_get()) << 8);
89 val |= (static_cast<uint32_t>(sf_get()) << 16);
90 val |= (static_cast<uint32_t>(sf_get()) << 24);
96 * @brief ロードファイルポインタから符号つき32bit値を読み込む
100 return static_cast<int32_t>(rd_u32b());
104 * @brief ロードファイルポインタから文字列を読み込んでポインタに渡す / Hack -- read a string
105 * @param str 読み込みポインタ
106 * @param max 最大読み取りバイト数
108 void rd_string(char *str, int max)
110 for (int i = 0; true; i++) {
111 auto tmp8u = rd_byte();
123 switch (kanji_code) {
137 byte code = codeconv(str);
139 /* 漢字コードが判明したら、それを記録 */
153 * @brief ロードファイルポインタから文字列を読み込んで std::string オブジェクトに格納する
154 * @param str std::string オブジェクトへの参照
155 * @param max 最大読み取りバイト数
157 void rd_string(std::string &str, int max)
159 std::vector<char> buf(max);
160 rd_string(buf.data(), max);
165 * @brief ロードファイルポインタを指定バイト分飛ばして進める / Hack -- strip some bytes
168 void strip_bytes(int n)
176 * @brief ロード中のセーブファイルのバージョンが引数で指定したバージョンと比較して古いかどうか調べる
178 * @param version 比較するセーブファイルのバージョン
179 * @return bool ロード中のセーブファイルのバージョンが version より古いなら true
180 * version と等しいかより新しいなら false
182 bool loading_savefile_version_is_older_than(uint32_t version)
184 return loading_savefile_version < version;