From: deskull Date: Mon, 6 May 2019 11:32:51 +0000 (+0900) Subject: [Refactor] #37353 セーブファイル情報を world_type へ移動. X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;ds=sidebyside;h=8e55f1ca494e66664bf819acbed4e8ce56da72e0;p=hengband%2Fhengband.git [Refactor] #37353 セーブファイル情報を world_type へ移動. --- diff --git a/src/externs.h b/src/externs.h index d156370fb..ae3438180 100644 --- a/src/externs.h +++ b/src/externs.h @@ -84,18 +84,7 @@ extern const byte feature_action_flags[FF_FLAG_MAX]; /* variable.c */ extern const concptr copyright[5]; -extern byte h_ver_major; -extern byte h_ver_minor; -extern byte h_ver_patch; -extern byte h_ver_extra; -extern byte sf_extra; -extern u32b sf_system; -extern byte z_major; -extern byte z_minor; -extern byte z_patch; -extern u32b sf_when; -extern u16b sf_lives; -extern u16b sf_saves; + extern bool arg_fiddle; extern bool arg_wizard; extern bool arg_music; diff --git a/src/load.c b/src/load.c index cc211b2ce..3d252dac1 100644 --- a/src/load.c +++ b/src/load.c @@ -126,20 +126,20 @@ static byte kanji_code = 0; static bool h_older_than(byte major, byte minor, byte patch, byte extra) { /* Much older, or much more recent */ - if (h_ver_major < major) return (TRUE); - if (h_ver_major > major) return (FALSE); + if (current_world_ptr->h_ver_major < major) return (TRUE); + if (current_world_ptr->h_ver_major > major) return (FALSE); /* Distinctly older, or distinctly more recent */ - if (h_ver_minor < minor) return (TRUE); - if (h_ver_minor > minor) return (FALSE); + if (current_world_ptr->h_ver_minor < minor) return (TRUE); + if (current_world_ptr->h_ver_minor > minor) return (FALSE); /* Barely older, or barely more recent */ - if (h_ver_patch < patch) return (TRUE); - if (h_ver_patch > patch) return (FALSE); + if (current_world_ptr->h_ver_patch < patch) return (TRUE); + if (current_world_ptr->h_ver_patch > patch) return (FALSE); /* Barely older, or barely more recent */ - if (h_ver_extra < extra) return (TRUE); - if (h_ver_extra > extra) return (FALSE); + if (current_world_ptr->h_ver_extra < extra) return (TRUE); + if (current_world_ptr->h_ver_extra > extra) return (FALSE); /* Identical versions */ return (FALSE); @@ -156,16 +156,16 @@ static bool h_older_than(byte major, byte minor, byte patch, byte extra) static bool z_older_than(byte x, byte y, byte z) { /* Much older, or much more recent */ - if (z_major < x) return (TRUE); - if (z_major > x) return (FALSE); + if (current_world_ptr->z_major < x) return (TRUE); + if (current_world_ptr->z_major > x) return (FALSE); /* Distinctly older, or distinctly more recent */ - if (z_minor < y) return (TRUE); - if (z_minor > y) return (FALSE); + if (current_world_ptr->z_minor < y) return (TRUE); + if (current_world_ptr->z_minor > y) return (FALSE); /* Barely older, or barely more recent */ - if (z_patch < z) return (TRUE); - if (z_patch > z) return (FALSE); + if (current_world_ptr->z_patch < z) return (TRUE); + if (current_world_ptr->z_patch > z) return (FALSE); /* Identical versions */ return (FALSE); @@ -954,7 +954,7 @@ static void rd_monster_old(monster_type *m_ptr) rd_byte(&tmp8u); m_ptr->mtimed[MTIMED_INVULNER] = (s16b)tmp8u; - if (!(z_major == 2 && z_minor == 0 && z_patch == 6)) + if (!(current_world_ptr->z_major == 2 && current_world_ptr->z_minor == 0 && current_world_ptr->z_patch == 6)) rd_u32b(&m_ptr->smart); else m_ptr->smart = 0; @@ -2110,7 +2110,7 @@ static void rd_extra(void) else rd_s16b(&p_ptr->tsuyoshi); /* Old savefiles do not have the following fields... */ - if ((z_major == 2) && (z_minor == 0) && (z_patch == 6)) + if ((current_world_ptr->z_major == 2) && (current_world_ptr->z_minor == 0) && (current_world_ptr->z_patch == 6)) { p_ptr->tim_esp = 0; p_ptr->wraith_form = 0; @@ -3447,7 +3447,7 @@ static errr rd_savefile_new_aux(void) strip_bytes(4); /* Hack -- decrypt */ - xor_byte = sf_extra; + xor_byte = current_world_ptr->sf_extra; /* Clear the checksums */ @@ -3456,28 +3456,28 @@ static errr rd_savefile_new_aux(void) /* Read the version number of the savefile */ /* Old savefile will be version 0.0.0.3 */ - rd_byte(&h_ver_extra); - rd_byte(&h_ver_patch); - rd_byte(&h_ver_minor); - rd_byte(&h_ver_major); + 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); /* 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)); + (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)); /* Operating system info */ - rd_u32b(&sf_system); + rd_u32b(¤t_world_ptr->sf_system); /* Time of savefile creation */ - rd_u32b(&sf_when); + rd_u32b(¤t_world_ptr->sf_when); /* Number of resurrections */ - rd_u16b(&sf_lives); + rd_u16b(¤t_world_ptr->sf_lives); /* Number of times played */ - rd_u16b(&sf_saves); + rd_u16b(¤t_world_ptr->sf_saves); /* Later use (always zero) */ @@ -4067,10 +4067,10 @@ static bool load_floor_aux(saved_floor_type *sf_ptr) /* Set the version number to current version */ /* Never load old temporal files */ - h_ver_extra = H_VER_EXTRA; - h_ver_patch = H_VER_PATCH; - h_ver_minor = H_VER_MINOR; - h_ver_major = H_VER_MAJOR; + current_world_ptr->h_ver_extra = H_VER_EXTRA; + current_world_ptr->h_ver_patch = H_VER_PATCH; + current_world_ptr->h_ver_minor = H_VER_MINOR; + current_world_ptr->h_ver_major = H_VER_MAJOR; /* Verify the sign */ rd_u32b(&tmp32u); @@ -4154,10 +4154,10 @@ bool load_floor(saved_floor_type *sf_ptr, BIT_FLAGS mode) old_xor_byte = xor_byte; old_v_check = v_check; old_x_check = x_check; - old_h_ver_major = h_ver_major; - old_h_ver_minor = h_ver_minor; - old_h_ver_patch = h_ver_patch; - old_h_ver_extra = h_ver_extra; + old_h_ver_major = current_world_ptr->h_ver_major; + old_h_ver_minor = current_world_ptr->h_ver_minor; + old_h_ver_patch = current_world_ptr->h_ver_patch; + old_h_ver_extra = current_world_ptr->h_ver_extra; } /* floor savefile */ @@ -4203,10 +4203,10 @@ bool load_floor(saved_floor_type *sf_ptr, BIT_FLAGS mode) xor_byte = old_xor_byte; v_check = old_v_check; x_check = old_x_check; - h_ver_major = old_h_ver_major; - h_ver_minor = old_h_ver_minor; - h_ver_patch = old_h_ver_patch; - h_ver_extra = old_h_ver_extra; + current_world_ptr->h_ver_major = old_h_ver_major; + current_world_ptr->h_ver_minor = old_h_ver_minor; + current_world_ptr->h_ver_patch = old_h_ver_patch; + current_world_ptr->h_ver_extra = old_h_ver_extra; } /* Restore old knowledge */ diff --git a/src/save.c b/src/save.c index e3b78d392..65c34fb57 100644 --- a/src/save.c +++ b/src/save.c @@ -1231,13 +1231,13 @@ static bool wr_savefile_new(void) /* Note the operating system */ - sf_system = 0L; + current_world_ptr->sf_system = 0L; /* Note when the file was saved */ - sf_when = now; + current_world_ptr->sf_when = now; /* Note the number of saves */ - sf_saves++; + current_world_ptr->sf_saves++; /*** Actually write the file ***/ @@ -1267,17 +1267,17 @@ static bool wr_savefile_new(void) wr_byte(H_VER_MAJOR); /* Operating system */ - wr_u32b(sf_system); + wr_u32b(current_world_ptr->sf_system); /* Time file last saved */ - wr_u32b(sf_when); + wr_u32b(current_world_ptr->sf_when); /* Number of past lives */ - wr_u16b(sf_lives); + wr_u16b(current_world_ptr->sf_lives); /* Number of times saved */ - wr_u16b(sf_saves); + wr_u16b(current_world_ptr->sf_saves); /* Space */ @@ -1831,10 +1831,10 @@ bool load_player(void) { /* Extract version */ - z_major = vvv[0]; - z_minor = vvv[1]; - z_patch = vvv[2]; - sf_extra = vvv[3]; + current_world_ptr->z_major = vvv[0]; + current_world_ptr->z_minor = vvv[1]; + current_world_ptr->z_patch = vvv[2]; + current_world_ptr->sf_extra = vvv[3]; Term_clear(); @@ -1858,8 +1858,8 @@ bool load_player(void) if (!err && !arg_wizard) { /* Hack -- Verify the timestamp */ - if (sf_when > (statbuf.st_ctime + 100) || - sf_when < (statbuf.st_ctime - 100)) + if (current_world_ptr->sf_when > (statbuf.st_ctime + 100) || + current_world_ptr->sf_when < (statbuf.st_ctime - 100)) { what = _("無効なタイム・スタンプです", "Invalid timestamp"); @@ -1872,18 +1872,18 @@ bool load_player(void) if (!err) { /* Give a conversion warning */ - if ((FAKE_VER_MAJOR != z_major) || - (FAKE_VER_MINOR != z_minor) || - (FAKE_VER_PATCH != z_patch)) + if ((FAKE_VER_MAJOR != current_world_ptr->z_major) || + (FAKE_VER_MINOR != current_world_ptr->z_minor) || + (FAKE_VER_PATCH != current_world_ptr->z_patch)) { - if (z_major == 2 && z_minor == 0 && z_patch == 6) + if (current_world_ptr->z_major == 2 && current_world_ptr->z_minor == 0 && current_world_ptr->z_patch == 6) { msg_print(_("バージョン 2.0.* 用のセーブファイルを変換しました。", "Converted a 2.0.* savefile.")); } else { msg_format(_("バージョン %d.%d.%d 用のセーブ・ファイルを変換しました。", "Converted a %d.%d.%d savefile."), - (z_major > 9) ? z_major-10 : z_major , z_minor, z_patch); + (current_world_ptr->z_major > 9) ? current_world_ptr->z_major-10 : current_world_ptr->z_major , current_world_ptr->z_minor, current_world_ptr->z_patch); } msg_print(NULL); } @@ -1903,7 +1903,7 @@ bool load_player(void) p_ptr->is_dead = FALSE; /* Count lives */ - sf_lives++; + current_world_ptr->sf_lives++; return (TRUE); } @@ -1943,7 +1943,7 @@ bool load_player(void) #endif msg_format(_("エラー(%s)がバージョン%d.%d.%d 用セーブファイル読み込み中に発生。", "Error (%s) reading %d.%d.%d savefile."), - what, (z_major>9) ? z_major - 10 : z_major, z_minor, z_patch); + what, (current_world_ptr->z_major>9) ? current_world_ptr->z_major - 10 : current_world_ptr->z_major, current_world_ptr->z_minor, current_world_ptr->z_patch); msg_print(NULL); diff --git a/src/variable.c b/src/variable.c index 308481197..a1eb36344 100644 --- a/src/variable.c +++ b/src/variable.c @@ -35,29 +35,6 @@ concptr macro_trigger_keycode[2][MAX_MACRO_TRIG]; /*!< マクロの内容 */ int level_up = 0; /*!< レベルアップの際に遅延してcalc_mana()関数上で上昇量を表示するかどうかの判定フラグ */ - -/* - * Savefile version - */ -byte h_ver_major; /* Savefile version for Hengband 1.1.1 and later */ -byte h_ver_minor; -byte h_ver_patch; -byte h_ver_extra; - -byte sf_extra; /* Savefile's encoding key */ - -byte z_major; /* Savefile version for Hengband */ -byte z_minor; -byte z_patch; - -/* - * Savefile information - */ -u32b sf_system; /* Operating system info */ -u32b sf_when; /* Time when savefile created */ -u16b sf_lives; /* Number of past "lives" with this file */ -u16b sf_saves; /* Number of "saves" during this life */ - /* * Run-time arguments */ diff --git a/src/world.h b/src/world.h index b71929555..2c12347b1 100644 --- a/src/world.h +++ b/src/world.h @@ -18,6 +18,28 @@ typedef struct { bool is_loading_now; /*!< ロード処理中フラグ...ロード直後にcalc_bonus()時の徳変化、及びsanity_blast()による異常を抑止する */ + /* + * Savefile version + */ + byte h_ver_major; /* Savefile version for Hengband 1.1.1 and later */ + byte h_ver_minor; + byte h_ver_patch; + byte h_ver_extra; + + byte sf_extra; /* Savefile's encoding key */ + + byte z_major; /* Savefile version for Hengband */ + byte z_minor; + byte z_patch; + + /* + * Savefile information + */ + u32b sf_system; /* Operating system info */ + u32b sf_when; /* Time when savefile created */ + u16b sf_lives; /* Number of past "lives" with this file */ + u16b sf_saves; /* Number of "saves" during this life */ + } world_type; extern bool is_daytime(void);