X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=src%2Fsave.c;h=8b15d295e8f996ea03d711f6bc261c648b09ea5e;hb=0c34d00691b952d2d6d2873c7d49b3817581fb3c;hp=0389198166a6908e0a8f848fe9f97d3e0338d0ae;hpb=d905dc395bccfa31f1c7973444e1c53a976e9d96;p=hengband%2Fhengband.git diff --git a/src/save.c b/src/save.c index 038919816..8b15d295e 100644 --- a/src/save.c +++ b/src/save.c @@ -12,11 +12,26 @@ */ #include "angband.h" +#include "util.h" +#include "save.h" +#include "load.h" + +#include "artifact.h" #include "sort.h" +#include "dungeon.h" #include "quest.h" #include "store.h" #include "wild.h" - +#include "floor.h" +#include "floor-events.h" +#include "floor-save.h" +#include "floor-town.h" +#include "files.h" +#include "world.h" +#include "objectkind.h" +#include "monsterrace.h" +#include "birth.h" +#include "bldg.h" /* @@ -804,8 +819,8 @@ static void wr_extra(void) /* Write the "object seeds" */ - wr_u32b(seed_flavor); - wr_u32b(seed_town); + wr_u32b(current_world_ptr->seed_flavor); + wr_u32b(current_world_ptr->seed_town); /* Special stuff */ @@ -852,59 +867,13 @@ static void wr_extra(void) /*! - * @brief フロア保存時のcurrent_floor_ptr->grid_array情報テンプレートをソートするための比較処理 - * @param u current_floor_ptr->grid_arrayテンプレートの参照ポインタ - * @param v 未使用 - * @param a スワップするモンスター種族のID1 - * @param b スワップするモンスター種族のID2 - * @return aの方が大きければtrue - */ -static bool ang_sort_comp_cave_temp(vptr u, vptr v, int a, int b) -{ - cave_template_type *who = (cave_template_type *)(u); - - u16b o1 = who[a].occurrence; - u16b o2 = who[b].occurrence; - - /* Unused */ - (void)v; - - return o2 <= o1; -} - - -/*! - * @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 - * @return なし - */ -static void ang_sort_swap_cave_temp(vptr u, vptr v, int a, int b) -{ - cave_template_type *who = (cave_template_type *)(u); - - cave_template_type holder; - - /* Unused */ - (void)v; - - /* Swap */ - holder = who[a]; - who[a] = who[b]; - who[b] = holder; -} - - -/*! * @brief 保存フロアの書き込み / Actually write a saved floor data using effectively compressed format. * @param sf_ptr 保存したいフロアの参照ポインタ * @return なし */ static void wr_saved_floor(saved_floor_type *sf_ptr) { - cave_template_type *templates; + grid_template_type *templates; u16b max_num_temp; u16b num_temp = 0; int dummy_why; @@ -967,7 +936,7 @@ static void wr_saved_floor(saved_floor_type *sf_ptr) max_num_temp = 255; /* Allocate the "template" array */ - C_MAKE(templates, max_num_temp, cave_template_type); + C_MAKE(templates, max_num_temp, grid_template_type); /* Extract template array */ for (y = 0; y < current_floor_ptr->height; y++) @@ -995,12 +964,12 @@ static void wr_saved_floor(saved_floor_type *sf_ptr) /* If the max_num_temp is too small, increase it. */ if (num_temp >= max_num_temp) { - cave_template_type *old_template = templates; + grid_template_type *old_template = templates; /* Re-allocate the "template" array */ - C_MAKE(templates, max_num_temp + 255, cave_template_type); - (void)C_COPY(templates, old_template, max_num_temp, cave_template_type); - C_KILL(old_template, max_num_temp, cave_template_type); + C_MAKE(templates, max_num_temp + 255, grid_template_type); + (void)C_COPY(templates, old_template, max_num_temp, grid_template_type); + C_KILL(old_template, max_num_temp, grid_template_type); max_num_temp += 255; } @@ -1016,13 +985,8 @@ static void wr_saved_floor(saved_floor_type *sf_ptr) } } - /* Select the sort method */ - ang_sort_comp = ang_sort_comp_cave_temp; - ang_sort_swap = ang_sort_swap_cave_temp; - /* Sort by occurrence */ - ang_sort(templates, &dummy_why, num_temp); - + ang_sort(templates, &dummy_why, num_temp, ang_sort_comp_cave_temp, ang_sort_swap_cave_temp); /*** Dump templates ***/ @@ -1032,7 +996,7 @@ static void wr_saved_floor(saved_floor_type *sf_ptr) /* Dump the templates */ for (i = 0; i < num_temp; i++) { - cave_template_type *ct_ptr = &templates[i]; + grid_template_type *ct_ptr = &templates[i]; /* Dump it */ wr_u16b((u16b)ct_ptr->info); @@ -1109,16 +1073,16 @@ static void wr_saved_floor(saved_floor_type *sf_ptr) /* Free the "template" array */ - C_KILL(templates, max_num_temp, cave_template_type); + C_KILL(templates, max_num_temp, grid_template_type); /*** Dump objects ***/ /* Total objects */ - wr_u16b(o_max); + wr_u16b(current_floor_ptr->o_max); /* Dump the objects */ - for (i = 1; i < o_max; i++) + for (i = 1; i < current_floor_ptr->o_max; i++) { object_type *o_ptr = ¤t_floor_ptr->o_list[i]; @@ -1130,10 +1094,10 @@ static void wr_saved_floor(saved_floor_type *sf_ptr) /*** Dump the monsters ***/ /* Total monsters */ - wr_u16b(m_max); + wr_u16b(current_floor_ptr->m_max); /* Dump the monsters */ - for (i = 1; i < m_max; i++) + for (i = 1; i < current_floor_ptr->m_max; i++) { monster_type *m_ptr = ¤t_floor_ptr->m_list[i]; @@ -1269,13 +1233,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 ***/ @@ -1305,17 +1269,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 */ @@ -1466,12 +1430,10 @@ static bool wr_savefile_new(void) } - /* Write the inventory */ + /* Write the p_ptr->inventory_list */ for (i = 0; i < INVEN_TOTAL; i++) { - object_type *o_ptr = &inventory[i]; - - /* Skip non-objects */ + object_type *o_ptr = &p_ptr->inventory_list[i]; if (!o_ptr->k_idx) continue; /* Dump index */ @@ -1770,11 +1732,7 @@ bool load_player(void) concptr what = "generic"; - - /* Paranoia */ current_world_ptr->game_turn = 0; - - /* Paranoia */ p_ptr->is_dead = FALSE; @@ -1875,10 +1833,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(); @@ -1888,8 +1846,6 @@ bool load_player(void) /* Message (below) */ if (err) what = _("セーブファイルを解析出来ません。", "Cannot parse savefile"); } - - /* Paranoia */ if (!err) { /* Invalid current_world_ptr->game_turn */ @@ -1904,8 +1860,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"); @@ -1918,18 +1874,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); } @@ -1949,7 +1905,7 @@ bool load_player(void) p_ptr->is_dead = FALSE; /* Count lives */ - sf_lives++; + current_world_ptr->sf_lives++; return (TRUE); } @@ -1989,7 +1945,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);