OSDN Git Service

[Refactor] #37353 ウィザードモードフラグ を player_type 構造体から world_type 構造体へ移動.
[hengband/hengband.git] / src / save.c
index 9306dae..44ad47a 100644 (file)
 
 #include "angband.h"
 #include "util.h"
+#include "save.h"
+#include "load.h"
+#include "report.h"
 
+#include "core.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"
 
 
 /*
@@ -476,7 +484,7 @@ static void wr_options(void)
 
        c = 0;
 
-       if (p_ptr->wizard) c |= 0x0002;
+       if (current_world_ptr->wizard) c |= 0x0002;
 
        if (cheat_sight) c |= 0x0040;
        if (cheat_turn) c |= 0x0080;
@@ -514,11 +522,8 @@ static void wr_options(void)
                                /* Set */
                                option_flag[os] |= (1L << ob);
                        }
-
-                       /* Clear */
                        else
                        {
-                               /* Clear */
                                option_flag[os] &= ~(1L << ob);
                        }
                }
@@ -689,7 +694,7 @@ static void wr_extra(void)
        wr_s16b(p_ptr->arena_number);
        wr_s16b(p_ptr->inside_arena);
        wr_s16b(p_ptr->inside_quest);
-       wr_s16b(p_ptr->inside_battle);
+       wr_s16b(p_ptr->phase_out);
        wr_byte(p_ptr->exit_bldg);
        wr_byte(0); /* Unused */
 
@@ -840,7 +845,7 @@ static void wr_extra(void)
 
        wr_s32b(current_world_ptr->dungeon_turn);
 
-       wr_s32b(old_battle);
+       wr_s32b(current_world_ptr->arena_start_turn);
 
        wr_s16b(today_mon);
        wr_s16b(p_ptr->today_mon);
@@ -867,7 +872,7 @@ static void wr_extra(void)
  */
 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;
@@ -930,7 +935,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++)
@@ -958,12 +963,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;
                        }
 
@@ -990,7 +995,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);
@@ -1067,7 +1072,7 @@ 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 ***/
@@ -1227,13 +1232,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 ***/
@@ -1263,17 +1268,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 */
@@ -1570,7 +1575,7 @@ static bool save_player_aux(char *name)
        counts_write(0, current_world_ptr->play_time);
 
        /* Successful save */
-       character_saved = TRUE;
+       current_world_ptr->character_saved = TRUE;
 
        /* Success */
        return (TRUE);
@@ -1645,7 +1650,7 @@ bool save_player(void)
                safe_setuid_drop();
 
                /* Hack -- Pretend the character was loaded */
-               character_loaded = TRUE;
+               current_world_ptr->character_loaded = TRUE;
 
 #ifdef VERIFY_SAVEFILE
 
@@ -1706,7 +1711,7 @@ bool save_player(void)
  * allowed to save his game when he quits.
  *
  * We return "TRUE" if the savefile was usable, and we set the global
- * flag "character_loaded" if a real, living, character was loaded.
+ * flag "current_world_ptr->character_loaded" if a real, living, character was loaded.
  *
  * Note that we always try to load the "current" savefile, even if
  * there is no such file, so we must check for "empty" savefile names.
@@ -1827,10 +1832,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();
 
@@ -1854,8 +1859,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");
 
@@ -1868,18 +1873,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);
                }
@@ -1891,7 +1896,7 @@ bool load_player(void)
                        if (arg_wizard)
                        {
                                /* A character was loaded */
-                               character_loaded = TRUE;
+                               current_world_ptr->character_loaded = TRUE;
                                return (TRUE);
                        }
 
@@ -1899,13 +1904,13 @@ bool load_player(void)
                        p_ptr->is_dead = FALSE;
 
                        /* Count lives */
-                       sf_lives++;
+                       current_world_ptr->sf_lives++;
 
                        return (TRUE);
                }
 
                /* A character was loaded */
-               character_loaded = TRUE;
+               current_world_ptr->character_loaded = TRUE;
 
                {
                        u32b tmp = counts_read(2);
@@ -1939,7 +1944,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);