X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=src%2Fsave.c;h=7719d332ba04f9ffc4d576fca83ad038e3016f3c;hb=ad951098494c9de50a330832bbd93a3e508989a8;hp=f5b87bf717703dd30748995c06919bd4c9b979f9;hpb=bd23dab5010eee32b843ffabf83d10cbdbc9fe9d;p=hengband%2Fhengband.git diff --git a/src/save.c b/src/save.c index f5b87bf71..7719d332b 100644 --- a/src/save.c +++ b/src/save.c @@ -12,6 +12,9 @@ */ #include "angband.h" +#include "sort.h" +#include "quest.h" +#include "store.h" @@ -19,12 +22,10 @@ * Some "local" parameters, used to help write savefiles */ -static FILE *fff; /* Current save "file" */ - -static byte xor_byte; /* Simple encryption */ - -static u32b v_stamp = 0L; /* A simple "checksum" on the actual values */ -static u32b x_stamp = 0L; /* A simple "checksum" on the encoded bytes */ +static FILE *fff; /* Current save "file" */ +static byte xor_byte; /* Simple encryption */ +static u32b v_stamp = 0L; /* A simple "checksum" on the actual values */ +static u32b x_stamp = 0L; /* A simple "checksum" on the encoded bytes */ @@ -103,7 +104,7 @@ static void wr_s32b(s32b v) * @param str 書き込む文字列 * @return なし */ -static void wr_string(cptr str) +static void wr_string(concptr str) { while (*str) { @@ -261,7 +262,7 @@ static void wr_monster(monster_type *m_ptr) if (flags & SAVE_MON_SUB_ALIGN) wr_byte(m_ptr->sub_align); if (flags & SAVE_MON_CSLEEP) wr_s16b(m_ptr->mtimed[MTIMED_CSLEEP]); - wr_byte(m_ptr->mspeed); + wr_byte((byte)m_ptr->mspeed); wr_s16b(m_ptr->energy_need); if (flags & SAVE_MON_FAST) @@ -351,7 +352,6 @@ static void wr_lore(MONRACE_IDX r_idx) wr_u32b(r_ptr->r_flags6); wr_u32b(r_ptr->r_flagsr); - /* Monster limit per level */ wr_byte((byte_hack)r_ptr->max_num); @@ -381,7 +381,7 @@ static void wr_xtra(KIND_OBJECT_IDX k_idx) /*! - * @brief 店舗情報を書き込む / Write a "store" record + * @brief セーブデータに店舗情報を書き込む / Write a "store" record * @param st_ptr 店舗情報の参照ポインタ * @return なし */ @@ -417,26 +417,20 @@ static void wr_store(store_type *st_ptr) /*! - * @brief 乱数情報を書き込む / Write RNG state - * @return なし + * @brief セーブデータに乱数情報を書き込む / Write RNG state + * @return 常に0(成功を返す) */ static errr wr_randomizer(void) { int i; - - /* Zero */ wr_u16b(0); - - /* Place */ wr_u16b(Rand_place); - /* State */ for (i = 0; i < RAND_DEG; i++) { wr_u32b(Rand_state[i]); } - /* Success */ return (0); } @@ -565,9 +559,9 @@ static void save_quick_start(void) int i; wr_byte(previous_char.psex); - wr_byte(previous_char.prace); - wr_byte(previous_char.pclass); - wr_byte(previous_char.pseikaku); + wr_byte((byte_hack)previous_char.prace); + wr_byte((byte_hack)previous_char.pclass); + wr_byte((byte_hack)previous_char.pseikaku); wr_byte((byte_hack)previous_char.realm1); wr_byte((byte_hack)previous_char.realm2); @@ -577,8 +571,8 @@ static void save_quick_start(void) wr_s16b(previous_char.sc); wr_s32b(previous_char.au); - for (i = 0; i < 6; i++) wr_s16b(previous_char.stat_max[i]); - for (i = 0; i < 6; i++) wr_s16b(previous_char.stat_max_max[i]); + for (i = 0; i < A_MAX; i++) wr_s16b(previous_char.stat_max[i]); + for (i = 0; i < A_MAX; i++) wr_s16b(previous_char.stat_max_max[i]); for (i = 0; i < PY_MAX_LEVEL; i++) wr_s16b((s16b)previous_char.player_hp[i]); @@ -608,9 +602,7 @@ static void wr_extra(void) byte tmp8u; wr_string(p_ptr->name); - wr_string(p_ptr->died_from); - wr_string(p_ptr->last_message ? p_ptr->last_message : ""); save_quick_start(); @@ -621,12 +613,13 @@ static void wr_extra(void) } /* Race/Class/Gender/Spells */ - wr_byte(p_ptr->prace); - wr_byte(p_ptr->pclass); - wr_byte(p_ptr->pseikaku); - wr_byte(p_ptr->psex); + wr_byte((byte_hack)p_ptr->prace); + wr_byte((byte_hack)p_ptr->pclass); + wr_byte((byte_hack)p_ptr->pseikaku); + wr_byte((byte_hack)p_ptr->psex); wr_byte((byte_hack)p_ptr->realm1); wr_byte((byte_hack)p_ptr->realm2); + wr_byte(0); wr_byte((byte)p_ptr->hitdie); wr_u16b(p_ptr->expfact); @@ -636,9 +629,9 @@ static void wr_extra(void) wr_s16b(p_ptr->wt); /* Dump the stats (maximum and current) */ - for (i = 0; i < 6; ++i) wr_s16b(p_ptr->stat_max[i]); - for (i = 0; i < 6; ++i) wr_s16b(p_ptr->stat_max_max[i]); - for (i = 0; i < 6; ++i) wr_s16b(p_ptr->stat_cur[i]); + for (i = 0; i < A_MAX; ++i) wr_s16b(p_ptr->stat_max[i]); + for (i = 0; i < A_MAX; ++i) wr_s16b(p_ptr->stat_max_max[i]); + for (i = 0; i < A_MAX; ++i) wr_s16b(p_ptr->stat_cur[i]); /* Ignore the transient stats */ for (i = 0; i < 12; ++i) wr_s16b(0); @@ -657,7 +650,7 @@ static void wr_extra(void) for (i = 0; i < 108; i++) wr_s32b(p_ptr->magic_num1[i]); for (i = 0; i < 108; i++) wr_byte(p_ptr->magic_num2[i]); - wr_byte(p_ptr->start_race); + wr_byte((byte_hack)p_ptr->start_race); wr_s32b(p_ptr->old_race1); wr_s32b(p_ptr->old_race2); wr_s16b(p_ptr->old_realm); @@ -712,6 +705,10 @@ static void wr_extra(void) wr_s16b((s16b)max_dlv[i]); /* More info */ + wr_s16b(0); + wr_s16b(0); + wr_s16b(0); + wr_s16b(0); wr_s16b(p_ptr->sc); wr_s16b(p_ptr->concent); @@ -790,6 +787,7 @@ static void wr_extra(void) wr_u32b(p_ptr->special_defense); wr_byte(p_ptr->knowledge); wr_byte(p_ptr->autopick_autoregister); + wr_byte(0); wr_byte((byte_hack)p_ptr->action); wr_byte(0); wr_byte(preserve_mode); @@ -799,6 +797,9 @@ static void wr_extra(void) for (i = 0; i < 12; i++) wr_u32b(0L); /* Ignore some flags */ + wr_u32b(0L); + wr_u32b(0L); + wr_u32b(0L); /* Write the "object seeds" */ @@ -850,8 +851,8 @@ static void wr_extra(void) /*! - * @brief フロア保存時のcave情報テンプレートをソートするための比較処理 - * @param u caveテンプレートの参照ポインタ + * @brief フロア保存時のcurrent_floor_ptr->grid_array情報テンプレートをソートするための比較処理 + * @param u current_floor_ptr->grid_arrayテンプレートの参照ポインタ * @param v 未使用 * @param a スワップするモンスター種族のID1 * @param b スワップするモンスター種族のID2 @@ -872,8 +873,8 @@ static bool ang_sort_comp_cave_temp(vptr u, vptr v, int a, int b) /*! - * @brief フロア保存時のcave情報テンプレートをソートするためのスワップ処理 / Sorting hook -- Swap function - * @param u caveテンプレートの参照ポインタ + * @brief フロア保存時のcurrent_floor_ptr->grid_array情報テンプレートをソートするためのスワップ処理 / Sorting hook -- Swap function + * @param u current_floor_ptr->grid_arrayテンプレートの参照ポインタ * @param v 未使用 * @param a スワップするモンスター種族のID1 * @param b スワップするモンスター種族のID2 @@ -923,7 +924,7 @@ static void wr_saved_floor(saved_floor_type *sf_ptr) { /*** Not a saved floor ***/ - wr_s16b((s16b)dun_level); + wr_s16b((s16b)current_floor_ptr->dun_level); } else { @@ -938,17 +939,17 @@ static void wr_saved_floor(saved_floor_type *sf_ptr) wr_s16b(sf_ptr->lower_floor_id); } - wr_u16b((u16b)base_level); + wr_u16b((u16b)current_floor_ptr->base_level); wr_u16b((s16b)num_repro); wr_u16b((u16b)p_ptr->y); wr_u16b((u16b)p_ptr->x); - wr_u16b((u16b)cur_hgt); - wr_u16b((u16b)cur_wid); + wr_u16b((u16b)current_floor_ptr->height); + wr_u16b((u16b)current_floor_ptr->width); wr_byte(p_ptr->feeling); - /*********** Make template for cave_type **********/ + /*********** Make template for grid_type **********/ /* * Usually number of templates are fewer than 255. Even if @@ -968,18 +969,18 @@ static void wr_saved_floor(saved_floor_type *sf_ptr) C_MAKE(templates, max_num_temp, cave_template_type); /* Extract template array */ - for (y = 0; y < cur_hgt; y++) + for (y = 0; y < current_floor_ptr->height; y++) { - for (x = 0; x < cur_wid; x++) + for (x = 0; x < current_floor_ptr->width; x++) { - cave_type *c_ptr = &cave[y][x]; + grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x]; for (i = 0; i < num_temp; i++) { - if (templates[i].info == c_ptr->info && - templates[i].feat == c_ptr->feat && - templates[i].mimic == c_ptr->mimic && - templates[i].special == c_ptr->special) + if (templates[i].info == g_ptr->info && + templates[i].feat == g_ptr->feat && + templates[i].mimic == g_ptr->mimic && + templates[i].special == g_ptr->special) { /* Same terrain is exist */ templates[i].occurrence++; @@ -1003,10 +1004,10 @@ static void wr_saved_floor(saved_floor_type *sf_ptr) } /* Add new template */ - templates[num_temp].info = c_ptr->info; - templates[num_temp].feat = c_ptr->feat; - templates[num_temp].mimic = c_ptr->mimic; - templates[num_temp].special = c_ptr->special; + templates[num_temp].info = g_ptr->info; + templates[num_temp].feat = g_ptr->feat; + templates[num_temp].mimic = g_ptr->mimic; + templates[num_temp].special = g_ptr->special; templates[num_temp].occurrence = 1; /* Increase number of template */ @@ -1041,25 +1042,25 @@ static void wr_saved_floor(saved_floor_type *sf_ptr) - /*** "Run-Length-Encoding" of cave ***/ + /*** "Run-Length-Encoding" of current_floor_ptr->grid_array ***/ /* Note that this will induce two wasted bytes */ count = 0; prev_u16b = 0; - /* Dump the cave */ - for (y = 0; y < cur_hgt; y++) + /* Dump the current_floor_ptr->grid_array */ + for (y = 0; y < current_floor_ptr->height; y++) { - for (x = 0; x < cur_wid; x++) + for (x = 0; x < current_floor_ptr->width; x++) { - cave_type *c_ptr = &cave[y][x]; + grid_type *g_ptr = ¤t_floor_ptr->grid_array[y][x]; for (i = 0; i < num_temp; i++) { - if (templates[i].info == c_ptr->info && - templates[i].feat == c_ptr->feat && - templates[i].mimic == c_ptr->mimic && - templates[i].special == c_ptr->special) + if (templates[i].info == g_ptr->info && + templates[i].feat == g_ptr->feat && + templates[i].mimic == g_ptr->mimic && + templates[i].special == g_ptr->special) break; } @@ -1151,29 +1152,21 @@ static bool wr_dungeon(void) saved_floor_type *cur_sf_ptr; int i; - /* Forget the lite */ forget_lite(); - - /* Forget the view */ forget_view(); - - /* Forget the view */ clear_mon_lite(); /* Update lite/view */ p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE); - - /* Update monsters */ p_ptr->update |= (PU_MONSTERS | PU_DISTANCE | PU_FLOW); - /*** Meta info ***/ /* Number of floor_id used from birth */ wr_s16b(max_floor_id); /* Current dungeon type */ - wr_byte((byte_hack)dungeon_type); + wr_byte((byte_hack)p_ptr->dungeon_idx); /*** No saved floor (On the surface etc.) ***/ @@ -1503,7 +1496,7 @@ static bool wr_savefile_new(void) { for (j = 0; j < MAX_STORES; j++) { - wr_store(&town[i].store[j]); + wr_store(&town_info[i].store[j]); } } @@ -1559,21 +1552,16 @@ static bool wr_savefile_new(void) */ static bool save_player_aux(char *name) { - bool ok = FALSE; - - int fd = -1; - - int mode = 0644; - + bool ok = FALSE; + int fd = -1; + int mode = 0644; /* No file yet */ fff = NULL; - /* File type is "SAVE" */ FILE_TYPE(FILE_TYPE_SAVE); - /* Grab permissions */ safe_setuid_grab(); @@ -1779,7 +1767,7 @@ bool load_player(void) struct stat statbuf; #endif - cptr what = "generic"; + concptr what = "generic"; /* Paranoia */ @@ -1831,7 +1819,6 @@ bool load_player(void) /* Oops, lock exists */ if (fkk) { - /* Close the file */ my_fclose(fkk); msg_print(_("セーブファイルは現在使用中です。", "Savefile is currently in use.")); @@ -1879,8 +1866,6 @@ bool load_player(void) /* What */ if (err) what = _("セーブファイルを読めません。", "Cannot read savefile"); - - /* Close the file */ (void)fd_close(fd); } @@ -1894,8 +1879,6 @@ bool load_player(void) z_patch = vvv[2]; sf_extra = vvv[3]; - - /* Clear screen */ Term_clear(); /* Attempt to load */ @@ -1944,13 +1927,8 @@ bool load_player(void) } else { -#ifdef JP - msg_format("バージョン %d.%d.%d 用のセーブ・ファイルを変換しました。", - (z_major > 9) ? z_major-10 : z_major , z_minor, z_patch); -#else - msg_format("Converted a %d.%d.%d savefile.", + msg_format(_("バージョン %d.%d.%d 用のセーブ・ファイルを変換しました。", "Converted a %d.%d.%d savefile."), (z_major > 9) ? z_major-10 : z_major , z_minor, z_patch); -#endif } msg_print(NULL); } @@ -1963,7 +1941,6 @@ bool load_player(void) { /* A character was loaded */ character_loaded = TRUE; - return (TRUE); } @@ -2010,14 +1987,9 @@ 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); -#ifdef JP - msg_format("エラー(%s)がバージョン%d.%d.%d 用セーブファイル読み込み中に発生。", - what, (z_major>9) ? z_major - 10 : z_major, z_minor, z_patch); -#else - msg_format("Error (%s) reading %d.%d.%d savefile.", - what, (z_major>9) ? z_major - 10 : z_major, z_minor, z_patch); -#endif msg_print(NULL); return (FALSE);