#include "load/angband-version-comparer.h"
#include "load/load-util.h"
#include "load/option-loader.h"
-#include "system/angband.h"
#include "system/angband-version.h"
+#include "system/angband.h"
#include "view/display-messages.h"
#include "world/world.h"
*/
void rd_version_info(void)
{
- byte fake_major;
- rd_byte(&fake_major);
+ auto tmp_major = rd_byte();
+ auto is_old_ver = (10 <= tmp_major) && (tmp_major <= 13);
+ constexpr auto variant_length = VARIANT_NAME.length();
+ if (tmp_major == variant_length) {
+ strip_bytes(variant_length);
+ load_xor_byte = 0;
+ w_ptr->h_ver_major = rd_byte();
+ w_ptr->h_ver_minor = rd_byte();
+ w_ptr->h_ver_patch = rd_byte();
+ w_ptr->h_ver_extra = rd_byte();
+ strip_bytes(1);
+ } else if (is_old_ver) {
+ strip_bytes(3);
+ } else {
+ throw("Invalid version is detected!");
+ }
- strip_bytes(3);
load_xor_byte = w_ptr->sf_extra;
v_check = 0L;
x_check = 0L;
- /* Old savefile will be version 0.0.0.3 */
- rd_byte(&w_ptr->h_ver_extra);
- rd_byte(&w_ptr->h_ver_patch);
- rd_byte(&w_ptr->h_ver_minor);
- rd_byte(&w_ptr->h_ver_major);
+ if (is_old_ver) {
+ /* Old savefile will be version 0.0.0.3 */
+ w_ptr->h_ver_extra = rd_byte();
+ w_ptr->h_ver_patch = rd_byte();
+ w_ptr->h_ver_minor = rd_byte();
+ w_ptr->h_ver_major = rd_byte();
+ }
- rd_u32b(&w_ptr->sf_system);
- rd_u32b(&w_ptr->sf_when);
- rd_u16b(&w_ptr->sf_lives);
- rd_u16b(&w_ptr->sf_saves);
+ w_ptr->sf_system = rd_u32b();
+ w_ptr->sf_when = rd_u32b();
+ w_ptr->sf_lives = rd_u16b();
+ w_ptr->sf_saves = rd_u16b();
- rd_u32b(&loading_savefile_version);
+ loading_savefile_version = rd_u32b();
/* h_ver_majorがfake_ver_majorと同じだったころへの対策 */
- if (fake_major - w_ptr->h_ver_major < FAKE_VER_PLUS)
- w_ptr->h_ver_major -= FAKE_VER_PLUS;
+ if (loading_savefile_version_is_older_than(10)) {
+ constexpr auto fake_ver_plus = 10;
+ if (tmp_major - w_ptr->h_ver_major < fake_ver_plus) {
+ w_ptr->h_ver_major -= fake_ver_plus;
+ }
+ }
- load_note(format(_("バージョン %d.%d.%d のセーブデータ(SAVE%lu形式)をロード中...", "Loading a Verison %d.%d.%d savefile (SAVE%lu format)..."),
+ load_note(format(_("バージョン %d.%d.%d のセーブデータ(SAVE%lu形式)をロード中...", "Loading a version %d.%d.%d savefile (SAVE%lu format)..."),
w_ptr->h_ver_major, w_ptr->h_ver_minor, w_ptr->h_ver_patch,
loading_savefile_version));
}
*/
void rd_randomizer(void)
{
- uint16_t tmp16u;
- rd_u16b(&tmp16u);
- rd_u16b(&Rand_place);
- for (int i = 0; i < RAND_DEG; i++)
- rd_u32b(&Rand_state[i]);
+ strip_bytes(4);
+
+ Xoshiro128StarStar::state_type state;
+ for (auto &s : state) {
+ s = rd_u32b();
+ }
+ w_ptr->rng.set_state(state);
+
+ strip_bytes(4 * (RAND_DEG - state.size()));
}
/*!
void rd_messages(void)
{
if (h_older_than(2, 2, 0, 75)) {
- uint16_t num;
- rd_u16b(&num);
+ auto num = rd_u16b();
int message_max;
message_max = (int)num;
}
}
- uint32_t num;
- rd_u32b(&num);
+ auto num = rd_u32b();
int message_max = (int)num;
for (int i = 0; i < message_max; i++) {
char buf[128];
void rd_system_info(void)
{
- rd_byte(&kanji_code);
+ kanji_code = rd_byte();
rd_randomizer();
load_note(_("乱数情報をロードしました", "Loaded Randomizer Info"));
rd_options();