char buf[32];
/* Save the version */
- sprintf(the_score.what, "%u.%u.%u", FAKE_VER_MAJOR, FAKE_VER_MINOR, FAKE_VER_PATCH);
+ sprintf(the_score.what, "%u.%u.%u", H_VER_MAJOR, H_VER_MINOR, H_VER_PATCH);
/* Calculate and save the points */
sprintf(the_score.pts, "%9ld", (long)calc_score(current_player_ptr));
}
/* Save the version */
- sprintf(the_score.what, "%u.%u.%u", FAKE_VER_MAJOR, FAKE_VER_MINOR, FAKE_VER_PATCH);
+ sprintf(the_score.what, "%u.%u.%u", H_VER_MAJOR, H_VER_MINOR, H_VER_PATCH);
/* Calculate and save the points */
sprintf(the_score.pts, "%9ld", (long)calc_score(current_player_ptr));
continue;
}
- prt(format(_("[変愚蛮怒 %d.%d.%d, %s, %d/%d]", "[Hengband %d.%d.%d, %s, Line %d/%d]"), FAKE_VER_MAJOR - 10, FAKE_VER_MINOR, FAKE_VER_PATCH, caption,
+ prt(format(_("[変愚蛮怒 %d.%d.%d, %s, %d/%d]", "[Hengband %d.%d.%d, %s, Line %d/%d]"), H_VER_MAJOR, H_VER_MINOR, H_VER_PATCH, caption,
line, size),
0, 0);
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, slist);
char user_agent[64];
- snprintf(user_agent, sizeof(user_agent), "Hengband %d.%d.%d", FAKE_VER_MAJOR - 10, FAKE_VER_MINOR, FAKE_VER_PATCH);
+ snprintf(user_agent, sizeof(user_agent), "Hengband %d.%d.%d", H_VER_MAJOR, H_VER_MINOR, H_VER_PATCH);
curl_easy_setopt(curl, CURLOPT_USERAGENT, user_agent);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);
*/
void rd_version_info(void)
{
- byte fake_major = rd_byte();
+ auto tmp_major = rd_byte();
+ auto is_old_ver = (10 <= tmp_major) && (tmp_major <= 13);
+ if (tmp_major == 8) {
+ // strip_byte() だと自動ローテーションされるので手動スキップ.
+ for (auto i = 0; i < 8; i++) {
+ load_xor_byte = 0;
+ (void)rd_byte();
+ }
+
+ 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();
+ } 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 */
- 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();
+ 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();
+ }
w_ptr->sf_system = rd_u32b();
w_ptr->sf_when = rd_u32b();
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)..."),
w_ptr->h_ver_major, w_ptr->h_ver_minor, w_ptr->h_ver_patch,
bool err = false;
int fd = -1;
- byte fake_ver[4];
+ char tmp_ver[13]{};
if (!err) {
fd = fd_open(savefile, O_RDONLY);
if (fd < 0)
}
if (!err) {
- if (fd_read(fd, (char *)(fake_ver), 4))
+ if (fd_read(fd, (char *)(tmp_ver), 13)) {
err = true;
+ }
- if (err)
+ if (err) {
what = _("セーブファイルを読めません", "Cannot read savefile");
-
- (void)fd_close(fd);
+ }
}
if (!err) {
- if (fake_ver[0] < FAKE_VER_PLUS) {
- what = _("セーブデータが古すぎます", "Savefile version is too old");
- err = true;
+ auto tmp_major = tmp_ver[0];
+ auto is_old_ver = (10 <= tmp_major) && (tmp_major <= 13);
+ if (tmp_major == 8) {
+ std::string variant_name(VERSION_NAME);
+ std::stringstream current_variant;
+ for (auto i = 1; i < 9; i++) {
+ current_variant << tmp_ver[i];
+ }
+
+ if (current_variant.str() != variant_name) {
+ throw(_("セーブデータのバリアントは変愚蛮怒以外です", "The variant of save data is other than Hengband!"));
+ }
+
+ w_ptr->sf_extra = tmp_ver[13];
+ (void)fd_close(fd);
+ } else if (is_old_ver) {
+ w_ptr->sf_extra = tmp_ver[3];
+ (void)fd_close(fd);
+ } else {
+ (void)fd_close(fd);
+ throw("Invalid version is detected!");
}
}
return false;
}
- w_ptr->sf_extra = fake_ver[3];
-
if (!err) {
term_clear();
if (rd_savefile(player_ptr))
w_ptr->sf_system = 0L;
w_ptr->sf_when = now;
w_ptr->sf_saves++;
+
+ std::string tmp_variant(VERSION_NAME);
save_xor_byte = 0;
- wr_byte(FAKE_VER_MAJOR);
- save_xor_byte = 0;
- wr_byte(FAKE_VER_MINOR);
- save_xor_byte = 0;
- wr_byte(FAKE_VER_PATCH);
+ wr_byte(static_cast<byte>(tmp_variant.length()));
+ for (auto i = 0; i < 8; i++) {
+ auto variant_name = tmp_variant.c_str();
+ save_xor_byte = 0;
+ wr_byte(variant_name[i]);
+ }
+
save_xor_byte = 0;
+ wr_byte(H_VER_MAJOR);
+ wr_byte(H_VER_MINOR);
+ wr_byte(H_VER_PATCH);
+ wr_byte(H_VER_EXTRA);
byte tmp8u = (byte)Rand_external(256);
wr_byte(tmp8u);
v_stamp = 0L;
x_stamp = 0L;
-
- wr_byte(H_VER_EXTRA);
- wr_byte(H_VER_PATCH);
- wr_byte(H_VER_MINOR);
- wr_byte(H_VER_MAJOR);
+
wr_u32b(w_ptr->sf_system);
wr_u32b(w_ptr->sf_when);
wr_u16b(w_ptr->sf_lives);
*/
#define IS_ALPHA_VERSION 1
-/*!
- * @brief ゲームのバージョン番号定義 / "Program Version Number" of the game
- * @details
- * 本FAKE_VERSIONそのものは未使用である。Zangと整合性を合わせるための疑似的処理のためFAKE_VER_MAJORは実値-10が該当のバージョン番号となる。
- * <pre>
- * FAKE_VER_MAJOR=1,2 were reserved for ZAngband version 1.x.x/2.x.x .
- * </pre>
- */
-#define FAKE_VER_PLUS 10 //!< 偽バージョン番号としていくつ足すか
-#define FAKE_VER_MAJOR (H_VER_MAJOR + FAKE_VER_PLUS) //!< 偽バージョン番号定義(メジャー番号) */
-#define FAKE_VER_MINOR H_VER_MINOR //!< 偽バージョン番号定義(マイナー番号) */
-#define FAKE_VER_PATCH H_VER_PATCH //!< 偽バージョン番号定義(パッチ番号) */
-#define FAKE_VER_EXTRA H_VER_EXTRA //!< 偽バージョン番号定義(エクストラ番号) */
-
void put_version(char *buf);