From 4115b0f8014b90544294a290a27e003771ffec4e Mon Sep 17 00:00:00 2001 From: Hourier Date: Sat, 18 Jul 2020 16:28:56 +0900 Subject: [PATCH] [Refactor] #40532 Separated info-loader.c/h from load.c --- Hengband/Hengband/Hengband.vcxproj | 2 + Hengband/Hengband/Hengband.vcxproj.filters | 6 ++ src/Makefile.am | 1 + src/load/info-loader.c | 89 ++++++++++++++++++++++++++++++ src/load/info-loader.h | 6 ++ src/load/load.c | 84 +--------------------------- 6 files changed, 105 insertions(+), 83 deletions(-) create mode 100644 src/load/info-loader.c create mode 100644 src/load/info-loader.h diff --git a/Hengband/Hengband/Hengband.vcxproj b/Hengband/Hengband/Hengband.vcxproj index 70ae117b8..f5c0d06d2 100644 --- a/Hengband/Hengband/Hengband.vcxproj +++ b/Hengband/Hengband/Hengband.vcxproj @@ -249,6 +249,7 @@ + @@ -772,6 +773,7 @@ + diff --git a/Hengband/Hengband/Hengband.vcxproj.filters b/Hengband/Hengband/Hengband.vcxproj.filters index 252bac496..1b251fbfd 100644 --- a/Hengband/Hengband/Hengband.vcxproj.filters +++ b/Hengband/Hengband/Hengband.vcxproj.filters @@ -1802,6 +1802,9 @@ save + + load + @@ -3934,6 +3937,9 @@ save + + load + diff --git a/src/Makefile.am b/src/Makefile.am index fc481d2fc..12e2fdca4 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -309,6 +309,7 @@ hengband_SOURCES = \ load/dungeon-loader.c load/dungeon-loader.h \ load/extra-loader.c load/extra-loader.h \ load/floor-loader.c load/floor-loader.h \ + load/info-loader.c load/info-loader.h \ load/inventory-loader.c load/inventory-loader.h \ load/item-loader.c load/item-loader.h \ load/monster-loader.c load/monster-loader.h \ diff --git a/src/load/info-loader.c b/src/load/info-loader.c new file mode 100644 index 000000000..d74ddef57 --- /dev/null +++ b/src/load/info-loader.c @@ -0,0 +1,89 @@ +#include "load/info-loader.h" +#include "game-option/runtime-arguments.h" +#include "load/angband-version-comparer.h" +#include "load/load-util.h" +#include "load/option-loader.h" +#include "system/angband.h" +#include "view/display-messages.h" +#include "world/world.h" + +void rd_version_info(void) +{ + strip_bytes(4); + load_xor_byte = current_world_ptr->sf_extra; + v_check = 0L; + x_check = 0L; + + /* Old savefile will be version 0.0.0.3 */ + rd_byte(¤t_world_ptr->h_ver_extra); + rd_byte(¤t_world_ptr->h_ver_patch); + rd_byte(¤t_world_ptr->h_ver_minor); + rd_byte(¤t_world_ptr->h_ver_major); + + load_note(format(_("バージョン %d.%d.%d.%d のセーブ・ファイルをロード中...", "Loading a %d.%d.%d.%d savefile..."), + (current_world_ptr->h_ver_major > 9) ? current_world_ptr->h_ver_major - 10 : current_world_ptr->h_ver_major, current_world_ptr->h_ver_minor, + current_world_ptr->h_ver_patch, current_world_ptr->h_ver_extra)); + + rd_u32b(¤t_world_ptr->sf_system); + rd_u32b(¤t_world_ptr->sf_when); + rd_u16b(¤t_world_ptr->sf_lives); + rd_u16b(¤t_world_ptr->sf_saves); +} + +/*! + * @brief 乱数状態を読み込む / Read RNG state (added in 2.8.0) + * @return なし + */ +void rd_randomizer(void) +{ + u16b tmp16u; + rd_u16b(&tmp16u); + rd_u16b(&Rand_place); + for (int i = 0; i < RAND_DEG; i++) + rd_u32b(&Rand_state[i]); +} + +/*! + * @brief メッセージログを読み込む / Read the saved messages + * @return なし + */ +void rd_messages(void) +{ + if (h_older_than(2, 2, 0, 75)) { + u16b num; + rd_u16b(&num); + int message_max; + message_max = (int)num; + + for (int i = 0; i < message_max; i++) { + char buf[128]; + rd_string(buf, sizeof(buf)); + message_add(buf); + } + } + + u32b num; + rd_u32b(&num); + int message_max = (int)num; + for (int i = 0; i < message_max; i++) { + char buf[128]; + rd_string(buf, sizeof(buf)); + message_add(buf); + } +} + +void rd_system_info(void) +{ + rd_byte(&kanji_code); + rd_randomizer(); + if (arg_fiddle) + load_note(_("乱数情報をロードしました", "Loaded Randomizer Info")); + + rd_options(); + if (arg_fiddle) + load_note(_("オプションをロードしました", "Loaded Option Flags")); + + rd_messages(); + if (arg_fiddle) + load_note(_("メッセージをロードしました", "Loaded Messages")); +} diff --git a/src/load/info-loader.h b/src/load/info-loader.h new file mode 100644 index 000000000..16b0f1dc3 --- /dev/null +++ b/src/load/info-loader.h @@ -0,0 +1,6 @@ +#pragma once + +void rd_version_info(void); +void rd_randomizer(void); +void rd_messages(void); +void rd_system_info(void); diff --git a/src/load/load.c b/src/load/load.c index 050339c5b..79a1fbde3 100644 --- a/src/load/load.c +++ b/src/load/load.c @@ -20,6 +20,7 @@ #include "load/dummy-loader.h" #include "load/dungeon-loader.h" #include "load/extra-loader.h" +#include "load/info-loader.h" #include "load/inventory-loader.h" #include "load/item-loader.h" #include "load/load-util.h" @@ -43,89 +44,6 @@ #include "view/display-messages.h" #include "world/world.h" -static void rd_version_info(void) -{ - strip_bytes(4); - load_xor_byte = current_world_ptr->sf_extra; - v_check = 0L; - x_check = 0L; - - /* Old savefile will be version 0.0.0.3 */ - rd_byte(¤t_world_ptr->h_ver_extra); - rd_byte(¤t_world_ptr->h_ver_patch); - rd_byte(¤t_world_ptr->h_ver_minor); - rd_byte(¤t_world_ptr->h_ver_major); - - load_note(format(_("バージョン %d.%d.%d.%d のセーブ・ファイルをロード中...", "Loading a %d.%d.%d.%d savefile..."), - (current_world_ptr->h_ver_major > 9) ? current_world_ptr->h_ver_major - 10 : current_world_ptr->h_ver_major, current_world_ptr->h_ver_minor, - current_world_ptr->h_ver_patch, current_world_ptr->h_ver_extra)); - - rd_u32b(¤t_world_ptr->sf_system); - rd_u32b(¤t_world_ptr->sf_when); - rd_u16b(¤t_world_ptr->sf_lives); - rd_u16b(¤t_world_ptr->sf_saves); -} - -/*! - * @brief 乱数状態を読み込む / Read RNG state (added in 2.8.0) - * @return なし - */ -static void rd_randomizer(void) -{ - u16b tmp16u; - rd_u16b(&tmp16u); - rd_u16b(&Rand_place); - for (int i = 0; i < RAND_DEG; i++) - rd_u32b(&Rand_state[i]); -} - -/*! - * @brief メッセージログを読み込む / Read the saved messages - * @return なし - */ -static void rd_messages(void) -{ - if (h_older_than(2, 2, 0, 75)) { - u16b num; - rd_u16b(&num); - int message_max; - message_max = (int)num; - - for (int i = 0; i < message_max; i++) { - char buf[128]; - rd_string(buf, sizeof(buf)); - message_add(buf); - } - } - - u32b num; - rd_u32b(&num); - int message_max; - message_max = (int)num; - - for (int i = 0; i < message_max; i++) { - char buf[128]; - rd_string(buf, sizeof(buf)); - message_add(buf); - } -} - -static void rd_system_info(void) -{ - rd_byte(&kanji_code); - rd_randomizer(); - if (arg_fiddle) - load_note(_("乱数情報をロードしました", "Loaded Randomizer Info")); - - rd_options(); - if (arg_fiddle) - load_note(_("オプションをロードしました", "Loaded Option Flags")); - - rd_messages(); - if (arg_fiddle) - load_note(_("メッセージをロードしました", "Loaded Messages")); -} - /*! * @brief 変愚蛮怒 v2.1.3で追加された街とクエストについて読み込む * @param creature_ptr プレーヤーへの参照ポインタ -- 2.11.0